mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
integrated TimerScreen
to navigation
This commit is contained in:
parent
922824e4c8
commit
0605605e54
8 changed files with 73 additions and 64 deletions
|
@ -18,7 +18,7 @@ class CameraContainerProvider extends StatelessWidget {
|
|||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
final List<ExposurePair> exposurePairs;
|
||||
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
|
||||
final ValueChanged<ExposurePair> onExposurePairTap;
|
||||
|
||||
const CameraContainerProvider({
|
||||
required this.fastest,
|
||||
|
|
|
@ -29,7 +29,7 @@ class CameraContainer extends StatelessWidget {
|
|||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
final List<ExposurePair> exposurePairs;
|
||||
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
|
||||
final ValueChanged<ExposurePair> onExposurePairTap;
|
||||
|
||||
const CameraContainer({
|
||||
required this.fastest,
|
||||
|
|
|
@ -15,7 +15,7 @@ class LightSensorContainerProvider extends StatelessWidget {
|
|||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
final List<ExposurePair> exposurePairs;
|
||||
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
|
||||
final ValueChanged<ExposurePair> onExposurePairTap;
|
||||
|
||||
const LightSensorContainerProvider({
|
||||
required this.fastest,
|
||||
|
|
|
@ -14,7 +14,7 @@ class LightSensorContainer extends StatelessWidget {
|
|||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
final List<ExposurePair> exposurePairs;
|
||||
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
|
||||
final ValueChanged<ExposurePair> onExposurePairTap;
|
||||
|
||||
const LightSensorContainer({
|
||||
required this.fastest,
|
||||
|
|
|
@ -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<ExposurePair> exposurePairs;
|
||||
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
|
||||
final ValueChanged<ExposurePair> 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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -34,7 +34,7 @@ class MeteringScreen extends StatelessWidget {
|
|||
nd: state.nd,
|
||||
onIsoChanged: (value) => context.read<MeteringBloc>().add(IsoChangedEvent(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()),
|
||||
onSettings: () {
|
||||
context.read<MeteringBloc>().add(const SettingsOpenedEvent());
|
||||
Navigator.pushNamed(context, 'settings').then((value) {
|
||||
Navigator.pushNamed(context, 'settings').then((_) {
|
||||
context.read<MeteringBloc>().add(const SettingsClosedEvent());
|
||||
});
|
||||
},
|
||||
|
@ -84,7 +84,7 @@ class MeteringContainerBuidler extends StatelessWidget {
|
|||
final NdValue nd;
|
||||
final ValueChanged<IsoValue> onIsoChanged;
|
||||
final ValueChanged<NdValue> onNdChanged;
|
||||
final ValueChanged<ShutterSpeedValue> onExposurePairTap;
|
||||
final ValueChanged<ExposurePair> onExposurePairTap;
|
||||
|
||||
const MeteringContainerBuidler({
|
||||
required this.ev,
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -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<TimerScreen> createState() => _TimerScreenState();
|
||||
|
@ -28,7 +29,10 @@ class _TimerScreenState extends State<TimerScreen> 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<double>(begin: 1, end: 0).animate(timelineController);
|
||||
|
||||
startStopIconController = AnimationController(vsync: this, duration: Dimens.durationS);
|
||||
|
@ -60,7 +64,7 @@ class _TimerScreenState extends State<TimerScreen> 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);
|
||||
|
|
Loading…
Reference in a new issue