Login flow fixed
This commit is contained in:
@@ -4,9 +4,12 @@ import UIKit
|
||||
#endif
|
||||
|
||||
struct HomeView: View {
|
||||
@Binding var appState: AppState
|
||||
@State var searchText = ""
|
||||
@State var selectedCategory = "Stores"
|
||||
@State var scrollOffset: CGFloat = 0
|
||||
@State var hasRequestedLocation = false
|
||||
let locationService = LocationService()
|
||||
|
||||
private let categories: [CategoryModel] = [
|
||||
.init(title: "Stores", systemIcon: "storefront"),
|
||||
@@ -104,6 +107,15 @@ struct HomeView: View {
|
||||
.background(AppColors.backgroundLight)
|
||||
.ignoresSafeArea(edges: .top)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||
.onAppear {
|
||||
if hasRequestedLocation == false {
|
||||
hasRequestedLocation = true
|
||||
locationService.requestLocation { lat, lng in
|
||||
appState.address.latitude = lat
|
||||
appState.address.longitude = lng
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var contentStack: some View {
|
||||
@@ -175,7 +187,7 @@ struct HomeView: View {
|
||||
.foregroundStyle(AppColors.brandSoft)
|
||||
|
||||
HStack(spacing: 6) {
|
||||
Text("Canggu, Kuta Utara, Bali")
|
||||
Text(appState.address.display)
|
||||
.font(AppTypography.heading3)
|
||||
.foregroundStyle(AppColors.textInverse)
|
||||
Image(systemName: "chevron.down")
|
||||
|
||||
@@ -4,11 +4,12 @@ struct MainTabView: View {
|
||||
@Binding var selectedTab: MainTab
|
||||
@Binding var root: RootFlow
|
||||
let tokenStore: TokenStore
|
||||
@Binding var appState: AppState
|
||||
|
||||
var body: some View {
|
||||
TabView(selection: $selectedTab) {
|
||||
NavigationStack {
|
||||
HomeView()
|
||||
HomeView(appState: $appState)
|
||||
}
|
||||
.tabItem { Label("Home", systemImage: "house.fill") }
|
||||
.tag(MainTab.home)
|
||||
@@ -20,7 +21,7 @@ struct MainTabView: View {
|
||||
.tag(MainTab.cart)
|
||||
|
||||
NavigationStack {
|
||||
ProfileView(root: $root, selectedTab: $selectedTab, tokenStore: tokenStore)
|
||||
ProfileView(root: $root, selectedTab: $selectedTab, tokenStore: tokenStore, appState: $appState)
|
||||
}
|
||||
.tabItem { Label("Perfil", systemImage: "person.fill") }
|
||||
.tag(MainTab.profile)
|
||||
|
||||
@@ -4,6 +4,7 @@ struct ProfileView: View {
|
||||
@Binding var root: RootFlow
|
||||
@Binding var selectedTab: MainTab
|
||||
let tokenStore: TokenStore
|
||||
@Binding var appState: AppState
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 20) {
|
||||
@@ -29,6 +30,8 @@ struct ProfileView: View {
|
||||
|
||||
SecondaryButton(title: "Sair") {
|
||||
tokenStore.clear()
|
||||
appState.session.isAuthenticated = false
|
||||
appState.session.jwt = nil
|
||||
root = .auth
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
@@ -49,11 +52,11 @@ struct ProfileView: View {
|
||||
.foregroundStyle(AppColors.textInverse)
|
||||
)
|
||||
|
||||
Text("Daniel Loverde")
|
||||
Text(appState.profile.name.isEmpty ? "Daniel Loverde" : appState.profile.name)
|
||||
.font(AppTypography.heading2)
|
||||
.foregroundStyle(AppColors.textPrimary)
|
||||
|
||||
Text("daniel@pedifoods.com.br")
|
||||
Text(appState.profile.email.isEmpty ? "daniel@pedifoods.com.br" : appState.profile.email)
|
||||
.font(.caption)
|
||||
.foregroundStyle(AppColors.secondary)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user