From 922824e4c80e64b5e1e4d9bf4df5f9d699a2a1d1 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Thu, 2 May 2024 16:54:37 +0200 Subject: [PATCH] added `onExposurePairTap` callback --- .../provider_container_camera.dart | 3 ++ .../widget_container_camera.dart | 7 ++- .../provider_container_light_sensor.dart | 3 ++ .../widget_container_light_sensor.dart | 9 +++- .../widget_list_exposure_pairs.dart | 52 ++++++++++--------- lib/screens/metering/screen_metering.dart | 5 ++ 6 files changed, 53 insertions(+), 26 deletions(-) diff --git a/lib/screens/metering/components/camera_container/provider_container_camera.dart b/lib/screens/metering/components/camera_container/provider_container_camera.dart index a4eec21..df705f7 100644 --- a/lib/screens/metering/components/camera_container/provider_container_camera.dart +++ b/lib/screens/metering/components/camera_container/provider_container_camera.dart @@ -18,6 +18,7 @@ class CameraContainerProvider extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; + final ValueChanged onExposurePairTap; const CameraContainerProvider({ required this.fastest, @@ -27,6 +28,7 @@ class CameraContainerProvider extends StatelessWidget { required this.onIsoChanged, required this.onNdChanged, required this.exposurePairs, + required this.onExposurePairTap, super.key, }); @@ -54,6 +56,7 @@ class CameraContainerProvider extends StatelessWidget { onIsoChanged: onIsoChanged, onNdChanged: onNdChanged, exposurePairs: exposurePairs, + onExposurePairTap: onExposurePairTap, ), ); } diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index 95cff57..1f512ff 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -29,6 +29,7 @@ class CameraContainer extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; + final ValueChanged onExposurePairTap; const CameraContainer({ required this.fastest, @@ -38,6 +39,7 @@ class CameraContainer extends StatelessWidget { required this.onIsoChanged, required this.onNdChanged, required this.exposurePairs, + required this.onExposurePairTap, super.key, }); @@ -81,7 +83,10 @@ class CameraContainer extends StatelessWidget { Expanded( child: Padding( padding: EdgeInsets.only(top: topBarOverflow >= 0 ? topBarOverflow : 0), - child: ExposurePairsList(exposurePairs), + child: ExposurePairsList( + exposurePairs, + onExposurePairTap: onExposurePairTap, + ), ), ), const SizedBox(width: Dimens.grid8), diff --git a/lib/screens/metering/components/light_sensor_container/provider_container_light_sensor.dart b/lib/screens/metering/components/light_sensor_container/provider_container_light_sensor.dart index 1d7f822..66f1c92 100644 --- a/lib/screens/metering/components/light_sensor_container/provider_container_light_sensor.dart +++ b/lib/screens/metering/components/light_sensor_container/provider_container_light_sensor.dart @@ -15,6 +15,7 @@ class LightSensorContainerProvider extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; + final ValueChanged onExposurePairTap; const LightSensorContainerProvider({ required this.fastest, @@ -24,6 +25,7 @@ class LightSensorContainerProvider extends StatelessWidget { required this.onIsoChanged, required this.onNdChanged, required this.exposurePairs, + required this.onExposurePairTap, super.key, }); @@ -43,6 +45,7 @@ class LightSensorContainerProvider extends StatelessWidget { onIsoChanged: onIsoChanged, onNdChanged: onNdChanged, exposurePairs: exposurePairs, + onExposurePairTap: onExposurePairTap, ), ); } diff --git a/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart b/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart index 2151ee0..4027cb0 100644 --- a/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart +++ b/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart @@ -14,6 +14,7 @@ class LightSensorContainer extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; + final ValueChanged onExposurePairTap; const LightSensorContainer({ required this.fastest, @@ -23,6 +24,7 @@ class LightSensorContainer extends StatelessWidget { required this.onIsoChanged, required this.onNdChanged, required this.exposurePairs, + required this.onExposurePairTap, super.key, }); @@ -43,7 +45,12 @@ class LightSensorContainer extends StatelessWidget { Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM), - child: Center(child: ExposurePairsList(exposurePairs)), + child: Center( + child: ExposurePairsList( + exposurePairs, + onExposurePairTap: onExposurePairTap, + ), + ), ), ), ], diff --git a/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart b/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart index cb78275..d373e86 100644 --- a/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart +++ b/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart @@ -5,11 +5,13 @@ import 'package:lightmeter/providers/films_provider.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/shared/icon_placeholder/widget_icon_placeholder.dart'; +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class ExposurePairsList extends StatelessWidget { final List exposurePairs; + final ValueChanged onExposurePairTap; - const ExposurePairsList(this.exposurePairs, {super.key}); + const ExposurePairsList(this.exposurePairs, {required this.onExposurePairTap, super.key}); @override Widget build(BuildContext context) { @@ -31,30 +33,34 @@ class ExposurePairsList extends StatelessWidget { itemBuilder: (_, index) => Stack( alignment: Alignment.center, children: [ - Row( - key: ValueKey(index), - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: ExposurePairsListItem( - exposurePairs[index].aperture, - tickOnTheLeft: false, + GestureDetector( + onTap: () { + onExposurePairTap(Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed)); + }, + child: Row( + key: ValueKey(index), + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: ExposurePairsListItem( + exposurePairs[index].aperture, + tickOnTheLeft: false, + ), ), ), - ), - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: ExposurePairsListItem( - Films.selectedOf(context) - .reciprocityFailure(exposurePairs[index].shutterSpeed), - tickOnTheLeft: true, + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: ExposurePairsListItem( + Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed), + tickOnTheLeft: true, + ), ), ), - ), - ], + ], + ), ), Positioned( top: 0, @@ -63,9 +69,7 @@ class ExposurePairsList extends StatelessWidget { builder: (context, constraints) => Align( alignment: index == 0 ? Alignment.bottomCenter - : (index == exposurePairs.length - 1 - ? Alignment.topCenter - : Alignment.center), + : (index == exposurePairs.length - 1 ? Alignment.topCenter : Alignment.center), child: SizedBox( height: index == 0 || index == exposurePairs.length - 1 ? constraints.maxHeight / 2 diff --git a/lib/screens/metering/screen_metering.dart b/lib/screens/metering/screen_metering.dart index 4a0aa83..0662192 100644 --- a/lib/screens/metering/screen_metering.dart +++ b/lib/screens/metering/screen_metering.dart @@ -34,6 +34,7 @@ class MeteringScreen extends StatelessWidget { nd: state.nd, onIsoChanged: (value) => context.read().add(IsoChangedEvent(value)), onNdChanged: (value) => context.read().add(NdChangedEvent(value)), + onExposurePairTap: (value) => context.read().add(SetTimerEvent(value)), ), ), ), @@ -83,6 +84,7 @@ class MeteringContainerBuidler extends StatelessWidget { final NdValue nd; final ValueChanged onIsoChanged; final ValueChanged onNdChanged; + final ValueChanged onExposurePairTap; const MeteringContainerBuidler({ required this.ev, @@ -90,6 +92,7 @@ class MeteringContainerBuidler extends StatelessWidget { required this.nd, required this.onIsoChanged, required this.onNdChanged, + required this.onExposurePairTap, }); @override @@ -113,6 +116,7 @@ class MeteringContainerBuidler extends StatelessWidget { onIsoChanged: onIsoChanged, onNdChanged: onNdChanged, exposurePairs: exposurePairs, + onExposurePairTap: onExposurePairTap, ) : LightSensorContainerProvider( fastest: fastest, @@ -122,6 +126,7 @@ class MeteringContainerBuidler extends StatelessWidget { onIsoChanged: onIsoChanged, onNdChanged: onNdChanged, exposurePairs: exposurePairs, + onExposurePairTap: onExposurePairTap, ); }