mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 01:10:39 +00:00
wip
This commit is contained in:
parent
abf4d77342
commit
b30d9ceb2e
1 changed files with 82 additions and 91 deletions
|
@ -30,24 +30,16 @@ class MeteringScreen extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BlocBuilder<MeteringBloc, MeteringState>(
|
child: BlocBuilder<MeteringBloc, MeteringState>(
|
||||||
builder: (_, state) {
|
builder: (_, state) => _MeteringContainerBuidler(
|
||||||
final exposurePairs = state is MeteringDataState && state.ev != null
|
ev: state is MeteringDataState ? state.ev : null,
|
||||||
? buildExposureValues(context, state.ev!, state.film)
|
film: state.film,
|
||||||
: <ExposurePair>[];
|
iso: state.iso,
|
||||||
return _MeteringContainerBuidler(
|
nd: state.nd,
|
||||||
fastest: exposurePairs.isNotEmpty ? exposurePairs.first : null,
|
onFilmChanged: (value) =>
|
||||||
slowest: exposurePairs.isNotEmpty ? exposurePairs.last : null,
|
context.read<MeteringBloc>().add(FilmChangedEvent(value)),
|
||||||
exposurePairs: exposurePairs,
|
onIsoChanged: (value) => context.read<MeteringBloc>().add(IsoChangedEvent(value)),
|
||||||
film: state.film,
|
onNdChanged: (value) => context.read<MeteringBloc>().add(NdChangedEvent(value)),
|
||||||
iso: state.iso,
|
),
|
||||||
nd: state.nd,
|
|
||||||
onFilmChanged: (value) =>
|
|
||||||
context.read<MeteringBloc>().add(FilmChangedEvent(value)),
|
|
||||||
onIsoChanged: (value) =>
|
|
||||||
context.read<MeteringBloc>().add(IsoChangedEvent(value)),
|
|
||||||
onNdChanged: (value) => context.read<MeteringBloc>().add(NdChangedEvent(value)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocBuilder<MeteringBloc, MeteringState>(
|
BlocBuilder<MeteringBloc, MeteringState>(
|
||||||
|
@ -66,6 +58,78 @@ class MeteringScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InheritedListeners extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const _InheritedListeners({required this.child});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return InheritedWidgetListener<EquipmentProfile>(
|
||||||
|
onDidChangeDependencies: (value) {
|
||||||
|
context.read<MeteringBloc>().add(EquipmentProfileChangedEvent(value));
|
||||||
|
},
|
||||||
|
child: InheritedModelAspectListener<MeteringScreenLayoutFeature, bool>(
|
||||||
|
aspect: MeteringScreenLayoutFeature.filmPicker,
|
||||||
|
onDidChangeDependencies: (value) {
|
||||||
|
if (!value) context.read<MeteringBloc>().add(const FilmChangedEvent(Film.other()));
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MeteringContainerBuidler extends StatelessWidget {
|
||||||
|
final double? ev;
|
||||||
|
final Film film;
|
||||||
|
final IsoValue iso;
|
||||||
|
final NdValue nd;
|
||||||
|
final ValueChanged<Film> onFilmChanged;
|
||||||
|
final ValueChanged<IsoValue> onIsoChanged;
|
||||||
|
final ValueChanged<NdValue> onNdChanged;
|
||||||
|
|
||||||
|
const _MeteringContainerBuidler({
|
||||||
|
required this.ev,
|
||||||
|
required this.film,
|
||||||
|
required this.iso,
|
||||||
|
required this.nd,
|
||||||
|
required this.onFilmChanged,
|
||||||
|
required this.onIsoChanged,
|
||||||
|
required this.onNdChanged,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final exposurePairs = ev != null ? buildExposureValues(context, ev!, film) : <ExposurePair>[];
|
||||||
|
final fastest = exposurePairs.isNotEmpty ? exposurePairs.first : null;
|
||||||
|
final slowest = exposurePairs.isNotEmpty ? exposurePairs.last : null;
|
||||||
|
return context.listen<EvSourceType>() == EvSourceType.camera
|
||||||
|
? CameraContainerProvider(
|
||||||
|
fastest: fastest,
|
||||||
|
slowest: slowest,
|
||||||
|
film: film,
|
||||||
|
iso: iso,
|
||||||
|
nd: nd,
|
||||||
|
onFilmChanged: onFilmChanged,
|
||||||
|
onIsoChanged: onIsoChanged,
|
||||||
|
onNdChanged: onNdChanged,
|
||||||
|
exposurePairs: exposurePairs,
|
||||||
|
)
|
||||||
|
: LightSensorContainerProvider(
|
||||||
|
fastest: fastest,
|
||||||
|
slowest: slowest,
|
||||||
|
film: film,
|
||||||
|
iso: iso,
|
||||||
|
nd: nd,
|
||||||
|
onFilmChanged: onFilmChanged,
|
||||||
|
onIsoChanged: onIsoChanged,
|
||||||
|
onNdChanged: onNdChanged,
|
||||||
|
exposurePairs: exposurePairs,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
List<ExposurePair> buildExposureValues(BuildContext context, double ev, Film film) {
|
List<ExposurePair> buildExposureValues(BuildContext context, double ev, Film film) {
|
||||||
if (ev.isNaN || ev.isInfinite) {
|
if (ev.isNaN || ev.isInfinite) {
|
||||||
|
@ -131,76 +195,3 @@ class MeteringScreen extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InheritedListeners extends StatelessWidget {
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
const _InheritedListeners({required this.child});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return InheritedWidgetListener<EquipmentProfile>(
|
|
||||||
onDidChangeDependencies: (value) {
|
|
||||||
context.read<MeteringBloc>().add(EquipmentProfileChangedEvent(value));
|
|
||||||
},
|
|
||||||
child: InheritedModelAspectListener<MeteringScreenLayoutFeature, bool>(
|
|
||||||
aspect: MeteringScreenLayoutFeature.filmPicker,
|
|
||||||
onDidChangeDependencies: (value) {
|
|
||||||
if (!value) context.read<MeteringBloc>().add(const FilmChangedEvent(Film.other()));
|
|
||||||
},
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MeteringContainerBuidler extends StatelessWidget {
|
|
||||||
final ExposurePair? fastest;
|
|
||||||
final ExposurePair? slowest;
|
|
||||||
final Film film;
|
|
||||||
final IsoValue iso;
|
|
||||||
final NdValue nd;
|
|
||||||
final ValueChanged<Film> onFilmChanged;
|
|
||||||
final ValueChanged<IsoValue> onIsoChanged;
|
|
||||||
final ValueChanged<NdValue> onNdChanged;
|
|
||||||
final List<ExposurePair> exposurePairs;
|
|
||||||
|
|
||||||
const _MeteringContainerBuidler({
|
|
||||||
required this.fastest,
|
|
||||||
required this.slowest,
|
|
||||||
required this.film,
|
|
||||||
required this.iso,
|
|
||||||
required this.nd,
|
|
||||||
required this.onFilmChanged,
|
|
||||||
required this.onIsoChanged,
|
|
||||||
required this.onNdChanged,
|
|
||||||
required this.exposurePairs,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return context.listen<EvSourceType>() == EvSourceType.camera
|
|
||||||
? CameraContainerProvider(
|
|
||||||
fastest: fastest,
|
|
||||||
slowest: slowest,
|
|
||||||
film: film,
|
|
||||||
iso: iso,
|
|
||||||
nd: nd,
|
|
||||||
onFilmChanged: onFilmChanged,
|
|
||||||
onIsoChanged: onIsoChanged,
|
|
||||||
onNdChanged: onNdChanged,
|
|
||||||
exposurePairs: exposurePairs,
|
|
||||||
)
|
|
||||||
: LightSensorContainerProvider(
|
|
||||||
fastest: fastest,
|
|
||||||
slowest: slowest,
|
|
||||||
film: film,
|
|
||||||
iso: iso,
|
|
||||||
nd: nd,
|
|
||||||
onFilmChanged: onFilmChanged,
|
|
||||||
onIsoChanged: onIsoChanged,
|
|
||||||
onNdChanged: onNdChanged,
|
|
||||||
exposurePairs: exposurePairs,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue