Transform to multi-account support

This commit is contained in:
2025-08-01 19:31:53 +02:00
parent 351f08e43e
commit 68239727fa
24 changed files with 635 additions and 503 deletions
+43
View File
@@ -0,0 +1,43 @@
//
// AccountButton.swift
// meterios
//
// (c) 2025 Martin "maride" Dessauer
//
import SwiftUI
/// **AccountButton** creates a button showing all relevant information of a Mete user account: profile picture, name, and balance
struct AccountButton : View {
@Bindable private var account: Account
private let action: () -> Void
init(account: Account, action: @escaping () -> Void = {}) {
self.account = account
self.action = action
}
var body: some View {
Button(action: action) {
HStack {
// Profile Image
AsyncImageWithPlaceholder(url: account.displayImageURL, width: 64, height: 64).clipShape(Circle()).fixedSize()
Spacer(minLength: 16.0)
// Account, Address & Balance
VStack(alignment: .leading) {
HStack {
if account.displayName != nil {
Text(account.displayName!).fontWeight(.bold)
}
Divider()
if account.balance != nil {
Text(account.balance!.formatted(.currency(code: "EUR"))).foregroundStyle(account.balance! > 0 ? .green : .red)
}
}.fixedSize()
Text("\(account.address)").fontWeight(.thin)
}.fixedSize()
}.fixedSize()
}
}
}