Skip to content

Commit

Permalink
Setup options panel
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Apr 5, 2024
1 parent 7e58f40 commit d54e2f6
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
4 changes: 4 additions & 0 deletions StrokeCog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
6347EB6A2BBBF3AC008E0C4A /* MapboxMaps in Frameworks */ = {isa = PBXBuildFile; productRef = 6347EB692BBBF3AC008E0C4A /* MapboxMaps */; };
6347EB742BBBF442008E0C4A /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6347EB732BBBF442008E0C4A /* Constants.swift */; };
63497B702BBF6ECE001F8419 /* LocationDataPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63497B6F2BBF6ECE001F8419 /* LocationDataPoint.swift */; };
63497B732BBF855E001F8419 /* OptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63497B722BBF855E001F8419 /* OptionsPanel.swift */; };
63BBF8162BB8993B006890CE /* StudyIDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63BBF8152BB8993B006890CE /* StudyIDView.swift */; };
63BBF8192BB89CF7006890CE /* studyIDs.csv in Resources */ = {isa = PBXBuildFile; fileRef = 63BBF8182BB89CF7006890CE /* studyIDs.csv */; };
63F4C3992BBCCC300033D985 /* MapboxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F4C3982BBCCC300033D985 /* MapboxView.swift */; };
Expand Down Expand Up @@ -152,6 +153,7 @@
6347EB632BBBA895008E0C4A /* StrokeCogMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StrokeCogMapView.swift; sourceTree = "<group>"; };
6347EB732BBBF442008E0C4A /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
63497B6F2BBF6ECE001F8419 /* LocationDataPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationDataPoint.swift; sourceTree = "<group>"; };
63497B722BBF855E001F8419 /* OptionsPanel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionsPanel.swift; sourceTree = "<group>"; };
63BBF8152BB8993B006890CE /* StudyIDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyIDView.swift; sourceTree = "<group>"; };
63BBF8182BB89CF7006890CE /* studyIDs.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = studyIDs.csv; sourceTree = "<group>"; };
63F4C3982BBCCC300033D985 /* MapboxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -330,6 +332,7 @@
children = (
6347EB632BBBA895008E0C4A /* StrokeCogMapView.swift */,
63F4C3982BBCCC300033D985 /* MapboxView.swift */,
63497B722BBF855E001F8419 /* OptionsPanel.swift */,
);
path = Map;
sourceTree = "<group>";
Expand Down Expand Up @@ -643,6 +646,7 @@
2FE5DC3829EDD7CA004B9AB4 /* InterestingModules.swift in Sources */,
2FE5DC3529EDD7CA004B9AB4 /* Consent.swift in Sources */,
2FE5DC4529EDD7F2004B9AB4 /* Binding+Negate.swift in Sources */,
63497B732BBF855E001F8419 /* OptionsPanel.swift in Sources */,
2FC975A82978F11A00BA99FE /* Home.swift in Sources */,
2FE5DC4E29EDD7FA004B9AB4 /* ScheduleView.swift in Sources */,
A9DFE8A92ABE551400428242 /* AccountButton.swift in Sources */,
Expand Down
53 changes: 53 additions & 0 deletions StrokeCog/Map/OptionsPanel.swift
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"),

Check failure on line 29 in StrokeCog/Map/OptionsPanel.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Multiline Arguments Brackets Violation: Multiline arguments should have their surrounding brackets in a new line (multiline_arguments_brackets)
message: Text(self.alertMessage),
dismissButton: .default(Text("OPTIONS_ALERT_OK")))

Check failure on line 31 in StrokeCog/Map/OptionsPanel.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Multiline Arguments Brackets Violation: Multiline arguments should have their surrounding brackets in a new line (multiline_arguments_brackets)
}
.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()
}
26 changes: 26 additions & 0 deletions StrokeCog/Map/StrokeCogMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ struct StrokeCogMapView: View {
var body: some View {
ZStack {
MapManagerViewWrapper()

VStack {
Spacer()

GroupBox {
optionsPanelButton

if self.optionsPanelOpen {
OptionsPanel()
}
}
}
}
}

private var optionsPanelButton: some View {
Button {
withAnimation {
self.optionsPanelOpen.toggle()
}
} label: {
HStack {
Text("OPTIONS_PANEL_TITLE")
Spacer()
Image(systemName: self.optionsPanelOpen ? "chevron.down" : "chevron.up")

Check failure on line 47 in StrokeCog/Map/StrokeCogMapView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Accessibility Label for Image Violation: Images that provide context should have an accessibility label or should be explicitly hidden from accessibility (accessibility_label_for_image)
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions StrokeCog/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@
}
}
}
},
"OPTIONS_ALERT_OK" : {

},
"OPTIONS_ALERT_SURVEY_NOT_AVAILABLE" : {

},
"OPTIONS_PANEL_SURVEY_BUTTON" : {

},
"OPTIONS_PANEL_TITLE" : {

},
"PROJECT_LICENSE_DESCRIPTION" : {
"localizations" : {
Expand Down Expand Up @@ -517,6 +529,9 @@
}
}
}
},
"TRACK_LOCATION_BUTTON" : {

},
"WELCOME_AREA1_DESCRIPTION" : {
"localizations" : {
Expand Down

0 comments on commit d54e2f6

Please sign in to comment.