diff --git a/lib/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula.dart b/lib/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula_film_edit.dart similarity index 85% rename from lib/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula.dart rename to lib/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula_film_edit.dart index 3b16739..a06dfed 100644 --- a/lib/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula.dart +++ b/lib/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula_film_edit.dart @@ -4,21 +4,21 @@ import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/shared/text_field/widget_text_field.dart'; -class ExponentialFormulaInput extends StatefulWidget { +class FilmEditExponentialFormulaInput extends StatefulWidget { final double? value; final ValueChanged onChanged; - const ExponentialFormulaInput({ + const FilmEditExponentialFormulaInput({ super.key, required this.value, required this.onChanged, }); @override - State createState() => _ExponentialFormulaInputState(); + State createState() => _FilmEditExponentialFormulaInputState(); } -class _ExponentialFormulaInputState extends State { +class _FilmEditExponentialFormulaInputState extends State { TextStyle get style => Theme.of(context).textTheme.bodyMedium!.copyWith(color: Theme.of(context).listTileTheme.textColor); diff --git a/lib/screens/film_edit/components/iso_picker/widget_picker_iso_film_edit.dart b/lib/screens/film_edit/components/iso_picker/widget_picker_iso_film_edit.dart new file mode 100644 index 0000000..9a37c6e --- /dev/null +++ b/lib/screens/film_edit/components/iso_picker/widget_picker_iso_film_edit.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart'; +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; + +class FilmEditIsoPicker extends StatelessWidget { + final IsoValue selected; + final ValueChanged onChanged; + + const FilmEditIsoPicker({ + required this.selected, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: const Icon(Icons.iso), + title: Text(S.of(context).iso), + trailing: Text(selected.value.toString()), + onTap: () { + showDialog( + context: context, + builder: (_) => Dialog( + child: DialogPicker( + icon: Icons.iso, + title: S.of(context).iso, + subtitle: S.of(context).filmSpeed, + values: IsoValue.values, + initialValue: selected, + itemTitleBuilder: (_, value) => Text(value.value.toString()), + onSelect: (value) { + onChanged(value); + Navigator.of(context).pop(); + }, + onCancel: () { + Navigator.of(context).pop(); + }, + ), + ), + ); + }, + ); + } +} diff --git a/lib/screens/film_edit/components/name_field/widget_field_name_film_edit.dart b/lib/screens/film_edit/components/name_field/widget_field_name_film_edit.dart new file mode 100644 index 0000000..d15c818 --- /dev/null +++ b/lib/screens/film_edit/components/name_field/widget_field_name_film_edit.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; +import 'package:lightmeter/screens/shared/text_field/widget_text_field.dart'; + +class FilmEditNameField extends StatelessWidget { + final String name; + final ValueChanged onChanged; + + const FilmEditNameField({ + required this.name, + required this.onChanged, + super.key, + }); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only( + left: Dimens.paddingM, + top: Dimens.paddingS / 2, + right: Dimens.paddingL, + bottom: Dimens.paddingS / 2, + ), + child: LightmeterTextField( + initialValue: name, + maxLength: 48, + hintText: S.of(context).name, + onChanged: onChanged, + style: Theme.of(context).listTileTheme.titleTextStyle, + leading: const Icon(Icons.edit_outlined), + ), + ); + } +} diff --git a/lib/screens/film_edit/screen_film_edit.dart b/lib/screens/film_edit/screen_film_edit.dart index 8666297..c8b7e24 100644 --- a/lib/screens/film_edit/screen_film_edit.dart +++ b/lib/screens/film_edit/screen_film_edit.dart @@ -3,13 +3,12 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/film_edit/bloc_film_edit.dart'; -import 'package:lightmeter/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula.dart'; +import 'package:lightmeter/screens/film_edit/components/exponential_formula_input/widget_input_exponential_formula_film_edit.dart'; +import 'package:lightmeter/screens/film_edit/components/iso_picker/widget_picker_iso_film_edit.dart'; +import 'package:lightmeter/screens/film_edit/components/name_field/widget_field_name_film_edit.dart'; import 'package:lightmeter/screens/film_edit/event_film_edit.dart'; import 'package:lightmeter/screens/film_edit/state_film_edit.dart'; -import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart'; import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart'; -import 'package:lightmeter/screens/shared/text_field/widget_text_field.dart'; -import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class FilmEditScreen extends StatefulWidget { const FilmEditScreen({super.key}); @@ -49,10 +48,18 @@ class _FilmEditScreenState extends State { padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM), child: Column( children: [ - _NameFieldBuilder(), + BlocBuilder( + buildWhen: (previous, current) => previous.name != current.name, + builder: (context, state) => FilmEditNameField( + name: state.name, + onChanged: (value) { + context.read().add(FilmEditNameChangedEvent(value)); + }, + ), + ), BlocBuilder( buildWhen: (previous, current) => previous.isoValue != current.isoValue, - builder: (context, state) => _IsoPickerListTile( + builder: (context, state) => FilmEditIsoPicker( selected: state.isoValue, onChanged: (value) { context.read().add(FilmEditIsoChangedEvent(value)); @@ -61,7 +68,7 @@ class _FilmEditScreenState extends State { ), BlocBuilder( buildWhen: (previous, current) => previous.exponent != current.exponent, - builder: (context, state) => ExponentialFormulaInput( + builder: (context, state) => FilmEditExponentialFormulaInput( value: state.exponent, onChanged: (value) { context.read().add(FilmEditExpChangedEvent(value)); @@ -79,73 +86,3 @@ class _FilmEditScreenState extends State { ); } } - -class _NameFieldBuilder extends StatelessWidget { - const _NameFieldBuilder(); - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only( - left: Dimens.paddingM, - top: Dimens.paddingS / 2, - right: Dimens.paddingL, - bottom: Dimens.paddingS / 2, - ), - child: BlocBuilder( - buildWhen: (previous, current) => previous.name != current.name, - builder: (context, state) => LightmeterTextField( - initialValue: state.name, - maxLength: 48, - hintText: S.of(context).name, - onChanged: (value) { - context.read().add(FilmEditNameChangedEvent(value)); - }, - style: Theme.of(context).listTileTheme.titleTextStyle, - leading: const Icon(Icons.edit_outlined), - ), - ), - ); - } -} - -class _IsoPickerListTile extends StatelessWidget { - final IsoValue selected; - final ValueChanged onChanged; - - const _IsoPickerListTile({ - required this.selected, - required this.onChanged, - }); - - @override - Widget build(BuildContext context) { - return ListTile( - leading: const Icon(Icons.iso), - title: Text(S.of(context).iso), - trailing: Text(selected.value.toString()), - onTap: () { - showDialog( - context: context, - builder: (_) => Dialog( - child: DialogPicker( - icon: Icons.iso, - title: S.of(context).iso, - subtitle: S.of(context).filmSpeed, - values: IsoValue.values, - initialValue: selected, - itemTitleBuilder: (_, value) => Text(value.value.toString()), - onSelect: (value) { - onChanged(value); - Navigator.of(context).pop(); - }, - onCancel: () { - Navigator.of(context).pop(); - }, - ), - ), - ); - }, - ); - } -}