Having greater than 5 tabs in a TabView provides a Extra tab, which comprises the tabs that would not be match on the tab bar. In UIKit, UITabBarControllers even have this performance and moreover have a built-in edit button as the precise nav bar merchandise, which might permit the person to vary order. However it seems to be like SwiftUI’s TabView doesn’t have this. How do I allow it?
Here is some primary code to work with.
struct TabBarView: View {
@State var tabs = Tabs.allCases
var physique: some View {
TabView {
ForEach(tabs) { tab in
NavigationView {
tab.physique.navigationTitle(tab.rawValue)
}.tabItem {
Label(tab.rawValue, systemImage: tab.systemImage)
}
}
}
}
}
For reference, that is the Tabs enum I am working with.
enum Tabs: String, Identifiable, CaseIterable {
case songs = "Songs"
case albums = "Albums"
case artists = "Artists"
case playlists = "Playlists"
case genres = "Genres"
case compilations = "Compilations"
case composers = "Composers"
var systemImage: String {
swap self {
case .songs: return "music.notice"
case .albums: return "sq..stack"
case .artists: return "music.mic"
case .playlists: return "music.notice.listing"
case .genres: return "guitars"
case .compilations: return "individual.2.crop.sq..stack"
case .composers: return "music.quarternote.3"
}
}
@ViewBuilder var physique: some View {
swap self {
case .songs: SongListView()
case .albums: Textual content("Unimplemented")
case .artists: Textual content("Unimplemented")
case .playlists: PlaylistsView()
case .genres: Textual content("Unimplemented")
case .compilations: Textual content("Unimplemented")
case .composers: Textual content("Unimplemented")
}
}
var id: String { rawValue }
}
I’ve tried including .moveDisabled(false)
and having the TabView reference the tabs as a binding. Undecided what the supposed use for both of these are within the context of a TabView.
struct TabBarView: View {
@State var tabs = Tabs.allCases
var physique: some View {
TabView(choice: $tabs) {
ForEach(tabs) { tab in
NavigationView {
tab.physique.navigationTitle(tab.rawValue)
}.tabItem {
Label(tab.rawValue, systemImage: tab.systemImage)
}.moveDisabled(false)
}
} // .moveDisabled(false)
}
}
What I need to see (what I see in UIKit by default)
I attempted a bunch of Googling and could not discover anybody speaking about it. And I swear the Edit button was there after I did it a yr or two in the past.
How do I allow the Edit button on SwiftUI TabView’s Extra menu?