mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 15:00:40 +00:00
[FilmEditScreen
] split into separate components
This commit is contained in:
parent
a6f319bf99
commit
756c179567
4 changed files with 98 additions and 81 deletions
|
@ -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<double?> onChanged;
|
||||
|
||||
const ExponentialFormulaInput({
|
||||
const FilmEditExponentialFormulaInput({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ExponentialFormulaInput> createState() => _ExponentialFormulaInputState();
|
||||
State<FilmEditExponentialFormulaInput> createState() => _FilmEditExponentialFormulaInputState();
|
||||
}
|
||||
|
||||
class _ExponentialFormulaInputState extends State<ExponentialFormulaInput> {
|
||||
class _FilmEditExponentialFormulaInputState extends State<FilmEditExponentialFormulaInput> {
|
||||
TextStyle get style =>
|
||||
Theme.of(context).textTheme.bodyMedium!.copyWith(color: Theme.of(context).listTileTheme.textColor);
|
||||
|
|
@ -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<IsoValue> 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<IsoValue>(
|
||||
context: context,
|
||||
builder: (_) => Dialog(
|
||||
child: DialogPicker<IsoValue>(
|
||||
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();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<String> 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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<FilmEditScreen> {
|
|||
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM),
|
||||
child: Column(
|
||||
children: [
|
||||
_NameFieldBuilder(),
|
||||
BlocBuilder<FilmEditBloc, FilmEditState>(
|
||||
buildWhen: (previous, current) => previous.name != current.name,
|
||||
builder: (context, state) => FilmEditNameField(
|
||||
name: state.name,
|
||||
onChanged: (value) {
|
||||
context.read<FilmEditBloc>().add(FilmEditNameChangedEvent(value));
|
||||
},
|
||||
),
|
||||
),
|
||||
BlocBuilder<FilmEditBloc, FilmEditState>(
|
||||
buildWhen: (previous, current) => previous.isoValue != current.isoValue,
|
||||
builder: (context, state) => _IsoPickerListTile(
|
||||
builder: (context, state) => FilmEditIsoPicker(
|
||||
selected: state.isoValue,
|
||||
onChanged: (value) {
|
||||
context.read<FilmEditBloc>().add(FilmEditIsoChangedEvent(value));
|
||||
|
@ -61,7 +68,7 @@ class _FilmEditScreenState extends State<FilmEditScreen> {
|
|||
),
|
||||
BlocBuilder<FilmEditBloc, FilmEditState>(
|
||||
buildWhen: (previous, current) => previous.exponent != current.exponent,
|
||||
builder: (context, state) => ExponentialFormulaInput(
|
||||
builder: (context, state) => FilmEditExponentialFormulaInput(
|
||||
value: state.exponent,
|
||||
onChanged: (value) {
|
||||
context.read<FilmEditBloc>().add(FilmEditExpChangedEvent(value));
|
||||
|
@ -79,73 +86,3 @@ class _FilmEditScreenState extends State<FilmEditScreen> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
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<FilmEditBloc, FilmEditState>(
|
||||
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<FilmEditBloc>().add(FilmEditNameChangedEvent(value));
|
||||
},
|
||||
style: Theme.of(context).listTileTheme.titleTextStyle,
|
||||
leading: const Icon(Icons.edit_outlined),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _IsoPickerListTile extends StatelessWidget {
|
||||
final IsoValue selected;
|
||||
final ValueChanged<IsoValue> 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<IsoValue>(
|
||||
context: context,
|
||||
builder: (_) => Dialog(
|
||||
child: DialogPicker<IsoValue>(
|
||||
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();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue