diff --git a/MC2-Team3-Pilling.xcodeproj/project.pbxproj b/MC2-Team3-Pilling.xcodeproj/project.pbxproj index a5fa050..cab117b 100644 --- a/MC2-Team3-Pilling.xcodeproj/project.pbxproj +++ b/MC2-Team3-Pilling.xcodeproj/project.pbxproj @@ -16,6 +16,8 @@ 1B6530592BFB8A0C00452ACB /* LiveTimeWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 1B6530492BFB8A0C00452ACB /* LiveTimeWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 1B65305E2BFB8ACD00452ACB /* LiveTimeAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6530432BFB7C1600452ACB /* LiveTimeAttributes.swift */; }; 21B273082BFB390C002BCC67 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B273072BFB390C002BCC67 /* Model.swift */; }; + 21B2730C2BFB7301002BCC67 /* SwiftDataTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B2730B2BFB7301002BCC67 /* SwiftDataTestView.swift */; }; + 21B2730E2BFB85E2002BCC67 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B2730D2BFB85E2002BCC67 /* Config.swift */; }; 939C87E02BF307B600572EDC /* MC2_Team3_PillingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C87DF2BF307B600572EDC /* MC2_Team3_PillingApp.swift */; }; 939C87E22BF307B600572EDC /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C87E12BF307B600572EDC /* ContentView.swift */; }; 939C87E42BF307B600572EDC /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C87E32BF307B600572EDC /* Item.swift */; }; @@ -26,6 +28,7 @@ 939C88322BF6B4AC00572EDC /* MedicineSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88312BF6B4AC00572EDC /* MedicineSheetView.swift */; }; 939C88362BF6B9BC00572EDC /* OnboardingSecondView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88352BF6B9BC00572EDC /* OnboardingSecondView.swift */; }; 939C88382BF6DF7000572EDC /* SplashScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88372BF6DF7000572EDC /* SplashScreenView.swift */; }; + 939C88742BFBA01C00572EDC /* PopoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88732BFBA01C00572EDC /* PopoverView.swift */; }; 9B0411762BF593A0006F8BB9 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B0411752BF593A0006F8BB9 /* MainView.swift */; }; 9BE4AA1D2BF6E280008BE893 /* CustomFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BE4AA1C2BF6E280008BE893 /* CustomFont.swift */; }; /* End PBXBuildFile section */ @@ -64,6 +67,8 @@ 1B6530542BFB8A0C00452ACB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 1B6530562BFB8A0C00452ACB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 21B273072BFB390C002BCC67 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = ""; }; + 21B2730B2BFB7301002BCC67 /* SwiftDataTestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDataTestView.swift; sourceTree = ""; }; + 21B2730D2BFB85E2002BCC67 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; 939C87DC2BF307B600572EDC /* MC2-Team3-Pilling.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MC2-Team3-Pilling.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 939C87DF2BF307B600572EDC /* MC2_Team3_PillingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MC2_Team3_PillingApp.swift; sourceTree = ""; }; 939C87E12BF307B600572EDC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -76,6 +81,7 @@ 939C88312BF6B4AC00572EDC /* MedicineSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MedicineSheetView.swift; sourceTree = ""; }; 939C88352BF6B9BC00572EDC /* OnboardingSecondView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingSecondView.swift; sourceTree = ""; }; 939C88372BF6DF7000572EDC /* SplashScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreenView.swift; sourceTree = ""; }; + 939C88732BFBA01C00572EDC /* PopoverView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopoverView.swift; sourceTree = ""; }; 9B0411752BF593A0006F8BB9 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; 9BE4AA1C2BF6E280008BE893 /* CustomFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomFont.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -130,6 +136,8 @@ 939C88352BF6B9BC00572EDC /* OnboardingSecondView.swift */, 939C882F2BF5CC9F00572EDC /* SettingView.swift */, 939C88372BF6DF7000572EDC /* SplashScreenView.swift */, + 939C88732BFBA01C00572EDC /* PopoverView.swift */, + 21B2730B2BFB7301002BCC67 /* SwiftDataTestView.swift */, ); path = View; sourceTree = ""; @@ -140,6 +148,7 @@ 1B6530432BFB7C1600452ACB /* LiveTimeAttributes.swift */, 939C87E32BF307B600572EDC /* Item.swift */, 21B273072BFB390C002BCC67 /* Model.swift */, + 21B2730D2BFB85E2002BCC67 /* Config.swift */, ); path = Model; sourceTree = ""; @@ -307,9 +316,12 @@ 939C87E22BF307B600572EDC /* ContentView.swift in Sources */, 939C882E2BF5CC9100572EDC /* OnboardingFirstView.swift in Sources */, 9B0411762BF593A0006F8BB9 /* MainView.swift in Sources */, + 21B2730E2BFB85E2002BCC67 /* Config.swift in Sources */, 21B273082BFB390C002BCC67 /* Model.swift in Sources */, 939C88362BF6B9BC00572EDC /* OnboardingSecondView.swift in Sources */, 939C88302BF5CC9F00572EDC /* SettingView.swift in Sources */, + 939C88742BFBA01C00572EDC /* PopoverView.swift in Sources */, + 21B2730C2BFB7301002BCC67 /* SwiftDataTestView.swift in Sources */, 939C87E42BF307B600572EDC /* Item.swift in Sources */, 9BE4AA1D2BF6E280008BE893 /* CustomFont.swift in Sources */, 939C88382BF6DF7000572EDC /* SplashScreenView.swift in Sources */, diff --git a/MC2-Team3-Pilling/MC2_Team3_PillingApp.swift b/MC2-Team3-Pilling/MC2_Team3_PillingApp.swift index 58b5333..4202b58 100644 --- a/MC2-Team3-Pilling/MC2_Team3_PillingApp.swift +++ b/MC2-Team3-Pilling/MC2_Team3_PillingApp.swift @@ -10,23 +10,12 @@ import SwiftData @main struct MC2_Team3_PillingApp: App { - var sharedModelContainer: ModelContainer = { - let schema = Schema([ - Item.self, - ]) - let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) - - do { - return try ModelContainer(for: schema, configurations: [modelConfiguration]) - } catch { - fatalError("Could not create ModelContainer: \(error)") - } - }() - + + var body: some Scene { WindowGroup { ContentView() } - .modelContainer(sharedModelContainer) + .modelContainer(for:UserInfo.self) } } diff --git a/MC2-Team3-Pilling/Model/Config.swift b/MC2-Team3-Pilling/Model/Config.swift new file mode 100644 index 0000000..7772349 --- /dev/null +++ b/MC2-Team3-Pilling/Model/Config.swift @@ -0,0 +1,88 @@ +// +// Config.swift +// MC2-Team3-Pilling +// +// Created by ram on 5/20/24. +// + +import Foundation +import SwiftUI + +class Config{ + enum IntakeStatus: Int { + case notYet = 0 // .customgray + case onePill = 1 // .customgreen + case twoPills = 2 // .customgreen + case placebo = 3 // .white + + var color: Color { + switch self { + case .notYet: + return .customGray + case .onePill, .twoPills: + return .customGreen + case .placebo: + return .white + } + } + } + + enum StatusMessage: Int, CustomStringConvertible { //문구 변경 예정 + case plantGrass = 0 + case limitTwoHours = 1 + case plantTwoGrass = 2 + case grassGrowingWell = 3 + case notRecording = 4 + + var description: String { + switch self { + case .plantGrass: + return "잔디를 심어주세요" + case .limitTwoHours: + return "잔디는 2시간을 초과하지 않게 심어주세요!" + case .plantTwoGrass: + return "2개의 잔디를 심어주세요" + case .grassGrowingWell: + return "잔디가 잘 자라고 있어요!" + case .notRecording: + return "기록을 안하고 계신가요?" + } + } + } + + let days = ["일", "월", "화", "수", "목", "금", "토"] + func DayDateToString(date: Date) -> String { + let format = "yyyy-MM-dd HH:mm:ss" + let dateFormatter = DateFormatter() + dateFormatter.timeZone = TimeZone.current + dateFormatter.dateFormat = format + return dateFormatter.string(from: date) + } + func DayStringToDate(dateString: String) -> Date? { + let format = "yyyy-MM-dd HH:mm:ss" + let dateFormatter = DateFormatter() + dateFormatter.timeZone = TimeZone.current + dateFormatter.dateFormat = format + return dateFormatter.date(from: dateString) + } + func AlarmDateToString(date: Date) -> String { + let format = "HH:mm" + let dateFormatter = DateFormatter() + dateFormatter.timeZone = TimeZone.current + dateFormatter.dateFormat = format + return dateFormatter.string(from: date) + } + func AlarmStringToDate(dateString: String) -> Date? { + let format = "HH:mm" + let dateFormatter = DateFormatter() + dateFormatter.timeZone = TimeZone.current + dateFormatter.dateFormat = format + return dateFormatter.date(from: dateString) + } + + + +} +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] +var colorArr:[Color] = [.customGray,.customGreen,.customGreen,.white] + diff --git a/MC2-Team3-Pilling/Model/Model.swift b/MC2-Team3-Pilling/Model/Model.swift index d387b7a..44ebbc2 100644 --- a/MC2-Team3-Pilling/Model/Model.swift +++ b/MC2-Team3-Pilling/Model/Model.swift @@ -9,15 +9,15 @@ import Foundation import SwiftData @Model -class UserInfo:Identifiable{ - let id:UUID - var scheduleTime:DateComponents +final class UserInfo:Identifiable{ + @Attribute(.unique) var id:UUID + var scheduleTime:String var curPill:PeriodPill - var historyPill:[PeriodPill] + @Relationship var historyPill:[PeriodPill] = [PeriodPill]() var isAlarm:Bool var isSiri:Bool - init(scheduleTime: DateComponents, curPill: PeriodPill) { + init(scheduleTime: String, curPill: PeriodPill) { self.id = UUID() self.scheduleTime = scheduleTime self.curPill = curPill @@ -25,35 +25,40 @@ class UserInfo:Identifiable{ self.isAlarm = false self.isSiri = false } - + + } @Model -class PeriodPill:Identifiable{ - let id:UUID - var pillInfo:PillInfo - var startIntake:DateComponents - var finishIntake:DateComponents? +final class PeriodPill:Identifiable{ + @Attribute(.unique) let id:UUID + @Relationship var pillInfo:PillInfo + var startIntake:String + var finishIntake:String? = nil var intakeCal:[Int] + var intakeCalTime:[String] var missDay:Int - init(pillInfo: PillInfo, startIntake: DateComponents, finishIntake: DateComponents? = nil, intakeCal: [Int], missDay: Int) { + init(pillInfo: PillInfo, startIntake: String) { self.id = UUID() self.pillInfo = pillInfo self.startIntake = startIntake - self.intakeCal = intakeCal + self.intakeCal = [] + self.intakeCalTime = [] self.missDay = 0 } } @Model -class PillInfo:Identifiable{ - let id:UUID +final class PillInfo:Identifiable{ + @Attribute(.unique) let id:UUID var pillName:String var intakeDay:Int var placeboDay:Int var wholeDay:Int + var descriptionInfo:String? = nil + var type:String? = nil init(pillName: String, intakeDay: Int, placeboDay: Int) { self.id = UUID() @@ -62,5 +67,6 @@ class PillInfo:Identifiable{ self.placeboDay = placeboDay self.wholeDay = intakeDay+placeboDay } + } diff --git a/MC2-Team3-Pilling/View/ContentView.swift b/MC2-Team3-Pilling/View/ContentView.swift index 953b35d..12d574c 100644 --- a/MC2-Team3-Pilling/View/ContentView.swift +++ b/MC2-Team3-Pilling/View/ContentView.swift @@ -16,19 +16,35 @@ struct ContentView: View { return formatter }() @Environment(\.modelContext) private var modelContext - @Query private var items: [Item] + @State private var isTracking = false @State private var alarmTime = dateFormatter.date(from: "\(Date.now.formatted(date: .numeric, time: .omitted))_23:00:00")! @State private var activity: Activity? = nil + @Query private var user: [UserInfo] // 하나만 쓰고싶다면? + var body: some View { NavigationStack{ - NavigationLink(destination: MainView()){ - Text("MainView") + VStack(spacing:20){ + NavigationLink(destination: MainView()){ + Text("MainView") + } + + NavigationLink(destination: OnboardingFirstView()){ + Text("OnboardingFirstView") + } + NavigationLink(destination: OnboardingSecondView()){ + Text("OnboardingSecondView") + } + NavigationLink(destination: SwiftDataTestView()){ + Text("SwiftDataTestView") + } + } - NavigationLink(destination: OnboardingFirstView()){ - Text("OnboardingView") + NavigationLink(destination: SplashScreenView()){ + Text("SplashScreenView") } + Button(action: { isTracking.toggle() if isTracking { @@ -54,7 +70,7 @@ struct ContentView: View { } } - + private func addItem() { withAnimation { let newItem = Item(timestamp: Date()) @@ -62,13 +78,13 @@ struct ContentView: View { } } - private func deleteItems(offsets: IndexSet) { - withAnimation { - for index in offsets { - modelContext.delete(items[index]) - } - } - } + // private func deleteItems(offsets: IndexSet) { + // withAnimation { + // for index in offsets { + // modelContext.delete(items[index]) + // } + // } + // } } #Preview { diff --git a/MC2-Team3-Pilling/View/MainView.swift b/MC2-Team3-Pilling/View/MainView.swift index fd1cada..7999f25 100644 --- a/MC2-Team3-Pilling/View/MainView.swift +++ b/MC2-Team3-Pilling/View/MainView.swift @@ -9,11 +9,13 @@ import SwiftUI struct MainView: View { @State private var showingPopover = false + @State var startNum = 4 + @State var statusMessage: Config.StatusMessage = .plantGrass + @State var isModal = false var body: some View { NavigationStack { ZStack { - LinearGradient(stops: [.init(color: .customGreen.opacity(0.3), location: 0), .init(color: .white, location: 0.15)], startPoint: .top, endPoint: .bottom) - .ignoresSafeArea() + GreenGradient() VStack(spacing: 20) { // navigation icons HStack { @@ -26,7 +28,7 @@ struct MainView: View { }) .popover(isPresented: $showingPopover, attachmentAnchor: .point(.bottom), arrowEdge: .top) { - Text("Popover test") + PopoverView() .padding() .presentationCompactAdaptation(.popover) } @@ -60,7 +62,7 @@ struct MainView: View { HStack { Image(systemName: "drop") .foregroundColor(.customGreen) - Text("잔디를 심어주세요") + Text(statusMessage.description) .boldRegular() Spacer() } @@ -73,29 +75,31 @@ struct MainView: View { // calendar view VStack(spacing: 10) { HStack { - Text("화") - .frame(width: 45, height: 45) - Text("수") - .frame(width: 45, height: 45) - Text("목") - .frame(width: 45, height: 45) - Text("금") - .frame(width: 45, height: 45) - Text("토") - .frame(width: 45, height: 45) - Text("일") - .frame(width: 45, height: 45) - Text("월") - .frame(width: 45, height: 45) + ForEach(startNum...(startNum+6),id:\.self){ num in + DayView(num: (num%7)) + } + } .regular() - ForEach(0..<4) { _ in + ForEach(0..<4) { y in HStack { - ForEach(0..<7) { _ in - Button(action: {}, label: {}) - .frame(width: 45, height: 45) - .background(.customGray) - .clipShape(RoundedRectangle(cornerRadius: 10)) + ForEach(0..<7) { x in + if x==3 && y==0{ + TwoCell(isModal: $isModal, backgroundColor: .customGreen) + } + else if x==1 && y==0 { + ActivateCell(isModal: $isModal, backgroundColor: .customBrown) + } + else if x==0 && y == 0{ + TodayCell(isModal: $isModal, backgroundColor: colorArr[myArray[y*7+x]]) + } + else{ + ActivateCell(isModal: $isModal, backgroundColor: colorArr[myArray[y*7+x]]) + } + + + + } } } @@ -115,10 +119,88 @@ struct MainView: View { } .padding() } + .sheet(isPresented: $isModal){ + EmptyView() + } } + } } #Preview { MainView() } + +struct GreenGradient: View { + var body: some View { + LinearGradient(stops: [.init(color: .customGreen.opacity(0.3), location: 0), .init(color: .white, location: 0.15)], startPoint: .top, endPoint: .bottom) + .ignoresSafeArea() + } +} + +struct DayView: View { + var num:Int + var body: some View { + Text(Config().days[num]) + .frame(width: 45, height: 45) + } +} + +struct ActivateCell: View { + @Binding var isModal:Bool + var backgroundColor: Color + var body: some View { + RoundedRectangle(cornerRadius: 10) + .frame(width: 45, height: 45) + .foregroundColor(backgroundColor) + .onTapGesture { + isModal = true + print(isModal) + } + } + +} +struct TodayCell: View { + @Binding var isModal:Bool + var backgroundColor: Color + var body: some View { + Rectangle() + .foregroundColor(.clear) + .frame(width: 45, height: 45) + .background(backgroundColor) + .cornerRadius(10) + .overlay( + RoundedRectangle(cornerRadius: 10) + .inset(by: 1) + .stroke(Color.green,lineWidth: 3) + + ) + } + +} +struct TwoCell: View { + @Binding var isModal:Bool + var backgroundColor: Color + var body: some View { + HStack(spacing: 5){ + + Rectangle() + .foregroundColor(.clear) + .frame(width: 20, height: 45) + .background(.customGreen) + .cornerRadius(10) + + Rectangle() + .foregroundColor(.clear) + .frame(width: 20, height: 45) + .background(Color(red: 0.5, green: 0.87, blue: 0.11)) + .cornerRadius(10) + + + } + .frame(width: 45, height: 45) + + + } + +} diff --git a/MC2-Team3-Pilling/View/MedicineSheetView.swift b/MC2-Team3-Pilling/View/MedicineSheetView.swift index 200fc2c..ddc5d1e 100644 --- a/MC2-Team3-Pilling/View/MedicineSheetView.swift +++ b/MC2-Team3-Pilling/View/MedicineSheetView.swift @@ -3,7 +3,8 @@ import SwiftUI struct MedicineSheetView: View { @State private var searchText = "" -// @State private var showingMedicineSheet = true + @Binding var showingMedicineSheet: Bool +// @State var showingMedicineSheet = false let BirthControlNames = [ "쎄스콘정", "미뉴렛정", "에이리스정", "머시론정", @@ -36,7 +37,7 @@ struct MedicineSheetView: View { // footer button Button(action: { -// self.showingMedicineSheet = false + self.showingMedicineSheet = false }, label: { Text("설정완료!") .largeBold() @@ -54,11 +55,13 @@ struct MedicineSheetView: View { //캔버스 컨텐츠뷰 -struct ContentView_Previews: PreviewProvider { - static var previews: some View { - MedicineSheetView() - } -} +//struct ContentView_Previews: PreviewProvider { +// static var previews: some View { +// +// MedicineSheetView(showingMedicineSheet: false) +//// MedicineSheetView() +// } +//} //화면 터치시 키보드 숨김 @@ -75,5 +78,7 @@ extension View { #Preview { - MedicineSheetView() + +// MedicineSheetView() + OnboardingFirstView() } diff --git a/MC2-Team3-Pilling/View/OnboardingFirstView.swift b/MC2-Team3-Pilling/View/OnboardingFirstView.swift index b3ab518..4efe19a 100644 --- a/MC2-Team3-Pilling/View/OnboardingFirstView.swift +++ b/MC2-Team3-Pilling/View/OnboardingFirstView.swift @@ -4,88 +4,86 @@ import SwiftUI struct OnboardingFirstView: View { @State private var showingMedicineSheet = false + var body: some View { - NavigationStack { - VStack { - Image("making-plan") - .resizable() - .frame(width: 240, height: 240) - - // Text + Image("making-plan") + .resizable() + .frame(width: 240, height: 240) + + // Text + VStack(alignment: .leading) { + Text("복용하고 계신 약을 알려주세요!") + .largeTitle() + .padding(.bottom, 2) + + Text("설정은 추후에 변경 가능합니다.") + .secondaryRegular() + } + + + // Selecting box + VStack { + Button(action: { + self.showingMedicineSheet = true + }, label: { + // sfSymbol 부재 : medicine-bottle-one HStack { - VStack(alignment: .leading) { - Text("복용하고 계신 약을 알려주세요!") - .largeTitle() - .padding(.bottom, 2) - - Text("설정은 추후에 변경 가능합니다.") - .secondaryRegular() - } + Image(systemName: "pill.circle.fill") + Text("약 종류") + .secondaryTitle() Spacer() + Image(systemName: "chevron.right") } - - - // Selecting box - VStack { - Button(action: { - self.showingMedicineSheet = true - }, label: { - // sfSymbol 부재 : medicine-bottle-one - HStack { - Image(systemName: "pill.circle.fill") - Text("약 종류") - .secondaryTitle() - Spacer() - Image(systemName: "chevron.right") - } - .padding([.leading, .trailing], 25) - }) - .padding(.vertical, 20) - .frame(maxWidth: .infinity) - .background(.customGray02) - .clipShape(RoundedRectangle(cornerRadius: 10)) - .foregroundColor(.secondary) - .sheet(isPresented: $showingMedicineSheet){ - MedicineSheetView() - .presentationDetents([.medium]) - } - - - - Button(action: {}, label: { - // sfSymbol 부재 : uis-calender - HStack { - Image(systemName: "note") - Text("현재 복용 일수") - .secondaryTitle() - Spacer() - } - .padding([.leading, .trailing], 25) - }) - .padding(.vertical, 20) - .frame(maxWidth: .infinity) - .background(.customGray02) - .clipShape(RoundedRectangle(cornerRadius: 10)) - .foregroundColor(.secondary) - - - } - - Spacer() - - // footer button - NavigationLink(destination: OnboardingSecondView()) { - Text("다음으로") - .largeBold() - } - .padding(.vertical, 30) - .frame(maxWidth: .infinity) - .background(.customGreen) - .clipShape(RoundedRectangle(cornerRadius: 20)) - .foregroundColor(.black) + .padding([.leading, .trailing], 25) + }) + .padding(.vertical, 20) + .frame(maxWidth: .infinity) + .background(.customGray02) + .clipShape(RoundedRectangle(cornerRadius: 10)) + .foregroundColor(.secondary) + .padding([.leading, .trailing], 20) + .sheet(isPresented: $showingMedicineSheet){ +// MedicineSheetView(showingMedicineSheet: true) + MedicineSheetView(showingMedicineSheet: $showingMedicineSheet) + .presentationDetents([.medium]) } - .padding() + + + + Button(action: {}, label: { + // sfSymbol 부재 : uis-calender + HStack { + Image(systemName: "note") + Text("현재 복용 일수") + .secondaryTitle() + Spacer() + } + .padding([.leading, .trailing], 25) + }) + .padding(.vertical, 20) + .frame(maxWidth: .infinity) + .background(.customGray02) + .clipShape(RoundedRectangle(cornerRadius: 10)) + .foregroundColor(.secondary) + .padding([.leading, .trailing], 20) + } + + Spacer() + + // footer button + Button(action: { + // OnboardingView02() + }, label: { + Text("다음으로") + .largeBold() + }) + .padding(.vertical, 30) + .frame(maxWidth: .infinity) + .background(.customGreen) + .clipShape(RoundedRectangle(cornerRadius: 20)) + .foregroundColor(.black) + .padding() } } diff --git a/MC2-Team3-Pilling/View/OnboardingSecondView.swift b/MC2-Team3-Pilling/View/OnboardingSecondView.swift index 7a050da..43d435a 100644 --- a/MC2-Team3-Pilling/View/OnboardingSecondView.swift +++ b/MC2-Team3-Pilling/View/OnboardingSecondView.swift @@ -6,12 +6,31 @@ struct OnboardingSecondView: View { @State var alarmToggle = false var body: some View { - VStack{ - Image("clock") - .resizable() - .frame(width: 240, height: 240) - + + Image("clock") + .resizable() + .frame(width: 240, height: 240) + + // Text + VStack(alignment: .leading) { // Text + Text("알람 받을 시간을 설정해주세요!") + .font(.title) + .fontWeight(.semibold) + .padding(.bottom, 2) + + + Text("설정은 추후에 변경 가능합니다.") + .font(.title3) + .foregroundStyle(.secondary) + } + + + Button(action: { + DatePicker("시간", selection: $alarmTime, displayedComponents: .hourAndMinute) + print(alarmTime) + }, label: { + HStack { VStack(alignment: .leading) { // Text @@ -24,6 +43,21 @@ struct OnboardingSecondView: View { } Spacer() } + + .padding([.leading, .trailing], 25) + }) + .padding(.vertical, 20) + .frame(maxWidth: .infinity) + .background(.customGray02) + .clipShape(RoundedRectangle(cornerRadius: 10)) + .foregroundColor(.secondary) + .padding() + + + VStack{ + Toggle("소리 알람여부추가", isOn: $alarmToggle) + .padding([.leading, .trailing], 20) + Button(action: { @@ -73,6 +107,7 @@ struct OnboardingSecondView: View { } .padding() + } } diff --git a/MC2-Team3-Pilling/View/PopoverView.swift b/MC2-Team3-Pilling/View/PopoverView.swift new file mode 100644 index 0000000..0ad8c01 --- /dev/null +++ b/MC2-Team3-Pilling/View/PopoverView.swift @@ -0,0 +1,54 @@ + +import SwiftUI + +struct PopoverView: View { + var body: some View { + VStack(alignment: .leading) { + Text("필링 가이드") + .largeBold() + .padding(.bottom, 3) + Text("피임약 복용 상태를 잔디로 알려줘요!") + .secondaryRegular() + .padding(.bottom) + + HStack{ + RoundedRectangle(cornerRadius: 10) + .frame(width: 45, height: 45) + .foregroundStyle(.customGreen) + + Text("피임약 복용") + } + .padding(.bottom) + + HStack{ + RoundedRectangle(cornerRadius: 10) + .frame(width: 45, height: 45) + .foregroundStyle(.customGreen) + + Text("피임약 2알 복용") + } + .padding(.bottom) + + HStack{ + RoundedRectangle(cornerRadius: 10) + .frame(width: 45, height: 45) + .foregroundStyle(.customBrown) + + Text("미복용") + } + .padding(.bottom) + + HStack{ + RoundedRectangle(cornerRadius: 10) + .frame(width: 45, height: 45) + .foregroundStyle(.customGreen) + + Text("현재") + } + } + } +} + +#Preview { + PopoverView() +} diff --git a/MC2-Team3-Pilling/View/SearchBar.swift b/MC2-Team3-Pilling/View/SearchBar.swift index 700f555..315ccc0 100644 --- a/MC2-Team3-Pilling/View/SearchBar.swift +++ b/MC2-Team3-Pilling/View/SearchBar.swift @@ -3,15 +3,15 @@ import SwiftUI struct SearchBar: View { @Binding var text: String - + var body: some View { HStack { HStack { Image(systemName: "magnifyingglass") - + TextField("Search", text: $text) .foregroundColor(.primary) - + if !text.isEmpty { Button(action: { self.text = "" diff --git a/MC2-Team3-Pilling/View/SettingView.swift b/MC2-Team3-Pilling/View/SettingView.swift index acd8e45..9185269 100644 --- a/MC2-Team3-Pilling/View/SettingView.swift +++ b/MC2-Team3-Pilling/View/SettingView.swift @@ -13,6 +13,7 @@ struct SettingView: View { @State private var selectedPill = 0 @State private var isShowingPills = false let pills = [(name: "야즈", type: "24일/4일"), (name: "머쉬론", type: "21일/7일")] + var body: some View { NavigationStack { Form { @@ -38,7 +39,9 @@ struct SettingView: View { } Section("알림") { DatePicker("시간", selection: $selectedAlarmTime, displayedComponents: .hourAndMinute) + Toggle("알람", isOn: $isSoundOn) + } } .navigationTitle("Settings") @@ -46,6 +49,7 @@ struct SettingView: View { Text("Pills") .presentationDetents([.height(300), .large]) }) + } } } diff --git a/MC2-Team3-Pilling/View/SplashScreenView.swift b/MC2-Team3-Pilling/View/SplashScreenView.swift index ac8e93a..7b2aa56 100644 --- a/MC2-Team3-Pilling/View/SplashScreenView.swift +++ b/MC2-Team3-Pilling/View/SplashScreenView.swift @@ -12,7 +12,7 @@ struct SplashScreenView: View { Image("Splash") .resizable() .ignoresSafeArea() - + } .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { diff --git a/MC2-Team3-Pilling/View/SwiftDataTestView.swift b/MC2-Team3-Pilling/View/SwiftDataTestView.swift new file mode 100644 index 0000000..531ce95 --- /dev/null +++ b/MC2-Team3-Pilling/View/SwiftDataTestView.swift @@ -0,0 +1,43 @@ +// +// SwiftDataTestView.swift +// MC2-Team3-Pilling +// +// Created by ram on 5/20/24. +// + +import SwiftUI +import SwiftData + +struct SwiftDataTestView: View { + @Environment(\.modelContext) private var modelContext + @State var txt = "" + + + var body: some View { + VStack { + TextField("테스트 글을 적어주세요.", text:$txt) + Button(action:{ + modelContext.insert(UserInfo(scheduleTime: "", curPill: PeriodPill(pillInfo: PillInfo(pillName: txt, intakeDay: 24, placeboDay: 4), startIntake: ""))) + do { + try modelContext.save() + print("스데 저장 성공") + } catch { + print("Failed to save context: \(error.localizedDescription)") + } + } + , label: { + /*@START_MENU_TOKEN@*/Text("Button")/*@END_MENU_TOKEN@*/ + }) + + + } + .padding() + + + + } +} + +#Preview { + SwiftDataTestView() +}