import SwiftUI /// The paired team and this device: who you are, until when, and Sign out, /// which revokes the device on the server. public struct AccountScreen: View { let model: EquipoAppModel let session: EquipoSession @State private var confirming = false public init(model: EquipoAppModel, session: EquipoSession) { self.model = model; self.session = session } public var body: some View { Form { Section(String(localized: "account.team", bundle: .module)) { LabeledContent(String(localized: "account.team_name", bundle: .module), value: session.teamName) LabeledContent(String(localized: "account.address", bundle: .module), value: session.origin.host ?? session.origin.absoluteString) if let me = session.me { LabeledContent(String(localized: "account.signed_in_as", bundle: .module), value: me.address) } } Section(String(localized: "account.device", bundle: .module)) { LabeledContent(String(localized: "account.device_name", bundle: .module), value: session.account.label) if let expires = session.account.credential?.expiresAt { LabeledContent(String(localized: "account.until", bundle: .module), value: expires.formatted(date: .long, time: .omitted)) } } MarkdownNotices() if session.account.oficinaIdentity != nil { EquipoOficinaAccountMenu(app: model, model: model.oficina.model) } else { Section { Button(String(localized: "account.sign_out", bundle: .module), role: .destructive) { confirming = true } } footer: { Text(String(localized: "account.sign_out_footer", bundle: .module)) } } } .formStyle(.grouped) .confirmationDialog(String(localized: "account.sign_out_confirm", bundle: .module), isPresented: $confirming) { Button(String(localized: "account.sign_out", bundle: .module), role: .destructive) { Task { await model.signOut() } } } } }