Skip to content

Commit

Permalink
Add ability to review used scenario if there’s time left
Browse files Browse the repository at this point in the history
  • Loading branch information
viere1234 committed Mar 8, 2024
1 parent 0664f99 commit 10c3054
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions OPass/Fastpass/ScenarioView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ struct ScenarioView: View {
Section(header: Text(sectionID)) {
ForEach(EventStore.attendee?.scenarios[sectionID] ?? []) { scenario in
Button {
if scenario.used == nil {
// Only if the scenario not been used or there still countdown time left.
if Date().timeIntervalSince1970 - (scenario.used?.timeIntervalSince1970 ?? 0) - Double(scenario.countdown) > 0 {
if let errorText = scenario.disabled {
disableAlertString = String(localized: String.LocalizationValue(errorText))
isDisableAlertPresented.toggle()
Expand Down Expand Up @@ -73,7 +74,9 @@ struct ScenarioView: View {
Button(String(localized: "Cancel"), role: .cancel) { }
}
.sheet(item: $sheetScenarioDataItem) { scenario in
UseScenarioView(scenario: scenario)
UseScenarioView(
scenario: scenario,
used: (Date().timeIntervalSince1970 - (scenario.used?.timeIntervalSince1970 ?? 0.0) - Double(scenario.countdown) > 0.0) && scenario.used != nil)
}
}

Expand Down
12 changes: 9 additions & 3 deletions OPass/Fastpass/UseScenarioView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ struct UseScenarioView: View {

let scenario: Scenario
@EnvironmentObject var EventStore: EventStore
@State private var viewState = 0
@State private var viewState: Int
@State private var isHttp403AlertPresented = false
@State private var usedTime: TimeInterval = 0
@State private var usedTime: TimeInterval
@Environment(\.dismiss) var dismiss


init (scenario: Scenario, used: Bool) {
self.scenario = scenario
self._viewState = .init(wrappedValue: used ? 2 : 0)
self._usedTime = .init(wrappedValue: used ? scenario.used!.timeIntervalSince1970 : 0)
}

var body: some View {
NavigationView {
VStack {
Expand Down

0 comments on commit 10c3054

Please sign in to comment.