generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e58f40
commit d54e2f6
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// OptionsPanel.swift | ||
// StrokeCog | ||
// | ||
// Created by Vishnu Ravi on 4/4/24. | ||
// | ||
|
||
import Spezi | ||
import SwiftUI | ||
|
||
struct OptionsPanel: View { | ||
@AppStorage(StorageKeys.trackingPreference) private var trackingOn = true | ||
@Environment(LocationModule.self) private var locationModule | ||
|
||
@State private var showingSurveyAlert = false | ||
@State private var alertMessage = "" | ||
@State private var showingSurvey = false | ||
|
||
var body: some View { | ||
GroupBox { | ||
Button { | ||
self.showingSurvey.toggle() | ||
} label: { | ||
Text("OPTIONS_PANEL_SURVEY_BUTTON") | ||
.foregroundColor(.white) | ||
.frame(maxWidth: .infinity) | ||
} | ||
.alert(isPresented: $showingSurveyAlert) { | ||
Alert(title: Text("OPTIONS_ALERT_SURVEY_NOT_AVAILABLE"), | ||
message: Text(self.alertMessage), | ||
dismissButton: .default(Text("OPTIONS_ALERT_OK"))) | ||
} | ||
.sheet(isPresented: $showingSurvey) { | ||
// TODO: Launch Survey | ||
} | ||
} | ||
|
||
GroupBox { | ||
Toggle("TRACK_LOCATION_BUTTON", isOn: $trackingOn) | ||
.onChange(of: trackingOn) { _ in | ||
if trackingOn { | ||
locationModule.startTracking() | ||
} else { | ||
locationModule.stopTracking() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
OptionsPanel() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters