Skip to content

Commit

Permalink
Feat: 복용 달력 구현 시작
Browse files Browse the repository at this point in the history
  • Loading branch information
piriram committed May 23, 2024
1 parent 5945dc4 commit a5ff5fb
Showing 1 changed file with 99 additions and 96 deletions.
195 changes: 99 additions & 96 deletions MC2-Team3-Pilling/View/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,114 +26,119 @@ struct MainView: View {

@State private var showingMedicineSheet = false

// @State private var selectedPill: PillInfo? = nil
// @State private var selectedPill: PillInfo? = nil
@State private var selectedPill: PillInfo?

var body: some View {

var body: some View {


ZStack {
GreenGradient()
VStack(spacing: 20) {
// navigation icons
HStack {
Spacer()
Button(action: {
showingPopover = true
}, label: {

Image(systemName: "info.circle.fill")
.Icon()
})
.popover(isPresented: $showingPopover, attachmentAnchor: .point(.bottom),
arrowEdge: .top) {
PopoverView()
.padding()
.presentationCompactAdaptation(.popover)
NavigationStack {
ZStack {
GreenGradient()
VStack(spacing: 20) {
// navigation icons
HStack {
Spacer()
Button(action: {
showingPopover = true
}, label: {

Image(systemName: "info.circle.fill")
.Icon()
})
.popover(isPresented: $showingPopover, attachmentAnchor: .point(.bottom),
arrowEdge: .top) {
PopoverView()
.padding()
.presentationCompactAdaptation(.popover)
}
NavigationLink(destination: SettingView(selectedPill: $selectedPill, showingMedicineSheet: $showingMedicineSheet), label: {
Image(systemName: "gearshape")
.Icon()
})
}
NavigationLink(destination: SettingView(selectedPill: $selectedPill, showingMedicineSheet: $showingMedicineSheet), label: {
Image(systemName: "gearshape")
.Icon()
})
}

// status header
HStack(alignment: .center) {
Image("1case")
.resizable()
.frame(width: 200, height: 200)
VStack(alignment: .leading, spacing: 16) {
HStack {
Text("4일차")
.largeTitle()
if let whole = user.first?.curPill?.pillInfo.wholeDay{
Text("/\(String(describing: whole))")
.secondaryTitle()

// status header
HStack(alignment: .center) {
Image("1case")
.resizable()
.frame(width: 200, height: 200)
VStack(alignment: .leading, spacing: 16) {
HStack {
Text("4일차")
.largeTitle()
if let whole = user.first?.curPill?.pillInfo.wholeDay{
Text("/\(String(describing: whole))")
.secondaryTitle()
}
else{
Text("")
}

}
else{
Text("")
if let intakeDay=user.first?.curPill?.pillInfo.intakeDay,let placeboday=user.first?.curPill?.pillInfo.placeboDay{
Label("\(String(describing: intakeDay))/\(String(describing: placeboday))", systemImage: "calendar")
.secondaryRegular()
}else{
Label("", systemImage: "calendar")
.secondaryRegular()
}

}
if let intakeDay=user.first?.curPill?.pillInfo.intakeDay,let placeboday=user.first?.curPill?.pillInfo.placeboDay{
Label("\(String(describing: intakeDay))/\(String(describing: placeboday))", systemImage: "calendar")
.secondaryRegular()
}else{
Label("", systemImage: "calendar")
Label(user.first?.scheduleTime ?? "00:00", systemImage: "clock.fill")
.secondaryRegular()

}

Label(user.first?.scheduleTime ?? "00:00", systemImage: "clock.fill")
.secondaryRegular()

Spacer()
}
Spacer()
}

// now statement
HStack {
Image(systemName: "drop")
.foregroundColor(.customGreen)
Text(statusMessage.description)
.boldRegular()
Spacer()
}
.padding(20)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color.customGray, lineWidth: 1)
)

// calendar view
VStack(spacing: 10) {

// now statement
HStack {
ForEach(startNum...(startNum+6),id:\.self){ num in
DayView(num: (num%7))
}

Image(systemName: "drop")
.foregroundColor(.customGreen)
Text(statusMessage.description)
.boldRegular()
Spacer()
}
.regular()
.padding(20)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color.customGray, lineWidth: 1)
)

ForEach(0..<week) { y in
// calendar view
VStack(spacing: 10) {
HStack {
ForEach(0..<7) { x in
let idx = y * 7 + x
let status = user.first?.curPill?.intakeCal[idx].status
let isToday = today == idx


switch status {
case 3: // 위약
PlaceboCell(isModal: $isModal, backgroundColor: Color.white)
case 0:
ActivateCell(isModal: $isModal, backgroundColor: colorArr[myArray[y*7+x]])
case 1:
ActivateCell(isModal: $isModal, backgroundColor: .customGreen)
case 2:
ActivateCell(isModal: $isModal, backgroundColor: .customBrown)
default:
EmptyView()
ForEach(startNum...(startNum+6),id:\.self){ num in
DayView(num: (num%7))
}

}
.regular()

ForEach(0..<week) { y in
HStack {
ForEach(0..<7) { x in
let idx = y * 7 + x
let status = user.first?.curPill?.intakeCal[idx].status
let isToday = today == idx


switch status {
case 3: // 위약
PlaceboCell(isModal: $isModal, backgroundColor: Color.white)
case 0:
ActivateCell(isModal: $isModal, backgroundColor: colorArr[myArray[y*7+x]])
case 1:
ActivateCell(isModal: $isModal, backgroundColor: .customGreen)
case 2:
ActivateCell(isModal: $isModal, backgroundColor: .customBrown)
default:
EmptyView()
}




}
}
}
Expand Down Expand Up @@ -179,14 +184,12 @@ struct MainView: View {
}
var changeUser = user.first?.curPill?.intakeCal[0]
changeUser?.status = 0
// modelContext.update(changeUser)
// modelContext.update(changeUser)

}
.navigationBarBackButtonHidden()

}


}


Expand Down

0 comments on commit a5ff5fb

Please sign in to comment.