Updates for beta 4

This commit is contained in:
Shadowfacts 2019-07-18 18:44:35 -04:00
parent f2e3870850
commit 319c76f60a
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
8 changed files with 28 additions and 27 deletions

View File

@ -21,7 +21,7 @@ struct Preference<Value>: BindingConvertible {
})
}
var value: Value {
var wrappedValue: Value {
get {
return Preferences.shared[keyPath: path]
}
@ -49,7 +49,7 @@ struct MappedPreference<Value, PrefValue>: BindingConvertible {
})
}
var value: Value {
var wrappedValue: Value {
get {
return fromPref(Preferences.shared[keyPath: path])
}

View File

@ -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<Preferences, Never>()
typealias PublisherType = PassthroughSubject<Preferences, Never>
let willChange = PassthroughSubject<Preferences, Never>()
// 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) } }
}

View File

@ -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")
}
}

View File

@ -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")
}
}

View File

@ -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")
}
}

View File

@ -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")
}
}

View File

@ -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

View File

@ -47,7 +47,7 @@ extension EnhancedTableViewController {
return nil
}
let actionProvider: UIContextMenuActionProvider = { (elements) in
return UIMenu<UIAction>.create(title: "test", children: elements + actionsProvider())
return UIMenu(title: "test", children: elements + actionsProvider())
}
return UIContextMenuConfiguration(identifier: nil, previewProvider: previewProvider, actionProvider: actionProvider)
} else {