mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-06-05 21:38:50 +00:00
Add avatar in setting account view
This commit is contained in:
parent
d393c4b90f
commit
55409f97db
2 changed files with 15 additions and 12 deletions
|
@ -8,18 +8,18 @@ class AppAccountsManager: ObservableObject {
|
||||||
oauthToken: currentAccount.oauthToken)
|
oauthToken: currentAccount.oauthToken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Published var availableAccount: [AppAccount]
|
@Published var availableAccounts: [AppAccount]
|
||||||
@Published var currentClient: Client
|
@Published var currentClient: Client
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
var defaultAccount = AppAccount(server: IceCubesApp.defaultServer, oauthToken: nil)
|
var defaultAccount = AppAccount(server: IceCubesApp.defaultServer, oauthToken: nil)
|
||||||
do {
|
do {
|
||||||
let keychainAccounts = try AppAccount.retrieveAll()
|
let keychainAccounts = try AppAccount.retrieveAll()
|
||||||
availableAccount = keychainAccounts
|
availableAccounts = keychainAccounts
|
||||||
defaultAccount = keychainAccounts.last ?? defaultAccount
|
defaultAccount = keychainAccounts.last ?? defaultAccount
|
||||||
} catch {}
|
} catch {}
|
||||||
currentAccount = defaultAccount
|
currentAccount = defaultAccount
|
||||||
availableAccount = [defaultAccount]
|
availableAccounts = [defaultAccount]
|
||||||
currentClient = .init(server: defaultAccount.server, oauthToken: defaultAccount.oauthToken)
|
currentClient = .init(server: defaultAccount.server, oauthToken: defaultAccount.oauthToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct SettingsTabs: View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
Form {
|
Form {
|
||||||
appSection
|
appSection
|
||||||
accountSection
|
accountsSection
|
||||||
themeSection
|
themeSection
|
||||||
instanceSection
|
instanceSection
|
||||||
}
|
}
|
||||||
|
@ -43,16 +43,19 @@ struct SettingsTabs: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var accountSection: some View {
|
private var accountsSection: some View {
|
||||||
Section("Account") {
|
Section("Account") {
|
||||||
if let accountData = currentAccount.account {
|
if let accountData = currentAccount.account {
|
||||||
VStack(alignment: .leading) {
|
HStack {
|
||||||
Text(appAccountsManager.currentAccount.server)
|
AvatarView(url: accountData.avatar)
|
||||||
.font(.headline)
|
VStack(alignment: .leading) {
|
||||||
Text(accountData.displayName)
|
Text(appAccountsManager.currentAccount.server)
|
||||||
Text(accountData.username)
|
.font(.headline)
|
||||||
.font(.footnote)
|
Text(accountData.displayName)
|
||||||
.foregroundColor(.gray)
|
Text(accountData.username)
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
signOutButton
|
signOutButton
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue