It looks like Apple's TabView supports rearrangements automatically, but it quickly loses a rearrangement after you click on a tab.
Here's my playground code.
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var arr = ["1","2","3","4","5","6"]
var body: some View {
TabView {
ForEach(self.arr, id: \.self) { name in
Text("Tab \(name) content")
.tabItem {
Image(systemName: "\(name).square.fill")
Text(name)
}
}
}
.font(.headline)
}
}
PlaygroundPage.current.setLiveView(ContentView())
Here's the steps I go through in the gif.
- I start on tab "1"
- I go to the "more" tab and then click "edit"
- I swap tab "2" with tab "3"
- Close the rearrange screen
- Then when I click tab "2" (which is now in position 3), the app resets the tabs back to their original order!
I'm not sure if this is a SwiftUI bug or if there's a onRearrange hook I should have been listening to or what.
.onMove
should be working, as it is dynamic content, but it does not - tested on Xcode 11.2 ... it looks like feature uncompleted )) – Copious