mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
[FilmEditScreen
] wip
This commit is contained in:
parent
cc2ab3b68a
commit
b7f0305055
5 changed files with 202 additions and 0 deletions
44
lib/screens/film_edit/bloc_film_edit.dart
Normal file
44
lib/screens/film_edit/bloc_film_edit.dart
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:lightmeter/screens/film_edit/event_film_edit.dart';
|
||||||
|
import 'package:lightmeter/screens/film_edit/state_film_edit.dart';
|
||||||
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
class FilmEditBloc extends Bloc<FilmEditEvent, FilmEditState> {
|
||||||
|
FilmEditBloc(FilmExponential film)
|
||||||
|
: super(
|
||||||
|
FilmEditState(
|
||||||
|
film,
|
||||||
|
IsoValue.values.firstWhere((element) => element.value == film.iso),
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
on<FilmEditEvent>(
|
||||||
|
(event, emit) {
|
||||||
|
switch (event) {
|
||||||
|
case final FilmEditNameChangedEvent e:
|
||||||
|
_onNameChanged(e, emit);
|
||||||
|
case final FilmEditIsoChangedEvent e:
|
||||||
|
_onIsoChanged(e, emit);
|
||||||
|
case final FilmEditExpChangedEvent e:
|
||||||
|
_onExpChanged(e, emit);
|
||||||
|
case FilmEditSaveEvent():
|
||||||
|
_onSave(event, emit);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onNameChanged(FilmEditNameChangedEvent event, Emitter emit) async {}
|
||||||
|
|
||||||
|
Future<void> _onIsoChanged(FilmEditIsoChangedEvent event, Emitter emit) async {
|
||||||
|
emit(
|
||||||
|
FilmEditState(
|
||||||
|
state.film.copyWith(iso: event.iso.value),
|
||||||
|
event.iso,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onExpChanged(FilmEditExpChangedEvent event, Emitter emit) async {}
|
||||||
|
|
||||||
|
Future<void> _onSave(FilmEditSaveEvent _, Emitter emit) async {}
|
||||||
|
}
|
27
lib/screens/film_edit/event_film_edit.dart
Normal file
27
lib/screens/film_edit/event_film_edit.dart
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
sealed class FilmEditEvent {
|
||||||
|
const FilmEditEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilmEditNameChangedEvent extends FilmEditEvent {
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
const FilmEditNameChangedEvent(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilmEditIsoChangedEvent extends FilmEditEvent {
|
||||||
|
final IsoValue iso;
|
||||||
|
|
||||||
|
const FilmEditIsoChangedEvent(this.iso);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilmEditExpChangedEvent extends FilmEditEvent {
|
||||||
|
final double exp;
|
||||||
|
|
||||||
|
const FilmEditExpChangedEvent(this.exp);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilmEditSaveEvent extends FilmEditEvent {
|
||||||
|
const FilmEditSaveEvent();
|
||||||
|
}
|
19
lib/screens/film_edit/flow_film_edit.dart
Normal file
19
lib/screens/film_edit/flow_film_edit.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:lightmeter/screens/film_edit/bloc_film_edit.dart';
|
||||||
|
import 'package:lightmeter/screens/film_edit/screen_film_edit.dart';
|
||||||
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
class FilmEditFlow extends StatelessWidget {
|
||||||
|
final FilmExponential film;
|
||||||
|
|
||||||
|
const FilmEditFlow(this.film, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocProvider(
|
||||||
|
create: (_) => FilmEditBloc(film),
|
||||||
|
child: const FilmEditScreen(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
104
lib/screens/film_edit/screen_film_edit.dart
Normal file
104
lib/screens/film_edit/screen_film_edit.dart
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:lightmeter/generated/l10n.dart';
|
||||||
|
import 'package:lightmeter/screens/film_edit/bloc_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/settings/components/shared/dialog_filter/widget_dialog_filter.dart';
|
||||||
|
import 'package:lightmeter/screens/settings/components/shared/expandable_section_list/widget_expandable_section_list.dart';
|
||||||
|
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
|
||||||
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
class FilmEditScreen extends StatefulWidget {
|
||||||
|
const FilmEditScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FilmEditScreen> createState() => _FilmEditScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FilmEditScreenState extends State<FilmEditScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SliverScreen(
|
||||||
|
title: BlocBuilder<FilmEditBloc, FilmEditState>(
|
||||||
|
buildWhen: (previous, current) => previous.film.name != current.film.name,
|
||||||
|
builder: (context, state) => TextFormField(
|
||||||
|
initialValue: state.film.name,
|
||||||
|
onChanged: (value) {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
appBarActions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {},
|
||||||
|
icon: const Icon(Icons.save),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: BlocBuilder<FilmEditBloc, FilmEditState>(
|
||||||
|
buildWhen: (previous, current) => previous.isoValue != current.isoValue,
|
||||||
|
builder: (context, state) => _IsoPickerListTile(
|
||||||
|
selected: state.isoValue,
|
||||||
|
onChanged: (value) {
|
||||||
|
context.read<FilmEditBloc>().add(FilmEditIsoChangedEvent(value));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: BlocBuilder<FilmEditBloc, FilmEditState>(
|
||||||
|
buildWhen: (previous, current) => previous.film.exponent != current.film.exponent,
|
||||||
|
builder: (context, state) => ListTile(
|
||||||
|
leading: const Icon(Icons.equalizer),
|
||||||
|
title: Text('Formula'),
|
||||||
|
trailing: Text(state.film.exponent.toString()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(child: SizedBox(height: MediaQuery.paddingOf(context).bottom)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
8
lib/screens/film_edit/state_film_edit.dart
Normal file
8
lib/screens/film_edit/state_film_edit.dart
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
class FilmEditState {
|
||||||
|
final FilmExponential film;
|
||||||
|
final IsoValue isoValue;
|
||||||
|
|
||||||
|
const FilmEditState(this.film, this.isoValue);
|
||||||
|
}
|
Loading…
Reference in a new issue