111 lines
3.7 KiB
Swift
111 lines
3.7 KiB
Swift
// AppearancePrefsView.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 6/13/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct AppearancePrefsView : View {
|
|
@ObservedObject var preferences = Preferences.shared
|
|
|
|
private var theme: Binding<UIUserInterfaceStyle> = Binding(get: {
|
|
Preferences.shared.theme
|
|
}, set: {
|
|
Preferences.shared.theme = $0
|
|
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
|
})
|
|
private var accentColor: Binding<Preferences.AccentColor> = Binding {
|
|
Preferences.shared.accentColor
|
|
} set: {
|
|
Preferences.shared.accentColor = $0
|
|
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
|
}
|
|
|
|
private var useCircularAvatars: Binding<Bool> = Binding(get: {
|
|
Preferences.shared.avatarStyle == .circle
|
|
}) {
|
|
Preferences.shared.avatarStyle = $0 ? .circle : .roundRect
|
|
}
|
|
|
|
var body: some View {
|
|
List {
|
|
themeSection
|
|
accountsSection
|
|
postsSection
|
|
}
|
|
.listStyle(InsetGroupedListStyle())
|
|
.navigationBarTitle(Text("Appearance"))
|
|
}
|
|
|
|
private var themeSection: some View {
|
|
Section {
|
|
Picker(selection: theme, label: Text("Theme")) {
|
|
Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified)
|
|
Text("Light").tag(UIUserInterfaceStyle.light)
|
|
Text("Dark").tag(UIUserInterfaceStyle.dark)
|
|
}
|
|
|
|
Picker(selection: accentColor, label: Text("Accent Color")) {
|
|
ForEach(Preferences.AccentColor.allCases, id: \.rawValue) { color in
|
|
HStack {
|
|
Text(color.name)
|
|
if let color = color.color {
|
|
Spacer()
|
|
Image(uiImage: UIImage(systemName: "circle.fill")!.withTintColor(color, renderingMode: .alwaysTemplate).withRenderingMode(.alwaysOriginal))
|
|
}
|
|
}
|
|
.tag(color)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private var accountsSection: some View {
|
|
Section(header: Text("Accounts")) {
|
|
Toggle(isOn: useCircularAvatars) {
|
|
Text("Use Circular Avatars")
|
|
}
|
|
Toggle(isOn: $preferences.hideCustomEmojiInUsernames) {
|
|
Text("Hide Custom Emoji in Usernames")
|
|
}
|
|
}
|
|
}
|
|
|
|
private var postsSection: some View {
|
|
Section(header: Text("Posts")) {
|
|
Toggle(isOn: $preferences.showIsStatusReplyIcon) {
|
|
Text("Show Status Reply Icons")
|
|
}
|
|
Toggle(isOn: $preferences.alwaysShowStatusVisibilityIcon) {
|
|
Text("Always Show Status Visibility Icons")
|
|
}
|
|
Toggle(isOn: $preferences.hideActionsInTimeline) {
|
|
Text("Hide Actions on Timeline")
|
|
}
|
|
Toggle(isOn: $preferences.showLinkPreviews) {
|
|
Text("Show Link Previews")
|
|
}
|
|
NavigationLink("Leading Swipe Actions") {
|
|
SwipeActionsPrefsView(selection: $preferences.leadingStatusSwipeActions)
|
|
.edgesIgnoringSafeArea(.all)
|
|
.navigationTitle("Leading Swipe Actions")
|
|
}
|
|
NavigationLink("Trailing Swipe Actions") {
|
|
SwipeActionsPrefsView(selection: $preferences.trailingStatusSwipeActions)
|
|
.edgesIgnoringSafeArea(.all)
|
|
.navigationTitle("Trailing Swipe Actions")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct AppearancePrefsView_Previews : PreviewProvider {
|
|
static var previews: some View {
|
|
AppearancePrefsView()
|
|
}
|
|
}
|
|
#endif
|