Improve default scrollbar

This commit is contained in:
Hillel Coren 2022-12-06 13:46:26 +02:00
parent 8515650055
commit c5dee0d4f2
14 changed files with 33 additions and 13 deletions

View File

@ -29,6 +29,7 @@ class AppForm extends StatelessWidget {
key: formKey, key: formKey,
child: child ?? child: child ??
ScrollableListView( ScrollableListView(
primary: true,
children: children, children: children,
), ),
), ),

View File

@ -69,6 +69,7 @@ class ScrollableListViewBuilder extends StatefulWidget {
this.separatorBuilder, this.separatorBuilder,
this.scrollController, this.scrollController,
this.padding, this.padding,
this.primary = false,
}) : super(key: key); }) : super(key: key);
final IndexedWidgetBuilder itemBuilder; final IndexedWidgetBuilder itemBuilder;
@ -76,6 +77,7 @@ class ScrollableListViewBuilder extends StatefulWidget {
final int itemCount; final int itemCount;
final ScrollController scrollController; final ScrollController scrollController;
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
final bool primary;
@override @override
_ScrollableListViewBuilderState createState() => _ScrollableListViewBuilderState createState() =>
@ -101,18 +103,24 @@ class _ScrollableListViewBuilderState extends State<ScrollableListViewBuilder> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return widget.separatorBuilder != null return widget.separatorBuilder != null
? ListView.separated( ? ListView.separated(
primary: widget.primary,
separatorBuilder: widget.separatorBuilder, separatorBuilder: widget.separatorBuilder,
padding: widget.padding, padding: widget.padding,
itemBuilder: widget.itemBuilder, itemBuilder: widget.itemBuilder,
itemCount: widget.itemCount, itemCount: widget.itemCount,
controller: widget.scrollController ?? _scrollController, controller: widget.primary
? null
: widget.scrollController ?? _scrollController,
shrinkWrap: true, shrinkWrap: true,
) )
: ListView.builder( : ListView.builder(
primary: widget.primary,
padding: widget.padding, padding: widget.padding,
itemBuilder: widget.itemBuilder, itemBuilder: widget.itemBuilder,
itemCount: widget.itemCount, itemCount: widget.itemCount,
controller: widget.scrollController ?? _scrollController, controller: widget.primary
? null
: widget.scrollController ?? _scrollController,
shrinkWrap: true, shrinkWrap: true,
); );
} }

View File

@ -64,14 +64,11 @@ class _EntityListState extends State<EntityList> {
EntityDataTableSource dataTableSource; EntityDataTableSource dataTableSource;
int _firstRowIndex = 0; int _firstRowIndex = 0;
ScrollController _controller;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_controller = ScrollController();
final entityType = widget.entityType; final entityType = widget.entityType;
final state = widget.state; final state = widget.state;
final entityList = widget.entityList; final entityList = widget.entityList;
@ -113,12 +110,6 @@ class _EntityListState extends State<EntityList> {
dataTableSource.notifyListeners(); dataTableSource.notifyListeners();
} }
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
@ -238,7 +229,7 @@ class _EntityListState extends State<EntityList> {
), ),
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
controller: _controller, primary: true,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16), padding: const EdgeInsets.symmetric(vertical: 16),
child: AppPaginatedDataTable( child: AppPaginatedDataTable(

View File

@ -445,6 +445,7 @@ class DashboardPanels extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(top: kTopBottomBarHeight), padding: const EdgeInsets.only(top: kTopBottomBarHeight),
child: ScrollableListViewBuilder( child: ScrollableListViewBuilder(
primary: true,
scrollController: scrollController, scrollController: scrollController,
itemCount: sections.length + 1, itemCount: sections.length + 1,
itemBuilder: (context, index) { itemBuilder: (context, index) {

View File

@ -436,6 +436,7 @@ class ReportsScreen extends StatelessWidget {
), ),
) )
: ScrollableListView( : ScrollableListView(
primary: true,
key: ValueKey( key: ValueKey(
'${viewModel.state.company.id}_${viewModel.state.isSaving}_${reportsState.report}_${reportsState.group}'), '${viewModel.state.company.id}_${viewModel.state.isSaving}_${reportsState.report}_${reportsState.group}'),
children: <Widget>[ children: <Widget>[

View File

@ -188,6 +188,7 @@ class _AccountManagementState extends State<AccountManagement>
children: <Widget>[ children: <Widget>[
_AccountOverview(viewModel: viewModel), _AccountOverview(viewModel: viewModel),
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
children: kModules.keys.map((module) { children: kModules.keys.map((module) {
@ -210,7 +211,7 @@ class _AccountManagementState extends State<AccountManagement>
}).toList()), }).toList()),
], ],
), ),
ScrollableListView(children: [ ScrollableListView(primary: true, children: [
FormCard( FormCard(
children: [ children: [
LearnMoreUrl( LearnMoreUrl(
@ -225,6 +226,7 @@ class _AccountManagementState extends State<AccountManagement>
) )
]), ]),
ScrollableListView( ScrollableListView(
primary: true,
children: [ children: [
FormCard( FormCard(
children: [ children: [
@ -315,6 +317,7 @@ class _AccountOverview extends StatelessWidget {
} }
return ScrollableListView( return ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
AppHeader( AppHeader(
label: localization.plan, label: localization.plan,

View File

@ -261,6 +261,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
tabController: _controller, tabController: _controller,
children: <Widget>[ children: <Widget>[
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
children: <Widget>[ children: <Widget>[
@ -385,6 +386,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
), ),
AutofillGroup( AutofillGroup(
child: ScrollableListView( child: ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
isLast: true, isLast: true,
@ -442,6 +444,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
child: ScrollableListView( child: ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
Builder( Builder(
builder: (context) { builder: (context) {
@ -496,6 +499,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
), ),
), ),
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,

View File

@ -109,6 +109,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
focusNode: _focusNode, focusNode: _focusNode,
children: [ children: [
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
children: <Widget>[ children: <Widget>[
@ -364,6 +365,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
], ],
), ),
ScrollableListView( ScrollableListView(
primary: true,
children: [ children: [
FormCard(children: [ FormCard(children: [
SwitchListTile( SwitchListTile(

View File

@ -85,6 +85,7 @@ class _ImportExportState extends State<ImportExport> {
formKey: _formKey, formKey: _formKey,
focusNode: _focusNode, focusNode: _focusNode,
child: ScrollableListView( child: ScrollableListView(
primary: true,
children: [ children: [
if (_response == null) if (_response == null)
_FileImport( _FileImport(

View File

@ -153,6 +153,7 @@ class _InvoiceDesignState extends State<InvoiceDesign>
focusNode: _focusNode, focusNode: _focusNode,
children: <Widget>[ children: <Widget>[
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: const EdgeInsets.only(right: 16, bottom: 10, left: 16), padding: const EdgeInsets.only(right: 16, bottom: 10, left: 16),

View File

@ -137,6 +137,7 @@ class _LocalizationSettingsState extends State<LocalizationSettings>
tabController: _controller, tabController: _controller,
children: <Widget>[ children: <Widget>[
ScrollableListView( ScrollableListView(
primary: true,
children: [ children: [
FormCard( FormCard(
children: <Widget>[ children: <Widget>[
@ -266,6 +267,7 @@ class _LocalizationSettingsState extends State<LocalizationSettings>
], ],
), ),
ScrollableListView( ScrollableListView(
primary: true,
children: [ children: [
FormCard( FormCard(
isLast: true, isLast: true,

View File

@ -343,6 +343,7 @@ class _TemplatesAndRemindersState extends State<TemplatesAndReminders>
focusNode: _focusNode, focusNode: _focusNode,
children: <Widget>[ children: <Widget>[
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard(children: <Widget>[ FormCard(children: <Widget>[
AppDropdownButton<EmailTemplate>( AppDropdownButton<EmailTemplate>(

View File

@ -308,6 +308,7 @@ class _UserDetailsState extends State<UserDetails>
tabController: _controller, tabController: _controller,
children: <Widget>[ children: <Widget>[
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard(children: <Widget>[ FormCard(children: <Widget>[
DecoratedFormField( DecoratedFormField(
@ -482,6 +483,7 @@ class _UserDetailsState extends State<UserDetails>
], ],
), ),
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
NotificationSettings( NotificationSettings(
user: user, user: user,

View File

@ -92,6 +92,7 @@ class _WorkflowSettingsState extends State<WorkflowSettings>
focusNode: _focusNode, focusNode: _focusNode,
children: <Widget>[ children: <Widget>[
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard(children: <Widget>[ FormCard(children: <Widget>[
BoolDropdownButton( BoolDropdownButton(
@ -155,6 +156,7 @@ class _WorkflowSettingsState extends State<WorkflowSettings>
], ],
), ),
ScrollableListView( ScrollableListView(
primary: true,
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
isLast: true, isLast: true,