@@ -13,7 +13,7 @@ class EmojiWidget extends StatelessWidget {
1313 required this .squareDimension,
1414 this .squareDimensionScaler = TextScaler .noScaling,
1515 this .imagePlaceholderStyle = EmojiImagePlaceholderStyle .square,
16- this .neverAnimateImage = false ,
16+ this .imageAnimationMode = ImageAnimationMode .animateConditionally ,
1717 this .buildCustomTextEmoji,
1818 });
1919
@@ -35,11 +35,12 @@ class EmojiWidget extends StatelessWidget {
3535
3636 final EmojiImagePlaceholderStyle imagePlaceholderStyle;
3737
38- /// Whether to show an animated emoji in its still (non-animated) variant
39- /// only, even if device settings permit animation.
38+ /// Whether to show an animated emoji in its still or animated version.
4039 ///
41- /// Defaults to false.
42- final bool neverAnimateImage;
40+ /// Ignored except for animated image emoji.
41+ ///
42+ /// Defaults to [ImageAnimationMode.animateConditionally] .
43+ final ImageAnimationMode imageAnimationMode;
4344
4445 /// An optional callback to specify a custom plain-text emoji style.
4546 ///
@@ -66,7 +67,7 @@ class EmojiWidget extends StatelessWidget {
6667 EmojiImagePlaceholderStyle .nothing => SizedBox .shrink (),
6768 EmojiImagePlaceholderStyle .text => _buildTextEmoji (),
6869 },
69- neverAnimate : neverAnimateImage ),
70+ animationMode : imageAnimationMode ),
7071 UnicodeEmojiDisplay () => UnicodeEmojiWidget (
7172 emojiDisplay: emojiDisplay,
7273 size: squareDimension,
@@ -185,7 +186,7 @@ class ImageEmojiWidget extends StatelessWidget {
185186 required this .size,
186187 this .textScaler = TextScaler .noScaling,
187188 this .errorBuilder,
188- this .neverAnimate = false ,
189+ this .animationMode = ImageAnimationMode .animateConditionally ,
189190 });
190191
191192 final ImageEmojiDisplay emojiDisplay;
@@ -202,30 +203,20 @@ class ImageEmojiWidget extends StatelessWidget {
202203
203204 final ImageErrorWidgetBuilder ? errorBuilder;
204205
205- /// Whether to show an animated emoji in its still (non-animated) variant
206- /// only, even if device settings permit animation.
206+ /// Whether to show an animated emoji in its still or animated version.
207+ ///
208+ /// Ignored for non-animated emoji.
207209 ///
208- /// Defaults to false .
209- final bool neverAnimate ;
210+ /// Defaults to [ImageAnimationMode.animateConditionally] .
211+ final ImageAnimationMode animationMode ;
210212
211213 @override
212214 Widget build (BuildContext context) {
213- final doNotAnimate =
214- neverAnimate
215- // From reading code, this doesn't actually get set on iOS:
216- // https://github.com/zulip/zulip-flutter/pull/410#discussion_r1408522293
217- || MediaQuery .disableAnimationsOf (context)
218- || (defaultTargetPlatform == TargetPlatform .iOS
219- // TODO(#1924) On iOS 17+ (new in 2023), there's a more closely
220- // relevant setting than "reduce motion". It's called "auto-play
221- // animated images"; we should use that once Flutter exposes it.
222- && WidgetsBinding .instance.platformDispatcher.accessibilityFeatures.reduceMotion);
223-
224215 final size = textScaler.scale (this .size);
225216
226- final resolvedUrl = doNotAnimate
227- ? ( emojiDisplay.resolvedStillUrl ?? emojiDisplay. resolvedUrl)
228- : emojiDisplay.resolvedUrl;
217+ final resolvedUrl = animationMode. resolve (context)
218+ ? emojiDisplay.resolvedUrl
219+ : ( emojiDisplay.resolvedStillUrl ?? emojiDisplay. resolvedUrl) ;
229220
230221 return RealmContentNetworkImage (
231222 width: size, height: size,
0 commit comments