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

View file

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

View file

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

View file

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

View file

@ -17,7 +17,8 @@ class CalibrationDialog extends StatelessWidget {
Widget build(BuildContext context) {
final bool hasLightSensor = context.read<Environment>().hasLightSensor;
return AlertDialog(
titlePadding: Dimens.dialogTitlePadding,
icon: const Icon(Icons.settings_brightness),
titlePadding: Dimens.dialogIconTitlePadding,
title: Text(S.of(context).calibration),
contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingL),
content: SingleChildScrollView(

View file

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

View file

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

View file

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

View file

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

View file

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