So I built an app where you can add your personal expenses and it works fine but I added a loginView with faceID and when you login with that, it hides the second view’s add and edit button, besides the search bar where you can filter the expenses
Here’s the code that worked before i added the loginView
struct MainView: View {
@StateObject var PEviewModel = PEViewModel()
var body: some View {
// NavigationStack {
TabView {
PersonalExpensesView()
.environmentObject(PEviewModel)
.tabItem {
Label("Personal expenses list", systemImage: "dollarsign.circle")
}
// another view
.tabItem {
Label("Graph", systemImage: "chart.bar.fill")
}
}
}
//.navigationBarBackButtonHidden()
}
}
The MainView contains the two views you can navigate in. I added that navigationStack
and the navigationBarBackButton()
just to delete the back bar button so I could try if it worked (it didn’t). PersonalExpensesView has the following (and it worked before the logInUpdate)
var body: some View {
NavigationStack {
VStack {
// all the listing of personal expenses and stuff
.navigationTitle("Personal Expenses")
.navigationBarBackButtonHidden()
.toolbar {
ToolbarItem(placement: .navigation) {
EditButton()
}
ToolbarItem(placement: .navigationBarTrailing) {
Button {
showingSheet() = true
} label: {
Label("Add Book", systemImage: "plus")
}
}
}
}
.searchable(text: $textFilter)
.sheet(isPresented: $showingSheet) {
NuevoGastoView()
.environmentObject(PEviewModel)
}
}
}
}
And here’s the code I added later (the logIn code) :
var body: some View {
NavigationStack {
VStack {
Button() {
authenticate()
} label: {
Label("Usar Face ID", systemImage: "faceid")
}
.customButton()
.navigationDestination(isPresented: $unlocked){// authenticate() sets unlocked true
MainView()
}
}
}
So the correct UI (without using login) is the following
correct
And with login: bugged
I tried using a NavigationStack as I showed in the MainView()