alphabet_scroll_view
alphabet_scroll_view copied to clipboard
Redesign and simplify the API to mimic official ListView.builder
- [ ] Get rid of item extent
- [ ] AlphabetScrollView should have a controller allowing to add listener and an api to scroll to letter
- [ ] overlay widget should be replaced with a overlay builder
- [ ] Trigger haptic feedback when the selected letter changes.
Current API
AlphabetScrollView(
list: list.map((e) => AlphaModel(e)).toList(),
// isAlphabetsFiltered: false,
alignment: LetterAlignment.right,
itemExtent: 50,
unselectedTextStyle: TextStyle(),
selectedTextStyle: TextStyle(),
overlayWidget: (String value){
return YourWidget();
},
itemBuilder: (_, k, id) {
return ListWidget(),
);
},
)
Proposal
AlphabetScrollView(
list: list.map((e) => AlphaModel(e)).toList(),
alignment: LetterAlignment.right,
unselectedTextStyle: TextStyle(),
selectedTextStyle: TextStyle(),
overlayBuilder: (BuildContext context, String selectedLetter){
return Widget(selectedLetter);
},
itemBuilder: (_, k, id) {
return ListWidget();
},
);
Sanitary Tests
- [X] Drag/Tap the alphabet should focus an alphabet
- [ ] AlphabetList should avoid letters for which there is no List Item
- [ ] Alphabet List can be aligned on the left/right
- [ ] Tap/Drag animates smoothly to the first element in the List (of selected letters)
Proposed Solution
- [ ] Get rid of item extent We should calculate and maintain the offset of each item everytime the widget updates (expensive)
It would also be great if it is possible to set scroll-physics - like for normal ListView e.g.
physics: const ClampingScrollPhysics(
parent: AlwaysScrollableScrollPhysics(),
),
Here are some questions when answered would help getting this issue resolved faster.
- When the widget renders it should have the offset stored in a map for each alphabet so as to quickly jump to the start of the letter. How do we handle lazy loading or the entire should always be in memory?
- Does this widget take unsorted list or should the widget handle it?
- If the list submitted to widget is an object what field should we consider for sorting.
On phone right now will make this detailed soon