// // AttendanceView.swift // AcaMate // // Created by TAnine on 2/7/25. // import SwiftUI struct AttendanceBoxView: View { @State var monthlyGroup: (Int,Int) = (5,10)//(0,0) @State var dailyGroup: (Int,Int) = (3,4)//(0,0) var body: some View { DashBoardView(image: Image(.Icon.attendance), title: "출석") { HStack(spacing: 4) { AttCellView(isDaily: false, valueGroup: $monthlyGroup) Spacer() AttCellView(isDaily: true, valueGroup: $dailyGroup) } .frame(maxWidth: .infinity) } moreAction: { // MARK: TO-DO // 출석 쪽 더보기 동작 만들기 print("123") } } } struct AttCellView: View { @StateObject var btnVM = ButtonViewModel() @State private var cellBtnID = UUID() let isDaily: Bool @Binding var valueGroup: (Int,Int) @State private var cellText: (name: String, group: String) = ("","") var body: some View { HStack { CircleBtnView(vm: btnVM, id: cellBtnID) VStack(alignment: .leading,spacing: 0) { HStack(alignment: .center, spacing: 2) { Text("\(cellText.name)").font(.nps(font: .bold, size: 12)) .foregroundStyle(Color(.Text.detail)) Text("출석").font(.nps(size: 12)) .foregroundStyle(Color(.Text.detail)) } .padding(.top,4) HStack(alignment: .center, spacing: 2) { Spacer() Text("\(valueGroup.0)") .font(.nps(font: .bold, size: 20)) .foregroundStyle(((Double(valueGroup.0)/Double(valueGroup.1)) < 0.7) ? Color(.Other.red) : Color(.Other.blue)) .frame(width: 28,alignment: .center) Text("/") .font(.nps(size: 12)) .foregroundStyle(Color(.Text.detail)) Text("\(valueGroup.1)") .font(.nps(font: .bold, size: 20)) .foregroundStyle(Color(.Text.detail)) .frame(width: 28,alignment: .center) Text("\(cellText.group)") .font(.nps(size: 16)) .foregroundStyle(Color(.Text.detail)) .multilineStyle() } .frame(maxWidth: .infinity) } } .onAppear { btnVM.setImage(for: cellBtnID, newImage: isDaily ? Image(.Icon.attendanceDaily) : Image(.Icon.attendanceMonthly)) btnVM.setSize(for: cellBtnID, newWidth: 48, newHeight: 48) btnVM.setIsReverse(for: cellBtnID, newValue: true) btnVM.setIsSelected(for: cellBtnID, newValue: true) if isDaily { cellText = ("일일", "시간") } else { cellText = ("월간", "일") } } } }