From 41f111f087d8f23cdba1cd9515e3889d0370d42e Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Wed, 1 Feb 2023 00:20:24 +0300 Subject: [PATCH] scroll to selected color --- .../widget_dialog_picker_primary_color.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/screens/settings/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart b/lib/screens/settings/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart index 1691b72..cab9007 100644 --- a/lib/screens/settings/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart +++ b/lib/screens/settings/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart @@ -13,6 +13,16 @@ class PrimaryColorDialogPicker extends StatefulWidget { class _PrimaryColorDialogPickerState extends State { late Color _selected = Theme.of(context).primaryColor; + late final ScrollController _scrollController = ScrollController( + initialScrollOffset: + ThemeProvider.primaryColorsList.indexOf(_selected) * (Dimens.grid48 + Dimens.grid8), + ); + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -24,13 +34,13 @@ class _PrimaryColorDialogPickerState extends State { Dimens.paddingM, ), title: Text(S.of(context).choosePrimaryColor), - contentPadding: EdgeInsets.zero, content: SizedBox( height: Dimens.grid48, width: double.maxFinite, child: ListView.separated( + controller: _scrollController, scrollDirection: Axis.horizontal, - padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingL), + padding: EdgeInsets.zero, separatorBuilder: (_, __) => const SizedBox(width: Dimens.grid8), itemCount: ThemeProvider.primaryColorsList.length, itemBuilder: (_, index) {