Skip to content

Commit

Permalink
chore: Do not loop gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
holzeis committed May 7, 2024
1 parent 6168453 commit 77dd96a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Binary file modified mobile/assets/error.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile/assets/info.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile/assets/success.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 21 additions & 11 deletions mobile/lib/common/task_status_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,35 @@ class _TaskStatusDialog extends State<TaskStatusDialog> {

bool timeout = false;

Image? coverImage;

@override
void dispose() {
_timeout?.cancel();
super.dispose();
_timeout?.cancel();

// we need to evict the image cache to ensure that the gif is re-run next time.
coverImage?.image.evict();
}

@override
Widget build(BuildContext context) {
bool isPending = widget.task.status == TaskStatus.pending;

// we need to evict the image cache to ensure that the gif is re-run next time.
coverImage?.image.evict();

coverImage = Image.asset(
widget.successAnim != null && widget.task.status == TaskStatus.success
? widget.successAnim!
: switch (widget.task.status) {
TaskStatus.pending => AppAnim.loading,
TaskStatus.failed => AppAnim.error,
TaskStatus.success => AppAnim.success,
},
fit: BoxFit.cover,
);

if (_timeout != null) {
// cancel already running timeout timer if we receive a new update.
_timeout!.cancel();
Expand Down Expand Up @@ -109,16 +128,7 @@ class _TaskStatusDialog extends State<TaskStatusDialog> {
decoration: const BoxDecoration(
color: Colors.white,
),
child: Image.asset(
widget.successAnim != null && widget.task.status == TaskStatus.success
? widget.successAnim!
: switch (widget.task.status) {
TaskStatus.pending => AppAnim.loading,
TaskStatus.failed => AppAnim.error,
TaskStatus.success => AppAnim.success,
},
fit: BoxFit.cover,
),
child: coverImage,
),
const SizedBox(height: 15),
if (widget.showSuccessTitle) buildTitle(widget.task.status),
Expand Down

0 comments on commit 77dd96a

Please sign in to comment.