2019-06-14 00:53:17 +00:00
|
|
|
// AppearancePrefsView.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 6/13/19.
|
|
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2023-02-03 04:02:11 +00:00
|
|
|
import Combine
|
2019-06-14 00:53:17 +00:00
|
|
|
|
|
|
|
struct AppearancePrefsView : View {
|
2019-11-15 00:53:00 +00:00
|
|
|
@ObservedObject var preferences = Preferences.shared
|
|
|
|
|
2023-02-03 04:02:11 +00:00
|
|
|
private var appearanceChangePublisher: some Publisher<Void, Never> {
|
|
|
|
preferences.$theme
|
|
|
|
.map { _ in () }
|
|
|
|
.merge(with: preferences.$pureBlackDarkMode.map { _ in () },
|
|
|
|
preferences.$accentColor.map { _ in () }
|
|
|
|
)
|
|
|
|
// the prefrence publishers are all willSet, but want to notify after the change, so wait one runloop iteration
|
|
|
|
.receive(on: DispatchQueue.main)
|
2023-01-14 16:27:41 +00:00
|
|
|
}
|
2019-12-31 05:12:18 +00:00
|
|
|
|
2023-01-14 16:27:41 +00:00
|
|
|
private var useCircularAvatars: Binding<Bool> = Binding(get: {
|
2019-11-15 00:53:00 +00:00
|
|
|
Preferences.shared.avatarStyle == .circle
|
|
|
|
}) {
|
|
|
|
Preferences.shared.avatarStyle = $0 ? .circle : .roundRect
|
|
|
|
}
|
|
|
|
|
2019-06-14 00:53:17 +00:00
|
|
|
var body: some View {
|
|
|
|
List {
|
2023-01-14 16:27:41 +00:00
|
|
|
themeSection
|
|
|
|
accountsSection
|
|
|
|
postsSection
|
|
|
|
}
|
2023-02-03 04:29:44 +00:00
|
|
|
.listStyle(.insetGrouped)
|
|
|
|
.appGroupedScrollBackgroundIfAvailable()
|
2023-01-14 16:27:41 +00:00
|
|
|
.navigationBarTitle(Text("Appearance"))
|
|
|
|
}
|
|
|
|
|
|
|
|
private var themeSection: some View {
|
|
|
|
Section {
|
2023-02-03 04:02:11 +00:00
|
|
|
Picker(selection: $preferences.theme, label: Text("Theme")) {
|
2019-12-31 05:12:18 +00:00
|
|
|
Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified)
|
|
|
|
Text("Light").tag(UIUserInterfaceStyle.light)
|
|
|
|
Text("Dark").tag(UIUserInterfaceStyle.dark)
|
|
|
|
}
|
2023-01-14 16:27:41 +00:00
|
|
|
|
2023-02-03 04:02:11 +00:00
|
|
|
Toggle(isOn: $preferences.pureBlackDarkMode) {
|
|
|
|
Text("Pure Black Dark Mode")
|
|
|
|
}
|
|
|
|
|
|
|
|
Picker(selection: $preferences.accentColor, label: Text("Accent Color")) {
|
2023-01-14 16:27:41 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2020-08-16 18:58:10 +00:00
|
|
|
}
|
2023-02-03 04:02:11 +00:00
|
|
|
.onReceive(appearanceChangePublisher) { _ in
|
|
|
|
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
|
|
|
}
|
2023-02-03 04:29:44 +00:00
|
|
|
.listRowBackground(Color.appGroupedCellBackground)
|
2020-08-16 18:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private var accountsSection: some View {
|
|
|
|
Section(header: Text("Accounts")) {
|
2019-11-15 00:53:00 +00:00
|
|
|
Toggle(isOn: useCircularAvatars) {
|
2019-06-14 00:53:17 +00:00
|
|
|
Text("Use Circular Avatars")
|
|
|
|
}
|
2019-11-15 00:53:00 +00:00
|
|
|
Toggle(isOn: $preferences.hideCustomEmojiInUsernames) {
|
2019-06-14 00:53:17 +00:00
|
|
|
Text("Hide Custom Emoji in Usernames")
|
|
|
|
}
|
2020-08-16 18:58:10 +00:00
|
|
|
}
|
2023-02-03 04:29:44 +00:00
|
|
|
.listRowBackground(Color.appGroupedCellBackground)
|
2020-08-16 18:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private var postsSection: some View {
|
|
|
|
Section(header: Text("Posts")) {
|
2020-06-17 21:45:34 +00:00
|
|
|
Toggle(isOn: $preferences.showIsStatusReplyIcon) {
|
|
|
|
Text("Show Status Reply Icons")
|
|
|
|
}
|
2020-06-17 22:00:13 +00:00
|
|
|
Toggle(isOn: $preferences.alwaysShowStatusVisibilityIcon) {
|
|
|
|
Text("Always Show Status Visibility Icons")
|
|
|
|
}
|
2022-04-08 22:42:15 +00:00
|
|
|
Toggle(isOn: $preferences.hideActionsInTimeline) {
|
|
|
|
Text("Hide Actions on Timeline")
|
|
|
|
}
|
2023-01-26 22:18:27 +00:00
|
|
|
Toggle(isOn: $preferences.showLinkPreviews) {
|
|
|
|
Text("Show Link Previews")
|
|
|
|
}
|
2022-11-27 01:13:16 +00:00
|
|
|
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")
|
|
|
|
}
|
2019-06-14 00:53:17 +00:00
|
|
|
}
|
2023-02-03 04:29:44 +00:00
|
|
|
.listRowBackground(Color.appGroupedCellBackground)
|
2019-06-14 00:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
struct AppearancePrefsView_Previews : PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
AppearancePrefsView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|