This commit is contained in:
2024-01-25 17:50:40 +08:00
parent 2d7d3dc836
commit 6f7f8deda1
19 changed files with 530 additions and 201 deletions

View File

@@ -11,51 +11,54 @@ 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()
NavigationView {
ZStack(alignment: .leading) {
Group {
switch selectedTab {
case .home:
HomeView()
case .explore:
MallView()
case .message:
MessageView()
case .account:
UserView()
}
}
}
// .offset(y: -64)
// .safeAreaInset(edge: .top) {
// Color.clear.frame(height: 32)
// }
// .offset(y: -64)
// .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)
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()
}
.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)
}
.statusBarHidden(false)
.navigationViewStyle(.columns)
}
}