forked from shadowfacts/Tusker
Updates for beta 4
This commit is contained in:
parent
f2e3870850
commit
319c76f60a
|
@ -21,7 +21,7 @@ struct Preference<Value>: BindingConvertible {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var value: Value {
|
var wrappedValue: Value {
|
||||||
get {
|
get {
|
||||||
return Preferences.shared[keyPath: path]
|
return Preferences.shared[keyPath: path]
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ struct MappedPreference<Value, PrefValue>: BindingConvertible {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var value: Value {
|
var wrappedValue: Value {
|
||||||
get {
|
get {
|
||||||
return fromPref(Preferences.shared[keyPath: path])
|
return fromPref(Preferences.shared[keyPath: path])
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import SwiftUI
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
class Preferences: Codable, BindableObject {
|
class Preferences: Codable, BindableObject {
|
||||||
|
|
||||||
static var shared: Preferences = load()
|
static var shared: Preferences = load()
|
||||||
|
|
||||||
private static var documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
private static var documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||||
|
@ -35,21 +35,22 @@ class Preferences: Codable, BindableObject {
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
let didChange = PassthroughSubject<Preferences, Never>()
|
typealias PublisherType = PassthroughSubject<Preferences, Never>
|
||||||
|
let willChange = PassthroughSubject<Preferences, Never>()
|
||||||
|
|
||||||
// MARK: - Appearance
|
// MARK: - Appearance
|
||||||
var showRepliesInProfiles = false { didSet { didChange.send(self) } }
|
var showRepliesInProfiles = false { willSet { willChange.send(self) } }
|
||||||
var avatarStyle = AvatarStyle.roundRect { didSet { didChange.send(self) } }
|
var avatarStyle = AvatarStyle.roundRect { willSet { willChange.send(self) } }
|
||||||
var hideCustomEmojiInUsernames = false { didSet { didChange.send(self) } }
|
var hideCustomEmojiInUsernames = false { willSet { willChange.send(self) } }
|
||||||
|
|
||||||
// MARK: - Behavior
|
// MARK: - Behavior
|
||||||
var defaultPostVisibility = Status.Visibility.public { didSet { didChange.send(self) } }
|
var defaultPostVisibility = Status.Visibility.public { willSet { willChange.send(self) } }
|
||||||
var automaticallySaveDrafts = true { didSet { didChange.send(self) } }
|
var automaticallySaveDrafts = true { willSet { willChange.send(self) } }
|
||||||
var openLinksInApps = true { didSet { didChange.send(self) } }
|
var openLinksInApps = true { willSet { willChange.send(self) } }
|
||||||
|
|
||||||
// MARK: - Advanced
|
// MARK: - Advanced
|
||||||
var silentActions: [String: Permission] = [:] { didSet { didChange.send(self) } }
|
var silentActions: [String: Permission] = [:] { willSet { willChange.send(self) } }
|
||||||
var statusContentType: StatusContentType = .plain { didSet { didChange.send(self) } }
|
var statusContentType: StatusContentType = .plain { willSet { willChange.send(self) } }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,15 @@ struct AdvancedPrefsView : View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
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)) {
|
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")) {
|
Picker(selection: _statusContentType.binding, label: Text("Post Content Type")) {
|
||||||
ForEach(StatusContentType.allCases.identified(by: \.self)) { type in
|
ForEach(StatusContentType.allCases, id: \.self) { type in
|
||||||
Text(type.displayName).tag(type)
|
Text(type.displayName).tag(type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section(header: Text("AUTOMATION")) {
|
Section(header: Text("AUTOMATION")) {
|
||||||
NavigationButton(destination: SilentActionPrefs()) {
|
NavigationLink(destination: SilentActionPrefs()) {
|
||||||
Text("Silent Action Permissions")
|
Text("Silent Action Permissions")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ struct AppearancePrefsView : View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
Toggle(isOn: $showRepliesInProfiles.binding) {
|
Toggle(isOn: _showRepliesInProfiles.binding) {
|
||||||
Text("Show Replies in Profiles")
|
Text("Show Replies in Profiles")
|
||||||
}
|
}
|
||||||
Toggle(isOn: $useCircularAvatars.binding) {
|
Toggle(isOn: _useCircularAvatars.binding) {
|
||||||
Text("Use Circular Avatars")
|
Text("Use Circular Avatars")
|
||||||
}
|
}
|
||||||
Toggle(isOn: $hideCustomEmojiInUsernames.binding) {
|
Toggle(isOn: _hideCustomEmojiInUsernames.binding) {
|
||||||
Text("Hide Custom Emoji in Usernames")
|
Text("Hide Custom Emoji in Usernames")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ struct BehaviorPrefsView : View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
Section {
|
Section {
|
||||||
Picker(selection: $defaultPostVisibility.binding, label: Text("Default Post Visibility")) {
|
Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) {
|
||||||
ForEach(Status.Visibility.allCases.identified(by: \.self)) { visibility in
|
ForEach(Status.Visibility.allCases, id: \.self) { visibility in
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: visibility.imageName)
|
Image(systemName: visibility.imageName)
|
||||||
Text(visibility.displayName)
|
Text(visibility.displayName)
|
||||||
|
@ -25,12 +25,12 @@ struct BehaviorPrefsView : View {
|
||||||
.tag(visibility)
|
.tag(visibility)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toggle(isOn: $automaticallySaveDrafts.binding) {
|
Toggle(isOn: _automaticallySaveDrafts.binding) {
|
||||||
Text("Automatically Save Drafts")
|
Text("Automatically Save Drafts")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Section {
|
Section {
|
||||||
Toggle(isOn: $openLinksInApps.binding) {
|
Toggle(isOn: _openLinksInApps.binding) {
|
||||||
Text("Open Links in Apps")
|
Text("Open Links in Apps")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,13 @@ struct PreferencesView : View {
|
||||||
// workaround: the navigation view is provided by MyProfileTableViewController so that it can inject the Done button
|
// workaround: the navigation view is provided by MyProfileTableViewController so that it can inject the Done button
|
||||||
// NavigationView {
|
// NavigationView {
|
||||||
List {
|
List {
|
||||||
NavigationButton(destination: AppearancePrefsView()) {
|
NavigationLink(destination: AppearancePrefsView()) {
|
||||||
Text("Appearance")
|
Text("Appearance")
|
||||||
}
|
}
|
||||||
NavigationButton(destination: BehaviorPrefsView()) {
|
NavigationLink(destination: BehaviorPrefsView()) {
|
||||||
Text("Behavior")
|
Text("Behavior")
|
||||||
}
|
}
|
||||||
NavigationButton(destination: AdvancedPrefsView()) {
|
NavigationLink(destination: AdvancedPrefsView()) {
|
||||||
Text("Advanced")
|
Text("Advanced")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct SilentActionPrefs : View {
|
||||||
@EnvironmentObject var preferences: Preferences
|
@EnvironmentObject var preferences: Preferences
|
||||||
|
|
||||||
var body: some View {
|
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)
|
SilentActionPermissionCell(source: source)
|
||||||
}.listStyle(.grouped)
|
}.listStyle(.grouped)
|
||||||
// List(Array(silentActions.keys).identified(by: \.self)) { application in
|
// List(Array(silentActions.keys).identified(by: \.self)) { application in
|
||||||
|
|
|
@ -47,7 +47,7 @@ extension EnhancedTableViewController {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
let actionProvider: UIContextMenuActionProvider = { (elements) in
|
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)
|
return UIContextMenuConfiguration(identifier: nil, previewProvider: previewProvider, actionProvider: actionProvider)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue