UIKitTabView Gist This gist integrates UIKit tab view to SwiftUI so that navigation stacks don't get reset when tabs are switched and double tapping on a tab reverts to the root view within a tab.
It doesn't support double tapping on a tab to scroll to the top, like in IG / FB / Twitter.
Tap tab bar to scroll to top of UITableViewController I found a couple of solutions in Swift, one example is above. But I wasn't able to get it to work for SwiftUI, I'm guessing there's a syntax difference.
I'm testing with the following (added List to the original example in the Gist)
struct ExampleView: View {
@State var text: String = ""
var body: some View {
UIKitTabView([
UIKitTabView.Tab(view: NavView(), title: "ImTab1", image: "heart"),
UIKitTabView.Tab(view: Text("Second View"), title: "ImTab2", image: "person")
])
}
}
struct NavView: View {
@State var yOffset: CGFloat = 0
var body: some View {
NavigationView {
ScrollView {
ForEach(0..<100) { i in
Text("Hello \(i)")
}
NavigationLink(destination: Text("This page stays when you switch back and forth between tabs (as expected on iOS)")) {
Text("Go to detail")
}
}
}
}
}