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 df705f7..b5f68e9 100644 --- a/lib/screens/metering/components/camera_container/provider_container_camera.dart +++ b/lib/screens/metering/components/camera_container/provider_container_camera.dart @@ -18,7 +18,7 @@ class CameraContainerProvider extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; - final ValueChanged onExposurePairTap; + final ValueChanged onExposurePairTap; const CameraContainerProvider({ required this.fastest, 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 1f512ff..4d83b0e 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -29,7 +29,7 @@ class CameraContainer extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; - final ValueChanged onExposurePairTap; + final ValueChanged onExposurePairTap; const CameraContainer({ required this.fastest, 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 66f1c92..5fcbedc 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,7 +15,7 @@ class LightSensorContainerProvider extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; - final ValueChanged onExposurePairTap; + final ValueChanged onExposurePairTap; const LightSensorContainerProvider({ required this.fastest, 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 4027cb0..b0af83f 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,7 +14,7 @@ class LightSensorContainer extends StatelessWidget { final ValueChanged onIsoChanged; final ValueChanged onNdChanged; final List exposurePairs; - final ValueChanged onExposurePairTap; + final ValueChanged onExposurePairTap; const LightSensorContainer({ required this.fastest, 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 d373e86..a2213b5 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,10 @@ 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; + final ValueChanged onExposurePairTap; const ExposurePairsList(this.exposurePairs, {required this.onExposurePairTap, super.key}); @@ -30,60 +29,66 @@ class ExposurePairsList extends StatelessWidget { key: ValueKey(exposurePairs.hashCode), padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL), itemCount: exposurePairs.length, - itemBuilder: (_, index) => Stack( - alignment: Alignment.center, - children: [ - 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, + itemBuilder: (_, index) { + final exposurePair = ExposurePair( + exposurePairs[index].aperture, + Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed), + ); + return Stack( + alignment: Alignment.center, + children: [ + GestureDetector( + onTap: () { + onExposurePairTap(exposurePair); + }, + child: Row( + key: ValueKey(index), + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: ExposurePairsListItem( + exposurePair.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( + exposurePair.shutterSpeed, + tickOnTheLeft: true, + ), ), ), - ), - ], + ], + ), ), - ), - Positioned( - top: 0, - bottom: 0, - child: LayoutBuilder( - builder: (context, constraints) => Align( - alignment: index == 0 - ? Alignment.bottomCenter - : (index == exposurePairs.length - 1 ? Alignment.topCenter : Alignment.center), - child: SizedBox( - height: index == 0 || index == exposurePairs.length - 1 - ? constraints.maxHeight / 2 - : constraints.maxHeight, - child: ColoredBox( - color: Theme.of(context).colorScheme.onBackground, - child: const SizedBox(width: 1), + Positioned( + top: 0, + bottom: 0, + child: LayoutBuilder( + builder: (context, constraints) => Align( + alignment: index == 0 + ? Alignment.bottomCenter + : (index == exposurePairs.length - 1 ? Alignment.topCenter : Alignment.center), + child: SizedBox( + height: index == 0 || index == exposurePairs.length - 1 + ? constraints.maxHeight / 2 + : constraints.maxHeight, + child: ColoredBox( + color: Theme.of(context).colorScheme.onBackground, + child: const SizedBox(width: 1), + ), ), ), ), ), - ), - ], - ), + ], + ); + }, ), ), ], diff --git a/lib/screens/metering/screen_metering.dart b/lib/screens/metering/screen_metering.dart index 0662192..6674773 100644 --- a/lib/screens/metering/screen_metering.dart +++ b/lib/screens/metering/screen_metering.dart @@ -34,7 +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)), + onExposurePairTap: (value) => Navigator.pushNamed(context, 'timer', arguments: value), ), ), ), @@ -49,7 +49,7 @@ class MeteringScreen extends StatelessWidget { onMeasure: () => context.read().add(const MeasureEvent()), onSettings: () { context.read().add(const SettingsOpenedEvent()); - Navigator.pushNamed(context, 'settings').then((value) { + Navigator.pushNamed(context, 'settings').then((_) { context.read().add(const SettingsClosedEvent()); }); }, @@ -84,7 +84,7 @@ class MeteringContainerBuidler extends StatelessWidget { final NdValue nd; final ValueChanged onIsoChanged; final ValueChanged onNdChanged; - final ValueChanged onExposurePairTap; + final ValueChanged onExposurePairTap; const MeteringContainerBuidler({ required this.ev, diff --git a/lib/screens/timer/flow_timer.dart b/lib/screens/timer/flow_timer.dart index 5d26057..2aa4688 100644 --- a/lib/screens/timer/flow_timer.dart +++ b/lib/screens/timer/flow_timer.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/interactors/metering_interactor.dart'; import 'package:lightmeter/providers/services_provider.dart'; import 'package:lightmeter/res/dimens.dart'; @@ -7,7 +8,9 @@ import 'package:lightmeter/screens/timer/bloc_timer.dart'; import 'package:lightmeter/screens/timer/screen_timer.dart'; class TimerFlow extends StatelessWidget { - const TimerFlow({super.key}); + final ExposurePair exposurePair; + + const TimerFlow({required this.exposurePair, super.key}); @override Widget build(BuildContext context) { @@ -35,11 +38,9 @@ class TimerFlow extends StatelessWidget { child: BlocProvider( create: (context) => TimerBloc( MeteringInteractorProvider.of(context), - 60, - ), - child: const TimerScreen( - duration: const Duration(seconds: 60), + exposurePair.shutterSpeed.value.toInt(), ), + child: TimerScreen(exposurePair: exposurePair), ), ), ); diff --git a/lib/screens/timer/screen_timer.dart b/lib/screens/timer/screen_timer.dart index c25bc87..f3bea92 100644 --- a/lib/screens/timer/screen_timer.dart +++ b/lib/screens/timer/screen_timer.dart @@ -2,6 +2,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/timer/bloc_timer.dart'; @@ -10,9 +11,9 @@ import 'package:lightmeter/screens/timer/state_timer.dart'; import 'package:material_color_utilities/material_color_utilities.dart'; class TimerScreen extends StatefulWidget { - final Duration duration; + final ExposurePair exposurePair; - const TimerScreen({required this.duration, super.key}); + const TimerScreen({required this.exposurePair, super.key}); @override State createState() => _TimerScreenState(); @@ -28,7 +29,10 @@ class _TimerScreenState extends State with TickerProviderStateMixin void initState() { super.initState(); - timelineController = AnimationController(vsync: this, duration: widget.duration); + timelineController = AnimationController( + vsync: this, + duration: Duration(seconds: widget.exposurePair.shutterSpeed.value.toInt()), + ); timelineAnimation = Tween(begin: 1, end: 0).animate(timelineController); startStopIconController = AnimationController(vsync: this, duration: Dimens.durationS); @@ -60,7 +64,7 @@ class _TimerScreenState extends State with TickerProviderStateMixin centerTitle: true, elevation: 0, title: Text( - 'Test', + widget.exposurePair.toString(), style: TextStyle( color: Theme.of(context).colorScheme.onSurface, fontSize: Dimens.grid24, @@ -245,7 +249,6 @@ class _TimelinePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - print('PROGRESS: $progress'); late final double radiansProgress = 2 * pi * progress; final radius = size.height / 2; final timerCenter = Offset(radius, radius);