65 lines
1.8 KiB
Swift
65 lines
1.8 KiB
Swift
//
|
|
// DrinkDetailView.swift
|
|
// meterios-watch
|
|
//
|
|
// (c) 2025 Martin "maride" Dessauer
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct DrinkDetailView: View {
|
|
private var drink: MeteClientDrink
|
|
|
|
@State var shouldShowTransactionSheet = false
|
|
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
init(drink: MeteClientDrink) {
|
|
self.drink = drink
|
|
}
|
|
|
|
var body: some View {
|
|
VStack {
|
|
// Title
|
|
Text(drink.name).font(.title)
|
|
|
|
// Basic info
|
|
HStack {
|
|
VStack {
|
|
if drink.caffeine != nil {
|
|
Text(String(format: "%img", drink.caffeine!)).fontWeight(.bold)
|
|
} else {
|
|
Text("? mg").fontWeight(.bold)
|
|
}
|
|
Text(String(localized: "CAFFEINE")).fontWeight(Font.Weight.thin)
|
|
}
|
|
Divider()
|
|
VStack {
|
|
if drink.price != nil {
|
|
Text(drink.price!.formatted(.currency(code: "EUR"))).fontWeight(.bold)
|
|
} else {
|
|
Text("? €").fontWeight(.bold)
|
|
}
|
|
Text(String(localized: "PRICE")).fontWeight(Font.Weight.thin)
|
|
}
|
|
}
|
|
|
|
// Pick button
|
|
Button(action: {
|
|
// Open the transaction sheet
|
|
shouldShowTransactionSheet = true
|
|
}) {
|
|
Text(String(localized: "POISON_PICKED"))
|
|
}.tint(.green)
|
|
}
|
|
|
|
// Transaction sheet
|
|
.sheet(isPresented: $shouldShowTransactionSheet) {
|
|
// Sheet dismissed - dismiss detail perspective as well.
|
|
dismiss()
|
|
} content: {
|
|
TransactionView(drinkID: drink.id).interactiveDismissDisabled()
|
|
}
|
|
}
|
|
}
|