Merge branch 'develop' into non-pure-black-mode

This commit is contained in:
Shadowfacts 2023-02-02 23:14:27 -05:00
commit 512eec09a8
2 changed files with 98 additions and 89 deletions

View File

@ -6,11 +6,11 @@
// //
import SwiftUI import SwiftUI
import TTTKit
struct PreferencesView: View { struct PreferencesView: View {
let mastodonController: MastodonController let mastodonController: MastodonController
@ObservedObject var localData = LocalData.shared
@ObservedObject private var localData = LocalData.shared
@State private var showingLogoutConfirmation = false @State private var showingLogoutConfirmation = false
init(mastodonController: MastodonController) { init(mastodonController: MastodonController) {
@ -18,10 +18,18 @@ struct PreferencesView: View {
} }
var body: some View { var body: some View {
// workaround: the navigation view is provided by MyProfileTableViewController so that it can inject the Done button
// NavigationView {
List { List {
Section(header: Text("Accounts")) { accountsSection
preferencesSection
aboutSection
}
.listStyle(.insetGrouped)
.navigationBarTitle("Preferences")
.navigationBarTitleDisplayMode(.inline)
}
private var accountsSection: some View {
Section {
ForEach(localData.accounts, id: \.accessToken) { (account) in ForEach(localData.accounts, id: \.accessToken) { (account) in
Button(action: { Button(action: {
NotificationCenter.default.post(name: .activateAccount, object: nil, userInfo: ["account": account]) NotificationCenter.default.post(name: .activateAccount, object: nil, userInfo: ["account": account])
@ -66,7 +74,6 @@ struct PreferencesView: View {
}) { }) {
Text("Add Account...") Text("Add Account...")
} }
if localData.getMostRecentAccount() != nil {
Button(action: { Button(action: {
self.showingLogoutConfirmation = true self.showingLogoutConfirmation = true
}) { }) {
@ -74,9 +81,12 @@ struct PreferencesView: View {
}.alert(isPresented: $showingLogoutConfirmation) { }.alert(isPresented: $showingLogoutConfirmation) {
Alert(title: Text("Are you sure you want to logout?"), message: nil, primaryButton: .destructive(Text("Logout"), action: self.logoutPressed), secondaryButton: .cancel()) Alert(title: Text("Are you sure you want to logout?"), message: nil, primaryButton: .destructive(Text("Logout"), action: self.logoutPressed), secondaryButton: .cancel())
} }
} header: {
Text("Accounts")
} }
} }
private var preferencesSection: some View {
Section { Section {
NavigationLink(destination: AppearancePrefsView()) { NavigationLink(destination: AppearancePrefsView()) {
Text("Appearance") Text("Appearance")
@ -97,7 +107,9 @@ struct PreferencesView: View {
Text("Advanced") Text("Advanced")
} }
} }
}
private var aboutSection: some View {
Section { Section {
NavigationLink("About") { NavigationLink("About") {
AboutView() AboutView()
@ -110,10 +122,6 @@ struct PreferencesView: View {
} }
} }
} }
.listStyle(InsetGroupedListStyle())
.navigationBarTitle(Text("Preferences"), displayMode: .inline)
// }
}
func logoutPressed() { func logoutPressed() {
NotificationCenter.default.post(name: .userLoggedOut, object: nil) NotificationCenter.default.post(name: .userLoggedOut, object: nil)

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
import Pachyderm import Pachyderm
import SwiftUI
class MyProfileViewController: ProfileViewController { class MyProfileViewController: ProfileViewController {