Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update location tracking settings #28

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "0382ca27f22fb3494cf657d8dc356dc282cd1193",
"version" : "3.4.1"
"revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b",
"version" : "3.5.0"
}
},
{
Expand Down Expand Up @@ -123,17 +123,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-common-ios.git",
"state" : {
"revision" : "8e3259433704add95894a3e7823f5658a17bd43b",
"version" : "24.5.0-rc.1"
"revision" : "add54e4b7d4cfe1e12600d73af6d38a536b37085",
"version" : "24.5.0"
}
},
{
"identity" : "mapbox-core-maps-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-core-maps-ios.git",
"state" : {
"revision" : "20d05d13d66371c46d486ce6d79d0e463df20fb9",
"version" : "11.5.0-rc.1"
"revision" : "5d5d126c7a0f743b05c8889437e788fdd2356308",
"version" : "11.5.0"
}
},
{
Expand All @@ -142,7 +142,7 @@
"location" : "https://github.com/mapbox/mapbox-maps-ios.git",
"state" : {
"branch" : "main",
"revision" : "a4fb127d3a48ce84fbff0aa922218766d27000e0"
"revision" : "833d90ca591fd24ca3bdea0e4298e943b8a949cd"
}
},
{
Expand Down Expand Up @@ -178,16 +178,16 @@
"location" : "https://github.com/StanfordBDHG/ResearchKitOnFHIR",
"state" : {
"revision" : "dcd5f95522ed02a873b03c9638dbf397b99c74e0",
"version" : "1.4.0"
"version" : "2.0.0"
}
},
{
"identity" : "spezi",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/Spezi",
"state" : {
"revision" : "734f90c19422a4196762b0e1dd055471066e89ee",
"version" : "1.3.0"
"revision" : "5ada3f3a18c86a658d140c6f4c45ca2e9d5e61ce",
"version" : "1.4.0"
}
},
{
Expand Down Expand Up @@ -222,8 +222,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziFoundation",
"state" : {
"revision" : "656f7659895dd4f182306963c2def75c16608472",
"version" : "1.1.1"
"revision" : "3326feab3dac120c16af63243615592990d33516",
"version" : "1.1.2"
}
},
{
Expand Down Expand Up @@ -258,8 +258,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziQuestionnaire.git",
"state" : {
"revision" : "76732ebcb0b521fa94d41c38a5fe35e6e1a87173",
"version" : "1.2.1"
"revision" : "853585fbdd5d2d0af440c805d629a025ef5545d9",
"version" : "1.2.2"
}
},
{
Expand All @@ -285,8 +285,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziViews.git",
"state" : {
"revision" : "0899c34c4b05e85b19e2dd2395783686aef81652",
"version" : "1.4.0"
"revision" : "ff61e6594677572df051b96905cc2a7a12cffd10",
"version" : "1.5.0"
}
},
{
Expand Down Expand Up @@ -321,8 +321,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/XCTestExtensions.git",
"state" : {
"revision" : "1fe9b8e76aeb7a132af37bfa0892160c9b662dcc",
"version" : "0.4.10"
"revision" : "cc2705fde81978eacd5496e14c9caf58909e2322",
"version" : "0.4.12"
}
},
{
Expand Down
41 changes: 31 additions & 10 deletions LifeSpace/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ struct AccountSheet: View {

@Environment(Account.self) private var account
@Environment(\.accountRequired) var accountRequired
@Environment(LocationModule.self) private var locationModule

@State var isInSetup = false
@State var overviewIsEditing = false

@AppStorage(StorageKeys.studyID) var studyID = "unknownStudyID"
@AppStorage(StorageKeys.trackingPreference) private var trackingOn = true


var body: some View {
NavigationStack {
Expand Down Expand Up @@ -82,20 +85,38 @@ struct AccountSheet: View {
Text("VIEW_HIPAA_AUTHORIZATION")
}
NavigationLink(destination: EmptyView()) {
Button(action: {
if let url = URL(string: "https://michelleodden.com/cardinal-lifespace-privacy-policy/") {
UIApplication.shared.open(url)
}
}) {
Text("VIEW_PRIVACY_POLICY")
}
.buttonStyle(PlainButtonStyle())
privacyPolicyButton
}
}
Section(header: Text("SETTINGS_SECTION")) {
locationTrackingToggle
}
}
}

var closeButton: some ToolbarContent {

private var privacyPolicyButton: some View {
Button(action: {
if let url = URL(string: "https://michelleodden.com/cardinal-lifespace-privacy-policy/") {
UIApplication.shared.open(url)
}
}) {
Text("VIEW_PRIVACY_POLICY")
}
.buttonStyle(PlainButtonStyle())
}

private var locationTrackingToggle: some View {
Toggle("TRACK_LOCATION_BUTTON", isOn: $trackingOn)
.onChange(of: trackingOn) {
if trackingOn {
locationModule.startTracking()
} else {
locationModule.stopTracking()
}
}
}

private var closeButton: some ToolbarContent {
ToolbarItem(placement: .cancellationAction) {
Button("CLOSE") {
dismiss()
Expand Down
21 changes: 21 additions & 0 deletions LifeSpace/Map/LifeSpaceMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ struct LifeSpaceMapView: View {
ZStack {
MapManagerViewWrapper()
VStack {
if !trackingOn {
locationTrackingOverlay
}
Spacer()
GroupBox {
optionsPanelButton
Expand Down Expand Up @@ -65,6 +68,24 @@ struct LifeSpaceMapView: View {
}
}

private var locationTrackingOverlay: some View {
VStack {
Spacer()
GroupBox {
Text("LOCATION_TRACKING_OFF")
Button(action: {
locationModule.startTracking()
trackingOn = true
}) {
Text("LOCATION_OVERLAY_ACTION_BUTTON")
}
}
.buttonStyle(.borderedProminent)
.padding()
Spacer()
}
}

private var optionsPanelButton: some View {
Button {
withAnimation {
Expand Down
16 changes: 3 additions & 13 deletions LifeSpace/Map/OptionsPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ struct OptionsPanel: View {
@State private var showingSurvey = false

var body: some View {
GroupBox {
Group {
Button {
self.showingSurvey.toggle()
} label: {
Text("OPTIONS_PANEL_SURVEY_BUTTON")
.frame(maxWidth: .infinity)
.padding()
}
.sheet(isPresented: $showingSurvey) {
DailySurveyTaskView(showingSurvey: $showingSurvey)
Expand All @@ -37,18 +38,7 @@ struct OptionsPanel: View {
}
}
}
}

GroupBox {
Toggle("TRACK_LOCATION_BUTTON", isOn: $trackingOn)
.onChange(of: trackingOn) {
if trackingOn {
locationModule.startTracking()
} else {
locationModule.stopTracking()
}
}
}
}.buttonStyle(.borderedProminent)
}
}

Expand Down
39 changes: 38 additions & 1 deletion LifeSpace/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@
}
},
"DOCUMENT_NOT_FOUND_MESSAGE" : {

"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Document not found."
}
}
}
},
"DOCUMENTS_SECTION" : {
"localizations" : {
Expand Down Expand Up @@ -358,6 +365,16 @@
}
}
},
"LOCATION_OVERLAY_ACTION_BUTTON" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Turn Location Tracking On"
}
}
}
},
"LOCATION_PERMISSIONS_BUTTON" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -388,6 +405,16 @@
}
}
},
"LOCATION_TRACKING_OFF" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Location tracking is switched off."
}
}
}
},
"NEXT_BUTTON" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -541,6 +568,16 @@
}
}
},
"SETTINGS_SECTION" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Settings"
}
}
}
},
"STUDYID_ACTION_BUTTON" : {
"localizations" : {
"en" : {
Expand Down
Loading