Skip to content

Commit

Permalink
Decomposed Dashboard Greeting into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
nriedman committed Apr 4, 2024
1 parent 27c37c3 commit 6f0fd66
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 38 deletions.
4 changes: 4 additions & 0 deletions ENGAGEHF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
4DB025C12BBDEA0B002D2545 /* MedicationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB025C02BBDEA0B002D2545 /* MedicationsView.swift */; };
4DB025C62BBE21EF002D2545 /* index.js in Resources */ = {isa = PBXBuildFile; fileRef = 4DB025C52BBE21EF002D2545 /* index.js */; };
4DB025CA2BBE3A59002D2545 /* HomeViewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB025C92BBE3A59002D2545 /* HomeViewUITests.swift */; };
4DB025CE2BBE8D2E002D2545 /* GreetingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB025CD2BBE8D2E002D2545 /* GreetingView.swift */; };
56E708352BB06B7100B08F0A /* SpeziLicense in Frameworks */ = {isa = PBXBuildFile; productRef = 56E708342BB06B7100B08F0A /* SpeziLicense */; };
56E7083B2BB06F6F00B08F0A /* SwiftPackageList in Frameworks */ = {isa = PBXBuildFile; productRef = 56E7083A2BB06F6F00B08F0A /* SwiftPackageList */; };
653A2551283387FE005D4D48 /* ENGAGEHF.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A2550283387FE005D4D48 /* ENGAGEHF.swift */; };
Expand Down Expand Up @@ -136,6 +137,7 @@
4DB025C02BBDEA0B002D2545 /* MedicationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MedicationsView.swift; sourceTree = "<group>"; };
4DB025C52BBE21EF002D2545 /* index.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = index.js; sourceTree = "<group>"; };
4DB025C92BBE3A59002D2545 /* HomeViewUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewUITests.swift; sourceTree = "<group>"; };
4DB025CD2BBE8D2E002D2545 /* GreetingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreetingView.swift; sourceTree = "<group>"; };
653A254D283387FE005D4D48 /* ENGAGEHF.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ENGAGEHF.app; sourceTree = BUILT_PRODUCTS_DIR; };
653A2550283387FE005D4D48 /* ENGAGEHF.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ENGAGEHF.swift; sourceTree = "<group>"; };
653A255428338800005D4D48 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -289,6 +291,7 @@
isa = PBXGroup;
children = (
4DB025B62BBDE903002D2545 /* DashboardView.swift */,
4DB025CD2BBE8D2E002D2545 /* GreetingView.swift */,
);
path = Dashboard;
sourceTree = "<group>";
Expand Down Expand Up @@ -637,6 +640,7 @@
2F65B44E2A3B8B0600A36932 /* NotificationPermissions.swift in Sources */,
27FA29902A388E9B009CAC45 /* ModalView.swift in Sources */,
2FE5DC2629EDD38A004B9AB4 /* Contacts.swift in Sources */,
4DB025CE2BBE8D2E002D2545 /* GreetingView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
32 changes: 0 additions & 32 deletions ENGAGEHF/Dashboard/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,8 @@
// Created by Nick Riedman on 4/3/24.
//

import SpeziAccount
import SpeziMockWebService
import SwiftUI

struct Greeting: View {
@State private var dateString: String?

var body: some View {
HStack {
// Todo: replace world! with first name from account info
Text("Hello, world!")
.font(.title2)
.accessibilityLabel(Text("DASHBOARD_GREETING"))
Spacer()
Text(dateString ?? "No date")
.font(.title2)
.accessibilityLabel(Text("DASHBOARD_DATE"))
}
.padding()
.task {
getDateString()
}
}

private func getDateString() {
let currentDate = Date()
let dateFormatter = DateFormatter()

dateFormatter.dateStyle = .short

dateString = dateFormatter.string(from: currentDate)
}
}

struct Dashboard: View {
@Binding var presentingAccount: Bool

Expand Down
44 changes: 44 additions & 0 deletions ENGAGEHF/Dashboard/GreetingView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// 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
//
// GreetingView.swift
// ENGAGEHF
//
// Created by Nick Riedman on 4/4/24.
//

import SwiftUI

struct Greeting: View {
@State private var dateString: String?

var body: some View {
HStack {
// Todo: replace world! with first name from account info
Text("Hello, world!")
.font(.title2)
.accessibilityLabel(Text("DASHBOARD_GREETING"))
Spacer()
Text(dateString ?? "No date")
.font(.title2)
.accessibilityLabel(Text("DASHBOARD_DATE"))
}
.padding()
.task {
getDateString()
}
}

private func getDateString() {
let currentDate = Date()
let dateFormatter = DateFormatter()

dateFormatter.dateStyle = .short

dateString = dateFormatter.string(from: currentDate)
}
}
2 changes: 0 additions & 2 deletions ENGAGEHF/Education/EducationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// Created by Nick Riedman on 4/3/24.
//

import SpeziAccount
import SpeziMockWebService
import SwiftUI

struct Education: View {
Expand Down
2 changes: 0 additions & 2 deletions ENGAGEHF/HeartHealth/HeartHealthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// Created by Nick Riedman on 4/3/24.
//

import SpeziAccount
import SpeziMockWebService
import SwiftUI

struct HeartHealth: View {
Expand Down
2 changes: 0 additions & 2 deletions ENGAGEHF/Medications/MedicationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// Created by Nick Riedman on 4/3/24.
//

import SpeziAccount
import SpeziMockWebService
import SwiftUI

struct Medications: View {
Expand Down

0 comments on commit 6f0fd66

Please sign in to comment.