Skip to content

Commit

Permalink
Unify button styles throughout application (#91)
Browse files Browse the repository at this point in the history
# Unify button styles throughout the application

## ♻️ Current situation & Problem
Currently, we use a variety of of button styles throughout the
application, especially regarding scrolling behavior.


## ⚙️ Release Notes 
- Unify button styles throughout the application, especially in regards
to scrollable behavior.


## 📚 Documentation
--


## ✅ Testing
--


## 📝 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
philippzagar authored Apr 2, 2024
1 parent a859470 commit dd1dedd
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 114 deletions.
32 changes: 20 additions & 12 deletions Intake/AllergyView/AllergyRecords.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,26 @@ struct AllergyList: View {

var body: some View {
if loaded.allergyData {
VStack {
allergyForm
/**/
if FeatureFlags.skipToScrollable {
SubmitButton(nextView: NavigationViews.pdfs)
.padding()
} else if data.generalData.sex == "Female" {
SubmitButton(nextView: NavigationViews.menstrual)
.padding()
} else {
SubmitButton(nextView: NavigationViews.smoking)
.padding()
ZStack {
VStack {
allergyForm

Spacer(minLength: 62)
}

VStack {
Spacer()

if FeatureFlags.skipToScrollable {
SubmitButton(nextView: NavigationViews.pdfs)
.padding()
} else if data.generalData.sex == "Female" {
SubmitButton(nextView: NavigationViews.menstrual)
.padding()
} else {
SubmitButton(nextView: NavigationViews.smoking)
.padding()
}
}
}
.sheet(isPresented: $showingChat, content: chatSheetView)
Expand Down
17 changes: 13 additions & 4 deletions Intake/ChiefComplaintView/SummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ struct SummaryView: View {


var body: some View {
VStack(alignment: .leading, spacing: 20) {
ComplaintForm(chiefComplaint: $chiefComplaint)
SubmitButton(nextView: .medical)
.padding()
ZStack {
VStack {
ComplaintForm(chiefComplaint: $chiefComplaint)

Spacer(minLength: 62)
}

VStack {
Spacer()

SubmitButton(nextView: NavigationViews.medical)
.padding()
}
}
}
}
34 changes: 21 additions & 13 deletions Intake/ExportView/ScrollablePDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,30 @@ struct ScrollablePDF: View {


var body: some View {
VStack {
Form {
PatientInfo()
ChiefComplaint()
ConditionSection()
SurgerySection()
MedicationSection()
AllergySection()
if data.generalData.sex == "Female" {
MenstrualSection()
ZStack {
VStack {
Form {
PatientInfo()
ChiefComplaint()
ConditionSection()
SurgerySection()
MedicationSection()
AllergySection()
if data.generalData.sex == "Female" {
MenstrualSection()
}
SmokingSection()
}
SmokingSection()

Spacer(minLength: 62)
}

ExportButton()
.padding()
VStack {
Spacer()

ExportButton()
.padding()
}
}
.navigationTitle("Patient Form")
.task {
Expand Down
1 change: 1 addition & 0 deletions Intake/Helper/Binding+Negate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import SwiftUI


extension Binding where Value == Bool {
/// Negates a `Binding`.
prefix static func ! (value: Binding<Bool>) -> Binding<Bool> {
Expand Down
1 change: 1 addition & 0 deletions Intake/Helper/Bundle+Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import SwiftUI


extension Foundation.Bundle {
/// Loads an image from the `Bundle` instance.
/// - Parameters:
Expand Down
1 change: 1 addition & 0 deletions Intake/Helper/CodableArray+RawRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation


extension Array: RawRepresentable where Element: Codable {
public var rawValue: String {
guard let data = try? JSONEncoder().encode(self),
Expand Down
3 changes: 3 additions & 0 deletions Intake/Helper/ViewElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI


struct SkipButton: View {
var action: () -> Void

Expand All @@ -27,6 +28,8 @@ struct SubmitButton: View {
@Environment(NavigationPathWrapper.self) private var navigationPath
@Environment(ReachedEndWrapper.self) private var end
var nextView: NavigationViews


var body: some View {
Button(action: {
if end.reachedEnd {
Expand Down
25 changes: 17 additions & 8 deletions Intake/MedicalHistoryView/MedicalHistoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@ struct MedicalHistoryView: View {

var body: some View {
if loaded.conditionData {
VStack {
medicalHistoryForm
if FeatureFlags.testCondition {
SubmitButton(nextView: NavigationViews.pdfs)
.padding()
} else {
SubmitButton(nextView: NavigationViews.surgical)
.padding()
ZStack {
VStack {
medicalHistoryForm

Spacer(minLength: 62)
}

VStack {
Spacer()

if FeatureFlags.testCondition {
SubmitButton(nextView: NavigationViews.pdfs)
.padding()
} else {
SubmitButton(nextView: NavigationViews.surgical)
.padding()
}
}
}
.sheet(isPresented: $showingChat, content: chatSheetView)
Expand Down
9 changes: 7 additions & 2 deletions Intake/PatientView/EditPatient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct EditPatientView: View {
var body: some View {
@Bindable var data = data

VStack {
ZStack {
Form {
Section(header: Text("Name")) {
TextField("Name", text: $data.generalData.name)
Expand All @@ -35,7 +35,12 @@ struct EditPatientView: View {
}
}

SubmitButton(nextView: NavigationViews.pdfs)
VStack {
Spacer()

SubmitButton(nextView: NavigationViews.pdfs)
.padding()
}
}
}
}
Expand Down
69 changes: 43 additions & 26 deletions Intake/PatientView/PatientInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,47 @@ struct PatientInfo: View {
@State private var birthdateDateFormat = Date()

@Environment(DataStore.self) private var data
@Environment(NavigationPathWrapper.self) private var navigationPath
@Environment(FHIRStore.self) private var fhirStore


var body: some View {
@Bindable var data = data

VStack {
Form {
Section(header: Text("Patient Information")) {
TextField(text: $data.generalData.name) {
Text("Full name")
}

DatePicker("Date of Birth:", selection: $birthdateDateFormat, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())

Picker("Sex", selection: $sexOption) {
ForEach(["Female", "Male"], id: \.self) { option in
Text(option).tag(option)
ZStack {
VStack {
Form {
Section(header: Text("Patient Information")) {
TextField(text: $data.generalData.name) {
Text("Full name")
}

DatePicker("Date of Birth:", selection: $birthdateDateFormat, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())

Picker("Sex", selection: $sexOption) {
ForEach(["Female", "Male"], id: \.self) { option in
Text(option).tag(option)
}
}
}
.pickerStyle(MenuPickerStyle())
}
}

Spacer(minLength: 62)
}

VStack {
Spacer()

SubmitButtonWithAction(
nextView: FeatureFlags.skipToScrollable ? .pdfs : .chat,
onButtonTap: {
updateData()
},
accessibilityIdentifier: "Next"
)
.padding()
}

SubmitButtonWithAction(
nextView: FeatureFlags.skipToScrollable ? .pdfs : .chat,
onButtonTap: {
updateData()
},
accessibilityIdentifier: "Next"
)
.padding()
}
.task {
loadData()
Expand Down Expand Up @@ -162,8 +169,18 @@ extension String {
}


struct PatientInfo_Previews: PreviewProvider {
static var previews: some View {
#Preview {
@State var dataStore = DataStore()
@State var fhirStore = FHIRStore()
@State var navigationPath = NavigationPathWrapper()
@State var reachedEnd = ReachedEndWrapper()


return NavigationStack {
PatientInfo()
}
.environment(dataStore)
.environment(fhirStore)
.environment(navigationPath)
.environment(reachedEnd)
}
3 changes: 3 additions & 0 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
},
"Back" : {

},
"Chat with LLM Assistant" : {

},
"Chief Complaint:" : {

Expand Down
65 changes: 37 additions & 28 deletions Intake/SocialHistoryView/MenstrualHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,49 @@ struct SocialHistoryQuestionView: View {


var body: some View {
VStack {
if data.generalData.sex == "Female" {
Form {
Section(header: Text("Menstrual Information").foregroundColor(.gray)) {
@Bindable var data = data
DatePicker("Last period's start date", selection: $startDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())
if data.generalData.sex == "Female" {
ZStack {
VStack {
Form {
Section(header: Text("Menstrual Information").foregroundColor(.gray)) {
@Bindable var data = data
DatePicker("Last period's start date", selection: $startDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())

DatePicker("Last period's end date", selection: $endDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())
}

DatePicker("Last period's end date", selection: $endDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())
Section(header: Text("Additional Symptoms").foregroundColor(.gray)) {
@Bindable var data = data
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
}
}

Section(header: Text("Additional Symptoms").foregroundColor(.gray)) {
@Bindable var data = data
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
}
}
.navigationTitle("Menstrual History")
.task {
startDate = data.menstrualHistory.startDate
endDate = data.menstrualHistory.endDate
additionalDetails = data.menstrualHistory.additionalDetails
Spacer(minLength: 62)
}
.onDisappear {
data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails)
}
if FeatureFlags.skipToScrollable {
SubmitButton(nextView: NavigationViews.pdfs)
.padding()
} else {
SubmitButton(nextView: NavigationViews.smoking)
.padding()

VStack {
Spacer()

if FeatureFlags.skipToScrollable {
SubmitButton(nextView: NavigationViews.pdfs)
.padding()
} else {
SubmitButton(nextView: NavigationViews.smoking)
.padding()
}
}
}
.navigationTitle("Menstrual History")
.task {
startDate = data.menstrualHistory.startDate
endDate = data.menstrualHistory.endDate
additionalDetails = data.menstrualHistory.additionalDetails
}
.onDisappear {
data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails)
}
}
}
}
Loading

0 comments on commit dd1dedd

Please sign in to comment.