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

Add Spezi ML & Health Records in the Onboarding Flow #14

Merged
merged 1 commit into from
Aug 28, 2023
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
26 changes: 15 additions & 11 deletions OwnYourData.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
2F5E32BD297E05EA003432F8 /* TemplateAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F5E32BC297E05EA003432F8 /* TemplateAppDelegate.swift */; };
2F6025CB29BBE70F0045459E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2F6025CA29BBE70F0045459E /* GoogleService-Info.plist */; };
2F6025D029BBEC610045459E /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 2F6025CF29BBEC610045459E /* FirebaseAuth */; };
2F8537632A9D122F006994BB /* OpenAIAPIKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F8537622A9D122F006994BB /* OpenAIAPIKey.swift */; };
2F8537652A9D1279006994BB /* HealthKitPermissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F8537642A9D1279006994BB /* HealthKitPermissions.swift */; };
2FA2023329CBCC0C0039C21A /* DocumentScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA2023229CBCC0C0039C21A /* DocumentScanner.swift */; };
2FB2943929CBA29900EE91A0 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2943329CBA29900EE91A0 /* ProfileView.swift */; };
2FB2943A29CBA29900EE91A0 /* AddDataView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2943429CBA29900EE91A0 /* AddDataView.swift */; };
Expand All @@ -40,7 +42,6 @@
2FB2FCD129CBDDC00027D85A /* UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2FCC629CBDDC00027D85A /* UserView.swift */; };
2FB2FCD229CBDDC00027D85A /* AccountSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2FCC729CBDDC00027D85A /* AccountSetup.swift */; };
2FB2FCD329CBDDC00027D85A /* TemplateLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2FCC829CBDDC00027D85A /* TemplateLogin.swift */; };
2FB2FCD429CBDDC00027D85A /* String+ModuleLocalized.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2FCC929CBDDC00027D85A /* String+ModuleLocalized.swift */; };
2FB2FCD529CBDDC00027D85A /* OnboardingFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2FCCA29CBDDC00027D85A /* OnboardingFlow.swift */; };
2FB2FCD729CBDDC00027D85A /* Consent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB2FCCC29CBDDC00027D85A /* Consent.swift */; };
2FC9759F2978E39600BA99FE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2FC9759E2978E39600BA99FE /* Localizable.strings */; };
Expand Down Expand Up @@ -92,6 +93,8 @@
2F4E23822989D51F0013F3D9 /* TemplateAppTestingSetup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateAppTestingSetup.swift; sourceTree = "<group>"; };
2F5E32BC297E05EA003432F8 /* TemplateAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateAppDelegate.swift; sourceTree = "<group>"; };
2F6025CA29BBE70F0045459E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
2F8537622A9D122F006994BB /* OpenAIAPIKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenAIAPIKey.swift; sourceTree = "<group>"; };
2F8537642A9D1279006994BB /* HealthKitPermissions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HealthKitPermissions.swift; sourceTree = "<group>"; };
2FA2023229CBCC0C0039C21A /* DocumentScanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentScanner.swift; sourceTree = "<group>"; };
2FAEC07F297F583900C11C42 /* TemplateApplication.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TemplateApplication.entitlements; sourceTree = "<group>"; };
2FB2943329CBA29900EE91A0 /* ProfileView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
Expand All @@ -111,7 +114,6 @@
2FB2FCC629CBDDC00027D85A /* UserView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserView.swift; sourceTree = "<group>"; };
2FB2FCC729CBDDC00027D85A /* AccountSetup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountSetup.swift; sourceTree = "<group>"; };
2FB2FCC829CBDDC00027D85A /* TemplateLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TemplateLogin.swift; sourceTree = "<group>"; };
2FB2FCC929CBDDC00027D85A /* String+ModuleLocalized.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "String+ModuleLocalized.swift"; path = "TemplateApplication/Onboarding/String+ModuleLocalized.swift"; sourceTree = SOURCE_ROOT; };
2FB2FCCA29CBDDC00027D85A /* OnboardingFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OnboardingFlow.swift; path = TemplateApplication/Onboarding/OnboardingFlow.swift; sourceTree = SOURCE_ROOT; };
2FB2FCCC29CBDDC00027D85A /* Consent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Consent.swift; path = TemplateApplication/Onboarding/Consent.swift; sourceTree = SOURCE_ROOT; };
2FC94CD4298B0A1D009C8209 /* TemplateApplication.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TemplateApplication.xctestplan; sourceTree = "<group>"; };
Expand Down Expand Up @@ -194,12 +196,13 @@
2FB2FCD829CBDDC30027D85A /* Onboarding */ = {
isa = PBXGroup;
children = (
2FB2FCC329CBDDC00027D85A /* AccountSetup */,
2FB2FCCC29CBDDC00027D85A /* Consent.swift */,
2FB2FCC129CBDDBF0027D85A /* InterestingModules.swift */,
2FB2FCCA29CBDDC00027D85A /* OnboardingFlow.swift */,
2FB2FCC929CBDDC00027D85A /* String+ModuleLocalized.swift */,
2FB2FCC229CBDDC00027D85A /* Welcome.swift */,
2FB2FCC129CBDDBF0027D85A /* InterestingModules.swift */,
2FB2FCCC29CBDDC00027D85A /* Consent.swift */,
2FB2FCC329CBDDC00027D85A /* AccountSetup */,
2F8537622A9D122F006994BB /* OpenAIAPIKey.swift */,
2F8537642A9D1279006994BB /* HealthKitPermissions.swift */,
);
path = Onboarding;
sourceTree = "<group>";
Expand Down Expand Up @@ -534,7 +537,6 @@
files = (
2FB2FCD229CBDDC00027D85A /* AccountSetup.swift in Sources */,
2FB2FCB829CBDC0E0027D85A /* StorageKeys.swift in Sources */,
2FB2FCD429CBDDC00027D85A /* String+ModuleLocalized.swift in Sources */,
2FCDD17729CE505D0097D6D2 /* OwnYourDataSection.swift in Sources */,
2FE573A929CD4697008EBBD4 /* PDFListRow.swift in Sources */,
2FE573AB29CD46BF008EBBD4 /* DocumentManager.swift in Sources */,
Expand All @@ -546,6 +548,7 @@
2FB2FCD029CBDDC00027D85A /* TemplateSignUp.swift in Sources */,
2FB2FCD729CBDDC00027D85A /* Consent.swift in Sources */,
2FB2FCD329CBDDC00027D85A /* TemplateLogin.swift in Sources */,
2F8537652A9D1279006994BB /* HealthKitPermissions.swift in Sources */,
2FE573A729CD4672008EBBD4 /* PDFView.swift in Sources */,
2FC975A82978F11A00BA99FE /* OwnYourDataTabView.swift in Sources */,
2F2146FB2A82B02D007CB929 /* OwnYourDateStandard.swift in Sources */,
Expand All @@ -559,6 +562,7 @@
2FB2FCBA29CBDC0E0027D85A /* CodableArray+RawRepresentable.swift in Sources */,
2FB2FCCD29CBDDC00027D85A /* InterestingModules.swift in Sources */,
2FB2FCB729CBDC0E0027D85A /* Binding+Negate.swift in Sources */,
2F8537632A9D122F006994BB /* OpenAIAPIKey.swift in Sources */,
2FB2943D29CBA29900EE91A0 /* ClinicalTrialsView.swift in Sources */,
2FCDD18329CE64BE0097D6D2 /* InstructionsStep.swift in Sources */,
2FB2943929CBA29900EE91A0 /* ProfileView.swift in Sources */,
Expand Down Expand Up @@ -1081,23 +1085,23 @@
repositoryURL = "https://github.com/StanfordSpezi/SpeziML.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.2.0;
minimumVersion = 0.2.2;
};
};
2F2146F52A82AF9B007CB929 /* XCRemoteSwiftPackageReference "SpeziOnboarding" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziOnboarding.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.3.0;
minimumVersion = 0.4.3;
};
};
2F2146F82A82AFB1007CB929 /* XCRemoteSwiftPackageReference "SpeziAccount" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziAccount.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.4.0;
minimumVersion = 0.4.1;
};
};
2F2146F92A82AFE1007CB929 /* XCRemoteSwiftPackageReference "SpeziHealthKit" */ = {
Expand All @@ -1121,7 +1125,7 @@
repositoryURL = "https://github.com/StanfordSpezi/Spezi.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.7.0;
minimumVersion = 0.7.2;
};
};
2F4E237F2989C5930013F3D9 /* XCRemoteSwiftPackageReference "XCTHealthKit" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "df2171b0c6afb9e9d4f7e07669d558c510b9f6be",
"version" : "10.13.0"
"revision" : "2bfe6abe1014aafe5cf28401708f7d39f9926a76",
"version" : "10.14.0"
}
},
{
Expand Down Expand Up @@ -71,6 +71,15 @@
"revision" : "9f942f21a485f4d552cfcefffae2e4077c0e9635"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
"version" : "100.0.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
Expand All @@ -94,8 +103,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/MacPaw/OpenAI",
"state" : {
"revision" : "a51a7fde78173e57b9166d38d1f665d17a3c4383",
"version" : "0.2.3"
"revision" : "c45f3320ffa760f043c0239f724850c0e4f8bde5",
"version" : "0.2.4"
}
},
{
Expand All @@ -112,17 +121,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/Spezi.git",
"state" : {
"revision" : "c98b2e550d83050b76693765884405737c302a77",
"version" : "0.7.0"
"revision" : "7462510badaa156c1e25efd7eabbf5b85ecb0098",
"version" : "0.7.2"
}
},
{
"identity" : "speziaccount",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziAccount.git",
"state" : {
"revision" : "5828932267c9f371bd0d821d85f915f07481739a",
"version" : "0.4.0"
"revision" : "520bb338bf32d98470cadd26bad87f5bda075337",
"version" : "0.4.1"
}
},
{
Expand All @@ -148,17 +157,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziML.git",
"state" : {
"revision" : "c9ccec165312ab82e2a380d93f8896f7fec96a9d",
"version" : "0.2.0"
"revision" : "700ab5e524ec4f12f3012b514ea24822bdc6066b",
"version" : "0.2.2"
}
},
{
"identity" : "spezionboarding",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziOnboarding",
"state" : {
"revision" : "a84ddd7cdb5ce48935ca3daf2a33ddc512d76b33",
"version" : "0.3.1"
"revision" : "63abc8bd50d1011a5908262756a74ad0e0a8691b",
"version" : "0.4.3"
}
},
{
Expand All @@ -175,8 +184,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziViews",
"state" : {
"revision" : "c6975e84c735b8b8a13740012c1c194f48893fa8",
"version" : "0.3.0"
"revision" : "3131708f262064231751a8963eb263f8648b6879",
"version" : "0.4.1"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum FeatureFlags {
public static let disableFirebase = CommandLine.arguments.contains("--disableFirebase")
#if targetEnvironment(simulator)
/// Defines if the application should connect to the local firebase emulator. Always set to true when using the iOS simulator.
public static let useFirebaseEmulator = false
public static let useFirebaseEmulator = true
#else
/// Defines if the application should connect to the local firebase emulator. Always set to true when using the iOS simulator.
public static let useFirebaseEmulator = CommandLine.arguments.contains("--useFirebaseEmulator")
Expand Down
39 changes: 15 additions & 24 deletions TemplateApplication/Onboarding/AccountSetup/AccountSetup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ import SwiftUI


struct AccountSetup: View {
@AppStorage(StorageKeys.onboardingFlowComplete) var completedOnboardingFlow = false
@AppStorage(StorageKeys.firstName) var firstName = ""
@AppStorage(StorageKeys.lastName) var lastName = ""
@AppStorage(StorageKeys.email) var email = ""

@Binding private var onboardingSteps: [OnboardingFlow.Step]
@EnvironmentObject private var onboardingNavigationPath: OnboardingNavigationPath
@EnvironmentObject var account: Account

@AppStorage(StorageKeys.firstName) private var firstName = ""
@AppStorage(StorageKeys.lastName) private var lastName = ""
@AppStorage(StorageKeys.email) private var email = ""


var body: some View {
OnboardingView(
contentView: {
VStack {
OnboardingTitleView(
title: "ACCOUNT_TITLE".moduleLocalized,
subtitle: "ACCOUNT_SUBTITLE".moduleLocalized
title: "ACCOUNT_TITLE",
subtitle: "ACCOUNT_SUBTITLE"
)
Spacer(minLength: 0)
accountImage
Expand Down Expand Up @@ -69,7 +68,7 @@ struct AccountSetup: View {
self.lastName = lastName
self.email = email

completedOnboardingFlow = true
onboardingNavigationPath.nextStep()
}
}
}
Expand Down Expand Up @@ -110,39 +109,31 @@ struct AccountSetup: View {
@ViewBuilder private var actionView: some View {
if account.signedIn {
OnboardingActionsView(
"ACCOUNT_NEXT".moduleLocalized,
"ACCOUNT_NEXT",
action: {
completedOnboardingFlow = true
onboardingNavigationPath.nextStep()
}
)
} else {
OnboardingActionsView(
primaryText: "ACCOUNT_SIGN_UP".moduleLocalized,
primaryText: "ACCOUNT_SIGN_UP",
primaryAction: {
onboardingSteps.append(.signUp)
onboardingNavigationPath.append(customView: TemplateSignUp())
},
secondaryText: "ACCOUNT_LOGIN".moduleLocalized,
secondaryText: "ACCOUNT_LOGIN",
secondaryAction: {
onboardingSteps.append(.login)
onboardingNavigationPath.append(customView: TemplateLogin())
}
)
}
}


init(onboardingSteps: Binding<[OnboardingFlow.Step]>) {
self._onboardingSteps = onboardingSteps
}
}


#if DEBUG
struct AccountSetup_Previews: PreviewProvider {
@State private static var path: [OnboardingFlow.Step] = []


static var previews: some View {
AccountSetup(onboardingSteps: $path)
AccountSetup()
.environmentObject(Account(accountServices: []))
.environmentObject(FirebaseAccountConfiguration(emulatorSettings: (host: "localhost", port: 9099)))
}
Expand Down
25 changes: 6 additions & 19 deletions TemplateApplication/Onboarding/Consent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import SwiftUI


struct Consent: View {
@Binding private var onboardingSteps: [OnboardingFlow.Step]
@AppStorage(StorageKeys.onboardingFlowComplete) var completedOnboardingFlow = false
@EnvironmentObject private var onboardingNavigationPath: OnboardingNavigationPath


private var consentDocument: Data {
guard let path = Bundle.main.url(forResource: "ConsentDocument", withExtension: "md"),
let data = try? Data(contentsOf: path) else {
return Data("CONSENT_LOADING_ERROR".moduleLocalized.utf8)
return Data(String(localized: "CONSENT_LOADING_ERROR", bundle: .main).utf8)
}
return data
}
Expand All @@ -27,37 +26,25 @@ struct Consent: View {
ConsentView(
header: {
OnboardingTitleView(
title: "CONSENT_TITLE".moduleLocalized,
subtitle: "CONSENT_SUBTITLE".moduleLocalized
title: "CONSENT_TITLE",
subtitle: "CONSENT_SUBTITLE"
)
},
asyncMarkdown: {
consentDocument
},
action: {
if !FeatureFlags.disableFirebase {
onboardingSteps.append(.accountSetup)
} else {
completedOnboardingFlow = true
}
onboardingNavigationPath.nextStep()
}
)
}


init(onboardingSteps: Binding<[OnboardingFlow.Step]>) {
self._onboardingSteps = onboardingSteps
}
}


#if DEBUG
struct Consent_Previews: PreviewProvider {
@State private static var path: [OnboardingFlow.Step] = []


static var previews: some View {
Consent(onboardingSteps: $path)
Consent()
}
}
#endif
Loading