mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
animated timeline
This commit is contained in:
parent
c532801358
commit
faeca1adbd
2 changed files with 26 additions and 21 deletions
|
@ -24,7 +24,9 @@ class TimerFlow extends StatelessWidget {
|
||||||
MeteringInteractorProvider.of(context),
|
MeteringInteractorProvider.of(context),
|
||||||
124,
|
124,
|
||||||
),
|
),
|
||||||
child: const TimerScreen(),
|
child: const TimerScreen(
|
||||||
|
duration: const Duration(seconds: 124),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,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 {
|
||||||
const TimerScreen({super.key});
|
final Duration duration;
|
||||||
|
|
||||||
|
const TimerScreen({required this.duration, super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<TimerScreen> createState() => _TimerScreenState();
|
State<TimerScreen> createState() => _TimerScreenState();
|
||||||
|
@ -26,11 +28,11 @@ class _TimerScreenState extends State<TimerScreen> with TickerProviderStateMixin
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
timelineController = AnimationController(vsync: this, duration: Dimens.durationS);
|
timelineController = AnimationController(vsync: this, duration: widget.duration);
|
||||||
timelineAnimation = Tween<double>(begin: 0.0, end: 1.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);
|
||||||
startStopIconAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(startStopIconController);
|
startStopIconAnimation = Tween<double>(begin: 0, end: 1).animate(startStopIconController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -75,24 +77,23 @@ class _TimerScreenState extends State<TimerScreen> with TickerProviderStateMixin
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// SizedBox.fromSize(
|
SizedBox.fromSize(
|
||||||
// size: Size.square(MediaQuery.sizeOf(context).width - Dimens.paddingL * 4),
|
size: Size.square(MediaQuery.sizeOf(context).width - Dimens.paddingL * 4),
|
||||||
// child: BlocBuilder<TimerBloc, TimerState>(
|
child: ValueListenableBuilder(
|
||||||
// builder: (context, state) {
|
valueListenable: timelineAnimation,
|
||||||
// return _Timer(
|
builder: (_, value, child) => _TimerTimeline(
|
||||||
// timeLeft: state.timeLeft,
|
progress: value,
|
||||||
// duration: state.duration,
|
child: child!,
|
||||||
// );
|
),
|
||||||
// },
|
child: BlocBuilder<TimerBloc, TimerState>(
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
BlocBuilder<TimerBloc, TimerState>(
|
|
||||||
buildWhen: (previous, current) => previous.timeLeft != current.timeLeft,
|
buildWhen: (previous, current) => previous.timeLeft != current.timeLeft,
|
||||||
builder: (_, state) => _Timer(
|
builder: (_, state) => _Timer(
|
||||||
timeLeft: state.timeLeft,
|
timeLeft: state.timeLeft,
|
||||||
duration: state.duration,
|
duration: state.duration,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
BlocBuilder<TimerBloc, TimerState>(
|
BlocBuilder<TimerBloc, TimerState>(
|
||||||
builder: (_, state) => FloatingActionButton(
|
builder: (_, state) => FloatingActionButton(
|
||||||
|
@ -120,8 +121,10 @@ class _TimerScreenState extends State<TimerScreen> with TickerProviderStateMixin
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case TimerResumedState():
|
case TimerResumedState():
|
||||||
startStopIconController.forward();
|
startStopIconController.forward();
|
||||||
|
timelineController.forward();
|
||||||
case TimerStoppedState():
|
case TimerStoppedState():
|
||||||
startStopIconController.reverse();
|
startStopIconController.reverse();
|
||||||
|
timelineController.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue