Skip to content

Commit

Permalink
Enhancement/customize home (#2)
Browse files Browse the repository at this point in the history
# Customize Landing Page

## ♻️ Current situation & Problem
Currently, the app is a direct copy of the Spezi Template Application,
with general views unrelated to ENGAGE-HF.


## ⚙️ Release Notes 
- Developed the Home tab to have basic navigation structure, including
title, account button, and a greeting that includes the current date

## 📚 Documentation
The landing page now appears like this:

<img width="256" alt="Screenshot 2024-04-04 at 4 16 17 PM"
src="https://github.com/StanfordBDHG/ENGAGE-HF/assets/108841122/ec999c99-5e5a-4249-af83-ff63482e63b2">


## ✅ Testing
Implemented UI tests for the Tab buttons and Static Text fields. Further
testing will be implemented after authentication is integrated into the
app.


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [X] I agree to follow the [Code of Conduct]

---------

Co-authored-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
nriedman and PSchmiedmayer authored Apr 8, 2024
1 parent 5c6ce1f commit db813e6
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 715 deletions.
117 changes: 24 additions & 93 deletions ENGAGEHF.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"originHash" : "d2097b02aed2e09776146d22c31b71e71570248079de679a782c846c09d0ae6f",
"originHash" : "84060c25a97a757bf3045128a2563021282283c70a9cb6009941a41298deef92",
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "7ce7be095bc3ed3c98b009532fe2d7698c132614",
"version" : "1.2024011601.0"
"revision" : "748c7837511d0e6a507737353af268484e1745e2",
"version" : "1.2024011601.1"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "3e464dad87dad2d29bb29a97836789bf0f8f67d2",
"version" : "10.18.1"
"revision" : "c218c2054299b15ae577e818bbba16084d3eabe6",
"version" : "10.18.2"
}
},
{
Expand All @@ -40,7 +40,7 @@
{
"identity" : "fhirmodels",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/FHIRModels.git",
"location" : "https://github.com/apple/FHIRModels",
"state" : {
"revision" : "861afd5816a98d38f86220eab2f812d76cad84a0",
"version" : "0.5.0"
Expand Down Expand Up @@ -87,8 +87,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "67043f6389d0e28b38fa02d1c6952afeb04d807f",
"version" : "1.62.1"
"revision" : "e9fad491d0673bdda7063a0341fb6b47a30c5359",
"version" : "1.62.2"
}
},
{
Expand All @@ -105,8 +105,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR.git",
"state" : {
"revision" : "00d64d38a8f0d826ee9e27b6f3ce32314a29fd3e",
"version" : "0.2.6"
"revision" : "d6ceecf11800d73fed0c6ce33717f3dc71a44bd7",
"version" : "0.2.7"
}
},
{
Expand Down Expand Up @@ -150,17 +150,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/ResearchKit",
"state" : {
"revision" : "6b28cdf0d06c3d6e96b5585369968b85deac96e0",
"version" : "2.2.29"
"revision" : "3f70adf898b5985ba15e25d5074d86a9c657d305",
"version" : "2.2.30"
}
},
{
"identity" : "researchkitonfhir",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/ResearchKitOnFHIR",
"state" : {
"revision" : "7c2efdcb17796fc9ee686900304dbbe9dd4aaf85",
"version" : "1.1.2"
"revision" : "7cd02fe3eee061b8cfbb32d272715af8838b978e",
"version" : "1.2.0"
}
},
{
Expand All @@ -186,8 +186,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziAccount.git",
"state" : {
"revision" : "a7d289ef3be54de62b25dc92e8f7ff1a0f093906",
"version" : "1.2.1"
"revision" : "cb9441e5fe9ca31a17be2507d03817a080e63e9d",
"version" : "1.2.2"
}
},
{
Expand All @@ -204,14 +204,14 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziFirebase.git",
"state" : {
"revision" : "e05e665b7da39aa399ecd7fba393aab49b8f3034",
"version" : "1.0.1"
"revision" : "16c1c751c14b08ae593eacf9bc2752c2e070fe2f",
"version" : "1.1.0"
}
},
{
"identity" : "spezifoundation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziFoundation",
"location" : "https://github.com/StanfordSpezi/SpeziFoundation.git",
"state" : {
"revision" : "01af5b91a54f30ddd121258e81aff2ddc2a99ff9",
"version" : "1.0.4"
Expand All @@ -232,16 +232,7 @@
"location" : "https://github.com/StanfordSpezi/SpeziLicense",
"state" : {
"branch" : "dependency-list",
"revision" : "9b1713dd9ac14708c0381cf54ad84e13f3780083"
}
},
{
"identity" : "spezimockwebservice",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziMockWebService.git",
"state" : {
"revision" : "b18067d3499e630bbd995ef05a296ef8fdd42528",
"version" : "1.0.0"
"revision" : "14e5581aa4dfcaeb2a3301318bc4f05bac9f182b"
}
},
{
Expand All @@ -262,15 +253,6 @@
"version" : "1.1.0"
}
},
{
"identity" : "spezischeduler",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziScheduler.git",
"state" : {
"revision" : "eed3980f20b01a788720c869010e3fe2fbfcd1fd",
"version" : "0.8.2"
}
},
{
"identity" : "spezistorage",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,30 @@
// SPDX-License-Identifier: MIT
//

import SpeziMockWebService
import SwiftUI


struct MockUpload: View {
struct Dashboard: View {
@Binding var presentingAccount: Bool


var body: some View {
NavigationStack {
RequestList()
VStack {
Greeting()
Spacer()
}
.navigationTitle("Home")
.toolbar {
if AccountButton.shouldDisplay {
AccountButton(isPresented: $presentingAccount)
}
}
}
}


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


#if DEBUG
#Preview {
MockUpload(presentingAccount: .constant(false))
.previewWith {
MockWebService()
}
Dashboard(presentingAccount: .constant(false))
}
#endif
29 changes: 29 additions & 0 deletions ENGAGEHF/Dashboard/Greeting.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// This source file is part of the ENGAGE-HF project based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

import SwiftUI


struct Greeting: View {
var body: some View {
HStack(alignment: .top) {
Text("Hello, world!")
.font(.title.bold())
Spacer()
Text(.now, style: .date)
.font(.title3)
.foregroundStyle(.secondary)
}
.padding()
}
}


#Preview {
Greeting()
}
5 changes: 0 additions & 5 deletions ENGAGEHF/ENGAGEHFDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import SpeziFirebaseAccount
import SpeziFirebaseStorage
import SpeziFirestore
import SpeziHealthKit
import SpeziMockWebService
import SpeziOnboarding
import SpeziScheduler
import SwiftUI


Expand Down Expand Up @@ -45,15 +43,12 @@ class ENGAGEHFDelegate: SpeziAppDelegate {
} else {
FirebaseStorageConfiguration()
}
} else {
MockWebService()
}

if HKHealthStore.isHealthDataAvailable() {
healthKit
}

ENGAGEHFScheduler()
OnboardingDataSource()
}
}
Expand Down
21 changes: 0 additions & 21 deletions ENGAGEHF/ENGAGEHFStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import SpeziAccount
import SpeziFirebaseAccountStorage
import SpeziFirestore
import SpeziHealthKit
import SpeziMockWebService
import SpeziOnboarding
import SpeziQuestionnaire
import SwiftUI
Expand All @@ -31,7 +30,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On
Firestore.firestore().collection("users")
}

@Dependency var mockWebService: MockWebService?
@Dependency var accountStorage: FirestoreAccountStorage?

@AccountReference var account: Account
Expand Down Expand Up @@ -68,14 +66,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On


func add(sample: HKSample) async {
if let mockWebService {
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
let jsonRepresentation = (try? String(data: encoder.encode(sample.resource), encoding: .utf8)) ?? ""
try? await mockWebService.upload(path: "healthkit/\(sample.uuid.uuidString)", body: jsonRepresentation)
return
}

do {
try await healthKitDocument(id: sample.id).setData(from: sample.resource)
} catch {
Expand All @@ -84,11 +74,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On
}

func remove(sample: HKDeletedObject) async {
if let mockWebService {
try? await mockWebService.remove(path: "healthkit/\(sample.uuid.uuidString)")
return
}

do {
try await healthKitDocument(id: sample.uuid).delete()
} catch {
Expand All @@ -99,12 +84,6 @@ actor ENGAGEHFStandard: Standard, EnvironmentAccessible, HealthKitConstraint, On
func add(response: ModelsR4.QuestionnaireResponse) async {
let id = response.identifier?.value?.value?.string ?? UUID().uuidString

if let mockWebService {
let jsonRepresentation = (try? String(data: JSONEncoder().encode(response), encoding: .utf8)) ?? ""
try? await mockWebService.upload(path: "questionnaireResponse/\(id)", body: jsonRepresentation)
return
}

do {
try await userDocumentReference
.collection("QuestionnaireResponse") // Add all HealthKit sources in a /QuestionnaireResponse collection.
Expand Down
44 changes: 6 additions & 38 deletions ENGAGEHF/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,30 @@
//

import SpeziAccount
import SpeziMockWebService
import SwiftUI


struct HomeView: View {
enum Tabs: String {
case schedule
case contact
case mockUpload
case home
}

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


@AppStorage(StorageKeys.homeTabSelection) private var selectedTab = Tabs.schedule
@AppStorage(StorageKeys.homeTabSelection) private var selectedTab = Tabs.home
@State private var presentingAccount = false


var body: some View {
TabView(selection: $selectedTab) {
ScheduleView(presentingAccount: $presentingAccount)
.tag(Tabs.schedule)
Dashboard(presentingAccount: $presentingAccount)
.tag(Tabs.home)
.tabItem {
Label("SCHEDULE_TAB_TITLE", systemImage: "list.clipboard")
Label("Home", systemImage: "house")
}
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()
Expand All @@ -58,29 +43,12 @@ struct HomeView: View {
}


#if DEBUG
#Preview {
let details = AccountDetails.Builder()
.set(\.userId, value: "[email protected]")
.set(\.name, value: PersonNameComponents(givenName: "Leland", familyName: "Stanford"))

return HomeView()
.previewWith(standard: ENGAGEHFStandard()) {
ENGAGEHFScheduler()
MockWebService()
AccountConfiguration(building: details, active: MockUserIdPasswordAccountService())
}
}

#Preview {
CommandLine.arguments.append("--disableFirebase") // make sure the MockWebService is displayed
CommandLine.arguments.append("--disableFirebase")
return HomeView()
.previewWith(standard: ENGAGEHFStandard()) {
ENGAGEHFScheduler()
MockWebService()
AccountConfiguration {
MockUserIdPasswordAccountService()
}
}
}
#endif
Loading

0 comments on commit db813e6

Please sign in to comment.