Indent + Restart label

This commit is contained in:
Lumaa 2024-03-23 11:13:43 +01:00
parent b07467f1a7
commit af2d85dcc1
1 changed files with 121 additions and 121 deletions

View File

@ -4,146 +4,146 @@ import SwiftUI
import SwiftData import SwiftData
import WatchConnectivity import WatchConnectivity
//TODO: "Privacy" with mutelist, blocklist
struct SettingsView: View { struct SettingsView: View {
@Environment(UniversalNavigator.self) private var uniNav: UniversalNavigator @Environment(UniversalNavigator.self) private var uniNav: UniversalNavigator
@Query private var loggedAccounts: [LoggedAccount] @Query private var loggedAccounts: [LoggedAccount]
@StateObject var navigator: Navigator @EnvironmentObject private var navigator: Navigator
@State private var switched: Bool = false @State private var switched: Bool = false
var body: some View { var body: some View {
NavigationStack(path: $navigator.path) { List {
List { if loggedAccounts.count > 0 {
if loggedAccounts.count > 0 { Section {
Section { ForEach(loggedAccounts) { logged in
ForEach(loggedAccounts) { logged in if let app = logged.app {
if let app = logged.app { SwitcherRow(app: app, loggedAccount: logged)
SwitcherRow(app: app, loggedAccount: logged) .listRowThreaded()
.listRowThreaded()
}
}
if AppDelegate.premium || loggedAccounts.count < 3 {
Button {
uniNav.presentedSheet = .mastodonLogin(logged: $switched)
} label: {
Label("settings.account-switcher.add", systemImage: "person.crop.circle.badge.plus")
.foregroundStyle(Color.blue)
}
.listRowThreaded()
} }
} }
.onChange(of: switched) { _, new in if AppDelegate.premium || loggedAccounts.count < 3 {
if new == true { Button {
// switched correctly uniNav.presentedSheet = .mastodonLogin(logged: $switched)
HapticManager.playHaptics(haptics: Haptic.success) } label: {
uniNav.selectedTab = .timeline Label("settings.account-switcher.add", systemImage: "person.crop.circle.badge.plus")
navigator.path = [] .foregroundStyle(Color.blue)
}
}
} else {
Section {
//MARK: Remove in later update
HStack(alignment: .center) {
Spacer()
Text("settings.account-switcher.relog")
.foregroundStyle(Color.gray)
.multilineTextAlignment(.center)
.font(.caption)
Spacer()
} }
.listRowThreaded() .listRowThreaded()
} }
} }
.onChange(of: switched) { _, new in
Spacer() if new == true {
.frame(height: 30) // switched correctly
.listRowThreaded() HapticManager.playHaptics(haptics: Haptic.success)
uniNav.selectedTab = .timeline
navigator.path = []
}
}
} else {
Section { Section {
Button { //MARK: Remove in later update
navigator.navigate(to: .about) HStack(alignment: .center) {
} label: { Spacer()
Label("about", systemImage: "info.circle") Text("settings.account-switcher.relog")
.foregroundStyle(Color.gray)
.multilineTextAlignment(.center)
.font(.caption)
Spacer()
} }
.listRowThreaded() .listRowThreaded()
Button {
navigator.navigate(to: .privacy)
} label: {
Label("privacy", systemImage: "lock")
}
.listRowThreaded()
Button {
navigator.presentedCover = .shop
} label: {
Label {
Text(String("Threaded+"))
} icon: {
Image("HeroPlus")
.resizable()
.scaledToFit()
}
}
.listRowThreaded()
Button {
navigator.navigate(to: .support)
} label: {
Label("setting.support", systemImage: "person.crop.circle.badge.questionmark")
}
.listRowThreaded()
Button {
navigator.navigate(to: .appearence)
} label: {
Label("setting.appearence", systemImage: "rectangle.3.group")
}
.listRowThreaded()
Button {
if loggedAccounts.count <= 1 {
AppAccount.clear()
navigator.path = []
uniNav.selectedTab = .timeline
uniNav.presentedCover = .welcome
} else {
Task {
if let app = loggedAccounts[0].app {
let c: Client = Client(server: app.server, oauthToken: app.oauthToken)
let am: AccountManager = .init(client: c)
let fetched: Account? = await am.fetchAccount()
if fetched == nil {
am.clear()
} else {
AccountManager.shared.setAccount(fetched!)
AccountManager.shared.setClient(c)
navigator.path = []
uniNav.selectedTab = .timeline
}
}
}
}
} label: {
Text("logout")
.foregroundStyle(.red)
}
.tint(Color.red)
.listRowThreaded()
} }
} }
.withAppRouter(navigator)
.withCovers(sheetDestination: $navigator.presentedCover) Spacer()
.listThreaded() .frame(height: 30)
.environmentObject(navigator) .listRowThreaded()
.navigationTitle("settings")
.navigationBarTitleDisplayMode(.inline) Section {
Text("settings.restart-app")
.font(.caption)
.foregroundStyle(Color.gray)
.listRowThreaded()
Button {
navigator.navigate(to: .about)
} label: {
Label("about", systemImage: "info.circle")
}
.listRowThreaded()
Button {
navigator.navigate(to: .privacy)
} label: {
Label("privacy", systemImage: "lock")
}
.listRowThreaded()
Button {
navigator.presentedCover = .shop
} label: {
Label {
Text(String("Threaded+"))
} icon: {
Image("HeroPlus")
.resizable()
.scaledToFit()
}
}
.listRowThreaded()
Button {
navigator.navigate(to: .support)
} label: {
Label("setting.support", systemImage: "person.crop.circle.badge.questionmark")
}
.listRowThreaded()
Button {
navigator.navigate(to: .appearence)
} label: {
Label("setting.appearence", systemImage: "rectangle.3.group")
}
.listRowThreaded()
Button {
if loggedAccounts.count <= 1 {
AppAccount.clear()
navigator.path = []
uniNav.selectedTab = .timeline
uniNav.presentedCover = .welcome
} else {
Task {
if let app = loggedAccounts[0].app {
let c: Client = Client(server: app.server, oauthToken: app.oauthToken)
let am: AccountManager = .init(client: c)
let fetched: Account? = await am.fetchAccount()
if fetched == nil {
am.clear()
} else {
AccountManager.shared.setAccount(fetched!)
AccountManager.shared.setClient(c)
navigator.path = []
uniNav.selectedTab = .timeline
}
}
}
}
} label: {
Text("logout")
.foregroundStyle(.red)
}
.tint(Color.red)
.listRowThreaded()
}
} }
.withAppRouter(navigator)
.withCovers(sheetDestination: $navigator.presentedCover)
.listThreaded()
.navigationTitle("settings")
.navigationBarTitleDisplayMode(.inline)
} }
} }