48 lines
1.9 KiB
Swift
48 lines
1.9 KiB
Swift
// MARK: - Blind Box Controls
|
|
import SwiftUI
|
|
|
|
struct BlindBoxControls: View {
|
|
let mediaType: BlindBoxMediaType
|
|
let animationPhase: BlindBoxAnimationPhase
|
|
let countdown: (minutes: Int, seconds: Int, milliseconds: Int)
|
|
let onButtonTap: () -> Void
|
|
let onCountdownStart: () -> Void
|
|
|
|
var body: some View {
|
|
if mediaType == .all {
|
|
Button(action: onButtonTap) {
|
|
if animationPhase == .loading {
|
|
Text("Next: \(countdown.minutes):\(String(format: "%02d", countdown.seconds)).\(String(format: "%02d", countdown.milliseconds))")
|
|
.font(Typography.font(for: .body))
|
|
.fontWeight(.bold)
|
|
.frame(maxWidth: .infinity)
|
|
.padding()
|
|
.background(Color.white)
|
|
.foregroundColor(.black)
|
|
.cornerRadius(32)
|
|
.onAppear(perform: onCountdownStart)
|
|
} else if animationPhase == .ready {
|
|
Text("Ready")
|
|
.font(Typography.font(for: .body))
|
|
.fontWeight(.bold)
|
|
.frame(maxWidth: .infinity)
|
|
.padding()
|
|
.background(Color.themePrimary)
|
|
.foregroundColor(Color.themeTextMessageMain)
|
|
.cornerRadius(32)
|
|
} else {
|
|
Text("Go to Buy")
|
|
.font(Typography.font(for: .body))
|
|
.fontWeight(.bold)
|
|
.frame(maxWidth: .infinity)
|
|
.padding()
|
|
.background(Color.themePrimary)
|
|
.foregroundColor(Color.themeTextMessageMain)
|
|
.cornerRadius(32)
|
|
}
|
|
}
|
|
.padding(.horizontal)
|
|
}
|
|
}
|
|
}
|