This commit is contained in:
2024-01-22 18:13:01 +08:00
parent b4f90a9019
commit 8c2daac591
23 changed files with 605 additions and 55 deletions

View File

@@ -0,0 +1,65 @@
//
// TabBarView.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct TabBarView: View {
@AppStorage("selectedTab") var selectedTab : Tab = .home
var body: some View {
ZStack(alignment: .leading) {
Group {
switch selectedTab {
case .home:
HomeView()
case .explore:
MallView()
case .message:
MessageView()
case .account:
UserView()
}
}
// .offset(y: -44)
// .safeAreaInset(edge: .top) {
// Color.clear.frame(height: 32)
// }
HStack {
ForEach(tabItems) { item in
Button(action: {
selectedTab = item.tab
}, label: {
VStack (spacing: 6) {
Image(systemName: item.icon).resizable().frame(width: 18, height: 18)
Text(item.text)
.font(.caption)
.fontWeight(.regular)
.multilineTextAlignment(.center)
.lineLimit(1)
}
.frame(maxWidth: .infinity)
})
.foregroundColor(selectedTab == item.tab ? Color("MainText") : Color.secondary)
.shadow(color: (selectedTab == item.tab ? Color.orange: Color.blue), radius: 15)
}
}
.padding(.top, 12.0)
.padding(.bottom, 32)
.background(Color("TabBarColor"))
.frame(maxHeight: .infinity, alignment: .bottom)
.shadow(color: Color.gray.opacity(0.5), radius: 6, x: 0, y: 6)
.ignoresSafeArea()
}
.statusBarHidden(false)
}
}
#Preview {
TabBarView()
}