Skip to content

Commit

Permalink
Move statistics to a new view
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Jan 5, 2025
1 parent 9eb7cd6 commit 4a783a2
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 17 deletions.
10 changes: 7 additions & 3 deletions LifeSpace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
63BBF8192BB89CF7006890CE /* studyIDs.csv in Resources */ = {isa = PBXBuildFile; fileRef = 63BBF8182BB89CF7006890CE /* studyIDs.csv */; };
63D86AD62C3B7F310096B9DB /* DocumentWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D86AD52C3B7F310096B9DB /* DocumentWebView.swift */; };
63EA2CCA2D29C21800224C06 /* CompletedSurveysView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA2CC92D29C21800224C06 /* CompletedSurveysView.swift */; };
63EA2CCC2D2A0F4100224C06 /* StatisticsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA2CCB2D2A0F4100224C06 /* StatisticsView.swift */; };
63EA5F7B2BC04F8400A48590 /* DailySurveyTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA5F7A2BC04F8400A48590 /* DailySurveyTask.swift */; };
63EA5F892BC78ADD00A48590 /* DailySurveyTaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA5F882BC78ADD00A48590 /* DailySurveyTaskView.swift */; };
63EA5F8C2BC78F8400A48590 /* DailySurveyResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA5F8B2BC78F8400A48590 /* DailySurveyResponse.swift */; };
Expand Down Expand Up @@ -164,6 +165,7 @@
63CC66972C204CC5001DCFDF /* LifeSpace.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = LifeSpace.xctestplan; sourceTree = "<group>"; };
63D86AD52C3B7F310096B9DB /* DocumentWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentWebView.swift; sourceTree = "<group>"; };
63EA2CC92D29C21800224C06 /* CompletedSurveysView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedSurveysView.swift; sourceTree = "<group>"; };
63EA2CCB2D2A0F4100224C06 /* StatisticsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatisticsView.swift; sourceTree = "<group>"; };
63EA5F7A2BC04F8400A48590 /* DailySurveyTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailySurveyTask.swift; sourceTree = "<group>"; };
63EA5F882BC78ADD00A48590 /* DailySurveyTaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailySurveyTaskView.swift; sourceTree = "<group>"; };
63EA5F8B2BC78F8400A48590 /* DailySurveyResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailySurveyResponse.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -432,6 +434,7 @@
A9720E412ABB68B300872D23 /* Account */ = {
isa = PBXGroup;
children = (
63EA2CCB2D2A0F4100224C06 /* StatisticsView.swift */,
63EA2CC92D29C21800224C06 /* CompletedSurveysView.swift */,
A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */,
A9720E422ABB68CC00872D23 /* AccountSetupHeader.swift */,
Expand Down Expand Up @@ -716,6 +719,7 @@
63BBF8162BB8993B006890CE /* StudyIDView.swift in Sources */,
A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */,
653A2551283387FE005D4D48 /* LifeSpace.swift in Sources */,
63EA2CCC2D2A0F4100224C06 /* StatisticsView.swift in Sources */,
2FE5DC3629EDD7CA004B9AB4 /* HealthKitPermissions.swift in Sources */,
2F65B44E2A3B8B0600A36932 /* NotificationPermissions.swift in Sources */,
27FA29902A388E9B009CAC45 /* ModalView.swift in Sources */,
Expand Down Expand Up @@ -828,7 +832,7 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1030,7 +1034,7 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1078,7 +1082,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = "";
Expand Down
22 changes: 9 additions & 13 deletions LifeSpace/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ struct AccountSheet: View {
@AppStorage(StorageKeys.studyID) var studyID = "unknownStudyID"
@AppStorage(StorageKeys.trackingPreference) private var trackingOn = true

@AppStorage(StorageKeys.lastSurveyTransmissionDate) private var lastSurveyTransmissionDate = "None"
@AppStorage(StorageKeys.lastLocationTransmissionDate) private var lastLocationTransmissionDate = "None"
@AppStorage(StorageKeys.lastHealthKitTransmissionDate) private var lastHealthKitTransmissionDate = "None"

var body: some View {
NavigationStack {
ZStack {
Expand Down Expand Up @@ -116,15 +112,7 @@ struct AccountSheet: View {
if FeatureFlags.showDebugOptions {
Section(header: Text("DEBUG_SECTION")) {
logExportButton
}
Section(header: Text("LAST_SURVEY_TRANSMISSION_SECTION")) {
Text(lastSurveyTransmissionDate)
}
Section(header: Text("LAST_LOCATION_TRANSMISSION_SECTION")) {
Text(lastLocationTransmissionDate)
}
Section(header: Text("LAST_HEALTHKIT_TRANSMISSION_SECTION")) {
Text(lastHealthKitTransmissionDate)
statisticsButton
}
}
}
Expand Down Expand Up @@ -201,6 +189,14 @@ struct AccountSheet: View {
}
}

private var statisticsButton: some View {
NavigationLink(destination: {
StatisticsView()
}) {
Text("VIEW_STATISTICS")
}
}

private func getDocumentURL(for fileName: String) -> URL? {
guard let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else {
return nil
Expand Down
30 changes: 30 additions & 0 deletions LifeSpace/Account/StatisticsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// StatisticsView.swift
// LifeSpace
//
// Created by Vishnu Ravi on 1/4/25.
//


import SwiftUI

struct StatisticsView: View {
@AppStorage(StorageKeys.lastSurveyTransmissionDate) private var lastSurveyTransmissionDate = "None"
@AppStorage(StorageKeys.lastLocationTransmissionDate) private var lastLocationTransmissionDate = "None"
@AppStorage(StorageKeys.lastHealthKitTransmissionDate) private var lastHealthKitTransmissionDate = "None"

var body: some View {
Form {
Section(header: Text("LAST_SURVEY_TRANSMISSION_SECTION")) {
Text(lastSurveyTransmissionDate)
}
Section(header: Text("LAST_LOCATION_TRANSMISSION_SECTION")) {
Text(lastLocationTransmissionDate)
}
Section(header: Text("LAST_HEALTHKIT_TRANSMISSION_SECTION")) {
Text(lastHealthKitTransmissionDate)
}
}
.navigationTitle("STATISTICS_TITLE")
}
}
29 changes: 28 additions & 1 deletion LifeSpace/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,14 @@
}
},
"LOGS_SHARE_PREVIEW_TITLE" : {

"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Share Logs"
}
}
}
},
"NEXT_BUTTON" : {
"localizations" : {
Expand Down Expand Up @@ -749,6 +756,16 @@
}
}
},
"STATISTICS_TITLE" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Statistics"
}
}
}
},
"STUDYID_ACTION_BUTTON" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -989,6 +1006,16 @@
}
}
},
"VIEW_STATISTICS" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "View Statistics"
}
}
}
},
"Was Happy:" : {
"localizations" : {
"en" : {
Expand Down

0 comments on commit 4a783a2

Please sign in to comment.