mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 16:00:41 +00:00
scroll to selected color
This commit is contained in:
parent
6c08a3d47f
commit
41f111f087
1 changed files with 12 additions and 2 deletions
|
@ -13,6 +13,16 @@ class PrimaryColorDialogPicker extends StatefulWidget {
|
|||
|
||||
class _PrimaryColorDialogPickerState extends State<PrimaryColorDialogPicker> {
|
||||
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<PrimaryColorDialogPicker> {
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue