dialog cleanup

This commit is contained in:
Vadim 2023-02-04 23:30:42 +03:00
parent b5ebc09d68
commit 0f78fd0e3a
6 changed files with 58 additions and 97 deletions

View file

@ -195,6 +195,11 @@ class _ThemeDataProvider extends StatelessWidget {
surfaceTintColor: scheme.surfaceTint, surfaceTintColor: scheme.surfaceTint,
elevation: 6, elevation: 6,
), ),
dividerColor: scheme.outlineVariant,
dividerTheme: DividerThemeData(
color: scheme.outlineVariant,
space: 0,
),
listTileTheme: ListTileThemeData( listTileTheme: ListTileThemeData(
style: ListTileStyle.list, style: ListTileStyle.list,
iconColor: scheme.onSurface, iconColor: scheme.onSurface,

View file

@ -37,5 +37,17 @@ class Dimens {
// Dialog // Dialog
// Taken from `Dialog` documentation // Taken from `Dialog` documentation
static const EdgeInsets dialogTitlePadding = EdgeInsets.fromLTRB(
paddingL,
paddingL,
paddingL,
paddingM,
);
static const EdgeInsets dialogActionsPadding = EdgeInsets.fromLTRB(
paddingL,
paddingM,
paddingL,
paddingL,
);
static const EdgeInsets dialogMargin = EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0); static const EdgeInsets dialogMargin = EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0);
} }

View file

@ -36,15 +36,8 @@ 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;
final _scrollController = ScrollController(); late final _scrollController =
ScrollController(initialScrollOffset: Dimens.grid56 * widget.values.indexOf(_selectedValue));
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_scrollController.jumpTo(Dimens.grid56 * widget.values.indexOf(_selectedValue));
});
}
@override @override
void dispose() { void dispose() {
@ -56,16 +49,9 @@ class _PhotographyValuePickerDialogState<T extends PhotographyValue>
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB( padding: Dimens.dialogTitlePadding,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingM,
),
child: Column( child: Column(
children: [ children: [
Text( Text(
@ -80,12 +66,7 @@ class _PhotographyValuePickerDialogState<T extends PhotographyValue>
], ],
), ),
), ),
Divider( const Divider(),
color: Theme.of(context).colorScheme.onSurface,
height: 0,
),
],
),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
controller: _scrollController, controller: _scrollController,
@ -114,14 +95,9 @@ class _PhotographyValuePickerDialogState<T extends PhotographyValue>
), ),
), ),
), ),
Column( const Divider(),
children: [
Divider(
color: Theme.of(context).colorScheme.onSurface,
height: 0,
),
Padding( Padding(
padding: const EdgeInsets.all(Dimens.paddingL), padding: Dimens.dialogActionsPadding,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
@ -140,8 +116,6 @@ class _PhotographyValuePickerDialogState<T extends PhotographyValue>
), ),
), ),
], ],
),
],
); );
} }
} }

View file

@ -3,11 +3,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/environment.dart'; import 'package:lightmeter/environment.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/settings/components/calibration/components/calibration_dialog/event_dialog_calibration.dart';
import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart'; import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart';
import 'package:lightmeter/utils/to_string_signed.dart'; import 'package:lightmeter/utils/to_string_signed.dart';
import 'bloc_dialog_calibration.dart'; import 'bloc_dialog_calibration.dart';
import 'event_dialog_calibration.dart';
import 'state_dialog_calibration.dart'; import 'state_dialog_calibration.dart';
class CalibrationDialog extends StatelessWidget { class CalibrationDialog extends StatelessWidget {
@ -17,12 +17,7 @@ class CalibrationDialog extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool hasLightSensor = context.read<Environment>().hasLightSensor; final bool hasLightSensor = context.read<Environment>().hasLightSensor;
return AlertDialog( return AlertDialog(
titlePadding: const EdgeInsets.fromLTRB( titlePadding: Dimens.dialogTitlePadding,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingM,
),
title: Text(S.of(context).calibration), title: Text(S.of(context).calibration),
contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingL), contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingL),
content: SingleChildScrollView( content: SingleChildScrollView(
@ -67,12 +62,7 @@ class CalibrationDialog extends StatelessWidget {
], ],
), ),
), ),
actionsPadding: const EdgeInsets.fromLTRB( actionsPadding: Dimens.dialogActionsPadding,
Dimens.paddingL,
Dimens.paddingM,
Dimens.paddingL,
Dimens.paddingL,
),
actions: [ actions: [
TextButton( TextButton(
onPressed: Navigator.of(context).pop, onPressed: Navigator.of(context).pop,

View file

@ -24,12 +24,7 @@ class _PrimaryColorDialogPickerState extends State<PrimaryColorDialogPicker> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
titlePadding: const EdgeInsets.fromLTRB( titlePadding: Dimens.dialogTitlePadding,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingM,
),
title: Text(S.of(context).choosePrimaryColor), title: Text(S.of(context).choosePrimaryColor),
content: SizedBox( content: SizedBox(
height: Dimens.grid48, height: Dimens.grid48,
@ -60,12 +55,7 @@ class _PrimaryColorDialogPickerState extends State<PrimaryColorDialogPicker> {
), ),
), ),
), ),
actionsPadding: const EdgeInsets.fromLTRB( actionsPadding: Dimens.dialogActionsPadding,
Dimens.paddingL,
Dimens.paddingM,
Dimens.paddingL,
Dimens.paddingL,
),
actions: [ actions: [
TextButton( TextButton(
onPressed: Navigator.of(context).pop, onPressed: Navigator.of(context).pop,

View file

@ -26,12 +26,7 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
titlePadding: const EdgeInsets.fromLTRB( titlePadding: Dimens.dialogTitlePadding,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingL,
Dimens.paddingM,
),
title: Text(widget.title), title: Text(widget.title),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
content: Column( content: Column(
@ -53,12 +48,7 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
) )
.toList(), .toList(),
), ),
actionsPadding: const EdgeInsets.fromLTRB( actionsPadding: Dimens.dialogActionsPadding,
Dimens.paddingL,
Dimens.paddingM,
Dimens.paddingL,
Dimens.paddingL,
),
actions: [ actions: [
TextButton( TextButton(
onPressed: Navigator.of(context).pop, onPressed: Navigator.of(context).pop,