Skip to content

Commit

Permalink
Merge pull request #43 from DeveloperAcademy-POSTECH/feat/#42
Browse files Browse the repository at this point in the history
Feat/#42 OnboardingFirstView 데이터 바인딩
  • Loading branch information
teabag759 authored May 22, 2024
2 parents af15388 + 701ca8c commit 7e7271a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 43 deletions.
47 changes: 30 additions & 17 deletions MC2-Team3-Pilling/Model/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class Config{

var color: Color {
switch self {
case .notYet:
return .customGray
case .onePill, .twoPills:
return .customGreen
case .placebo:
return .white
case .notYet:
return .customGray
case .onePill, .twoPills:
return .customGreen
case .placebo:
return .white
}
}
}
Expand All @@ -36,16 +36,16 @@ class Config{

var description: String {
switch self {
case .plantGrass:
return "잔디를 심어주세요"
case .limitTwoHours:
return "잔디는 2시간을 초과하지 않게 심어주세요!"
case .plantTwoGrass:
return "2개의 잔디를 심어주세요"
case .grassGrowingWell:
return "잔디가 잘 자라고 있어요!"
case .notRecording:
return "기록을 안하고 계신가요?"
case .plantGrass:
return "잔디를 심어주세요"
case .limitTwoHours:
return "잔디는 2시간을 초과하지 않게 심어주세요!"
case .plantTwoGrass:
return "2개의 잔디를 심어주세요"
case .grassGrowingWell:
return "잔디가 잘 자라고 있어요!"
case .notRecording:
return "기록을 안하고 계신가요?"
}
}
}
Expand Down Expand Up @@ -75,12 +75,25 @@ class Config{
func AlarmStringToDate(dateString: String) -> Date? {
let format = "HH:mm"
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone.current
dateFormatter.timeZone = TimeZone.current
dateFormatter.dateFormat = format
return dateFormatter.date(from: dateString)
}


static let dummyPillInfos: [PillInfo] = [
PillInfo(pillName: "머시론정", intakeDay: 24, placeboDay: 4),
PillInfo(pillName: "야즈", intakeDay: 21, placeboDay: 7),
PillInfo(pillName: "마이보라", intakeDay: 28, placeboDay: 0),
PillInfo(pillName: "디미아", intakeDay: 24, placeboDay: 4),
PillInfo(pillName: "클레라", intakeDay: 21, placeboDay: 7),
PillInfo(pillName: "벨라라", intakeDay: 21, placeboDay: 7),
PillInfo(pillName: "레보니아", intakeDay: 28, placeboDay: 0),
PillInfo(pillName: "디안느35", intakeDay: 21, placeboDay: 7),
PillInfo(pillName: "로젠정", intakeDay: 24, placeboDay: 4),
PillInfo(pillName: "센시발", intakeDay: 28, placeboDay: 0)
]


}
let myArray: [Int] = [1, 2 , 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3]
Expand Down
6 changes: 3 additions & 3 deletions MC2-Team3-Pilling/View/ChooseStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ struct ChooseStatusView: View {
}
.pickerStyle(.segmented)
// selection Print 되는 값 확인
// .onChange(of: selectedNum) { newValue in
// print("Selected number: \(newValue)")
// }
// .onChange(of: selectedNum) { newValue in
// print("Selected number: \(newValue)")
// }

// 복용시간 버튼
Button(action: {
Expand Down
27 changes: 16 additions & 11 deletions MC2-Team3-Pilling/View/MedicineSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@ import SwiftUI

struct MedicineSheetView: View {
@State private var searchText = ""
@Binding var showingMedicineSheet: Bool
// @State var showingMedicineSheet = false
// @Binding var showingMedicineSheet: Bool

@Binding var selectedPill: PillInfo?

let BirthControlNames = [
"쎄스콘정", "미뉴렛정", "에이리스정", "머시론정",
"마이보라", "미니보라30","트리퀄라", "멜리안정",
"센스리베정", "디어미정", "야스민정", "야즈정","클래라정"]

var filteredBirthControl: [String] {
var filteredBirthControl: [PillInfo] {
if searchText.isEmpty {
BirthControlNames
return Config.dummyPillInfos
} else {
BirthControlNames.filter{ $0.localizedStandardContains(searchText) }
return Config.dummyPillInfos.filter{ $0.pillName.localizedStandardContains(searchText) }
}
}

var body: some View {
NavigationView {
VStack {
List(filteredBirthControl, id: \.self) {
birthControl in
Text(birthControl)
List(filteredBirthControl) { pill in
Button(action: {
selectedPill = pill
// showingMedicineSheet = false
}) {
Text(pill.pillName)
}
}
.searchable(text: $searchText)
} //리스트의 스타일 수정
Expand All @@ -37,7 +42,7 @@ struct MedicineSheetView: View {

// footer button
Button(action: {
self.showingMedicineSheet = false
// self.showingMedicineSheet = false
}, label: {
Text("설정완료!")
.largeBold()
Expand Down Expand Up @@ -78,7 +83,7 @@ extension View {


#Preview {

// MedicineSheetView()
// MedicineSheetView()
OnboardingFirstView()
}
9 changes: 5 additions & 4 deletions MC2-Team3-Pilling/View/OnboardingFirstView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SwiftUI

struct OnboardingFirstView: View {
@State private var showingMedicineSheet = false
@State private var selectedPill: PillInfo?


var body: some View {
Expand Down Expand Up @@ -47,8 +48,8 @@ struct OnboardingFirstView: View {
.foregroundColor(.secondary)
.padding([.leading, .trailing], 16)
.sheet(isPresented: $showingMedicineSheet){
// MedicineSheetView(showingMedicineSheet: true)
MedicineSheetView(showingMedicineSheet: $showingMedicineSheet)
MedicineSheetView(selectedPill: $selectedPill)
// MedicineSheetView(showingMedicineSheet: $showingMedicineSheet, selectedPill: $selectedPill)
.presentationDetents([.medium])
}

Expand Down Expand Up @@ -78,7 +79,7 @@ struct OnboardingFirstView: View {
// footer button
Button(action: {
// OnboardingView02()

}, label: {
Text("다음으로")
.largeBold()
Expand All @@ -90,7 +91,7 @@ struct OnboardingFirstView: View {
.foregroundColor(.black)
.padding()
}

}

#Preview {
Expand Down
8 changes: 4 additions & 4 deletions MC2-Team3-Pilling/View/OnboardingSecondView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ struct OnboardingSecondView: View {

Button(action: {
}, label: {

ZStack{
HStack {
Image(systemName: "clock")
Text("복용 시간")
.secondaryTitle()
Spacer()

}
DatePicker("", selection: $alarmTime, displayedComponents: .hourAndMinute)

}
.padding([.leading, .trailing], 20)

Expand All @@ -61,7 +61,7 @@ struct OnboardingSecondView: View {
Toggle("소리 알람여부추가", isOn: $alarmToggle)
.regular()
.padding(.bottom, 2)



HStack {
Expand Down
4 changes: 2 additions & 2 deletions MC2-Team3-Pilling/View/PopoverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct PopoverView: View {

}
.frame(width: 45, height: 45)

Text("피임약 2알 복용")
}
.padding(.bottom)
Expand All @@ -64,7 +64,7 @@ struct PopoverView: View {
.stroke(Color.green,lineWidth: 3)

)

Text("현재")
}
}
Expand Down
4 changes: 2 additions & 2 deletions MC2-Team3-Pilling/View/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct SettingView: View {
}
Section("알림") {
DatePicker("시간", selection: $selectedAlarmTime, displayedComponents: .hourAndMinute)

Toggle("알람", isOn: $isSoundOn)

}
Expand All @@ -49,7 +49,7 @@ struct SettingView: View {
Text("Pills")
.presentationDetents([.height(300), .large])
})

}
}
}
Expand Down

0 comments on commit 7e7271a

Please sign in to comment.