Changes for iOS 13 beta 5

This commit is contained in:
Shadowfacts 2019-08-05 21:08:00 -06:00
parent abd73fbe3b
commit 7064ae950e
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
8 changed files with 24 additions and 24 deletions

View File

@ -14,9 +14,9 @@ struct Preference<Value>: BindingConvertible {
init(_ path: WritableKeyPath<Preferences, Value>) { init(_ path: WritableKeyPath<Preferences, Value>) {
self.path = path self.path = path
self.binding = Binding(getValue: { self.binding = Binding(get: {
return Preferences.shared[keyPath: path] return Preferences.shared[keyPath: path]
}, setValue: { (newValue) in }, set: { (newValue) in
Preferences.shared[keyPath: path] = newValue Preferences.shared[keyPath: path] = newValue
}) })
} }
@ -42,9 +42,9 @@ struct MappedPreference<Value, PrefValue>: BindingConvertible {
self.path = path self.path = path
self.fromPref = fromPref self.fromPref = fromPref
self.toPref = toPref self.toPref = toPref
self.binding = Binding(getValue: { self.binding = Binding(get: {
return fromPref(Preferences.shared[keyPath: path]) return fromPref(Preferences.shared[keyPath: path])
}, setValue: { (newValue) in }, set: { (newValue) in
Preferences.shared[keyPath: path] = toPref(newValue) Preferences.shared[keyPath: path] = toPref(newValue)
}) })
} }

View File

@ -11,7 +11,7 @@ import Pachyderm
import SwiftUI import SwiftUI
import Combine import Combine
class Preferences: Codable, BindableObject { class Preferences: Codable, ObservableObject {
static var shared: Preferences = load() static var shared: Preferences = load()
@ -35,23 +35,23 @@ class Preferences: Codable, BindableObject {
private init() {} private init() {}
typealias PublisherType = PassthroughSubject<Preferences, Never> typealias ObjectWillChangePublisher = PassthroughSubject<Preferences, Never>
let willChange = PassthroughSubject<Preferences, Never>() let objectWillChange = PassthroughSubject<Preferences, Never>()
// MARK: - Appearance // MARK: - Appearance
var showRepliesInProfiles = false { willSet { willChange.send(self) } } var showRepliesInProfiles = false { willSet { objectWillChange.send(self) } }
var avatarStyle = AvatarStyle.roundRect { willSet { willChange.send(self) } } var avatarStyle = AvatarStyle.roundRect { willSet { objectWillChange.send(self) } }
var hideCustomEmojiInUsernames = false { willSet { willChange.send(self) } } var hideCustomEmojiInUsernames = false { willSet { objectWillChange.send(self) } }
// MARK: - Behavior // MARK: - Behavior
var defaultPostVisibility = Status.Visibility.public { willSet { willChange.send(self) } } var defaultPostVisibility = Status.Visibility.public { willSet { objectWillChange.send(self) } }
var automaticallySaveDrafts = true { willSet { willChange.send(self) } } var automaticallySaveDrafts = true { willSet { objectWillChange.send(self) } }
var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { willChange.send(self) } } var contentWarningCopyMode = ContentWarningCopyMode.asIs { willSet { objectWillChange.send(self) } }
var openLinksInApps = true { willSet { willChange.send(self) } } var openLinksInApps = true { willSet { objectWillChange.send(self) } }
// MARK: - Advanced // MARK: - Advanced
var silentActions: [String: Permission] = [:] { willSet { willChange.send(self) } } var silentActions: [String: Permission] = [:] { willSet { objectWillChange.send(self) } }
var statusContentType: StatusContentType = .plain { willSet { willChange.send(self) } } var statusContentType: StatusContentType = .plain { willSet { objectWillChange.send(self) } }
} }

View File

@ -15,7 +15,7 @@ struct AdvancedPrefsView : View {
List { List {
formattingSection formattingSection
automationSection automationSection
}.listStyle(.grouped) }.listStyle(GroupedListStyle())
.navigationBarTitle(Text("Advanced")) .navigationBarTitle(Text("Advanced"))
} }

View File

@ -26,7 +26,7 @@ struct AppearancePrefsView : View {
Text("Hide Custom Emoji in Usernames") Text("Hide Custom Emoji in Usernames")
} }
} }
.listStyle(.grouped) .listStyle(GroupedListStyle())
.navigationBarTitle(Text("Appearance")) .navigationBarTitle(Text("Appearance"))
} }
} }

View File

@ -18,7 +18,7 @@ struct BehaviorPrefsView : View {
List { List {
section1 section1
section2 section2
}.listStyle(.grouped) }.listStyle(GroupedListStyle())
.navigationBarTitle(Text("Behavior")) .navigationBarTitle(Text("Behavior"))
} }

View File

@ -22,7 +22,7 @@ struct PreferencesView : View {
Text("Advanced") Text("Advanced")
} }
} }
.listStyle(.grouped) .listStyle(GroupedListStyle())
.navigationBarTitle(Text("Preferences"), displayMode: .inline) .navigationBarTitle(Text("Preferences"), displayMode: .inline)
.onDisappear { .onDisappear {
// todo: this onDisappear callback is not called in beta 4, check again in beta 5 // todo: this onDisappear callback is not called in beta 4, check again in beta 5

View File

@ -37,7 +37,7 @@ struct SilentActionPrefs : View {
List(Array(preferences.silentActions.keys), id: \.self) { source in List(Array(preferences.silentActions.keys), id: \.self) { source in
SilentActionPermissionCell(source: source) SilentActionPermissionCell(source: source)
} }
.listStyle(.grouped) .listStyle(GroupedListStyle())
// .navigationBarTitle("Silent Action Permissions") // .navigationBarTitle("Silent Action Permissions")
// see FB6838291 // see FB6838291
// List(Array(silentActions.keys).identified(by: \.self)) { application in // List(Array(silentActions.keys).identified(by: \.self)) { application in
@ -58,9 +58,9 @@ struct SilentActionPermissionCell: View {
} }
var body: some View { var body: some View {
Toggle(isOn: Binding(getValue: { Toggle(isOn: Binding(get: {
self.preferences.silentActions[self.source] == .accepted self.preferences.silentActions[self.source] == .accepted
}, setValue: { }, set: {
self.preferences.silentActions[self.source] = $0 ? .accepted : .rejected self.preferences.silentActions[self.source] = $0 ? .accepted : .rejected
})) { })) {
Text(verbatim: source) Text(verbatim: source)

View File

@ -15,7 +15,7 @@ class EnhancedTableViewController: UITableViewController {
private var topOffset: CGPoint { 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) // 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) 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 // 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) return CGPoint(x: 0, y: barOffset + 1)