AcaMate_iOS/AcaMate/1. View/12. Main/121. Home/TopProfileView.swift
2025-02-14 17:51:08 +09:00

134 lines
4.8 KiB
Swift

//
// TopProfileView.swift
// AcaMate
//
// Created by TAnine on 2/5/25.
//
import SwiftUI
struct TopProfileView: View {
@StateObject var btnVM = ButtonViewModel()
var myType: UserType
// MARK: TO-DO
//
var childrenList: [String] = ["name1", "name2", "name3"]
var academyName: String = "Academy' NAME"
var myName: String = "Name"
@State private var typeName: String = "유형"
@State private var ParentsSelectID: UUID?
@State private var shopID = UUID()
@State private var notifyID = UUID()
@State private var childIDList: [UUID] = []
var body: some View {
VStack(spacing: 0){
VStack(alignment: .center, spacing: 0) {
HStack(spacing: 0) {
SimpleBtnView(vm: btnVM, id: shopID)
Spacer(minLength: 1)
SimpleBtnView(vm: btnVM, id: notifyID)
} /// Stack
ZStack{
Circle()
.stroke(Color(.Second.normal) ,lineWidth: 4)
.frame(width: 200, height: 200)
Text("\(typeName)")
.font(.nps(font: .bold, size: 48))
.foregroundStyle(Color(.Second.normal))
} /// Stack
.padding([.top, .bottom], 40)
VStack(alignment: .center, spacing: 8) {
Text("\(self.academyName)")
.font(.nps(font: .bold, size: 36))
.foregroundStyle(Color(.Text.title))
.multilineStyle()
.frame(alignment: .center)
Text("\(self.myName)")
.font(.nps(size: 18))
.foregroundStyle(Color(.Text.detail))
.multilineStyle()
.frame(alignment: .center)
}
} /// VStack
.padding(EdgeInsets(top: 24, leading: 24, bottom: 12, trailing: 24))
// MARK: TO-DO
//
if myType == .Parent {
HStack(spacing: 0) {
ForEach(Array(childIDList.enumerated()),id: \.offset){ index, id in
CircleBtnView(vm: btnVM, id: id)
if index != childIDList.count-1 {
Spacer()
}
}
} /// HStack
.padding([.leading, .trailing, .bottom], 24)
}
}
.fullDrawView(.Other.cell)
.onAppear {
let topBtnIDList = [shopID,notifyID]
let iconList = [Image(.Icon.market), Image(.Icon.notificationSET)]
topBtnIDList.enumerated().forEach { (index, id) in
btnVM.setImage(for: topBtnIDList[index], newImage: iconList[index])
btnVM.setSize(for: topBtnIDList[index], newWidth: 40, newHeight: 40)
}
// MARK: TO-DO
//
switch self.myType {
case .Student:
typeName = "학생"
case .Parent:
typeName = "학부모"
for _ in 0..<childrenList.count {
childIDList.append(UUID())
}
ParentsSelectID = childIDList[0]
btnVM.setIsSelected(for: childIDList[0], newValue: true)
childIDList.enumerated().forEach { (index, id) in
btnVM.setImage(for: id, newImage: Image(.Icon.face))
btnVM.setSize(for: id, newWidth: 64, newHeight: 64)
btnVM.setText(for: id, newText: "\(childrenList[index])", newFont: .nps(size: 12))
// MARK: TO-DO
//
btnVM.setAction(for: id) {
if let selectID = ParentsSelectID {
btnVM.setIsSelected(for: selectID, newValue: false)
}
btnVM.setIsSelected(for: id, newValue: true)
ParentsSelectID = id
}
}
case .Teacher:
typeName = "선생님"
case .Admin:
typeName = "관리자"
case .Employee:
typeName = "직원"
case .ETC:
typeName = "방문객"
}
}
}
}