Made code for example. If you make an incomplete swipe to the previous view, then in case of scrolling, the text of the editor starts to be duplicated with the title. I checked it even without @Environment
, but through isActive, which was transmitted, but still this bug. Also, with an incomplete swipe, the buttons stop working. Could someone know the complete NavigationView tutorial to avoid some bugs? I need the title not to jump and the buttons are fine.
struct View1: View {
@Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView {
ZStack {
Color.red
NavigationLink("View 2", destination: View2())
}
.navigationBarTitle("Back").navigationBarHidden(true).animation(.default)
}
}
}
struct View2: View {
@State private var texti: String = ""
@Environment(\.presentationMode) var presentationMode
var body: some View {
ZStack {
VStack {
TextEditor(text: $texti)
.padding().onReceive(texti.publisher.collect()) {
self.texti = String($0.prefix(2000))}
}
}
.navigationBarTitle("Your Title")
.navigationBarItems(trailing: HStack { Button(action:{}) {
Text("Ed").foregroundColor(Color(#colorLiteral(red: 0.3647058824, green: 0.6901960784, blue: 0.4588235294, alpha: 1)))
}; Button(action: {}) {
Text("S").foregroundColor(Color(#colorLiteral(red: 0.3647058824, green: 0.6901960784, blue: 0.4588235294, alpha: 1)))
}})
}
}