diff --git a/Tusker/Preferences/Preference.swift b/Tusker/Preferences/Preference.swift index ac05294f27..b08fe5d5fa 100644 --- a/Tusker/Preferences/Preference.swift +++ b/Tusker/Preferences/Preference.swift @@ -21,7 +21,7 @@ struct Preference: BindingConvertible { }) } - var value: Value { + var wrappedValue: Value { get { return Preferences.shared[keyPath: path] } @@ -49,7 +49,7 @@ struct MappedPreference: BindingConvertible { }) } - var value: Value { + var wrappedValue: Value { get { return fromPref(Preferences.shared[keyPath: path]) } diff --git a/Tusker/Preferences/Preferences.swift b/Tusker/Preferences/Preferences.swift index 35408677d6..877a5c966c 100644 --- a/Tusker/Preferences/Preferences.swift +++ b/Tusker/Preferences/Preferences.swift @@ -12,7 +12,7 @@ import SwiftUI import Combine class Preferences: Codable, BindableObject { - + static var shared: Preferences = load() private static var documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! @@ -35,21 +35,22 @@ class Preferences: Codable, BindableObject { private init() {} - let didChange = PassthroughSubject() + typealias PublisherType = PassthroughSubject + let willChange = PassthroughSubject() // MARK: - Appearance - var showRepliesInProfiles = false { didSet { didChange.send(self) } } - var avatarStyle = AvatarStyle.roundRect { didSet { didChange.send(self) } } - var hideCustomEmojiInUsernames = false { didSet { didChange.send(self) } } + var showRepliesInProfiles = false { willSet { willChange.send(self) } } + var avatarStyle = AvatarStyle.roundRect { willSet { willChange.send(self) } } + var hideCustomEmojiInUsernames = false { willSet { willChange.send(self) } } // MARK: - Behavior - var defaultPostVisibility = Status.Visibility.public { didSet { didChange.send(self) } } - var automaticallySaveDrafts = true { didSet { didChange.send(self) } } - var openLinksInApps = true { didSet { didChange.send(self) } } + var defaultPostVisibility = Status.Visibility.public { willSet { willChange.send(self) } } + var automaticallySaveDrafts = true { willSet { willChange.send(self) } } + var openLinksInApps = true { willSet { willChange.send(self) } } // MARK: - Advanced - var silentActions: [String: Permission] = [:] { didSet { didChange.send(self) } } - var statusContentType: StatusContentType = .plain { didSet { didChange.send(self) } } + var silentActions: [String: Permission] = [:] { willSet { willChange.send(self) } } + var statusContentType: StatusContentType = .plain { willSet { willChange.send(self) } } } diff --git a/Tusker/Screens/Preferences/AdvancedPrefsView.swift b/Tusker/Screens/Preferences/AdvancedPrefsView.swift index 913649029d..9cbf3dff18 100644 --- a/Tusker/Screens/Preferences/AdvancedPrefsView.swift +++ b/Tusker/Screens/Preferences/AdvancedPrefsView.swift @@ -14,15 +14,15 @@ struct AdvancedPrefsView : View { var body: some View { List { Section(footer: Text("This option is only supported for Pleroma and Mastodon instances with formatting enabled. On all other instances, formatting symbols will remain in the unformatted plain text.").lineLimit(nil)) { - Picker(selection: $statusContentType.binding, label: Text("Post Content Type")) { - ForEach(StatusContentType.allCases.identified(by: \.self)) { type in + Picker(selection: _statusContentType.binding, label: Text("Post Content Type")) { + ForEach(StatusContentType.allCases, id: \.self) { type in Text(type.displayName).tag(type) } } } Section(header: Text("AUTOMATION")) { - NavigationButton(destination: SilentActionPrefs()) { + NavigationLink(destination: SilentActionPrefs()) { Text("Silent Action Permissions") } } diff --git a/Tusker/Screens/Preferences/AppearancePrefsView.swift b/Tusker/Screens/Preferences/AppearancePrefsView.swift index c115d1fc18..48eb8060cf 100644 --- a/Tusker/Screens/Preferences/AppearancePrefsView.swift +++ b/Tusker/Screens/Preferences/AppearancePrefsView.swift @@ -16,13 +16,13 @@ struct AppearancePrefsView : View { var body: some View { List { - Toggle(isOn: $showRepliesInProfiles.binding) { + Toggle(isOn: _showRepliesInProfiles.binding) { Text("Show Replies in Profiles") } - Toggle(isOn: $useCircularAvatars.binding) { + Toggle(isOn: _useCircularAvatars.binding) { Text("Use Circular Avatars") } - Toggle(isOn: $hideCustomEmojiInUsernames.binding) { + Toggle(isOn: _hideCustomEmojiInUsernames.binding) { Text("Hide Custom Emoji in Usernames") } } diff --git a/Tusker/Screens/Preferences/BehaviorPrefsView.swift b/Tusker/Screens/Preferences/BehaviorPrefsView.swift index 6404fb2592..02b090353b 100644 --- a/Tusker/Screens/Preferences/BehaviorPrefsView.swift +++ b/Tusker/Screens/Preferences/BehaviorPrefsView.swift @@ -16,8 +16,8 @@ struct BehaviorPrefsView : View { var body: some View { List { Section { - Picker(selection: $defaultPostVisibility.binding, label: Text("Default Post Visibility")) { - ForEach(Status.Visibility.allCases.identified(by: \.self)) { visibility in + Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) { + ForEach(Status.Visibility.allCases, id: \.self) { visibility in HStack { Image(systemName: visibility.imageName) Text(visibility.displayName) @@ -25,12 +25,12 @@ struct BehaviorPrefsView : View { .tag(visibility) } } - Toggle(isOn: $automaticallySaveDrafts.binding) { + Toggle(isOn: _automaticallySaveDrafts.binding) { Text("Automatically Save Drafts") } } Section { - Toggle(isOn: $openLinksInApps.binding) { + Toggle(isOn: _openLinksInApps.binding) { Text("Open Links in Apps") } } diff --git a/Tusker/Screens/Preferences/PreferencesView.swift b/Tusker/Screens/Preferences/PreferencesView.swift index 4cbfea4fa7..3b69e7ead3 100644 --- a/Tusker/Screens/Preferences/PreferencesView.swift +++ b/Tusker/Screens/Preferences/PreferencesView.swift @@ -12,13 +12,13 @@ struct PreferencesView : View { // workaround: the navigation view is provided by MyProfileTableViewController so that it can inject the Done button // NavigationView { List { - NavigationButton(destination: AppearancePrefsView()) { + NavigationLink(destination: AppearancePrefsView()) { Text("Appearance") } - NavigationButton(destination: BehaviorPrefsView()) { + NavigationLink(destination: BehaviorPrefsView()) { Text("Behavior") } - NavigationButton(destination: AdvancedPrefsView()) { + NavigationLink(destination: AdvancedPrefsView()) { Text("Advanced") } } diff --git a/Tusker/Screens/Preferences/SilentActionPrefs.swift b/Tusker/Screens/Preferences/SilentActionPrefs.swift index b45cb4a01f..e917ac4e38 100644 --- a/Tusker/Screens/Preferences/SilentActionPrefs.swift +++ b/Tusker/Screens/Preferences/SilentActionPrefs.swift @@ -34,7 +34,7 @@ struct SilentActionPrefs : View { @EnvironmentObject var preferences: Preferences var body: some View { - List(Array(preferences.silentActions.keys).identified(by: \.self)) { source in + List(Array(preferences.silentActions.keys), id: \.self) { source in SilentActionPermissionCell(source: source) }.listStyle(.grouped) // List(Array(silentActions.keys).identified(by: \.self)) { application in diff --git a/Tusker/Screens/Utilities/EnhancedTableViewController.swift b/Tusker/Screens/Utilities/EnhancedTableViewController.swift index b97f4c93d3..55fcc195a3 100644 --- a/Tusker/Screens/Utilities/EnhancedTableViewController.swift +++ b/Tusker/Screens/Utilities/EnhancedTableViewController.swift @@ -47,7 +47,7 @@ extension EnhancedTableViewController { return nil } let actionProvider: UIContextMenuActionProvider = { (elements) in - return UIMenu.create(title: "test", children: elements + actionsProvider()) + return UIMenu(title: "test", children: elements + actionsProvider()) } return UIContextMenuConfiguration(identifier: nil, previewProvider: previewProvider, actionProvider: actionProvider) } else {