From 05a1328b1d997f81560b5e8ab351cfe0d5bedf28 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Fri, 8 Dec 2023 23:04:01 +0100 Subject: [PATCH] feat: Support light and dark modes for the eye animation (#4885) * Support light and dark modes for the eye animation * Minor fix * Reformat file * Refix --- packages/smooth_app/assets/animations/off.riv | Bin 76231 -> 90039 bytes .../lib/resources/app_animations.dart | 40 ++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/smooth_app/assets/animations/off.riv b/packages/smooth_app/assets/animations/off.riv index e50fb6faefc7bfb6145868e51d3c33ef7f833a6a..684ff082552b07ace37f94b4365ff177529775ec 100644 GIT binary patch delta 14847 zcma)j3s@CZ*Z&;gh#Uj~kHRszsUW1{<%mjp&dh)c-cocfmXx7+RJ;I2^$FE@L*Kli zPKuCPzF_s1;f3DhEn#LrEfcIhP1LkH`eqhbX@O;#|F!na0j&H#pU=Z_?b&Ouz4qE` z{r1{>&wOy&=dfbl+*kh9);HLvYjSp8UiRY2ne&z`a4nd-R1WW%<=ZJ`!O}U4=2mX* zx!vUBJ$BjL%7k8}-jdIl%%uyHOq9(&fa;kTL&c0S&7dgiEQZ4qzoQo8b?vD zGV;HY66JMCz2%!padO^6gJtHSVWuwf)T9_WUqT_v zsG<4WyyW_7hndCdY*{yeLfJYZpP8&4`qm#PJuI>x`{6KgJ6*0yn*LRPS`}9bao4b#YvwDn> z-|q3eA9k(Rjt%WEKNuPz=Y%H7eqoN{k-lJxZ$i7uM?=TTyYciNU@Sh zSx$p&ll*wzUzn?A=9qcRi4bd6M!>lYMVcbksDV=hI#2~ z>e7i%5g#*E2CmvZK;C`8DUUiZM=sxAEDHw<?2oS43%$Pd`LcWs9WWjOF?FH9}pQNAGq9G z-hX+z%v~NP@BO)}JnTwvW$!DUO@DE}r2kIxlXqVal~-N2flu@(u821UO1f_nH#PbA zOv;{@?MqS5kLgS;e&U33g3Mk~CaRO!JFKC;hh~c`4AnRoCdF4pB(cKhUB@$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tVW!M}QB>ePXTX)wf{a=C=!*q#IChwtpNp;0yo_0yXp4pMXnV0u4n!d$ zC4(V3Lh&&Qhe7?Seae`rA8MiM$?cp7tkIEJ&$Spbu0&WtBWy5-5>;kW!Dy{ zm(`oaI61ix-<>SP-zICULT$39L9(R=uVts5NL73F5u|LoCuwL7)9gHe%5Dp3m32D?ehU7+H2HHlFtjKZ#S=`r { } } -class SearchEyeAnimation extends StatelessWidget { +class SearchEyeAnimation extends StatefulWidget { const SearchEyeAnimation({ this.size, super.key, @@ -140,20 +141,41 @@ class SearchEyeAnimation extends StatelessWidget { final double? size; + @override + State createState() => _SearchEyeAnimationState(); +} + +class _SearchEyeAnimationState extends State { + StateMachineController? _controller; + @override Widget build(BuildContext context) { - final double size = this.size ?? IconTheme.of(context).size ?? 24.0; + final double size = widget.size ?? IconTheme.of(context).size ?? 24.0; + final bool lightTheme = context.watch().isLightTheme; + + return ExcludeSemantics( + child: SizedBox( + width: size, + height: (80 / 87) * size, + child: RiveAnimation.direct(AnimationsLoader.of(context), + artboard: 'Search eye', onInit: (Artboard artboard) { + _controller = StateMachineController.fromArtboard( + artboard, + 'LoopMachine', + ); - return SizedBox( - width: size, - height: (80 / 87) * size, - child: RiveAnimation.direct( - AnimationsLoader.of(context), - artboard: 'Search eye', - stateMachines: const ['LoopMachine'], + artboard.addController(_controller!); + _controller!.findInput('light')?.value = !lightTheme; + }), ), ); } + + @override + void dispose() { + _controller?.dispose(); + super.dispose(); + } } class SearchAnimation extends StatefulWidget {