AcaMate_iOS/AcaMate/1. View/12. Main/121. Home/HomeView.swift

73 lines
3.2 KiB
Swift

//
// HomeView.swift
// AcaMate
//
// Created by TAnine on 2/11/25.
//
import SwiftUI
struct HomeView: View {
@State private var scrollOffset: CGPoint = .zero
@State private var topViewState: Bool = false
var body: some View {
VStack(spacing: 0) {
ZStack {
OffsetObservableScrollView(showsIndicators: false, scrollOffset: $scrollOffset) { proxy in
VStack(spacing: 0) {
TopProfileView(userType: .Student)
// .padding(EdgeInsets(top: 0, leading: 0, bottom: 12, trailing: 0))s
.padding(.bottom,12)
Group {
AttendanceBoxView()
CalendarBoxView(summaryCalDataList: [])
CalendarBoxView(summaryCalDataList: [
SummaryCalendar(id: "123", date: "2025-02-28", summary: "요약내용입니다."),
SummaryCalendar(id: "123", date: "2025-02-28", summary: "요약내용입니다.")])
ManagementBoxView(managementList: [])
ManagementBoxView(managementList: [
SummaryManagement(id: "01", title: "과목 명1", teacher: "A", ratio: 27, homework: 3),
SummaryManagement(id: "02", title: "과목 명2", teacher: "B", ratio: 80, homework: 10),
SummaryManagement(id: "03", title: "과목 명3", teacher: "C", ratio: 13, homework: 2),
SummaryManagement(id: "04", title: "과목 명4", teacher: "D", ratio: 72, homework: 0),
])
NoticeBoxView(noticeList: [
SummaryNotice(id: "00", title: "공지사항1", date: "2025-02-11", new: true),
SummaryNotice(id: "01", title: "공지사항2", date: "2025-01-11", new: false),
SummaryNotice(id: "02", title: "공지사항3", date: "2025-01-01", new: false)
])
}
.background {
RoundedRectangle(cornerRadius: 8)
.foregroundStyle(Color(.Other.cell))
}
.padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 24))
}
}
if topViewState {
VStack(spacing: 0) {
TopView(titleName: "Name")
.transition(.move(edge: .top))
.animation(.easeInOut, value: scrollOffset)
Spacer(minLength: 1)
}
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onChange(of: scrollOffset.y) { oldValue, newValue in
if newValue > 200 && topViewState == false {
topViewState = true
} else if newValue < 20 && topViewState == true{
topViewState = false
}
}
}
}