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

Initial restructuring of the onboarding flow #8

Merged
merged 13 commits into from
Jun 17, 2023
4 changes: 0 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ only_rules:
- implicitly_unwrapped_optional
# Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status
- inclusive_language
# If defer is at the end of its parent scope, it will be executed right where it is anyway.
- inert_defer
# Prefer using Set.isDisjoint(with:) over Set.intersection(_:).isEmpty.
- is_disjoint
# Discouraged explicit usage of the default separator.
Expand Down Expand Up @@ -331,8 +329,6 @@ only_rules:
- unowned_variable_capture
# Catch statements should not declare error variables without type casting.
- untyped_error_in_catch
# Unused reference in a capture list should be removed.
- unused_capture_list
# Unused parameter in a closure should be replaced with _.
- unused_closure_parameter
# Unused control flow label should be removed.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ SPDX-License-Identifier: MIT
Neurodevelopment Assessment and Monitoring System (NAMS) Contributors
=================================

* [Andreas Bauer](https://github.com/Supereg)
* [Paul Schmiedmayer](https://github.com/PSchmiedmayer)
79 changes: 8 additions & 71 deletions NAMS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@
"version" : "3.1.1"
}
},
{
"identity" : "healthkitonfhir",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR",
"state" : {
"revision" : "d10f408766264183cd50bb117b99580255520aa3",
"version" : "0.2.3"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -180,24 +171,6 @@
"version" : "0.3.0"
}
},
{
"identity" : "spezihealthkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziHealthKit.git",
"state" : {
"revision" : "d03eabcaae2de1e25a626c9a3116dc50f01cdc68",
"version" : "0.2.0"
}
},
{
"identity" : "spezihealthkittofhiradapter",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziHealthKitToFHIRAdapter.git",
"state" : {
"revision" : "e43f2c05cebcd16a697397721e6a2d72bf418a9c",
"version" : "0.3.0"
}
},
{
"identity" : "spezionboarding",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -261,15 +234,6 @@
"version" : "0.4.2"
}
},
{
"identity" : "xcthealthkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/XCTHealthKit.git",
"state" : {
"revision" : "19395bbd14a2554e4c9d3fe5cf38aa626c807269",
"version" : "0.3.3"
}
},
{
"identity" : "xctruntimeassertions",
"kind" : "remoteSourceControl",
Expand Down
4 changes: 4 additions & 0 deletions NAMS.xcodeproj/xcshareddata/xcschemes/NAMS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
<LocationScenarioReference
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
referenceType = "1">
</LocationScenarioReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
1 change: 0 additions & 1 deletion NAMS/Helper/CodableArray+RawRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


extension Array: RawRepresentable where Element: Codable {
public var rawValue: String {
guard let data = try? JSONEncoder().encode(self),
Expand Down
5 changes: 2 additions & 3 deletions NAMS/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ struct HomeView: View {
case mockUpload
}


@AppStorage(StorageKeys.homeTabSelection) var selectedTab = Tabs.schedule

@AppStorage(StorageKeys.homeTabSelection)
var selectedTab = Tabs.schedule

var body: some View {
TabView(selection: $selectedTab) {
Expand Down
9 changes: 5 additions & 4 deletions NAMS/NAMS.swift → NAMS/NAMSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import SwiftUI


@main
struct NAMS: App {
@UIApplicationDelegateAdaptor(NAMSDelegate.self) var appDelegate
@AppStorage(StorageKeys.onboardingFlowComplete) var completedOnboardingFlow = false

struct NAMSApp: App {
@UIApplicationDelegateAdaptor(NAMSAppDelegate.self)
var appDelegate
@AppStorage(StorageKeys.onboardingFlowComplete)
var completedOnboardingFlow = false

var body: some Scene {
WindowGroup {
Expand Down
20 changes: 1 addition & 19 deletions NAMS/NAMSAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ import SpeziFirebaseAccount
import class FirebaseFirestore.FirestoreSettings
import class FirebaseFirestore.MemoryCacheSettings
import FirebaseAuth
import HealthKit
import SpeziFirestore
import SpeziFirestorePrefixUserIdAdapter
import SpeziHealthKit
import SpeziHealthKitToFHIRAdapter
import SpeziQuestionnaire
import SpeziScheduler
import SwiftUI


class NAMSDelegate: SpeziAppDelegate {
class NAMSAppDelegate: SpeziAppDelegate {
override var configuration: Configuration {
Configuration(standard: FHIR()) {
if !FeatureFlags.disableFirebase {
Expand All @@ -35,9 +32,6 @@ class NAMSDelegate: SpeziAppDelegate {
}
firestore
}
if HKHealthStore.isHealthDataAvailable() {
healthKit
}
QuestionnaireDataSource()
MockDataStorageProvider()
NAMSScheduler()
Expand All @@ -61,16 +55,4 @@ class NAMSDelegate: SpeziAppDelegate {
settings: settings
)
}


private var healthKit: HealthKit<FHIR> {
HealthKit {
CollectSample(
HKQuantityType(.stepCount),
deliverySetting: .anchorQuery(.afterAuthorizationAndApplicationWillLaunch)
)
} adapter: {
HealthKitToFHIRAdapter()
}
}
}
4 changes: 2 additions & 2 deletions NAMS/NAMSTestingSetup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SwiftUI


private struct NAMSTestingSetup: ViewModifier {
@AppStorage(StorageKeys.onboardingFlowComplete) var completedOnboardingFlow = false

@AppStorage(StorageKeys.onboardingFlowComplete)
var completedOnboardingFlow = false

func body(content: Content) -> some View {
content
Expand Down
14 changes: 9 additions & 5 deletions NAMS/Onboarding/AccountSetup/AccountSetup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ struct AccountSetup: View {
@Binding private var onboardingSteps: [OnboardingFlow.Step]
@EnvironmentObject var account: Account


var body: some View {
OnboardingView(
contentView: {
Expand All @@ -38,7 +37,7 @@ struct AccountSetup: View {
)
.onReceive(account.objectWillChange) {
if account.signedIn {
onboardingSteps.append(.healthKitPermissions)
onboardingSteps.append(.finished)
// Unfortunately, SwiftUI currently animates changes in the navigation path that do not change
// the current top view. Therefore we need to do the following async procedure to remove the
// `.login` and `.signUp` steps while disabling the animations before and re-enabling them
Expand All @@ -59,8 +58,10 @@ struct AccountSetup: View {
Group {
if account.signedIn {
Image(systemName: "person.badge.shield.checkmark.fill")
.symbolRenderingMode(.hierarchical)
} else {
Image(systemName: "person.fill.badge.plus")
.symbolRenderingMode(.hierarchical)
}
}
.font(.system(size: 150))
Expand All @@ -79,10 +80,14 @@ struct AccountSetup: View {
}
.multilineTextAlignment(.center)
.padding(.vertical, 16)

if account.signedIn {
UserView()
.padding()
Button("Logout", role: .destructive) {
// workaround as of https://github.com/StanfordSpezi/SpeziTemplateApplication/issues/21
account.signedIn = false

try? Auth.auth().signOut()
}
}
Expand All @@ -95,7 +100,7 @@ struct AccountSetup: View {
OnboardingActionsView(
"ACCOUNT_NEXT".moduleLocalized,
action: {
onboardingSteps.append(.healthKitPermissions)
onboardingSteps.append(.finished)
}
)
} else {
Expand All @@ -122,8 +127,7 @@ struct AccountSetup: View {
#if DEBUG
struct AccountSetup_Previews: PreviewProvider {
@State private static var path: [OnboardingFlow.Step] = []



static var previews: some View {
AccountSetup(onboardingSteps: $path)
.environmentObject(Account(accountServices: []))
Expand Down
1 change: 0 additions & 1 deletion NAMS/Onboarding/AccountSetup/IconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import SwiftUI
struct IconView: View {
let size: Double


var body: some View {
Image(uiImage: Bundle.main.image(withName: "AppIcon", fileExtension: "png"))
.resizable()
Expand Down
6 changes: 4 additions & 2 deletions NAMS/Onboarding/AccountSetup/NAMSLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ struct NAMSLogin: View {
#if DEBUG
struct NAMSLogin_Previews: PreviewProvider {
static var previews: some View {
NAMSLogin()
.environmentObject(Account(accountServices: []))
NavigationStack {
NAMSLogin()
.environmentObject(Account(accountServices: []))
}
}
}
#endif
6 changes: 4 additions & 2 deletions NAMS/Onboarding/AccountSetup/NAMSSignUp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ struct NAMSSignUp: View {
#if DEBUG
struct NAMSSignUp_Previews: PreviewProvider {
static var previews: some View {
NAMSSignUp()
.environmentObject(Account(accountServices: []))
NavigationStack {
NAMSSignUp()
.environmentObject(Account(accountServices: [EmailPasswordAccountService()]))
}
}
}
#endif
4 changes: 2 additions & 2 deletions NAMS/Onboarding/AccountSetup/UserView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct UserView: View {
)
}


@ViewBuilder
private var userInformation: some View {
HStack(spacing: 16) {
Expand All @@ -48,7 +47,7 @@ struct UserView: View {
Spacer()
} else {
Spacer()
VStack(spacing: 16) {
HStack(spacing: 16) {
ProgressView()
Text("USER_VIEW_LOADING")
.multilineTextAlignment(.center)
Expand All @@ -66,6 +65,7 @@ struct SwiftUIView_Previews: PreviewProvider {
UserView()
.padding()
.environmentObject(FirebaseAccountConfiguration<FHIR>(emulatorSettings: (host: "localhost", port: 9099)))
.environmentObject(Account(accountServices: []))
}
}
#endif
62 changes: 0 additions & 62 deletions NAMS/Onboarding/Consent.swift

This file was deleted.

Loading