Skip to content

Commit

Permalink
Setup Basic Onboarding Infrastructure (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer authored Dec 21, 2023
1 parent 0ccaeea commit 54f08fd
Show file tree
Hide file tree
Showing 26 changed files with 215 additions and 696 deletions.
58 changes: 16 additions & 42 deletions StudyApplication.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--testSchedule"
argument = "--accountEnabled"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
Expand Down
2 changes: 1 addition & 1 deletion StudyApplication/Account/AccountButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI


struct AccountButton: View {
static let shouldDisplay = !FeatureFlags.disableFirebase || ProcessInfo.processInfo.isPreviewSimulator
static let shouldDisplay = FeatureFlags.accountEnabled && (!FeatureFlags.disableFirebase || ProcessInfo.processInfo.isPreviewSimulator)

@Binding private var isPresented: Bool

Expand Down
78 changes: 0 additions & 78 deletions StudyApplication/Contacts/Contacts.swift

This file was deleted.

19 changes: 2 additions & 17 deletions StudyApplication/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct HomeView: View {
}

static var accountEnabled: Bool {
!FeatureFlags.disableFirebase && !FeatureFlags.skipOnboarding
FeatureFlags.accountEnabled && (!FeatureFlags.disableFirebase && !FeatureFlags.skipOnboarding)
}


Expand All @@ -32,27 +32,12 @@ struct HomeView: View {
ScheduleView(presentingAccount: $presentingAccount)
.tag(Tabs.schedule)
.tabItem {
Label("SCHEDULE_TAB_TITLE", systemImage: "list.clipboard")
Label("Tasks", systemImage: "list.clipboard")
}
Contacts(presentingAccount: $presentingAccount)
.tag(Tabs.contact)
.tabItem {
Label("CONTACTS_TAB_TITLE", systemImage: "person.fill")
}
if FeatureFlags.disableFirebase {
MockUpload(presentingAccount: $presentingAccount)
.tag(Tabs.mockUpload)
.tabItem {
Label("MOCK_WEB_SERVICE_TAB_TITLE", systemImage: "server.rack")
}
}
}
.sheet(isPresented: $presentingAccount) {
AccountSheet()
}
.accountRequired(Self.accountEnabled) {
AccountSheet()
}
.verifyRequiredAccountDetails(Self.accountEnabled)
}
}
Expand Down
39 changes: 0 additions & 39 deletions StudyApplication/MockUpload/MockUpload.swift

This file was deleted.

31 changes: 18 additions & 13 deletions StudyApplication/Onboarding/AccountOnboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,26 @@ struct AccountOnboarding: View {


var body: some View {
AccountSetup { _ in
Task {
// Placing the nextStep() call inside this task will ensure that the sheet dismiss animation is
// played till the end before we navigate to the next step.
onboardingNavigationPath.nextStep()
}
} header: {
AccountSetupHeader()
} continue: {
OnboardingActionsView(
"ACCOUNT_NEXT",
action: {
HStack {
AccountSetup { _ in
Task {
// Placing the nextStep() call inside this task will ensure that the sheet dismiss animation is
// played till the end before we navigate to the next step.
onboardingNavigationPath.nextStep()
}
)
} header: {
AccountSetupHeader()
} continue: {
OnboardingActionsView(
"ACCOUNT_NEXT",
action: {
onboardingNavigationPath.nextStep()
}
)
}
Button("Skip") {
onboardingNavigationPath.nextStep()
}
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions StudyApplication/Onboarding/InterestingModules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ struct InterestingModules: View {
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath


// swiftlint:disable line_length
// We disable line lengh checks to ensure that we can fit the complete english text in the SwiftUI views,
// avoiding unspecific localization keys.
var body: some View {
SequentialOnboardingView(
title: "INTERESTING_MODULES_TITLE",
subtitle: "INTERESTING_MODULES_SUBTITLE",
title: "Your First Steps",
subtitle: "Enroll in a Research Study",
content: [
SequentialOnboardingView.Content(
title: "INTERESTING_MODULES_AREA1_TITLE",
description: "INTERESTING_MODULES_AREA1_DESCRIPTION"
title: "Find your Research Studies",
description: "If you are alredy enrolled in a research study, find it on the application home screen after the onboarding and enter your inviation code."
),
SequentialOnboardingView.Content(
title: "INTERESTING_MODULES_AREA2_TITLE",
description: "INTERESTING_MODULES_AREA2_DESCRIPTION"
title: "Enroll in the Study",
description: "You will need to provide the application permission to get access to the data that the study collects."
),
SequentialOnboardingView.Content(
title: "INTERESTING_MODULES_AREA3_TITLE",
description: "INTERESTING_MODULES_AREA3_DESCRIPTION"
),
SequentialOnboardingView.Content(
title: "INTERESTING_MODULES_AREA4_TITLE",
description: "INTERESTING_MODULES_AREA4_DESCRIPTION"
title: "Contribute to Science",
description: "You are all set. Please follow the Study Schedule and consider enabeling notifications to get informed about any upcoming tasks."
)
],
actionText: "INTERESTING_MODULES_BUTTON",
actionText: "Finish Onboarding",
action: {
onboardingNavigationPath.nextStep()
}
)
}
// swiftlint:enable line_length
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import SwiftUI
/// Defines onboarding views that are shown in the Xcode preview simulator
extension OnboardingFlow {
static let previewSimulatorViews: [any View] = {
[Welcome(), InterestingModules(), AccountOnboarding(), Consent(), HealthKitPermissions(), NotificationPermissions()]
[Welcome(), InterestingModules(), AccountOnboarding()]
}()
}
33 changes: 1 addition & 32 deletions StudyApplication/Onboarding/OnboardingFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,18 @@ import SwiftUI

/// Displays an multi-step onboarding flow for the Spezi Study Application.
struct OnboardingFlow: View {
@Environment(HealthKit.self) private var healthKitDataSource
@Environment(StudyApplicationScheduler.self) private var scheduler

@AppStorage(StorageKeys.onboardingFlowComplete) private var completedOnboardingFlow = false

@State private var localNotificationAuthorization = false


private var healthKitAuthorization: Bool {
// As HealthKit not available in preview simulator
if ProcessInfo.processInfo.isPreviewSimulator {
return false
}

return healthKitDataSource.authorized
}


var body: some View {
OnboardingStack(onboardingFlowComplete: $completedOnboardingFlow) {
Welcome()
InterestingModules()

if !FeatureFlags.disableFirebase {
if FeatureFlags.accountEnabled && !FeatureFlags.disableFirebase {
AccountOnboarding()
}

#if !(targetEnvironment(simulator) && (arch(i386) || arch(x86_64)))
Consent()
#endif

if HKHealthStore.isHealthDataAvailable() && !healthKitAuthorization {
HealthKitPermissions()
}

if !localNotificationAuthorization {
NotificationPermissions()
}
}
.task {
localNotificationAuthorization = await scheduler.localNotificationAuthorization
}
.interactiveDismissDisabled(!completedOnboardingFlow)
}
}
Expand All @@ -66,6 +36,5 @@ struct OnboardingFlow: View {
#Preview {
OnboardingFlow()
.environment(Account(MockUserIdPasswordAccountService()))
.environment(StudyApplicationScheduler())
}
#endif
22 changes: 13 additions & 9 deletions StudyApplication/Onboarding/Welcome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,47 @@ struct Welcome: View {
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath


// swiftlint:disable line_length
// We disable line lengh checks to ensure that we can fit the complete english text in the SwiftUI views,
// avoiding unspecific localization keys.
var body: some View {
OnboardingView(
title: "WELCOME_TITLE",
subtitle: "WELCOME_SUBTITLE",
title: "Welcome to the Spezi Study Application",
subtitle: "Enroll and Participate in Research Projects",
areas: [
OnboardingInformationView.Content(
icon: {
Image(systemName: "apps.iphone")
.accessibilityHidden(true)
},
title: "WELCOME_AREA1_TITLE",
description: "WELCOME_AREA1_DESCRIPTION"
title: "Right on your phone",
description: "Single application to enroll into multiple studies."
),
OnboardingInformationView.Content(
icon: {
Image(systemName: "shippingbox.fill")
.accessibilityHidden(true)
},
title: "WELCOME_AREA2_TITLE",
description: "WELCOME_AREA2_DESCRIPTION"
title: "Automatic Data Transfer",
description: "After you provide detailed permissions, your data is automatically shared with the studies you participate in."
),
OnboardingInformationView.Content(
icon: {
Image(systemName: "list.bullet.clipboard.fill")
.accessibilityHidden(true)
},
title: "WELCOME_AREA3_TITLE",
description: "WELCOME_AREA3_DESCRIPTION"
title: "Surveys, Activity Data, and More",
description: "The Spezi Study Application can collect a wide variety of data points that can be helpful for a broad range of digital health studies."
)
],
actionText: "WELCOME_BUTTON",
actionText: "Welcome",
action: {
onboardingNavigationPath.nextStep()
}
)
.padding(.top, 24)
}
// swiftlint:enable line_length
}


Expand Down
Loading

0 comments on commit 54f08fd

Please sign in to comment.