This commit is contained in:
Daniel Arantes Loverde
2026-02-06 09:51:53 -03:00
parent 379bb35cfa
commit 92c2a67736
13 changed files with 574 additions and 138 deletions

View File

@@ -110,9 +110,14 @@ struct HomeView: View {
.onAppear {
if hasRequestedLocation == false {
hasRequestedLocation = true
locationService.requestLocation { lat, lng in
appState.address.latitude = lat
appState.address.longitude = lng
locationService.requestLocation { result in
switch result {
case .success(let coordinate):
appState.address.latitude = coordinate.0
appState.address.longitude = coordinate.1
case .failure:
appState.address.display = "Defina seu endereco"
}
}
}
}
@@ -186,14 +191,19 @@ struct HomeView: View {
.tracking(AppTypography.captionLetterSpacing)
.foregroundStyle(AppColors.brandSoft)
HStack(spacing: 6) {
Text(appState.address.display)
.font(AppTypography.heading3)
.foregroundStyle(AppColors.textInverse)
Image(systemName: "chevron.down")
.font(.caption)
.foregroundStyle(AppColors.brandSoft)
Button {
appState.activeModal = .addressPicker
} label: {
HStack(spacing: 6) {
Text(appState.address.display)
.font(AppTypography.heading3)
.foregroundStyle(AppColors.textInverse)
Image(systemName: "chevron.down")
.font(.caption)
.foregroundStyle(AppColors.brandSoft)
}
}
.buttonStyle(.plain)
}
Spacer()
@@ -216,7 +226,9 @@ struct HomeView: View {
.opacity(titleOpacity)
.offset(y: collapseProgress * -20)
SearchBar(placeholder: "Search menu, restaurant or craving", text: $searchText)
SearchBar(placeholder: "Search menu, restaurant or craving", text: $searchText) {
appState.activeModal = .filters
}
.offset(y: collapseProgress * -140)
}
.padding(.horizontal, 20)
@@ -313,6 +325,7 @@ struct CategoryChip: View {
struct SearchBar: View {
let placeholder: String
@Binding var text: String
var onFilterTap: () -> Void = {}
var body: some View {
HStack(spacing: 12) {
@@ -322,8 +335,10 @@ struct SearchBar: View {
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
Spacer()
Image(systemName: "slider.horizontal.3")
.foregroundStyle(AppColors.textMuted)
Button(action: onFilterTap) {
Image(systemName: "slider.horizontal.3")
.foregroundStyle(AppColors.textMuted)
}
}
.padding(.horizontal, 16)
.frame(height: 52)

View File

@@ -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)
}
}