mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-18 20:15:36 +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)
|
||||
}
|
||||
}
|
||||
@Published var availableAccount: [AppAccount]
|
||||
@Published var availableAccounts: [AppAccount]
|
||||
@Published var currentClient: Client
|
||||
|
||||
init() {
|
||||
var defaultAccount = AppAccount(server: IceCubesApp.defaultServer, oauthToken: nil)
|
||||
do {
|
||||
let keychainAccounts = try AppAccount.retrieveAll()
|
||||
availableAccount = keychainAccounts
|
||||
availableAccounts = keychainAccounts
|
||||
defaultAccount = keychainAccounts.last ?? defaultAccount
|
||||
} catch {}
|
||||
currentAccount = defaultAccount
|
||||
availableAccount = [defaultAccount]
|
||||
availableAccounts = [defaultAccount]
|
||||
currentClient = .init(server: defaultAccount.server, oauthToken: defaultAccount.oauthToken)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ struct SettingsTabs: View {
|
|||
NavigationStack {
|
||||
Form {
|
||||
appSection
|
||||
accountSection
|
||||
accountsSection
|
||||
themeSection
|
||||
instanceSection
|
||||
}
|
||||
|
@ -43,16 +43,19 @@ struct SettingsTabs: View {
|
|||
}
|
||||
}
|
||||
|
||||
private var accountSection: some View {
|
||||
private var accountsSection: some View {
|
||||
Section("Account") {
|
||||
if let accountData = currentAccount.account {
|
||||
VStack(alignment: .leading) {
|
||||
Text(appAccountsManager.currentAccount.server)
|
||||
.font(.headline)
|
||||
Text(accountData.displayName)
|
||||
Text(accountData.username)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.gray)
|
||||
HStack {
|
||||
AvatarView(url: accountData.avatar)
|
||||
VStack(alignment: .leading) {
|
||||
Text(appAccountsManager.currentAccount.server)
|
||||
.font(.headline)
|
||||
Text(accountData.displayName)
|
||||
Text(accountData.username)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
signOutButton
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue