@@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart';
33
44import '../api/model/model.dart' ;
55import '../model/emoji.dart' ;
6+ import '../model/settings.dart' ;
67import 'content.dart' ;
78
89/// A widget showing an emoji.
@@ -13,7 +14,7 @@ class EmojiWidget extends StatelessWidget {
1314 required this .squareDimension,
1415 this .squareDimensionScaler = TextScaler .noScaling,
1516 this .imagePlaceholderStyle = EmojiImagePlaceholderStyle .square,
16- this .neverAnimateImage = false ,
17+ this .imageAnimationMode = ImageAnimationMode .animateConditionally ,
1718 this .buildCustomTextEmoji,
1819 });
1920
@@ -35,11 +36,12 @@ class EmojiWidget extends StatelessWidget {
3536
3637 final EmojiImagePlaceholderStyle imagePlaceholderStyle;
3738
38- /// Whether to show an animated emoji in its still (non-animated) variant
39- /// only, even if device settings permit animation.
39+ /// Whether to show an animated emoji in its still or animated version.
4040 ///
41- /// Defaults to false.
42- final bool neverAnimateImage;
41+ /// Ignored except for animated image emoji.
42+ ///
43+ /// Defaults to [ImageAnimationMode.animateConditionally] .
44+ final ImageAnimationMode imageAnimationMode;
4345
4446 /// An optional callback to specify a custom plain-text emoji style.
4547 ///
@@ -66,7 +68,7 @@ class EmojiWidget extends StatelessWidget {
6668 EmojiImagePlaceholderStyle .nothing => SizedBox .shrink (),
6769 EmojiImagePlaceholderStyle .text => _buildTextEmoji (),
6870 },
69- neverAnimate : neverAnimateImage ),
71+ animationMode : imageAnimationMode ),
7072 UnicodeEmojiDisplay () => UnicodeEmojiWidget (
7173 emojiDisplay: emojiDisplay,
7274 size: squareDimension,
@@ -185,7 +187,7 @@ class ImageEmojiWidget extends StatelessWidget {
185187 required this .size,
186188 this .textScaler = TextScaler .noScaling,
187189 this .errorBuilder,
188- this .neverAnimate = false ,
190+ this .animationMode = ImageAnimationMode .animateConditionally ,
189191 });
190192
191193 final ImageEmojiDisplay emojiDisplay;
@@ -202,30 +204,20 @@ class ImageEmojiWidget extends StatelessWidget {
202204
203205 final ImageErrorWidgetBuilder ? errorBuilder;
204206
205- /// Whether to show an animated emoji in its still (non-animated) variant
206- /// only, even if device settings permit animation.
207+ /// Whether to show an animated emoji in its still or animated version.
208+ ///
209+ /// Ignored for non-animated emoji.
207210 ///
208- /// Defaults to false .
209- final bool neverAnimate ;
211+ /// Defaults to [ImageAnimationMode.animateConditionally] .
212+ final ImageAnimationMode animationMode ;
210213
211214 @override
212215 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-
224216 final size = textScaler.scale (this .size);
225217
226- final resolvedUrl = doNotAnimate
227- ? ( emojiDisplay.resolvedStillUrl ?? emojiDisplay. resolvedUrl)
228- : emojiDisplay.resolvedUrl;
218+ final resolvedUrl = animationMode. resolve (context)
219+ ? emojiDisplay.resolvedUrl
220+ : ( emojiDisplay.resolvedStillUrl ?? emojiDisplay. resolvedUrl) ;
229221
230222 return RealmContentNetworkImage (
231223 width: size, height: size,
0 commit comments