First of all, this view was inspired by the DoorDash app's Scrollview, while user scroll through certain content. The header's indicator will change to corresponding section. Specially thanks to Ali Pourhadi, who gave me the idea by using the @resultBuilder in order to create this elegant approach.
AnchorScrollView is consist by the AnchorScrollView and the ScrollViewContent which is the pure SwiftUI view. With AnchorScrollView it can simply create the ScrollView with the auto-selected header for better user experience.
- Make the tab bar ability to customize
- Using the View's extension to cleanup the each section(content)'s modifier in ScrollViewContainerBuilder
- Finish remaining AnchorScrollView's initializer in order to support up to 10 contents.
- Check the accessibility
- Write the blogger for this view's inspiration and step to step tuturial
Usage
struct ExampleView: View {
@State private var isRedacted = true
var body: some View {
VStack {
AnchorScrollView {
// Put your own view with the desired header title
ScrollViewContent(title: "|Breakfast|") {
BreakfastItemList()
}
ScrollViewContent(title: "|Fast Food|") {
FastFoodItemList()
}
ScrollViewContent(title: "|Cheezy-Up! Pizza|") {
PizzaItemList()
}
ScrollViewContent(title: "|Waterloo Housemade Breakfast|") {
BreakfastItemList()
}
}
}
}
}This project was inspired by following project and people
- DoorDash
- Ali Pourhadi
