Skip to content

Commit

Permalink
Minor layout and functionality follow-up (#63)
Browse files Browse the repository at this point in the history
# Minor layout and functionality follow-up


## ⚙️ Release Notes 
* Fixed Map Pin in German region
* Minor layout issues in Assessments and Edit view
* Add configurable minimum step count setting in Account Overview.


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Mar 19, 2024
1 parent 955fd37 commit 05a77f4
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 31 deletions.
23 changes: 20 additions & 3 deletions PICS/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ struct AccountSheet: View {

@Environment(Account.self)
private var account
@Environment(PatientInformation.self)
private var patientInformation

@Environment(\.accountRequired)
private var accountRequired

Expand All @@ -28,10 +31,10 @@ struct AccountSheet: View {
ZStack {
if account.signedIn && !isInSetup {
AccountOverview(isEditing: $overviewIsEditing) {
NavigationLink {
healthSection

NavigationLink("LICENSE_INFO_TITLE") {
ContributionsList()
} label: {
Text("LICENSE_INFO_TITLE")
}
}
.onDisappear {
Expand Down Expand Up @@ -61,6 +64,19 @@ struct AccountSheet: View {
}
}

@ViewBuilder var healthSection: some View {
@Bindable var patientInformation = patientInformation
Section("Health") {
Stepper(value: $patientInformation.minimumStepCount, in: 2000...15000, step: 200) {
VStack(alignment: .leading) {
Text("Recommended Step Count")
Text("\(patientInformation.minimumStepCount) steps")
.foregroundColor(.secondary)
}
}
}
}

var closeButton: some ToolbarContent {
ToolbarItem(placement: .cancellationAction) {
Button("CLOSE") {
Expand All @@ -85,6 +101,7 @@ struct AccountSheet: View {

#Preview("AccountSheet SignIn") {
AccountSheet()
.environment(PatientInformation())
.previewWith {
AccountConfiguration {
MockUserIdPasswordAccountService()
Expand Down
38 changes: 21 additions & 17 deletions PICS/Appointment/AppointmentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,33 @@ struct AppointmentView: View {
}
.navigationTitle("APPOINTMENTS_NAVIGATION_TITLE")
.sheet(isPresented: $showingEdit) {
// swiftlint:disable:previous closure_body_length
NavigationStack {
List {
Text("APPTQ_0")
.font(.headline)
.padding(.top, 32)
DateTimePickerView(selectedDateTime: $appt0User)
.padding(.bottom, 32)
Text("APPTQ_1")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt1User)
.padding(.bottom, 32)
Text("APPTQ_2")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt2User)
.padding(.bottom, 32)
Button("SAVE_BUTTON") {
Section {
Text("APPTQ_0")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt0User)
}
Section {
Text("APPTQ_1")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt1User)
}
Section {
Text("APPTQ_2")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt2User)
}

Button(action: {
patientInformation.storeDates(appt0User, appt1User, appt2User)
showingEdit.toggle()
}) {
Text("SAVE_BUTTON")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
Spacer()
}
.padding(.horizontal, 20)
.navigationTitle("EDIT_APPT_HEADER")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Expand Down
5 changes: 4 additions & 1 deletion PICS/Appointment/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct MapView: View {
private var region: MKCoordinateRegion {
MKCoordinateRegion(
center: coordinate,
span: MKCoordinateSpan(latitudeDelta: 0.002, longitudeDelta: 0.002)
span: MKCoordinateSpan(latitudeDelta: 0.003, longitudeDelta: 0.003)
)
}

Expand Down Expand Up @@ -74,6 +74,9 @@ struct MapView: View {
}
}


#if DEBUG
#Preview {
MapView()
}
#endif
10 changes: 5 additions & 5 deletions PICS/Assessment/Views/AssessmentTaskSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct AssessmentTaskSection: View {
}

Divider()
.padding(.bottom, 5)

Button(action: {
presentingTask = task
Expand All @@ -39,10 +38,11 @@ struct AssessmentTaskSection: View {
Text("Retake Assessment")
}
}
.multilineTextAlignment(.center)
.foregroundStyle(.accent)
.accessibilityIdentifier(task.accessibilityIdentifier)
.buttonStyle(.plain) // Use style to restrict clickable area.
.padding(.vertical, 4)
.multilineTextAlignment(.center)
.foregroundStyle(.accent)
.accessibilityIdentifier(task.accessibilityIdentifier)
.buttonStyle(.plain) // Use style to restrict clickable area.
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion PICS/Assessment/Views/ResultsViz.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct ResultsViz: View {
init(task: AssessmentTask, data: [AssessmentResult]) {
self.task = task
self.data = data
self.hasErrorCountMetrics = !data.contains { $0.errorCnt != nil }
self.hasErrorCountMetrics = data.contains { $0.errorCnt != nil }
}


Expand Down
7 changes: 6 additions & 1 deletion PICS/HealthVisulization/HKVisualization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct HKData: Identifiable {
}

struct HKVisualization: View {
@Environment(PatientInformation.self)
private var patientInformation

@State var stepData: [HKData] = []
@State var heartRateData: [HKData] = []
@State var oxygenSaturationData: [HKData] = []
Expand All @@ -37,7 +40,7 @@ struct HKVisualization: View {
xName: "Time",
yName: "Step Count",
title: "HKVIZ_PLOT_STEP_TITLE",
threshold: 5000.0,
threshold: Double(patientInformation.minimumStepCount),
helperText: "HKVIZ_PLOT_STEP_RECOMD"
)
}
Expand Down Expand Up @@ -327,8 +330,10 @@ func parseSampleQueryData(results: [HKSample], quantityTypeIDF: HKQuantityTypeId
return collectedData
}


#if DEBUG
#Preview {
HKVisualization(presentingAccount: .constant(false))
.environment(PatientInformation())
}
#endif
12 changes: 9 additions & 3 deletions PICS/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
},
"%@: Not Completed" : {

},
"%lld steps" : {

},
"ACCOUNT_NEXT" : {
"localizations" : {
Expand Down Expand Up @@ -429,6 +432,9 @@
}
}
}
},
"Health" : {

},
"HEALTHKIT_PERMISSIONS_BUTTON" : {
"localizations" : {
Expand Down Expand Up @@ -740,9 +746,6 @@
},
"Measurement" : {

},
"Medication Plan" : {

},
"MEDICATION_SUBTITLE" : {
"extractionState" : "manual",
Expand Down Expand Up @@ -978,6 +981,9 @@
}
}
}
},
"Recommended Step Count" : {

},
"Repository Link" : {
"localizations" : {
Expand Down
15 changes: 15 additions & 0 deletions PICS/Schedule/PatientInformation/PatientInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class PatientInformation {
@AppStorage("isSurveyCompleted")
@ObservationIgnored private var _isSurveyCompleted = false

@AppStorage("minimumStepCount")
@ObservationIgnored private var _minimumStepCount: Int = 5000

var appt0: Date {
get {
self.access(keyPath: \.appt0)
Expand Down Expand Up @@ -71,6 +74,18 @@ class PatientInformation {
}
}

var minimumStepCount: Int {
get {
self.access(keyPath: \.minimumStepCount)
return _minimumStepCount
}
set {
self.withMutation(keyPath: \.minimumStepCount) {
self._minimumStepCount = newValue
}
}
}

func storeDates(_ date0: Date, _ date1: Date, _ date2: Date) {
self.appt0 = date0
self.appt1 = date1
Expand Down

0 comments on commit 05a77f4

Please sign in to comment.