added multi accounting #4
Build Unsigned iOS ipa / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned macOS App / Build macOS ZIP (push) Canceled after 0s
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s

This commit is contained in:
wt committed 2026-09-27 22:59:20 +07:00
1 parent 95a1c62b54
commit ca1a69e61f
5 files changed
+211 -34

No files matched your search

+26 -1
View File
@@ -12,6 +12,7 @@ struct SettingsView: View {
@State private var forgetHistory = false
@State private var avatarItem: PhotosPickerItem?
@State private var passcodeSheetMode: AppLockPasscodeSheet.Mode?
@State private var showingAddAccount = false
var body: some View {
#if os(iOS)
@@ -19,6 +20,7 @@ struct SettingsView: View {
Form {
formcontent()
}
.sheet(isPresented: $showingAddAccount) { LoginView(model: model) }
.navigationTitle("")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -34,13 +36,36 @@ struct SettingsView: View {
}
}
#else
formcontent()
formcontent().sheet(isPresented: $showingAddAccount) { LoginView(model: model) }
#endif
}
@ViewBuilder
private func formcontent() -> some View {
if let account = model.account {
Section("Аккаунты") {
ForEach(model.accounts) { configured in
Button {
Task { await model.switchAccount(to: configured) }
} label: {
HStack {
Image(systemName: configured.id == account.id ? "checkmark.circle.fill" : "person.circle")
.foregroundStyle(configured.id == account.id ? .green : .secondary)
VStack(alignment: .leading) {
Text(configured.displayName.isEmpty ? configured.normalizedJID : configured.displayName)
if !configured.displayName.isEmpty { Text(configured.normalizedJID).font(.caption).foregroundStyle(.secondary) }
}
Spacer()
}
}
.buttonStyle(.plain)
}
Button {
showingAddAccount = true
} label: {
Label("Добавить аккаунт", systemImage: "person.badge.plus")
}
}
Section("Профиль") {
HStack(spacing: 14) {
AvatarView(