Files
Gas-Tank-AR-App/GasTankAR/Views/Leads/Overview/LeadOverviewHeaderView.swift

63 lines
2.3 KiB
Swift

import SwiftUI
struct LeadOverviewHeaderView: View {
let session: LoginSession
let lastUpdated: Date?
let isLoading: Bool
let onRefresh: () -> Void
let onLogout: () -> Void
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
var body: some View {
let layout = dynamicTypeSize.isAccessibilitySize
? AnyLayout(VStackLayout(alignment: .leading, spacing: 12))
: AnyLayout(HStackLayout(spacing: 20))
layout {
HStack(spacing: 8) {
Image("LoginLogo")
.resizable()
.scaledToFit()
.frame(width: 34, height: 34)
.clipShape(.rect(cornerRadius: 8))
.accessibilityHidden(true)
Text("DrachenGas")
.font(.title3.bold())
.foregroundStyle(LeadOverviewStyle.blue)
}
Button(action: onRefresh) {
HStack(spacing: 6) {
Image(systemName: "arrow.clockwise")
if let lastUpdated {
Text("Aktualisiert um \(lastUpdated.formatted(.dateTime.hour().minute().second()))")
} else {
Text("Aktualisieren")
}
}
.font(.subheadline)
.foregroundStyle(.secondary)
}
.disabled(isLoading)
if !dynamicTypeSize.isAccessibilitySize {
Spacer(minLength: 8)
}
Menu {
Button("Abmelden", systemImage: "rectangle.portrait.and.arrow.right", action: onLogout)
} label: {
HStack(spacing: 10) {
if let displayName = session.displayName {
Text(displayName)
}
Text(session.salesCode)
.font(.subheadline.bold())
.padding(10)
.background(LeadOverviewStyle.blue, in: .capsule)
.foregroundStyle(.white)
}
.foregroundStyle(LeadOverviewStyle.blue)
}
.accessibilityLabel("Benutzerkonto \(session.displayName ?? session.salesCode)")
}
.buttonStyle(.plain)
}
}