fixed photography value picker overscroll

This commit is contained in:
Vadim 2023-02-04 23:55:09 +03:00
parent 0f78fd0e3a
commit 537e19f9c8
2 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/data/models/photography_values/photography_value.dart'; import 'package:lightmeter/data/models/photography_values/photography_value.dart';
@ -36,8 +37,19 @@ class PhotographyValuePickerDialog<T extends PhotographyValue> extends StatefulW
class _PhotographyValuePickerDialogState<T extends PhotographyValue> class _PhotographyValuePickerDialogState<T extends PhotographyValue>
extends State<PhotographyValuePickerDialog<T>> { extends State<PhotographyValuePickerDialog<T>> {
late T _selectedValue = widget.initialValue; late T _selectedValue = widget.initialValue;
late final _scrollController = late final _scrollController = ScrollController();
ScrollController(initialScrollOffset: Dimens.grid56 * widget.values.indexOf(_selectedValue));
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_scrollController.jumpTo(clampDouble(
Dimens.grid56 * widget.values.indexOf(_selectedValue),
_scrollController.position.minScrollExtent,
_scrollController.position.maxScrollExtent,
));
});
}
@override @override
void dispose() { void dispose() {

View file

@ -91,7 +91,7 @@ class _SelectableColorItemState extends State<_SelectableColorItem> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.selected) { if (widget.selected) {
Scrollable.ensureVisible(context); Scrollable.ensureVisible(context);
} }