Fix style issues, remove unused code

This commit is contained in:
Arkadiusz Fal 2023-09-23 15:15:21 +02:00
parent dfda1181e2
commit 12a8582e89
9 changed files with 10 additions and 198 deletions

View File

@ -1,97 +0,0 @@
/*
Copyright © 2020 Apple Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import SwiftUI
#if os(iOS)
public struct VisualEffectBlur<Content: View>: View {
/// Defaults to .systemMaterial
var blurStyle: UIBlurEffect.Style
/// Defaults to nil
var vibrancyStyle: UIVibrancyEffectStyle?
var content: Content
public init(blurStyle: UIBlurEffect.Style = .systemMaterial, vibrancyStyle: UIVibrancyEffectStyle? = nil, @ViewBuilder content: () -> Content) {
self.blurStyle = blurStyle
self.vibrancyStyle = vibrancyStyle
self.content = content()
}
public var body: some View {
Representable(blurStyle: blurStyle, vibrancyStyle: vibrancyStyle, content: ZStack { content })
.accessibility(hidden: Content.self == EmptyView.self)
}
}
// MARK: - Representable
extension VisualEffectBlur {
struct Representable<Content: View>: UIViewRepresentable {
var blurStyle: UIBlurEffect.Style
var vibrancyStyle: UIVibrancyEffectStyle?
var content: Content
func makeUIView(context: Context) -> UIVisualEffectView {
context.coordinator.blurView
}
func updateUIView(_: UIVisualEffectView, context: Context) {
context.coordinator.update(content: content, blurStyle: blurStyle, vibrancyStyle: vibrancyStyle)
}
func makeCoordinator() -> Coordinator {
Coordinator(content: content)
}
}
}
// MARK: - Coordinator
extension VisualEffectBlur.Representable {
class Coordinator {
let blurView = UIVisualEffectView()
let vibrancyView = UIVisualEffectView()
let hostingController: UIHostingController<Content>
init(content: Content) {
hostingController = UIHostingController(rootView: content)
hostingController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
hostingController.view.backgroundColor = nil
blurView.contentView.addSubview(vibrancyView)
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
vibrancyView.contentView.addSubview(hostingController.view)
vibrancyView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
}
func update(content: Content, blurStyle: UIBlurEffect.Style, vibrancyStyle: UIVibrancyEffectStyle?) {
hostingController.rootView = content
let blurEffect = UIBlurEffect(style: blurStyle)
blurView.effect = blurEffect
if let vibrancyStyle {
vibrancyView.effect = UIVibrancyEffect(blurEffect: blurEffect, style: vibrancyStyle)
} else {
vibrancyView.effect = nil
}
hostingController.view.setNeedsDisplay()
}
}
}
extension VisualEffectBlur where Content == EmptyView {
init(blurStyle: UIBlurEffect.Style = .systemMaterial) {
self.init(blurStyle: blurStyle, vibrancyStyle: nil) {
EmptyView()
}
}
}
#endif

View File

@ -1,83 +0,0 @@
/*
Copyright © 2020 Apple Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import SwiftUI
#if os(macOS)
public struct VisualEffectBlur: View {
private var material: NSVisualEffectView.Material
private var blendingMode: NSVisualEffectView.BlendingMode
private var state: NSVisualEffectView.State
public init(
material: NSVisualEffectView.Material = .headerView,
blendingMode: NSVisualEffectView.BlendingMode = .withinWindow,
state: NSVisualEffectView.State = .followsWindowActiveState
) {
self.material = material
self.blendingMode = blendingMode
self.state = state
}
public var body: some View {
Representable(
material: material,
blendingMode: blendingMode,
state: state
).accessibility(hidden: true)
}
}
// MARK: - Representable
extension VisualEffectBlur {
struct Representable: NSViewRepresentable {
var material: NSVisualEffectView.Material
var blendingMode: NSVisualEffectView.BlendingMode
var state: NSVisualEffectView.State
func makeNSView(context: Context) -> NSVisualEffectView {
context.coordinator.visualEffectView
}
func updateNSView(_: NSVisualEffectView, context: Context) {
context.coordinator.update(material: material)
context.coordinator.update(blendingMode: blendingMode)
context.coordinator.update(state: state)
}
func makeCoordinator() -> Coordinator {
Coordinator()
}
}
class Coordinator {
let visualEffectView = NSVisualEffectView()
init() {
visualEffectView.blendingMode = .withinWindow
}
func update(material: NSVisualEffectView.Material) {
visualEffectView.material = material
}
func update(blendingMode: NSVisualEffectView.BlendingMode) {
visualEffectView.blendingMode = blendingMode
}
func update(state: NSVisualEffectView.State) {
visualEffectView.state = state
}
}
}
#endif

View File

@ -53,7 +53,7 @@ struct Video: Identifiable, Equatable, Hashable {
var channel: Channel var channel: Channel
var related = [Video]() var related = [Self]()
var chapters = [Chapter]() var chapters = [Chapter]()
var captions = [Captions]() var captions = [Captions]()

View File

@ -47,12 +47,12 @@ struct VideoPlayerView: View {
#if !os(tvOS) #if !os(tvOS)
@GestureState var dragGestureState = false @GestureState var dragGestureState = false
@GestureState var dragGestureOffset = CGSize.zero @GestureState var dragGestureOffset = CGSize.zero
@State var isHorizontalDrag = false @State var isHorizontalDrag = false // swiftlint:disable:this swiftui_state_private
@State var isVerticalDrag = false @State var isVerticalDrag = false // swiftlint:disable:this swiftui_state_private
@State var viewDragOffset = Self.hiddenOffset @State var viewDragOffset = Self.hiddenOffset // swiftlint:disable:this swiftui_state_private
#endif #endif
@ObservedObject var player = PlayerModel.shared @ObservedObject var player = PlayerModel.shared // swiftlint:disable:this swiftui_state_private
#if os(macOS) #if os(macOS)
@ObservedObject private var navigation = NavigationModel.shared @ObservedObject private var navigation = NavigationModel.shared
@ -66,7 +66,7 @@ struct VideoPlayerView: View {
@Default(.gestureForwardSeekDuration) private var gestureForwardSeekDuration @Default(.gestureForwardSeekDuration) private var gestureForwardSeekDuration
@Default(.avPlayerUsesSystemControls) var avPlayerUsesSystemControls @Default(.avPlayerUsesSystemControls) var avPlayerUsesSystemControls
@ObservedObject var controlsOverlayModel = ControlOverlaysModel.shared @ObservedObject var controlsOverlayModel = ControlOverlaysModel.shared // swiftlint:disable:this swiftui_state_private
var body: some View { var body: some View {
ZStack(alignment: overlayAlignment) { ZStack(alignment: overlayAlignment) {

View File

@ -92,7 +92,7 @@ struct ChannelsView: View {
} }
#if os(iOS) #if os(iOS)
.refreshable { .refreshable {
await subscriptions.load(force: true) subscriptions.load(force: true)
} }
#endif #endif
#if !os(tvOS) #if !os(tvOS)

View File

@ -23,7 +23,7 @@ struct FeedView: View {
} }
#if os(iOS) #if os(iOS)
.refreshable { .refreshable {
await feed.loadResources(force: true) feed.loadResources(force: true)
} }
#endif #endif
#if !os(tvOS) #if !os(tvOS)

View File

@ -294,7 +294,7 @@ struct VideoCell: View {
HStack(spacing: 8) { HStack(spacing: 8) {
if channelOnThumbnail, if channelOnThumbnail,
!inChannelView, !inChannelView,
let url = video.channel.thumbnailURLOrCached, video.channel.thumbnailURLOrCached != nil,
video != .fixture video != .fixture
{ {
ChannelLinkView(channel: video.channel) { ChannelLinkView(channel: video.channel) {

View File

@ -13,7 +13,7 @@ struct ControlsBar: View {
@State private var shareURL: URL? @State private var shareURL: URL?
@Binding var expansionState: ExpansionState @Binding var expansionState: ExpansionState
@State var gestureThrottle = Throttle(interval: 0.25) @State var gestureThrottle = Throttle(interval: 0.25) // swiftlint:disable:this swiftui_state_private
var presentingControls = true var presentingControls = true
var backgroundEnabled = true var backgroundEnabled = true

View File

@ -174,8 +174,6 @@
37270F1C28E06E3E00856150 /* String+Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37270F1B28E06E3E00856150 /* String+Localizable.swift */; }; 37270F1C28E06E3E00856150 /* String+Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37270F1B28E06E3E00856150 /* String+Localizable.swift */; };
37270F1D28E06E3E00856150 /* String+Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37270F1B28E06E3E00856150 /* String+Localizable.swift */; }; 37270F1D28E06E3E00856150 /* String+Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37270F1B28E06E3E00856150 /* String+Localizable.swift */; };
37270F1E28E06E3E00856150 /* String+Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37270F1B28E06E3E00856150 /* String+Localizable.swift */; }; 37270F1E28E06E3E00856150 /* String+Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37270F1B28E06E3E00856150 /* String+Localizable.swift */; };
3727B74A27872A920021C15E /* VisualEffectBlur-iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3727B74927872A920021C15E /* VisualEffectBlur-iOS.swift */; };
3727B74B27872B880021C15E /* VisualEffectBlur-macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3727B74727872A500021C15E /* VisualEffectBlur-macOS.swift */; };
372820402945E4A8009A0E2D /* SubscriptionsPageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3728203F2945E4A8009A0E2D /* SubscriptionsPageButton.swift */; }; 372820402945E4A8009A0E2D /* SubscriptionsPageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3728203F2945E4A8009A0E2D /* SubscriptionsPageButton.swift */; };
3729037E2739E47400EA99F6 /* MenuCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3729037D2739E47400EA99F6 /* MenuCommands.swift */; }; 3729037E2739E47400EA99F6 /* MenuCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3729037D2739E47400EA99F6 /* MenuCommands.swift */; };
3729037F2739E47400EA99F6 /* MenuCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3729037D2739E47400EA99F6 /* MenuCommands.swift */; }; 3729037F2739E47400EA99F6 /* MenuCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3729037D2739E47400EA99F6 /* MenuCommands.swift */; };
@ -1070,8 +1068,6 @@
371F2F19269B43D300E4A7AB /* NavigationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationModel.swift; sourceTree = "<group>"; }; 371F2F19269B43D300E4A7AB /* NavigationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationModel.swift; sourceTree = "<group>"; };
3722AEBD274DA401005EA4D6 /* Backport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Backport.swift; sourceTree = "<group>"; }; 3722AEBD274DA401005EA4D6 /* Backport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Backport.swift; sourceTree = "<group>"; };
37270F1B28E06E3E00856150 /* String+Localizable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Localizable.swift"; sourceTree = "<group>"; }; 37270F1B28E06E3E00856150 /* String+Localizable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Localizable.swift"; sourceTree = "<group>"; };
3727B74727872A500021C15E /* VisualEffectBlur-macOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisualEffectBlur-macOS.swift"; sourceTree = "<group>"; };
3727B74927872A920021C15E /* VisualEffectBlur-iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisualEffectBlur-iOS.swift"; sourceTree = "<group>"; };
3728203F2945E4A8009A0E2D /* SubscriptionsPageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionsPageButton.swift; sourceTree = "<group>"; }; 3728203F2945E4A8009A0E2D /* SubscriptionsPageButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionsPageButton.swift; sourceTree = "<group>"; };
3729037D2739E47400EA99F6 /* MenuCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuCommands.swift; sourceTree = "<group>"; }; 3729037D2739E47400EA99F6 /* MenuCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuCommands.swift; sourceTree = "<group>"; };
372915E52687E3B900F5A35B /* Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; }; 372915E52687E3B900F5A35B /* Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; };
@ -1662,8 +1658,6 @@
376E331128AD3B320070E30C /* ScrollDismissesKeyboard+Backport.swift */, 376E331128AD3B320070E30C /* ScrollDismissesKeyboard+Backport.swift */,
37B7CFE82A19603B001B0564 /* ToolbarBackground+Backport.swift */, 37B7CFE82A19603B001B0564 /* ToolbarBackground+Backport.swift */,
37B7CFEA2A1960EC001B0564 /* ToolbarColorScheme+Backport.swift */, 37B7CFEA2A1960EC001B0564 /* ToolbarColorScheme+Backport.swift */,
3727B74927872A920021C15E /* VisualEffectBlur-iOS.swift */,
3727B74727872A500021C15E /* VisualEffectBlur-macOS.swift */,
); );
path = Backports; path = Backports;
sourceTree = "<group>"; sourceTree = "<group>";
@ -2807,7 +2801,6 @@
37E80F40287B472300561799 /* ScrollContentBackground+Backport.swift in Sources */, 37E80F40287B472300561799 /* ScrollContentBackground+Backport.swift in Sources */,
375EC959289EEB8200751258 /* QualityProfileForm.swift in Sources */, 375EC959289EEB8200751258 /* QualityProfileForm.swift in Sources */,
37D2E0D028B67DBC00F64D52 /* AnimationCompletionObserverModifier.swift in Sources */, 37D2E0D028B67DBC00F64D52 /* AnimationCompletionObserverModifier.swift in Sources */,
3727B74A27872A920021C15E /* VisualEffectBlur-iOS.swift in Sources */,
3709528829283A21001ECA40 /* RecentDocumentsView.swift in Sources */, 3709528829283A21001ECA40 /* RecentDocumentsView.swift in Sources */,
377F9F7F2944175F0043F856 /* FeedCacheModel.swift in Sources */, 377F9F7F2944175F0043F856 /* FeedCacheModel.swift in Sources */,
37977583268922F600DD52A8 /* InvidiousAPI.swift in Sources */, 37977583268922F600DD52A8 /* InvidiousAPI.swift in Sources */,
@ -3042,7 +3035,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
37D836BD294927E700005E5E /* ChannelsCacheModel.swift in Sources */, 37D836BD294927E700005E5E /* ChannelsCacheModel.swift in Sources */,
3727B74B27872B880021C15E /* VisualEffectBlur-macOS.swift in Sources */,
374710062755291C00CE0F87 /* SearchTextField.swift in Sources */, 374710062755291C00CE0F87 /* SearchTextField.swift in Sources */,
37B7CFEC2A197844001B0564 /* AppleAVPlayerView.swift in Sources */, 37B7CFEC2A197844001B0564 /* AppleAVPlayerView.swift in Sources */,
37F0F4EB286F397E00C06C2E /* SettingsModel.swift in Sources */, 37F0F4EB286F397E00C06C2E /* SettingsModel.swift in Sources */,