AcaMate_iOS/AcaMate/1. View/12. Main/TopView.swift
2025-02-05 17:59:49 +09:00

77 lines
2.1 KiB
Swift

//
// TopView.swift
// AcaMate
//
// Created by TAnine on 2/4/25.
//
import SwiftUI
struct TopView: View {
@State var titleName: String = ""
@State var changeLogo: Bool = false
@State var tailLogo: Bool = false
var myType: UserType = .Teacher
var body: some View {
HStack(alignment: .center, spacing: 0) {
ZStack {
TypeIcon(myType: myType)
.opacity(changeLogo ? 0 : 1)
SimpleBtnView(title: nil, image: Image(.Icon.back), font: nil, width: 40, height: 40) {
}
.opacity(changeLogo ? 1 : 0)
}
.padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 12))
Text("\(titleName)")
.foregroundStyle(Color(.Text.detail))
.font(.nps(font: .bold, size: 20))
Spacer()
SimpleBtnView(title: nil, image: Image(.Icon.face), font: nil, width: 40, height: 40)
{
}
.padding(EdgeInsets(top: 12, leading: 12, bottom: 12, trailing: 24))
.opacity(tailLogo ? 0 : 1)
}
.background {
Rectangle()
.foregroundStyle(Color(.Other.cell))
.ignoresSafeArea(edges: .top)
}
.frame(maxWidth: .infinity)
}
}
struct TypeIcon: View {
var myType: UserType
var body: some View {
if self.myType == .Student {
SimpleBtnView(title: nil, image: Image(.Icon.face), font: nil, width: 40, height: 40, isUsable: false) {
}
} else {
SimpleBtnView(title: "\(self.myType.rawValue)", image: Image(.Icon.face),
font: .nps(font: .bold, size: 24), width: 40, height: 40, isUsable: false) {
}.background {
Circle()
.strokeBorder(Color(.Second.normal) ,lineWidth: 4)
.frame(width: 40, height: 40)
}
}
}
}
#Preview {
TopView(titleName: "Name")
}