2022-12-30 08:36:22 +01:00
|
|
|
import SwiftUI
|
|
|
|
import DesignSystem
|
|
|
|
|
|
|
|
struct AppAccountView: View {
|
|
|
|
@EnvironmentObject var appAccounts: AppAccountsManager
|
|
|
|
@StateObject var viewModel: AppAccountViewModel
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack {
|
|
|
|
if let account = viewModel.account {
|
|
|
|
ZStack(alignment: .topTrailing) {
|
|
|
|
AvatarView(url: account.avatar)
|
|
|
|
if viewModel.appAccount.id == appAccounts.currentAccount.id {
|
|
|
|
Image(systemName: "checkmark.circle.fill")
|
2023-01-08 19:45:11 +01:00
|
|
|
.foregroundStyle(.white, .green)
|
2022-12-30 08:36:22 +01:00
|
|
|
.offset(x: 5, y: -5)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
if let account = viewModel.account {
|
2022-12-30 22:30:18 +01:00
|
|
|
account.displayNameWithEmojis
|
|
|
|
Text("\(account.username)@\(viewModel.appAccount.server)")
|
|
|
|
.font(.subheadline)
|
2022-12-30 08:36:22 +01:00
|
|
|
.foregroundColor(.gray)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.onAppear {
|
|
|
|
Task {
|
|
|
|
await viewModel.fetchAccount()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|