Impressia/Vernissage/Widgets/SettingsView/AccountsSection.swift

41 lines
1.1 KiB
Swift
Raw Normal View History

2023-01-13 13:37:01 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import SwiftUI
struct AccountsSection: View {
@State private var accounts: [AccountData] = []
var body: some View {
Section("Accounts") {
ForEach(self.accounts) { account in
UsernameRow(accountAvatar: account.avatar,
accountDisplayName: account.displayName,
accountUsername: account.username,
cachedAvatar: CacheAvatarService.shared.getImage(for: account.id))
}
NavigationLink(destination: SignInView()) {
HStack {
Text("New account")
Spacer()
Image(systemName: "person.crop.circle.badge.plus")
}
}
}
.task {
self.accounts = AccountDataHandler.shared.getAccountsData()
}
}
}
struct AccountsSection_Previews: PreviewProvider {
static var previews: some View {
AccountsSection()
}
}