tabbar
This commit is contained in:
@@ -7,25 +7,66 @@ struct MainTabView: View {
|
||||
@Binding var appState: AppState
|
||||
|
||||
var body: some View {
|
||||
TabView(selection: $selectedTab) {
|
||||
NavigationStack {
|
||||
HomeView(appState: $appState)
|
||||
ZStack(alignment: .bottom) {
|
||||
Group {
|
||||
switch selectedTab {
|
||||
case .home:
|
||||
NavigationStack {
|
||||
HomeView(appState: $appState)
|
||||
}
|
||||
case .cart:
|
||||
NavigationStack {
|
||||
CartView()
|
||||
}
|
||||
case .profile:
|
||||
NavigationStack {
|
||||
ProfileView(root: $root, selectedTab: $selectedTab, tokenStore: tokenStore, appState: $appState)
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabItem { Label("Home", systemImage: "house.fill") }
|
||||
.tag(MainTab.home)
|
||||
|
||||
NavigationStack {
|
||||
CartView()
|
||||
}
|
||||
.tabItem { Label("Carrinho", systemImage: "cart.fill") }
|
||||
.tag(MainTab.cart)
|
||||
|
||||
NavigationStack {
|
||||
ProfileView(root: $root, selectedTab: $selectedTab, tokenStore: tokenStore, appState: $appState)
|
||||
}
|
||||
.tabItem { Label("Perfil", systemImage: "person.fill") }
|
||||
.tag(MainTab.profile)
|
||||
customTabBar
|
||||
}
|
||||
.tint(AppColors.primary)
|
||||
}
|
||||
|
||||
private var customTabBar: some View {
|
||||
HStack(spacing: 12) {
|
||||
tabBarButton(tab: .home, title: "Home", icon: "house.fill")
|
||||
tabBarButton(tab: .cart, title: "Carrinho", icon: "cart.fill")
|
||||
tabBarButton(tab: .profile, title: "Perfil", icon: "person.fill")
|
||||
}
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 10)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 30, style: .continuous)
|
||||
.fill(AppColors.surface.opacity(0.95))
|
||||
)
|
||||
.padding(.horizontal, 18)
|
||||
.padding(.bottom, 10)
|
||||
.shadow(color: AppShadow.soft.color, radius: AppShadow.soft.radius, y: AppShadow.soft.y)
|
||||
}
|
||||
|
||||
private func tabBarButton(tab: MainTab, title: String, icon: String) -> some View {
|
||||
let isActive = selectedTab == tab
|
||||
return Button {
|
||||
selectedTab = tab
|
||||
} label: {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: icon)
|
||||
.font(.system(size: 18, weight: .semibold))
|
||||
if isActive {
|
||||
Text(title)
|
||||
.font(AppTypography.heading3)
|
||||
}
|
||||
}
|
||||
.foregroundStyle(isActive ? AppColors.primary : AppColors.textPrimary)
|
||||
.padding(.horizontal, 18)
|
||||
.padding(.vertical, 10)
|
||||
.background(
|
||||
Capsule()
|
||||
.fill(isActive ? AppColors.brandSoft : Color.clear)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user