From 7064ae950ef5bdea9cd667da12bf95695e9a5a57 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 5 Aug 2019 21:08:00 -0600 Subject: [PATCH] Changes for iOS 13 beta 5 --- Tusker/Preferences/Preference.swift | 8 +++---- Tusker/Preferences/Preferences.swift | 24 +++++++++---------- .../Preferences/AdvancedPrefsView.swift | 2 +- .../Preferences/AppearancePrefsView.swift | 2 +- .../Preferences/BehaviorPrefsView.swift | 2 +- .../Screens/Preferences/PreferencesView.swift | 2 +- .../Preferences/SilentActionPrefs.swift | 6 ++--- .../EnhancedTableViewController.swift | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Tusker/Preferences/Preference.swift b/Tusker/Preferences/Preference.swift index b08fe5d5..d180bac5 100644 --- a/Tusker/Preferences/Preference.swift +++ b/Tusker/Preferences/Preference.swift @@ -14,9 +14,9 @@ struct Preference: BindingConvertible { init(_ path: WritableKeyPath) { self.path = path - self.binding = Binding(getValue: { + self.binding = Binding(get: { return Preferences.shared[keyPath: path] - }, setValue: { (newValue) in + }, set: { (newValue) in Preferences.shared[keyPath: path] = newValue }) } @@ -42,9 +42,9 @@ struct MappedPreference: BindingConvertible { self.path = path self.fromPref = fromPref self.toPref = toPref - self.binding = Binding(getValue: { + self.binding = Binding(get: { return fromPref(Preferences.shared[keyPath: path]) - }, setValue: { (newValue) in + }, set: { (newValue) in Preferences.shared[keyPath: path] = toPref(newValue) }) } diff --git a/Tusker/Preferences/Preferences.swift b/Tusker/Preferences/Preferences.swift index 2984bbaf..50d9eb51 100644 --- a/Tusker/Preferences/Preferences.swift +++ b/Tusker/Preferences/Preferences.swift @@ -11,7 +11,7 @@ import Pachyderm import SwiftUI import Combine -class Preferences: Codable, BindableObject { +class Preferences: Codable, ObservableObject { static var shared: Preferences = load() @@ -35,23 +35,23 @@ class Preferences: Codable, BindableObject { private init() {} - typealias PublisherType = PassthroughSubject - let willChange = PassthroughSubject() + typealias ObjectWillChangePublisher = PassthroughSubject + let objectWillChange = PassthroughSubject() // MARK: - Appearance - var showRepliesInProfiles = false { willSet { willChange.send(self) } } - var avatarStyle = AvatarStyle.roundRect { willSet { willChange.send(self) } } - var hideCustomEmojiInUsernames = false { willSet { willChange.send(self) } } + var showRepliesInProfiles = false { willSet { objectWillChange.send(self) } } + var avatarStyle = AvatarStyle.roundRect { willSet { objectWillChange.send(self) } } + var hideCustomEmojiInUsernames = false { willSet { objectWillChange.send(self) } } // MARK: - Behavior - var defaultPostVisibility = Status.Visibility.public { willSet { willChange.send(self) } } - var automaticallySaveDrafts = true { willSet { willChange.send(self) } } - var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { willChange.send(self) } } - var openLinksInApps = true { willSet { willChange.send(self) } } + var defaultPostVisibility = Status.Visibility.public { willSet { objectWillChange.send(self) } } + var automaticallySaveDrafts = true { willSet { objectWillChange.send(self) } } + var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { objectWillChange.send(self) } } + var openLinksInApps = true { willSet { objectWillChange.send(self) } } // MARK: - Advanced - var silentActions: [String: Permission] = [:] { willSet { willChange.send(self) } } - var statusContentType: StatusContentType = .plain { willSet { willChange.send(self) } } + var silentActions: [String: Permission] = [:] { willSet { objectWillChange.send(self) } } + var statusContentType: StatusContentType = .plain { willSet { objectWillChange.send(self) } } } diff --git a/Tusker/Screens/Preferences/AdvancedPrefsView.swift b/Tusker/Screens/Preferences/AdvancedPrefsView.swift index cfff61c2..9c30fe04 100644 --- a/Tusker/Screens/Preferences/AdvancedPrefsView.swift +++ b/Tusker/Screens/Preferences/AdvancedPrefsView.swift @@ -15,7 +15,7 @@ struct AdvancedPrefsView : View { List { formattingSection automationSection - }.listStyle(.grouped) + }.listStyle(GroupedListStyle()) .navigationBarTitle(Text("Advanced")) } diff --git a/Tusker/Screens/Preferences/AppearancePrefsView.swift b/Tusker/Screens/Preferences/AppearancePrefsView.swift index 48eb8060..ffc57462 100644 --- a/Tusker/Screens/Preferences/AppearancePrefsView.swift +++ b/Tusker/Screens/Preferences/AppearancePrefsView.swift @@ -26,7 +26,7 @@ struct AppearancePrefsView : View { Text("Hide Custom Emoji in Usernames") } } - .listStyle(.grouped) + .listStyle(GroupedListStyle()) .navigationBarTitle(Text("Appearance")) } } diff --git a/Tusker/Screens/Preferences/BehaviorPrefsView.swift b/Tusker/Screens/Preferences/BehaviorPrefsView.swift index daaf7ad9..0f392252 100644 --- a/Tusker/Screens/Preferences/BehaviorPrefsView.swift +++ b/Tusker/Screens/Preferences/BehaviorPrefsView.swift @@ -18,7 +18,7 @@ struct BehaviorPrefsView : View { List { section1 section2 - }.listStyle(.grouped) + }.listStyle(GroupedListStyle()) .navigationBarTitle(Text("Behavior")) } diff --git a/Tusker/Screens/Preferences/PreferencesView.swift b/Tusker/Screens/Preferences/PreferencesView.swift index 185c98d3..e2b0beb1 100644 --- a/Tusker/Screens/Preferences/PreferencesView.swift +++ b/Tusker/Screens/Preferences/PreferencesView.swift @@ -22,7 +22,7 @@ struct PreferencesView : View { Text("Advanced") } } - .listStyle(.grouped) + .listStyle(GroupedListStyle()) .navigationBarTitle(Text("Preferences"), displayMode: .inline) .onDisappear { // todo: this onDisappear callback is not called in beta 4, check again in beta 5 diff --git a/Tusker/Screens/Preferences/SilentActionPrefs.swift b/Tusker/Screens/Preferences/SilentActionPrefs.swift index ccda62a4..62971cab 100644 --- a/Tusker/Screens/Preferences/SilentActionPrefs.swift +++ b/Tusker/Screens/Preferences/SilentActionPrefs.swift @@ -37,7 +37,7 @@ struct SilentActionPrefs : View { List(Array(preferences.silentActions.keys), id: \.self) { source in SilentActionPermissionCell(source: source) } - .listStyle(.grouped) + .listStyle(GroupedListStyle()) // .navigationBarTitle("Silent Action Permissions") // see FB6838291 // List(Array(silentActions.keys).identified(by: \.self)) { application in @@ -58,9 +58,9 @@ struct SilentActionPermissionCell: View { } var body: some View { - Toggle(isOn: Binding(getValue: { + Toggle(isOn: Binding(get: { self.preferences.silentActions[self.source] == .accepted - }, setValue: { + }, set: { self.preferences.silentActions[self.source] = $0 ? .accepted : .rejected })) { Text(verbatim: source) diff --git a/Tusker/Screens/Utilities/EnhancedTableViewController.swift b/Tusker/Screens/Utilities/EnhancedTableViewController.swift index 200a7577..9edda988 100644 --- a/Tusker/Screens/Utilities/EnhancedTableViewController.swift +++ b/Tusker/Screens/Utilities/EnhancedTableViewController.swift @@ -15,7 +15,7 @@ class EnhancedTableViewController: UITableViewController { private var topOffset: CGPoint { // when scrolled to top, the content offset is negative the height of the UI above the scroll view (i.e. the nav and status bars) - let windowScene = UIApplication.shared.keyWindow!.windowScene! + let windowScene = view.window!.windowScene! let barOffset = -1 * (navigationController!.navigationBar.frame.height + windowScene.statusBarManager!.statusBarFrame.height) // add one so it's not technically all the way at the top, and scrollViewWShouldScrollToTop is still called to trigger undo return CGPoint(x: 0, y: barOffset + 1)