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,
child: child ??
ScrollableListView(
primary: true,
children: children,
),
),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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