Skip to content

Commit

Permalink
Fixsmoking (#60)
Browse files Browse the repository at this point in the history
# *FIX SMOKING BEFORE AKASH*
  • Loading branch information
zoyagarg authored Mar 9, 2024
1 parent 56d1e78 commit 92324c9
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 204 deletions.
44 changes: 16 additions & 28 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@
},
"Additional Details" : {

},
"Additional details: %@" : {

},
"Additional Symptoms" : {

Expand All @@ -105,6 +102,9 @@
},
"Auto-fill Intake Form" : {

},
"Calculation" : {

},
"Chat" : {

Expand Down Expand Up @@ -217,6 +217,9 @@
},
"DETAILS" : {

},
"Do you currently smoke or have you smoked in the past?" : {

},
"Download your medical records from your health system." : {

Expand Down Expand Up @@ -319,6 +322,12 @@
},
"It looks like an unexpected view was appended to the NavigationPath!" : {

},
"Last period's end date" : {

},
"Last period's start date" : {

},
"LICENSE_INFO_TITLE" : {
"localizations" : {
Expand Down Expand Up @@ -433,6 +442,9 @@
},
"Next" : {

},
"No" : {

},
"NOTIFICATION_PERMISSIONS_BUTTON" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -595,18 +607,6 @@
}
}
}
},
"Select End Date" : {

},
"Select Start Date" : {

},
"Select your last period's end date" : {

},
"Select your last period's start date" : {

},
"SETTINGS" : {

Expand All @@ -631,12 +631,6 @@
},
"Start" : {

},
"Start Date: %@" : {

},
"START_CALENDAR" : {

},
"Status" : {

Expand All @@ -658,9 +652,6 @@
},
"Surgical History" : {

},
"Symptoms: %@" : {

},
"TASK_CONTEXT_ACTION_QUESTIONNAIRE" : {
"localizations" : {
Expand Down Expand Up @@ -733,10 +724,7 @@

},
"Your Responses" : {

},
"YYYY-MM-DD" : {


}
},
"version" : "1.0"
Expand Down
164 changes: 22 additions & 142 deletions Intake/SocialHistory/MenstrualHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,152 +14,37 @@ import Foundation
import HealthKit
import SwiftUI


struct SectionHeader: View {
let title: String
let subtitle: String

var body: some View {
VStack(alignment: .leading) {
Text(title)
.font(.title)
.multilineTextAlignment(.leading)
.padding(.bottom, 2)

if !subtitle.isEmpty {
Text(subtitle)
.font(.subheadline)
.foregroundColor(.gray)
.multilineTextAlignment(.leading)
.padding(.bottom)
}
}
}
}

struct SocialHistoryQuestionView: View {
struct SectionHeader: View {
let title: String

var body: some View {
VStack(alignment: .leading) {
Text(title)
.font(.headline)
}
}
}

private var menstrualCycleButtons: some View {
VStack {
Button(action: {
isSelectingStartDate = true
}) {
HStack {
Text("Select your last period's start date")
Spacer() // Add Spacer here for white space
Image(systemName: "calendar")
.accessibilityLabel(Text("START_CALENDAR"))
}
}
.buttonStyle(BorderlessButtonStyle())

Spacer().frame(height: 16)

Button(action: {
isSelectingEndDate = true
}) {
HStack {
Text("Select your last period's end date")
Spacer()
Image(systemName: "calendar")
.accessibilityLabel(Text("END_CALENDAR"))
}
}
.buttonStyle(BorderlessButtonStyle())
}
}

private var menstrualCycleInformationSection: some View {
Group {
Section(header: Text("Menstrual Information").foregroundColor(.gray)) {
menstrualCycleButtons
}

Section(header: Text("Additional Symptoms")) {
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
}
if shouldDisplayResponses {
Section(header: Text("Your Responses").foregroundColor(.gray)) {
VStack(alignment: .leading) {
Text("Start Date: \(formatDate(startDate))")
Text("End Date: \(formatDate(endDate))")
if !additionalDetails.isEmpty {
Text("Symptoms: \(additionalDetails)")
}
}
}
}
}
}

@State private var dateString: String = ""
@State private var additionalDetails: String = ""
@State private var isFemale = false
@State private var showMaleSlide = false
@State private var healthStore = HKHealthStore()

@State private var isSelectingStartDate = false
@State private var isSelectingEndDate = false
@State private var startDate = Date()
@State private var endDate = Date()
@State private var lastPeriodDate: Date?

@State private var healthStore = HKHealthStore()
@State private var isFemale = false
@State private var showMaleSlide = false
@Environment(NavigationPathWrapper.self) private var navigationPath

private var shouldDisplayResponses: Bool {
!additionalDetails.isEmpty || startDate != Date() || endDate != Date()
}


let numberFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.minimum = 0
return formatter
}()


var body: some View {
NavigationView { // swiftlint:disable:this closure_body_length
VStack { // swiftlint:disable:this closure_body_length
NavigationView {
VStack {
Form {
menstrualCycleInformationSection
Section(header: Text("Menstrual Information").foregroundColor(.gray)) {
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())
}

Section(header: Text("Additional Symptoms").foregroundColor(.gray)) {
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
}
}
.navigationTitle("Social History")
.onAppear {
fetchHealthKitData()
}
.sheet(isPresented: $isSelectingStartDate, content: {
VStack {
DatePicker("Select Start Date", selection: $startDate, displayedComponents: .date)
.datePickerStyle(GraphicalDatePickerStyle())

Button("Save") {
lastPeriodDate = startDate
isSelectingStartDate = false
}
}
})
.sheet(isPresented: $isSelectingEndDate, content: {
VStack {
DatePicker("Select End Date", selection: $endDate, displayedComponents: .date)
.datePickerStyle(GraphicalDatePickerStyle())

Button("Save") {
isSelectingEndDate = false
}
}
})
Spacer()

// Adding the Submit button outside the Form
Button(action: {
navigationPath.path.append(NavigationViews.smoking)
}) {
Expand All @@ -170,17 +55,12 @@ struct SocialHistoryQuestionView: View {
.background(Color.blue)
.cornerRadius(8)
}
.padding()
.padding(.horizontal)
.padding(.bottom)
}
}
}

private func formatDate(_ date: Date) -> String {
let formatter = DateFormatter()
formatter.dateStyle = .medium
return formatter.string(from: date)
}


private func fetchHealthKitData() {
let infoToRead = Set([HKObjectType.characteristicType(forIdentifier: .biologicalSex)].compactMap { $0 })

Expand Down
Loading

0 comments on commit 92324c9

Please sign in to comment.