added icons to all dialogs

This commit is contained in:
Vadim 2023-04-04 18:22:55 +03:00
parent 02e2803d97
commit a875a9c8a8
10 changed files with 45 additions and 14 deletions

View file

@ -6,6 +6,7 @@ typedef DialogPickerItemTitleBuilder<T> = Widget Function(BuildContext context,
typedef DialogPickerItemTrailingBuilder<T> = Widget? Function(T selected, T value); typedef DialogPickerItemTrailingBuilder<T> = Widget? Function(T selected, T value);
class DialogPicker<T> extends StatefulWidget { class DialogPicker<T> extends StatefulWidget {
final IconData icon;
final String title; final String title;
final String? subtitle; final String? subtitle;
final T initialValue; final T initialValue;
@ -16,6 +17,7 @@ class DialogPicker<T> extends StatefulWidget {
final ValueChanged onSelect; final ValueChanged onSelect;
const DialogPicker({ const DialogPicker({
required this.icon,
required this.title, required this.title,
this.subtitle, this.subtitle,
required this.initialValue, required this.initialValue,
@ -45,27 +47,38 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Padding( Padding(
padding: Dimens.dialogTitlePadding, padding: Dimens.dialogTitlePadding,
child: Column( child: Icon(widget.icon),
children: [ ),
Text( Padding(
padding: Dimens.dialogIconTitlePadding,
child: Text(
widget.title, widget.title,
style: Theme.of(context).textTheme.headlineSmall!, style: Theme.of(context).textTheme.headlineSmall!,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
if (widget.subtitle != null) ...[ ),
const SizedBox(height: Dimens.grid16), if (widget.subtitle != null)
Text( Padding(
padding: const EdgeInsets.fromLTRB(
Dimens.paddingL,
0,
Dimens.paddingL,
Dimens.paddingM,
),
child: Text(
widget.subtitle!, widget.subtitle!,
style: Theme.of(context).textTheme.bodyMedium!, style: Theme.of(context).textTheme.bodyMedium!,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
]
],
), ),
],
), ),
const Divider(), const Divider(),
Expanded( Expanded(

View file

@ -5,6 +5,7 @@ import 'components/dialog_picker/widget_picker_dialog.dart';
class AnimatedDialogPicker<T> extends StatelessWidget { class AnimatedDialogPicker<T> extends StatelessWidget {
final _key = GlobalKey<AnimatedDialogState>(); final _key = GlobalKey<AnimatedDialogState>();
final IconData icon;
final String title; final String title;
final String? subtitle; final String? subtitle;
final T selectedValue; final T selectedValue;
@ -15,6 +16,7 @@ class AnimatedDialogPicker<T> extends StatelessWidget {
final Widget closedChild; final Widget closedChild;
AnimatedDialogPicker({ AnimatedDialogPicker({
required this.icon,
required this.title, required this.title,
this.subtitle, this.subtitle,
required this.selectedValue, required this.selectedValue,
@ -32,6 +34,7 @@ class AnimatedDialogPicker<T> extends StatelessWidget {
key: _key, key: _key,
closedChild: closedChild, closedChild: closedChild,
openedChild: DialogPicker<T>( openedChild: DialogPicker<T>(
icon: icon,
title: title, title: title,
subtitle: subtitle, subtitle: subtitle,
initialValue: selectedValue, initialValue: selectedValue,

View file

@ -106,6 +106,7 @@ class _EquipmentProfilePicker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedDialogPicker<EquipmentProfileData>( return AnimatedDialogPicker<EquipmentProfileData>(
icon: Icons.camera,
title: S.of(context).equipmentProfile, title: S.of(context).equipmentProfile,
selectedValue: EquipmentProfile.of(context), selectedValue: EquipmentProfile.of(context),
values: EquipmentProfiles.of(context), values: EquipmentProfiles.of(context),
@ -137,6 +138,7 @@ class _FilmPicker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedDialogPicker<Film>( return AnimatedDialogPicker<Film>(
icon: Icons.camera_roll,
title: S.of(context).film, title: S.of(context).film,
selectedValue: selectedValue, selectedValue: selectedValue,
values: values, values: values,
@ -166,6 +168,7 @@ class _IsoValuePicker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedDialogPicker<IsoValue>( return AnimatedDialogPicker<IsoValue>(
icon: Icons.iso,
title: S.of(context).iso, title: S.of(context).iso,
subtitle: S.of(context).filmSpeed, subtitle: S.of(context).filmSpeed,
selectedValue: selectedValue, selectedValue: selectedValue,
@ -200,6 +203,7 @@ class _NdValuePicker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedDialogPicker<NdValue>( return AnimatedDialogPicker<NdValue>(
icon: Icons.filter_b_and_w,
title: S.of(context).nd, title: S.of(context).nd,
subtitle: S.of(context).ndFilterFactor, subtitle: S.of(context).ndFilterFactor,
selectedValue: selectedValue, selectedValue: selectedValue,

View file

@ -18,6 +18,7 @@ class LanguageListTile extends StatelessWidget {
showDialog<SupportedLocale>( showDialog<SupportedLocale>(
context: context, context: context,
builder: (_) => DialogPicker<SupportedLocale>( builder: (_) => DialogPicker<SupportedLocale>(
icon: Icons.language,
title: S.of(context).chooseLanguage, title: S.of(context).chooseLanguage,
selectedValue: context.read<SupportedLocale>(), selectedValue: context.read<SupportedLocale>(),
values: SupportedLocale.values, values: SupportedLocale.values,

View file

@ -17,7 +17,8 @@ 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: Dimens.dialogTitlePadding, icon: const Icon(Icons.settings_brightness),
titlePadding: Dimens.dialogIconTitlePadding,
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(

View file

@ -1,5 +1,6 @@
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/res/dimens.dart';
class EquipmentProfileNameDialog extends StatefulWidget { class EquipmentProfileNameDialog extends StatefulWidget {
final String initialValue; final String initialValue;
@ -22,6 +23,8 @@ class _EquipmentProfileNameDialogState extends State<EquipmentProfileNameDialog>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
icon: const Icon(Icons.edit),
titlePadding: Dimens.dialogIconTitlePadding,
title: Text(S.of(context).equipmentProfileName), title: Text(S.of(context).equipmentProfileName),
content: TextField( content: TextField(
autofocus: true, autofocus: true,

View file

@ -18,6 +18,7 @@ class StopTypeListTile extends StatelessWidget {
showDialog<StopType>( showDialog<StopType>(
context: context, context: context,
builder: (_) => DialogPicker<StopType>( builder: (_) => DialogPicker<StopType>(
icon: Icons.straighten,
title: S.of(context).showFractionalStops, title: S.of(context).showFractionalStops,
selectedValue: context.read<StopType>(), selectedValue: context.read<StopType>(),
values: StopType.values, values: StopType.values,

View file

@ -3,12 +3,14 @@ import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
class DialogPicker<T> extends StatefulWidget { class DialogPicker<T> extends StatefulWidget {
final IconData icon;
final String title; final String title;
final T selectedValue; final T selectedValue;
final List<T> values; final List<T> values;
final String Function(BuildContext context, T value) titleAdapter; final String Function(BuildContext context, T value) titleAdapter;
const DialogPicker({ const DialogPicker({
required this.icon,
required this.title, required this.title,
required this.selectedValue, required this.selectedValue,
required this.values, required this.values,
@ -26,7 +28,8 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
titlePadding: Dimens.dialogTitlePadding, icon: Icon(widget.icon),
titlePadding: Dimens.dialogIconTitlePadding,
title: Text(widget.title), title: Text(widget.title),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
content: Column( content: Column(

View file

@ -24,7 +24,8 @@ class _PrimaryColorDialogPickerState extends State<PrimaryColorDialogPicker> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
titlePadding: Dimens.dialogTitlePadding, icon: const Icon(Icons.palette),
titlePadding: Dimens.dialogIconTitlePadding,
title: Text(S.of(context).choosePrimaryColor), title: Text(S.of(context).choosePrimaryColor),
content: SizedBox( content: SizedBox(
height: Dimens.grid48, height: Dimens.grid48,

View file

@ -18,6 +18,7 @@ class ThemeTypeListTile extends StatelessWidget {
showDialog<ThemeType>( showDialog<ThemeType>(
context: context, context: context,
builder: (_) => DialogPicker<ThemeType>( builder: (_) => DialogPicker<ThemeType>(
icon: Icons.brightness_6,
title: S.of(context).chooseTheme, title: S.of(context).chooseTheme,
selectedValue: context.read<ThemeType>(), selectedValue: context.read<ThemeType>(),
values: ThemeType.values, values: ThemeType.values,