Skip to content

Commit dea3211

Browse files
authored
Merge branch 'main' into feat/#25
2 parents c2ac902 + f626c3a commit dea3211

14 files changed

+491
-159
lines changed

MC2-Team3-Pilling.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
1B6530592BFB8A0C00452ACB /* LiveTimeWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 1B6530492BFB8A0C00452ACB /* LiveTimeWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
1717
1B65305E2BFB8ACD00452ACB /* LiveTimeAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6530432BFB7C1600452ACB /* LiveTimeAttributes.swift */; };
1818
21B273082BFB390C002BCC67 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B273072BFB390C002BCC67 /* Model.swift */; };
19+
21B2730C2BFB7301002BCC67 /* SwiftDataTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B2730B2BFB7301002BCC67 /* SwiftDataTestView.swift */; };
20+
21B2730E2BFB85E2002BCC67 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B2730D2BFB85E2002BCC67 /* Config.swift */; };
1921
939C87E02BF307B600572EDC /* MC2_Team3_PillingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C87DF2BF307B600572EDC /* MC2_Team3_PillingApp.swift */; };
2022
939C87E22BF307B600572EDC /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C87E12BF307B600572EDC /* ContentView.swift */; };
2123
939C87E42BF307B600572EDC /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C87E32BF307B600572EDC /* Item.swift */; };
@@ -26,6 +28,7 @@
2628
939C88322BF6B4AC00572EDC /* MedicineSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88312BF6B4AC00572EDC /* MedicineSheetView.swift */; };
2729
939C88362BF6B9BC00572EDC /* OnboardingSecondView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88352BF6B9BC00572EDC /* OnboardingSecondView.swift */; };
2830
939C88382BF6DF7000572EDC /* SplashScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88372BF6DF7000572EDC /* SplashScreenView.swift */; };
31+
939C88742BFBA01C00572EDC /* PopoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 939C88732BFBA01C00572EDC /* PopoverView.swift */; };
2932
9B0411762BF593A0006F8BB9 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B0411752BF593A0006F8BB9 /* MainView.swift */; };
3033
9BE4AA1D2BF6E280008BE893 /* CustomFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BE4AA1C2BF6E280008BE893 /* CustomFont.swift */; };
3134
/* End PBXBuildFile section */
@@ -64,6 +67,8 @@
6467
1B6530542BFB8A0C00452ACB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6568
1B6530562BFB8A0C00452ACB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6669
21B273072BFB390C002BCC67 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
70+
21B2730B2BFB7301002BCC67 /* SwiftDataTestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDataTestView.swift; sourceTree = "<group>"; };
71+
21B2730D2BFB85E2002BCC67 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
6772
939C87DC2BF307B600572EDC /* MC2-Team3-Pilling.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MC2-Team3-Pilling.app"; sourceTree = BUILT_PRODUCTS_DIR; };
6873
939C87DF2BF307B600572EDC /* MC2_Team3_PillingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MC2_Team3_PillingApp.swift; sourceTree = "<group>"; };
6974
939C87E12BF307B600572EDC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -76,6 +81,7 @@
7681
939C88312BF6B4AC00572EDC /* MedicineSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MedicineSheetView.swift; sourceTree = "<group>"; };
7782
939C88352BF6B9BC00572EDC /* OnboardingSecondView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingSecondView.swift; sourceTree = "<group>"; };
7883
939C88372BF6DF7000572EDC /* SplashScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreenView.swift; sourceTree = "<group>"; };
84+
939C88732BFBA01C00572EDC /* PopoverView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopoverView.swift; sourceTree = "<group>"; };
7985
9B0411752BF593A0006F8BB9 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
8086
9BE4AA1C2BF6E280008BE893 /* CustomFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomFont.swift; sourceTree = "<group>"; };
8187
/* End PBXFileReference section */
@@ -130,6 +136,8 @@
130136
939C88352BF6B9BC00572EDC /* OnboardingSecondView.swift */,
131137
939C882F2BF5CC9F00572EDC /* SettingView.swift */,
132138
939C88372BF6DF7000572EDC /* SplashScreenView.swift */,
139+
939C88732BFBA01C00572EDC /* PopoverView.swift */,
140+
21B2730B2BFB7301002BCC67 /* SwiftDataTestView.swift */,
133141
);
134142
path = View;
135143
sourceTree = "<group>";
@@ -140,6 +148,7 @@
140148
1B6530432BFB7C1600452ACB /* LiveTimeAttributes.swift */,
141149
939C87E32BF307B600572EDC /* Item.swift */,
142150
21B273072BFB390C002BCC67 /* Model.swift */,
151+
21B2730D2BFB85E2002BCC67 /* Config.swift */,
143152
);
144153
path = Model;
145154
sourceTree = "<group>";
@@ -307,9 +316,12 @@
307316
939C87E22BF307B600572EDC /* ContentView.swift in Sources */,
308317
939C882E2BF5CC9100572EDC /* OnboardingFirstView.swift in Sources */,
309318
9B0411762BF593A0006F8BB9 /* MainView.swift in Sources */,
319+
21B2730E2BFB85E2002BCC67 /* Config.swift in Sources */,
310320
21B273082BFB390C002BCC67 /* Model.swift in Sources */,
311321
939C88362BF6B9BC00572EDC /* OnboardingSecondView.swift in Sources */,
312322
939C88302BF5CC9F00572EDC /* SettingView.swift in Sources */,
323+
939C88742BFBA01C00572EDC /* PopoverView.swift in Sources */,
324+
21B2730C2BFB7301002BCC67 /* SwiftDataTestView.swift in Sources */,
313325
939C87E42BF307B600572EDC /* Item.swift in Sources */,
314326
9BE4AA1D2BF6E280008BE893 /* CustomFont.swift in Sources */,
315327
939C88382BF6DF7000572EDC /* SplashScreenView.swift in Sources */,

MC2-Team3-Pilling/MC2_Team3_PillingApp.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,12 @@ import SwiftData
1010

1111
@main
1212
struct MC2_Team3_PillingApp: App {
13-
var sharedModelContainer: ModelContainer = {
14-
let schema = Schema([
15-
Item.self,
16-
])
17-
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
18-
19-
do {
20-
return try ModelContainer(for: schema, configurations: [modelConfiguration])
21-
} catch {
22-
fatalError("Could not create ModelContainer: \(error)")
23-
}
24-
}()
25-
13+
14+
2615
var body: some Scene {
2716
WindowGroup {
2817
ContentView()
2918
}
30-
.modelContainer(sharedModelContainer)
19+
.modelContainer(for:UserInfo.self)
3120
}
3221
}

MC2-Team3-Pilling/Model/Config.swift

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// Config.swift
3+
// MC2-Team3-Pilling
4+
//
5+
// Created by ram on 5/20/24.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
class Config{
12+
enum IntakeStatus: Int {
13+
case notYet = 0 // .customgray
14+
case onePill = 1 // .customgreen
15+
case twoPills = 2 // .customgreen
16+
case placebo = 3 // .white
17+
18+
var color: Color {
19+
switch self {
20+
case .notYet:
21+
return .customGray
22+
case .onePill, .twoPills:
23+
return .customGreen
24+
case .placebo:
25+
return .white
26+
}
27+
}
28+
}
29+
30+
enum StatusMessage: Int, CustomStringConvertible { //문구 변경 예정
31+
case plantGrass = 0
32+
case limitTwoHours = 1
33+
case plantTwoGrass = 2
34+
case grassGrowingWell = 3
35+
case notRecording = 4
36+
37+
var description: String {
38+
switch self {
39+
case .plantGrass:
40+
return "잔디를 심어주세요"
41+
case .limitTwoHours:
42+
return "잔디는 2시간을 초과하지 않게 심어주세요!"
43+
case .plantTwoGrass:
44+
return "2개의 잔디를 심어주세요"
45+
case .grassGrowingWell:
46+
return "잔디가 잘 자라고 있어요!"
47+
case .notRecording:
48+
return "기록을 안하고 계신가요?"
49+
}
50+
}
51+
}
52+
53+
let days = ["", "", "", "", "", "", ""]
54+
func DayDateToString(date: Date) -> String {
55+
let format = "yyyy-MM-dd HH:mm:ss"
56+
let dateFormatter = DateFormatter()
57+
dateFormatter.timeZone = TimeZone.current
58+
dateFormatter.dateFormat = format
59+
return dateFormatter.string(from: date)
60+
}
61+
func DayStringToDate(dateString: String) -> Date? {
62+
let format = "yyyy-MM-dd HH:mm:ss"
63+
let dateFormatter = DateFormatter()
64+
dateFormatter.timeZone = TimeZone.current
65+
dateFormatter.dateFormat = format
66+
return dateFormatter.date(from: dateString)
67+
}
68+
func AlarmDateToString(date: Date) -> String {
69+
let format = "HH:mm"
70+
let dateFormatter = DateFormatter()
71+
dateFormatter.timeZone = TimeZone.current
72+
dateFormatter.dateFormat = format
73+
return dateFormatter.string(from: date)
74+
}
75+
func AlarmStringToDate(dateString: String) -> Date? {
76+
let format = "HH:mm"
77+
let dateFormatter = DateFormatter()
78+
dateFormatter.timeZone = TimeZone.current
79+
dateFormatter.dateFormat = format
80+
return dateFormatter.date(from: dateString)
81+
}
82+
83+
84+
85+
}
86+
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]
87+
var colorArr:[Color] = [.customGray,.customGreen,.customGreen,.white]
88+

MC2-Team3-Pilling/Model/Model.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,56 @@ import Foundation
99
import SwiftData
1010

1111
@Model
12-
class UserInfo:Identifiable{
13-
let id:UUID
14-
var scheduleTime:DateComponents
12+
final class UserInfo:Identifiable{
13+
@Attribute(.unique) var id:UUID
14+
var scheduleTime:String
1515
var curPill:PeriodPill
16-
var historyPill:[PeriodPill]
16+
@Relationship var historyPill:[PeriodPill] = [PeriodPill]()
1717
var isAlarm:Bool
1818
var isSiri:Bool
1919

20-
init(scheduleTime: DateComponents, curPill: PeriodPill) {
20+
init(scheduleTime: String, curPill: PeriodPill) {
2121
self.id = UUID()
2222
self.scheduleTime = scheduleTime
2323
self.curPill = curPill
2424
self.historyPill = []
2525
self.isAlarm = false
2626
self.isSiri = false
2727
}
28-
28+
29+
2930
}
3031

3132
@Model
32-
class PeriodPill:Identifiable{
33-
let id:UUID
34-
var pillInfo:PillInfo
35-
var startIntake:DateComponents
36-
var finishIntake:DateComponents?
33+
final class PeriodPill:Identifiable{
34+
@Attribute(.unique) let id:UUID
35+
@Relationship var pillInfo:PillInfo
36+
var startIntake:String
37+
var finishIntake:String? = nil
3738
var intakeCal:[Int]
39+
var intakeCalTime:[String]
3840
var missDay:Int
3941

40-
init(pillInfo: PillInfo, startIntake: DateComponents, finishIntake: DateComponents? = nil, intakeCal: [Int], missDay: Int) {
42+
init(pillInfo: PillInfo, startIntake: String) {
4143
self.id = UUID()
4244
self.pillInfo = pillInfo
4345
self.startIntake = startIntake
44-
self.intakeCal = intakeCal
46+
self.intakeCal = []
47+
self.intakeCalTime = []
4548
self.missDay = 0
4649
}
4750

4851
}
4952

5053
@Model
51-
class PillInfo:Identifiable{
52-
let id:UUID
54+
final class PillInfo:Identifiable{
55+
@Attribute(.unique) let id:UUID
5356
var pillName:String
5457
var intakeDay:Int
5558
var placeboDay:Int
5659
var wholeDay:Int
60+
var descriptionInfo:String? = nil
61+
var type:String? = nil
5762

5863
init(pillName: String, intakeDay: Int, placeboDay: Int) {
5964
self.id = UUID()
@@ -62,5 +67,6 @@ class PillInfo:Identifiable{
6267
self.placeboDay = placeboDay
6368
self.wholeDay = intakeDay+placeboDay
6469
}
70+
6571
}
6672

MC2-Team3-Pilling/View/ContentView.swift

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,35 @@ struct ContentView: View {
1616
return formatter
1717
}()
1818
@Environment(\.modelContext) private var modelContext
19-
@Query private var items: [Item]
19+
2020
@State private var isTracking = false
2121
@State private var alarmTime = dateFormatter.date(from: "\(Date.now.formatted(date: .numeric, time: .omitted))_23:00:00")!
2222
@State private var activity: Activity<LiveTimeAttributes>? = nil
2323

24+
@Query private var user: [UserInfo] // 하나만 쓰고싶다면?
25+
2426
var body: some View {
2527
NavigationStack{
26-
NavigationLink(destination: MainView()){
27-
Text("MainView")
28+
VStack(spacing:20){
29+
NavigationLink(destination: MainView()){
30+
Text("MainView")
31+
}
32+
33+
NavigationLink(destination: OnboardingFirstView()){
34+
Text("OnboardingFirstView")
35+
}
36+
NavigationLink(destination: OnboardingSecondView()){
37+
Text("OnboardingSecondView")
38+
}
39+
NavigationLink(destination: SwiftDataTestView()){
40+
Text("SwiftDataTestView")
41+
}
42+
2843
}
29-
NavigationLink(destination: OnboardingFirstView()){
30-
Text("OnboardingView")
44+
NavigationLink(destination: SplashScreenView()){
45+
Text("SplashScreenView")
3146
}
47+
3248
Button(action: {
3349
isTracking.toggle()
3450
if isTracking {
@@ -54,21 +70,21 @@ struct ContentView: View {
5470
}
5571

5672
}
57-
73+
5874
private func addItem() {
5975
withAnimation {
6076
let newItem = Item(timestamp: Date())
6177
modelContext.insert(newItem)
6278
}
6379
}
6480

65-
private func deleteItems(offsets: IndexSet) {
66-
withAnimation {
67-
for index in offsets {
68-
modelContext.delete(items[index])
69-
}
70-
}
71-
}
81+
// private func deleteItems(offsets: IndexSet) {
82+
// withAnimation {
83+
// for index in offsets {
84+
// modelContext.delete(items[index])
85+
// }
86+
// }
87+
// }
7288
}
7389

7490
#Preview {

0 commit comments

Comments
 (0)