mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
added icons to all dialogs
This commit is contained in:
parent
02e2803d97
commit
a875a9c8a8
10 changed files with 45 additions and 14 deletions
|
@ -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,
|
||||||
|
@ -47,25 +49,36 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Column(
|
||||||
padding: Dimens.dialogTitlePadding,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Padding(
|
||||||
Text(
|
padding: Dimens.dialogTitlePadding,
|
||||||
|
child: Icon(widget.icon),
|
||||||
|
),
|
||||||
|
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(
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue