integrated TimerScreen to navigation

This commit is contained in:
Vadim 2024-05-02 17:11:53 +02:00
parent 922824e4c8
commit 0605605e54
8 changed files with 73 additions and 64 deletions

View file

@ -18,7 +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; final ValueChanged<ExposurePair> onExposurePairTap;
const CameraContainerProvider({ const CameraContainerProvider({
required this.fastest, required this.fastest,

View file

@ -29,7 +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; final ValueChanged<ExposurePair> onExposurePairTap;
const CameraContainer({ const CameraContainer({
required this.fastest, required this.fastest,

View file

@ -15,7 +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; final ValueChanged<ExposurePair> onExposurePairTap;
const LightSensorContainerProvider({ const LightSensorContainerProvider({
required this.fastest, required this.fastest,

View file

@ -14,7 +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; final ValueChanged<ExposurePair> onExposurePairTap;
const LightSensorContainer({ const LightSensorContainer({
required this.fastest, required this.fastest,

View file

@ -5,11 +5,10 @@ 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; final ValueChanged<ExposurePair> onExposurePairTap;
const ExposurePairsList(this.exposurePairs, {required this.onExposurePairTap, super.key}); const ExposurePairsList(this.exposurePairs, {required this.onExposurePairTap, super.key});
@ -30,12 +29,17 @@ class ExposurePairsList extends StatelessWidget {
key: ValueKey(exposurePairs.hashCode), key: ValueKey(exposurePairs.hashCode),
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL), padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL),
itemCount: exposurePairs.length, itemCount: exposurePairs.length,
itemBuilder: (_, index) => Stack( itemBuilder: (_, index) {
final exposurePair = ExposurePair(
exposurePairs[index].aperture,
Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed),
);
return Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
onExposurePairTap(Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed)); onExposurePairTap(exposurePair);
}, },
child: Row( child: Row(
key: ValueKey(index), key: ValueKey(index),
@ -45,7 +49,7 @@ class ExposurePairsList extends StatelessWidget {
child: Align( child: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: ExposurePairsListItem( child: ExposurePairsListItem(
exposurePairs[index].aperture, exposurePair.aperture,
tickOnTheLeft: false, tickOnTheLeft: false,
), ),
), ),
@ -54,7 +58,7 @@ class ExposurePairsList extends StatelessWidget {
child: Align( child: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: ExposurePairsListItem( child: ExposurePairsListItem(
Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed), exposurePair.shutterSpeed,
tickOnTheLeft: true, tickOnTheLeft: true,
), ),
), ),
@ -83,7 +87,8 @@ class ExposurePairsList extends StatelessWidget {
), ),
), ),
], ],
), );
},
), ),
), ),
], ],

View file

@ -34,7 +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)), onExposurePairTap: (value) => Navigator.pushNamed(context, 'timer', arguments: value),
), ),
), ),
), ),
@ -49,7 +49,7 @@ class MeteringScreen extends StatelessWidget {
onMeasure: () => context.read<MeteringBloc>().add(const MeasureEvent()), onMeasure: () => context.read<MeteringBloc>().add(const MeasureEvent()),
onSettings: () { onSettings: () {
context.read<MeteringBloc>().add(const SettingsOpenedEvent()); context.read<MeteringBloc>().add(const SettingsOpenedEvent());
Navigator.pushNamed(context, 'settings').then((value) { Navigator.pushNamed(context, 'settings').then((_) {
context.read<MeteringBloc>().add(const SettingsClosedEvent()); context.read<MeteringBloc>().add(const SettingsClosedEvent());
}); });
}, },
@ -84,7 +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; final ValueChanged<ExposurePair> onExposurePairTap;
const MeteringContainerBuidler({ const MeteringContainerBuidler({
required this.ev, required this.ev,

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/interactors/metering_interactor.dart';
import 'package:lightmeter/providers/services_provider.dart'; import 'package:lightmeter/providers/services_provider.dart';
import 'package:lightmeter/res/dimens.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'; import 'package:lightmeter/screens/timer/screen_timer.dart';
class TimerFlow extends StatelessWidget { class TimerFlow extends StatelessWidget {
const TimerFlow({super.key}); final ExposurePair exposurePair;
const TimerFlow({required this.exposurePair, super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -35,11 +38,9 @@ class TimerFlow extends StatelessWidget {
child: BlocProvider( child: BlocProvider(
create: (context) => TimerBloc( create: (context) => TimerBloc(
MeteringInteractorProvider.of(context), MeteringInteractorProvider.of(context),
60, exposurePair.shutterSpeed.value.toInt(),
),
child: const TimerScreen(
duration: const Duration(seconds: 60),
), ),
child: TimerScreen(exposurePair: exposurePair),
), ),
), ),
); );

View file

@ -2,6 +2,7 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/timer/bloc_timer.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'; import 'package:material_color_utilities/material_color_utilities.dart';
class TimerScreen extends StatefulWidget { 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 @override
State<TimerScreen> createState() => _TimerScreenState(); State<TimerScreen> createState() => _TimerScreenState();
@ -28,7 +29,10 @@ class _TimerScreenState extends State<TimerScreen> with TickerProviderStateMixin
void initState() { void initState() {
super.initState(); super.initState();
timelineController = AnimationController(vsync: this, duration: widget.duration); timelineController = AnimationController(
vsync: this,
duration: Duration(seconds: widget.exposurePair.shutterSpeed.value.toInt()),
);
timelineAnimation = Tween<double>(begin: 1, end: 0).animate(timelineController); timelineAnimation = Tween<double>(begin: 1, end: 0).animate(timelineController);
startStopIconController = AnimationController(vsync: this, duration: Dimens.durationS); startStopIconController = AnimationController(vsync: this, duration: Dimens.durationS);
@ -60,7 +64,7 @@ class _TimerScreenState extends State<TimerScreen> with TickerProviderStateMixin
centerTitle: true, centerTitle: true,
elevation: 0, elevation: 0,
title: Text( title: Text(
'Test', widget.exposurePair.toString(),
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.onSurface, color: Theme.of(context).colorScheme.onSurface,
fontSize: Dimens.grid24, fontSize: Dimens.grid24,
@ -245,7 +249,6 @@ class _TimelinePainter extends CustomPainter {
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
print('PROGRESS: $progress');
late final double radiansProgress = 2 * pi * progress; late final double radiansProgress = 2 * pi * progress;
final radius = size.height / 2; final radius = size.height / 2;
final timerCenter = Offset(radius, radius); final timerCenter = Offset(radius, radius);