Hello, I have a sheet included in my App where the user can set a goal to achieve. The transition when the sheet disappears is performed well, as long as I don't switch the tab in my custom tab bar. As soon as I go to another tab, go back to the initial tab and try to open the sheet, it appears with a transition but disappears completely without a transition. I hope there is somebody who can help me.
The Button that opens the sheet:
The sheet:
The custom tab bar:
The Button that opens the sheet:
Code Block //Button to show DailyGoalSetting screen/ Button(action: { //Opens DailyGoalSetting up self.showGoalSetting.toggle() }) { Image("icon_editgoal").foregroundColor(ThemeManager.Theme.current.buttonColor) } .sheet(isPresented: self.$showGoalSetting, content: { /Initialiser for DailyGoalSetting/ DailyGoalSetting(dailyGoal: self.$dailyGoal, showMe: self.$showGoalSetting) })
The sheet:
Code Block NavigationView { VStack{ Form { //TextField to enter the goal //With some stylings TextField("Enter goal...", text: $textFieldManager.userInput) .multilineTextAlignment(.leading) .keyboardType(.asciiCapableNumberPad) .scaledToFit() //Snippet that clears the entered value from everything thats not a number .onReceive(Just(textFieldManager.userInput)) { newValue in let filtered = newValue.filter { "0123456789".contains($0) } if filtered != newValue { self.textFieldManager.userInput = filtered } } //Button that sets the goal Button(action: { //Sets the goal to the amount entered in TextField or if impossible to zero self.dailyGoal = Int(self.textFieldManager.userInput) ?? 0 if self.dailyGoal > 0 { //Update CoreData self.updateGoal(givenGoal: self.dailyGoal) if #available(iOS 14.0, *) { WidgetCenter.shared.reloadAllTimelines() } else { // Fallback on earlier versions } //Dismisses this Screen self.showMe.toggle() } else { self.showError01.toggle() } }) { Text("Submit") } .alert(isPresented: $showError01, content: { Alert(title: Text("Error"), message: Text("Your goal can not be to die of thirst."), dismissButton: .default(Text("I understand"))) }) } } .keyboardAdaptive() .navigationBarItems(leading: Button(action: { self.showMe.toggle() }) { Image(systemName: "chevron.left") Text("Back") }) }
The custom tab bar:
Code Block var body: some View { GeometryReader { geometry in VStack(spacing: 0) { if self.viewManager.currentView == "drinksscreen" { SyncView(selection: self.$viewManager.selection, tag: 0) { DrinksScreen() } } else if self.viewManager.currentView == "notificationsscreen" { SyncView(selection: self.$viewManager.selection, tag: 1) { NotificationsScreen() } } else if self.viewManager.currentView == "historyscreen" { SyncView(selection: self.$viewManager.selection, tag: 2) { HistoryScreen() } } else if self.viewManager.currentView == "settingsscreen" { SyncView(selection: self.$viewManager.selection, tag: 3) { SettingsScreen(selectedTheme: getFromUD()) } } Divider() CustomTabView(width: geometry.size.width, height: UITabBarController.getHeight(UITabBarController())() + geometry.safeAreaInsets.bottom) } .edgesIgnoringSafeArea(.bottom) } }