Skip to content

Commit

Permalink
Improve survey workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Jul 13, 2024
1 parent ffda76d commit fec961e
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 82 deletions.
File renamed without changes.
File renamed without changes.
32 changes: 18 additions & 14 deletions LifeSpace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
2FE5DCB129EE6107004B9AB4 /* AccountOnboarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DCAC29EE6107004B9AB4 /* AccountOnboarding.swift */; };
2FF53D8B2A8725DE00042B76 /* SpeziMockWebService in Frameworks */ = {isa = PBXBuildFile; productRef = 2FF53D8A2A8725DE00042B76 /* SpeziMockWebService */; };
2FF53D8D2A8729D600042B76 /* LifeSpaceStandard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FF53D8C2A8729D600042B76 /* LifeSpaceStandard.swift */; };
6326011A2C41EF6A0002CDF4 /* SurveyModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 632601192C41EF6A0002CDF4 /* SurveyModule.swift */; };
6347EB642BBBA895008E0C4A /* LifeSpaceMapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6347EB632BBBA895008E0C4A /* LifeSpaceMapView.swift */; };
6347EB6A2BBBF3AC008E0C4A /* MapboxMaps in Frameworks */ = {isa = PBXBuildFile; productRef = 6347EB692BBBF3AC008E0C4A /* MapboxMaps */; };
6347EB742BBBF442008E0C4A /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6347EB732BBBF442008E0C4A /* Constants.swift */; };
Expand Down Expand Up @@ -136,6 +137,7 @@
2FE5DC5529EDD811004B9AB4 /* SocialSupportQuestionnaire.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = SocialSupportQuestionnaire.json; sourceTree = "<group>"; };
2FE5DCAC29EE6107004B9AB4 /* AccountOnboarding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountOnboarding.swift; sourceTree = "<group>"; };
2FF53D8C2A8729D600042B76 /* LifeSpaceStandard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LifeSpaceStandard.swift; sourceTree = "<group>"; };
632601192C41EF6A0002CDF4 /* SurveyModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyModule.swift; sourceTree = "<group>"; };
6347EB632BBBA895008E0C4A /* LifeSpaceMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LifeSpaceMapView.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>"; };
Expand Down Expand Up @@ -334,6 +336,7 @@
63EA5F7A2BC04F8400A48590 /* DailySurveyTask.swift */,
63EA5F882BC78ADD00A48590 /* DailySurveyTaskView.swift */,
63EA5F8B2BC78F8400A48590 /* DailySurveyResponse.swift */,
632601192C41EF6A0002CDF4 /* SurveyModule.swift */,
);
path = Survey;
sourceTree = "<group>";
Expand All @@ -343,6 +346,11 @@
children = (
63CC66972C204CC5001DCFDF /* LifeSpace.xctestplan */,
653A254F283387FE005D4D48 /* LifeSpace */,
653A2550283387FE005D4D48 /* LifeSpace.swift */,
2F5E32BC297E05EA003432F8 /* LifeSpaceDelegate.swift */,
2FF53D8C2A8729D600042B76 /* LifeSpaceStandard.swift */,
2F4E23822989D51F0013F3D9 /* LifeSpaceTestingSetup.swift */,
2FC975A72978F11A00BA99FE /* Home.swift */,
653A256028338800005D4D48 /* LifeSpaceTests */,
653A256A28338800005D4D48 /* LifeSpaceUITests */,
653A254E283387FE005D4D48 /* Products */,
Expand All @@ -363,19 +371,14 @@
653A254F283387FE005D4D48 /* LifeSpace */ = {
isa = PBXGroup;
children = (
63EA5F792BC04F6E00A48590 /* Survey */,
653A2550283387FE005D4D48 /* LifeSpace.swift */,
2F5E32BC297E05EA003432F8 /* LifeSpaceDelegate.swift */,
2FF53D8C2A8729D600042B76 /* LifeSpaceStandard.swift */,
2F4E23822989D51F0013F3D9 /* LifeSpaceTestingSetup.swift */,
2FC975A72978F11A00BA99FE /* Home.swift */,
A9720E412ABB68B300872D23 /* Account */,
2FE5DC2829EDD398004B9AB4 /* Onboarding */,
2FE5DC3B29EDD7D0004B9AB4 /* Schedule */,
2FE5DC2729EDD38D004B9AB4 /* Contacts */,
637AA5CF2BBDA686007BD7A3 /* Location */,
6347EB622BBBA874008E0C4A /* Map */,
2FE5DC2829EDD398004B9AB4 /* Onboarding */,
2FE5DC3B29EDD7D0004B9AB4 /* Schedule */,
2FE5DC3C29EDD7DA004B9AB4 /* SharedContext */,
63EA5F792BC04F6E00A48590 /* Survey */,
2FE5DC3D29EDD7E4004B9AB4 /* Helper */,
2FE5DC2D29EDD792004B9AB4 /* Resources */,
2FC9759D2978E30800BA99FE /* Supporting Files */,
Expand Down Expand Up @@ -683,6 +686,7 @@
63EA5F7B2BC04F8400A48590 /* DailySurveyTask.swift in Sources */,
63EA5F892BC78ADD00A48590 /* DailySurveyTaskView.swift in Sources */,
2F5E32BD297E05EA003432F8 /* LifeSpaceDelegate.swift in Sources */,
6326011A2C41EF6A0002CDF4 /* SurveyModule.swift in Sources */,
2FE5DC5229EDD7FA004B9AB4 /* LifeSpaceScheduler.swift in Sources */,
63BBF8162BB8993B006890CE /* StudyIDView.swift in Sources */,
A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */,
Expand Down Expand Up @@ -800,7 +804,7 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1004,7 +1008,7 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1051,7 +1055,7 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1231,7 +1235,7 @@
repositoryURL = "https://github.com/StanfordBDHG/HealthKitOnFHIR.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.2.4;
minimumVersion = 0.2.9;
};
};
2FE5DC6229EDD883004B9AB4 /* XCRemoteSwiftPackageReference "SpeziAccount" */ = {
Expand Down Expand Up @@ -1262,8 +1266,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziFirebase.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
kind = upToNextMinorVersion;
minimumVersion = 1.1.3;
};
};
2FE5DC8229EDD934004B9AB4 /* XCRemoteSwiftPackageReference "SpeziQuestionnaire" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR.git",
"state" : {
"revision" : "418929f315f37e6d9c8f30f40030bc65b9cc47c9",
"version" : "0.2.8"
"revision" : "b0cfe35a2263a517b22196b559d2dd1d1e2afcd9",
"version" : "0.2.9"
}
},
{
Expand Down Expand Up @@ -213,8 +213,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziFirebase.git",
"state" : {
"revision" : "00ff0db12bf72ba39354e263d8f916ae8392368b",
"version" : "1.1.2"
"revision" : "67981d0f0b4f0bb70f120f9b5304e7c0b08e5717",
"version" : "1.1.3"
}
},
{
Expand Down
56 changes: 55 additions & 1 deletion LifeSpace/Map/OptionsPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,83 @@ struct OptionsPanel: View {

@State private var showingSurveyAlert = false
@State private var showingSurvey = false
@State private var showingStartSurveyModal = false

var body: some View {
GroupBox {
Button {
self.showingSurvey.toggle()
} label: {
Text("OPTIONS_PANEL_SURVEY_BUTTON")
.bold()
.foregroundColor(.white)
.frame(maxWidth: .infinity)
}
.sheet(isPresented: $showingSurvey) {
DailySurveyTaskView(showingSurvey: $showingSurvey)
}
.sheet(isPresented: $showingStartSurveyModal) {
startSurveyModal
.presentationDetents([.medium, .large])
.presentationDragIndicator(.hidden)
}
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .active {
Task {
await standard.getLatestSurveyDate()
_ = await standard.getLatestSurveyDate()
launchSurvey()
}
}
}
}.groupBoxStyle(ButtonGroupBoxStyle())
}

private var startSurveyModal: some View {
VStack {
Text("SURVEY_READY_QUESTION")
.font(.largeTitle)
.multilineTextAlignment(.center)

Button(action: {
self.showingSurvey = true
self.showingStartSurveyModal = false
}, label: {
Text("YES")
.padding()
.frame(maxWidth: .infinity)
})
.padding()
.buttonStyle(.borderedProminent)

Button(action: {
self.showingStartSurveyModal = false
}, label: {
Text("NO")
.padding()
.frame(maxWidth: .infinity)
})
.padding()
.buttonStyle(.bordered)

Check failure on line 78 in LifeSpace/Map/OptionsPanel.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Vertical Whitespace before Closing Braces Violation: Don't include vertical whitespace (empty line) before closing braces (vertical_whitespace_closing_braces)
}
}

private func launchSurvey() {
if SurveyModule.currentHour > 7 && !SurveyModule.surveyAlreadyTaken {
self.showingStartSurveyModal = true
}
}
}

#Preview {
OptionsPanel()
}

struct ButtonGroupBoxStyle: GroupBoxStyle {
func makeBody(configuration: Self.Configuration) -> some View {
configuration.content
.frame(maxWidth: .infinity)
.padding()
.background(RoundedRectangle(cornerRadius: 8).fill(Color("AccentColor")))
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x15",
"green" : "0x15",
"red" : "0x8C"
}
},
"idiom" : "universal"
},
{
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal"
}
],
Expand Down
20 changes: 20 additions & 0 deletions LifeSpace/Resources/Assets.xcassets/Color.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
18 changes: 17 additions & 1 deletion LifeSpace/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@
}
}
}
},
"NO" : {

},
"NOTIFICATION_PERMISSIONS_BUTTON" : {
"localizations" : {
Expand Down Expand Up @@ -474,7 +477,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Options"
"value" : "After 7 PM"
}
}
}
Expand Down Expand Up @@ -631,6 +634,16 @@
}
}
},
"SURVEY_READY_QUESTION" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Are you ready to take your daily survey?"
}
}
}
},
"SURVEY_TAKEN_NOTICE" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -831,6 +844,9 @@
}
}
}
},
"YES" : {

}
},
"version" : "1.0"
Expand Down
Loading

0 comments on commit fec961e

Please sign in to comment.