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

Migrate Prisma iOS Code to New Repo #9

Merged
merged 17 commits into from
Jan 24, 2024
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
110 changes: 85 additions & 25 deletions Behavior.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

19 changes: 5 additions & 14 deletions Behavior/Account/AccountSetupHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@
var body: some View {
VStack {
Text("ACCOUNT_TITLE")
.font(.largeTitle)
.bold()
.padding(.bottom)
.padding(.top, 30)

Text("ACCOUNT_SUBTITLE")
.padding(.bottom, 8)
Divider()
.font(.largeTitle)
.bold()
.padding(.bottom)
.padding(.top, 30)

Check warning on line 24 in Behavior/Account/AccountSetupHeader.swift

View check run for this annotation

Codecov / codecov/patch

Behavior/Account/AccountSetupHeader.swift#L21-L24

Added lines #L21 - L24 were not covered by tests
if account.signedIn, case .generic = setupState {
Text("ACCOUNT_SIGNED_IN_DESCRIPTION")
.padding()
} else {
VStack {
Text("ACCOUNT_SETUP_DESCRIPTION")
Text("ACCOUNT_REQUIRED_ITEMS")
}
.padding()
Text("ACCOUNT_SETUP_DESCRIPTION")

Check warning on line 28 in Behavior/Account/AccountSetupHeader.swift

View check run for this annotation

Codecov / codecov/patch

Behavior/Account/AccountSetupHeader.swift#L28

Added line #L28 was not covered by tests
}
}
.multilineTextAlignment(.center)
Expand Down
30 changes: 19 additions & 11 deletions Behavior/BehaviorDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class BehaviorDelegate: SpeziAppDelegate {
if !FeatureFlags.disableFirebase {
AccountConfiguration(configuration: [
.requires(\.userId),
.requires(\.name),
.requires(\.dateOfBirth),

// additional values stored using the `FirestoreAccountStorage` within our Standard implementation
.collects(\.genderIdentity)
.requires(\.name)
])

if FeatureFlags.useFirebaseEmulator {
Expand Down Expand Up @@ -74,12 +70,24 @@ class BehaviorDelegate: SpeziAppDelegate {

private var healthKit: HealthKit {
HealthKit {
CollectSample(
HKQuantityType(.stepCount),
deliverySetting: .anchorQuery(.afterAuthorizationAndApplicationWillLaunch)
)
CollectSample(
HKQuantityType(.activeEnergyBurned),
CollectSamples(
[
HKQuantityType(.activeEnergyBurned),
HKQuantityType(.stepCount),
HKQuantityType(.distanceWalkingRunning),
HKQuantityType(.vo2Max),
HKQuantityType(.heartRate),
HKQuantityType(.restingHeartRate),
HKQuantityType(.oxygenSaturation),
HKQuantityType(.respiratoryRate),
HKQuantityType(.walkingHeartRateAverage)
],
/// predicate to request data from one month in the past to present.
predicate: HKQuery.predicateForSamples(
withStart: Calendar.current.date(byAdding: .month, value: -1, to: .now),
end: nil,
options: .strictEndDate
),
deliverySetting: .anchorQuery(.afterAuthorizationAndApplicationWillLaunch)
)
}
Expand Down
42 changes: 42 additions & 0 deletions Behavior/Chat/ChatView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// This source file is part of the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

import Foundation
import SwiftUI


struct ChatView: View {
@Binding var presentingAccount: Bool


var body: some View {
NavigationStack {
Text("Coming soon!")
.navigationTitle("Chat")
.toolbar {
if AccountButton.shouldDisplay {
AccountButton(isPresented: $presentingAccount)
}
}
}
}

Check warning on line 27 in Behavior/Chat/ChatView.swift

View check run for this annotation

Codecov / codecov/patch

Behavior/Chat/ChatView.swift#L17-L27

Added lines #L17 - L27 were not covered by tests


init(presentingAccount: Binding<Bool>) {
self._presentingAccount = presentingAccount
}
}


#if DEBUG
struct ChatView_Previews: PreviewProvider {
static var previews: some View {
ChatView(presentingAccount: .constant(false))
}
}
#endif
6 changes: 6 additions & 0 deletions Behavior/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SwiftUI
struct HomeView: View {
enum Tabs: String {
case schedule
case chat
case contact
case mockUpload
}
Expand All @@ -29,6 +30,11 @@ struct HomeView: View {

var body: some View {
TabView(selection: $selectedTab) {
ChatView(presentingAccount: $presentingAccount)
.tag(Tabs.chat)
.tabItem {
Label("Chat", systemImage: "message.fill")
}
ScheduleView(presentingAccount: $presentingAccount)
.tag(Tabs.schedule)
.tabItem {
Expand Down
49 changes: 0 additions & 49 deletions Behavior/Onboarding/Consent.swift

This file was deleted.

74 changes: 74 additions & 0 deletions Behavior/Onboarding/Features.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// This source file is part of the Behavior based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

import SpeziOnboarding
import SwiftUI


struct Features: View {
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath


var body: some View {
Group {
GeometryReader { geometry in
ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .center, spacing: 0) {
Text("FEATURES_TITLE")
.font(.title)
.fontWeight(.bold)
.foregroundColor(.accentColor)
.multilineTextAlignment(.center)
Spacer()
features
Spacer()
Spacer()
OnboardingActionsView("FEATURES_BUTTON") {
onboardingNavigationPath.nextStep()
}
Spacer()
.frame(height: 10)
}
.frame(minHeight: geometry.size.height)
}
}
.padding(24)
}
}

Check warning on line 42 in Behavior/Onboarding/Features.swift

View check run for this annotation

Codecov / codecov/patch

Behavior/Onboarding/Features.swift#L17-L42

Added lines #L17 - L42 were not covered by tests

var features: some View {
OnboardingInformationView(
areas: [
.init(
icon: Image(systemName: "applewatch"), // swiftlint:disable:this accessibility_label_for_image
title: "FEATURES_AREA1_TITLE",
description: "FEATURES_AREA1_DESCRIPTION"
),
.init(
icon: Image(systemName: "message.fill"), // swiftlint:disable:this accessibility_label_for_image
title: "FEATURES_AREA2_TITLE",
description: "FEATURES_AREA2_DESCRIPTION"
),
.init(
icon: Image(systemName: "chart.dots.scatter"), // swiftlint:disable:this accessibility_label_for_image
title: "FEATURES_AREA3_TITLE",
description: "FEATURES_AREA3_DESCRIPTION"
)
]
)
}

Check warning on line 64 in Behavior/Onboarding/Features.swift

View check run for this annotation

Codecov / codecov/patch

Behavior/Onboarding/Features.swift#L44-L64

Added lines #L44 - L64 were not covered by tests
}


#if DEBUG
#Preview {
OnboardingStack {
Features()
}
}
#endif
50 changes: 0 additions & 50 deletions Behavior/Onboarding/InterestingModules.swift

This file was deleted.

77 changes: 77 additions & 0 deletions Behavior/Onboarding/NotificationPermissions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// This source file is part of the Behavior based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

import SpeziOnboarding
import SpeziScheduler
import SwiftUI


struct NotificationPermissions: View {
@Environment(BehaviorScheduler.self) private var scheduler
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath

@State private var notificationProcessing = false


var body: some View {
OnboardingView(
contentView: {
VStack {
OnboardingTitleView(
title: "NOTIFICATION_PERMISSIONS_TITLE",
subtitle: "NOTIFICATION_PERMISSIONS_SUBTITLE"
)
Spacer()
Image(systemName: "bell.square.fill")
.font(.system(size: 150))
.foregroundColor(.accentColor)
.accessibilityHidden(true)
Text("NOTIFICATION_PERMISSIONS_DESCRIPTION")
.multilineTextAlignment(.center)
.padding(.vertical, 16)
Spacer()
}
}, actionView: {
OnboardingActionsView(
"NOTIFICATION_PERMISSIONS_BUTTON",
action: {
do {
notificationProcessing = true
// Notification Authorization is not available in the preview simulator.
if ProcessInfo.processInfo.isPreviewSimulator {
try await _Concurrency.Task.sleep(for: .seconds(5))
} else {
try await scheduler.requestLocalNotificationAuthorization()
}
} catch {
print("Could not request notification permissions.")
}
notificationProcessing = false

onboardingNavigationPath.nextStep()
}
)
}
)
.navigationBarBackButtonHidden(notificationProcessing)
// Small fix as otherwise "Login" or "Sign up" is still shown in the nav bar
.navigationTitle(Text(verbatim: ""))
}

Check warning on line 64 in Behavior/Onboarding/NotificationPermissions.swift

View check run for this annotation

Codecov / codecov/patch

Behavior/Onboarding/NotificationPermissions.swift#L21-L64

Added lines #L21 - L64 were not covered by tests
}


#if DEBUG
#Preview {
OnboardingStack {
NotificationPermissions()
}
.previewWith {
BehaviorScheduler()
}
}
#endif
Loading