Transform to multi-account support
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user