update animation

This commit is contained in:
julian 2023-09-20 19:17:47 -06:00
parent 758392ede4
commit 9f10b4db5d

View file

@ -246,9 +246,17 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
} }
} }
Future<void> _playConnecting() async { Future<void> _playPlug() async {
await _play( await _play(
from: "connecting-start", from: "0.0",
to: "connecting-start",
repeat: false,
);
}
Future<void> _playConnecting({double? start}) async {
await _play(
from: start?.toString() ?? "connecting-start",
to: "connecting-end", to: "connecting-end",
repeat: true, repeat: true,
); );
@ -256,7 +264,7 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
Future<void> _playConnectingDone() async { Future<void> _playConnectingDone() async {
await _play( await _play(
from: "connecting-end", from: "${controller1.value}",
to: "connected-start", to: "connected-start",
repeat: false, repeat: false,
); );
@ -285,7 +293,7 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
required bool repeat, required bool repeat,
}) async { }) async {
final composition = await _completer.future; final composition = await _completer.future;
final start = composition.getMarker(from)!.start; final start = double.tryParse(from) ?? composition.getMarker(from)!.start;
final end = composition.getMarker(to)!.start; final end = composition.getMarker(to)!.start;
controller1.value = start; controller1.value = start;
@ -326,7 +334,6 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// TODO: modify size (waiting for updated onion lottie animation file)
final width = MediaQuery.of(context).size.width / 1.5; final width = MediaQuery.of(context).size.width / 1.5;
return TorSubscription( return TorSubscription(
@ -343,6 +350,7 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
break; break;
case TorConnectionStatus.connecting: case TorConnectionStatus.connecting:
await _playPlug();
await _playConnecting(); await _playConnecting();
break; break;
} }