67 lines
2.3 KiB
Swift
67 lines
2.3 KiB
Swift
//
|
|
// BottomView.swift
|
|
// AcaMate
|
|
//
|
|
// Created by TAnine on 2/4/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct BottomView: View {
|
|
@StateObject var btnVM = ButtonViewModel()
|
|
@State var pageType: PageType = .Home
|
|
|
|
@State private var homeID = UUID()
|
|
@State private var managementID = UUID()
|
|
@State private var chattingID = UUID()
|
|
@State private var calendarID = UUID()
|
|
@State private var etcID = UUID()
|
|
|
|
var body: some View {
|
|
let idList: [UUID] = [homeID,managementID,chattingID,calendarID,etcID]
|
|
|
|
HStack(alignment: .center, spacing: 0){
|
|
ForEach(Array(idList.enumerated()), id: \.offset) { index, id in
|
|
CircleBtnView(vm: btnVM, id: id)
|
|
if index != idList.count-1 {
|
|
Spacer(minLength: 1)
|
|
}
|
|
|
|
}
|
|
}
|
|
.padding(EdgeInsets(top: 12, leading: 24, bottom: 0, trailing: 24))
|
|
|
|
.background {
|
|
Rectangle()
|
|
.foregroundStyle(Color(.Normal.dark))
|
|
.ignoresSafeArea(edges: .bottom)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.onAppear {
|
|
let idList: [UUID] = [homeID,managementID,chattingID,calendarID,etcID]
|
|
let btnText: [String] = ["홈", "학습 관리", "채팅", "일정", "더보기"]
|
|
let btnImage: [Image] = [Image(.Icon.home),Image(.Icon.management),Image(.Icon.chatting),Image(.Icon.calendar),Image(.Icon.etc)]
|
|
|
|
idList.enumerated().forEach { (index, id) in
|
|
btnVM.btnStates[id] = ButtonState()
|
|
btnVM.setSize(for: id, newWidth: 52, newHeight: 52)
|
|
btnVM.setText(for: id, newText: btnText[index],
|
|
newFont: .nps(font: .bold, size: 6))
|
|
btnVM.setImage(for: id, newImage: btnImage[index])
|
|
|
|
btnVM.setAction(for: id) {
|
|
btnVM.setIsSelected(for: id, newValue: true)
|
|
idList.forEach {
|
|
if $0 != id {
|
|
btnVM.setIsSelected(for: $0, newValue: false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
btnVM.setIsSelected(for: idList[pageType.rawValue], newValue: true)
|
|
}
|
|
|
|
}
|
|
}
|