SlidingTabView
SlidingTabView copied to clipboard
Improve usability by using content closures
This pull request aims to use a more SwiftUI-like approach to content being displayed. With the help of content closures there is no need to update the content manually inside the hosting view.
To express the changes in code, this is how the usability is improved:
Before:
VStack(alignment: .leading) {
SlidingTabView(
selection: self.$selectedTabIndex,
tabs: ["First", "Second"]
),
(selectedTabIndex == 0 ? Text("First View") : Text("Second View")).padding()
Spacer()
}
After:
SlidingTabView(
selection: $selectedTab,
tabs: SlidingTab(title: "Hello") {
Text("Hello")
},
SlidingTab(title: "World!") {
Text("World!")
}
)
Note: Because I had problems debugging the code I also edited the Package.swift, to resolve the errors. This ensures a required platform of iOS 13 or above. The README was also updated.