added onExposurePairTap callback

This commit is contained in:
Vadim 2024-05-02 16:54:37 +02:00
parent 985ecaa41e
commit 922824e4c8
6 changed files with 53 additions and 26 deletions

View file

@ -18,6 +18,7 @@ class CameraContainerProvider extends StatelessWidget {
final ValueChanged<IsoValue> onIsoChanged; final ValueChanged<IsoValue> onIsoChanged;
final ValueChanged<NdValue> onNdChanged; final ValueChanged<NdValue> onNdChanged;
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
const CameraContainerProvider({ const CameraContainerProvider({
required this.fastest, required this.fastest,
@ -27,6 +28,7 @@ class CameraContainerProvider extends StatelessWidget {
required this.onIsoChanged, required this.onIsoChanged,
required this.onNdChanged, required this.onNdChanged,
required this.exposurePairs, required this.exposurePairs,
required this.onExposurePairTap,
super.key, super.key,
}); });
@ -54,6 +56,7 @@ class CameraContainerProvider extends StatelessWidget {
onIsoChanged: onIsoChanged, onIsoChanged: onIsoChanged,
onNdChanged: onNdChanged, onNdChanged: onNdChanged,
exposurePairs: exposurePairs, exposurePairs: exposurePairs,
onExposurePairTap: onExposurePairTap,
), ),
); );
} }

View file

@ -29,6 +29,7 @@ class CameraContainer extends StatelessWidget {
final ValueChanged<IsoValue> onIsoChanged; final ValueChanged<IsoValue> onIsoChanged;
final ValueChanged<NdValue> onNdChanged; final ValueChanged<NdValue> onNdChanged;
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
const CameraContainer({ const CameraContainer({
required this.fastest, required this.fastest,
@ -38,6 +39,7 @@ class CameraContainer extends StatelessWidget {
required this.onIsoChanged, required this.onIsoChanged,
required this.onNdChanged, required this.onNdChanged,
required this.exposurePairs, required this.exposurePairs,
required this.onExposurePairTap,
super.key, super.key,
}); });
@ -81,7 +83,10 @@ class CameraContainer extends StatelessWidget {
Expanded( Expanded(
child: Padding( child: Padding(
padding: EdgeInsets.only(top: topBarOverflow >= 0 ? topBarOverflow : 0), padding: EdgeInsets.only(top: topBarOverflow >= 0 ? topBarOverflow : 0),
child: ExposurePairsList(exposurePairs), child: ExposurePairsList(
exposurePairs,
onExposurePairTap: onExposurePairTap,
),
), ),
), ),
const SizedBox(width: Dimens.grid8), const SizedBox(width: Dimens.grid8),

View file

@ -15,6 +15,7 @@ class LightSensorContainerProvider extends StatelessWidget {
final ValueChanged<IsoValue> onIsoChanged; final ValueChanged<IsoValue> onIsoChanged;
final ValueChanged<NdValue> onNdChanged; final ValueChanged<NdValue> onNdChanged;
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
const LightSensorContainerProvider({ const LightSensorContainerProvider({
required this.fastest, required this.fastest,
@ -24,6 +25,7 @@ class LightSensorContainerProvider extends StatelessWidget {
required this.onIsoChanged, required this.onIsoChanged,
required this.onNdChanged, required this.onNdChanged,
required this.exposurePairs, required this.exposurePairs,
required this.onExposurePairTap,
super.key, super.key,
}); });
@ -43,6 +45,7 @@ class LightSensorContainerProvider extends StatelessWidget {
onIsoChanged: onIsoChanged, onIsoChanged: onIsoChanged,
onNdChanged: onNdChanged, onNdChanged: onNdChanged,
exposurePairs: exposurePairs, exposurePairs: exposurePairs,
onExposurePairTap: onExposurePairTap,
), ),
); );
} }

View file

@ -14,6 +14,7 @@ class LightSensorContainer extends StatelessWidget {
final ValueChanged<IsoValue> onIsoChanged; final ValueChanged<IsoValue> onIsoChanged;
final ValueChanged<NdValue> onNdChanged; final ValueChanged<NdValue> onNdChanged;
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
const LightSensorContainer({ const LightSensorContainer({
required this.fastest, required this.fastest,
@ -23,6 +24,7 @@ class LightSensorContainer extends StatelessWidget {
required this.onIsoChanged, required this.onIsoChanged,
required this.onNdChanged, required this.onNdChanged,
required this.exposurePairs, required this.exposurePairs,
required this.onExposurePairTap,
super.key, super.key,
}); });
@ -43,7 +45,12 @@ class LightSensorContainer extends StatelessWidget {
Expanded( Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM), padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
child: Center(child: ExposurePairsList(exposurePairs)), child: Center(
child: ExposurePairsList(
exposurePairs,
onExposurePairTap: onExposurePairTap,
),
),
), ),
), ),
], ],

View file

@ -5,11 +5,13 @@ import 'package:lightmeter/providers/films_provider.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart'; import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart';
import 'package:lightmeter/screens/shared/icon_placeholder/widget_icon_placeholder.dart'; import 'package:lightmeter/screens/shared/icon_placeholder/widget_icon_placeholder.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class ExposurePairsList extends StatelessWidget { class ExposurePairsList extends StatelessWidget {
final List<ExposurePair> exposurePairs; final List<ExposurePair> exposurePairs;
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
const ExposurePairsList(this.exposurePairs, {super.key}); const ExposurePairsList(this.exposurePairs, {required this.onExposurePairTap, super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -31,30 +33,34 @@ class ExposurePairsList extends StatelessWidget {
itemBuilder: (_, index) => Stack( itemBuilder: (_, index) => Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
Row( GestureDetector(
key: ValueKey(index), onTap: () {
mainAxisAlignment: MainAxisAlignment.center, onExposurePairTap(Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed));
children: [ },
Expanded( child: Row(
child: Align( key: ValueKey(index),
alignment: Alignment.centerLeft, mainAxisAlignment: MainAxisAlignment.center,
child: ExposurePairsListItem( children: [
exposurePairs[index].aperture, Expanded(
tickOnTheLeft: false, child: Align(
alignment: Alignment.centerLeft,
child: ExposurePairsListItem(
exposurePairs[index].aperture,
tickOnTheLeft: false,
),
), ),
), ),
), Expanded(
Expanded( child: Align(
child: Align( alignment: Alignment.centerLeft,
alignment: Alignment.centerLeft, child: ExposurePairsListItem(
child: ExposurePairsListItem( Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed),
Films.selectedOf(context) tickOnTheLeft: true,
.reciprocityFailure(exposurePairs[index].shutterSpeed), ),
tickOnTheLeft: true,
), ),
), ),
), ],
], ),
), ),
Positioned( Positioned(
top: 0, top: 0,
@ -63,9 +69,7 @@ class ExposurePairsList extends StatelessWidget {
builder: (context, constraints) => Align( builder: (context, constraints) => Align(
alignment: index == 0 alignment: index == 0
? Alignment.bottomCenter ? Alignment.bottomCenter
: (index == exposurePairs.length - 1 : (index == exposurePairs.length - 1 ? Alignment.topCenter : Alignment.center),
? Alignment.topCenter
: Alignment.center),
child: SizedBox( child: SizedBox(
height: index == 0 || index == exposurePairs.length - 1 height: index == 0 || index == exposurePairs.length - 1
? constraints.maxHeight / 2 ? constraints.maxHeight / 2

View file

@ -34,6 +34,7 @@ class MeteringScreen extends StatelessWidget {
nd: state.nd, nd: state.nd,
onIsoChanged: (value) => context.read<MeteringBloc>().add(IsoChangedEvent(value)), onIsoChanged: (value) => context.read<MeteringBloc>().add(IsoChangedEvent(value)),
onNdChanged: (value) => context.read<MeteringBloc>().add(NdChangedEvent(value)), onNdChanged: (value) => context.read<MeteringBloc>().add(NdChangedEvent(value)),
onExposurePairTap: (value) => context.read<MeteringBloc>().add(SetTimerEvent(value)),
), ),
), ),
), ),
@ -83,6 +84,7 @@ class MeteringContainerBuidler extends StatelessWidget {
final NdValue nd; final NdValue nd;
final ValueChanged<IsoValue> onIsoChanged; final ValueChanged<IsoValue> onIsoChanged;
final ValueChanged<NdValue> onNdChanged; final ValueChanged<NdValue> onNdChanged;
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
const MeteringContainerBuidler({ const MeteringContainerBuidler({
required this.ev, required this.ev,
@ -90,6 +92,7 @@ class MeteringContainerBuidler extends StatelessWidget {
required this.nd, required this.nd,
required this.onIsoChanged, required this.onIsoChanged,
required this.onNdChanged, required this.onNdChanged,
required this.onExposurePairTap,
}); });
@override @override
@ -113,6 +116,7 @@ class MeteringContainerBuidler extends StatelessWidget {
onIsoChanged: onIsoChanged, onIsoChanged: onIsoChanged,
onNdChanged: onNdChanged, onNdChanged: onNdChanged,
exposurePairs: exposurePairs, exposurePairs: exposurePairs,
onExposurePairTap: onExposurePairTap,
) )
: LightSensorContainerProvider( : LightSensorContainerProvider(
fastest: fastest, fastest: fastest,
@ -122,6 +126,7 @@ class MeteringContainerBuidler extends StatelessWidget {
onIsoChanged: onIsoChanged, onIsoChanged: onIsoChanged,
onNdChanged: onNdChanged, onNdChanged: onNdChanged,
exposurePairs: exposurePairs, exposurePairs: exposurePairs,
onExposurePairTap: onExposurePairTap,
); );
} }