Skip to content

Commit

Permalink
Replacing lottie scanning animation with cleaner shimmer
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFreal committed Jun 27, 2024
1 parent 8567ef8 commit 12d6391
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/scooter_visual.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:shimmer/shimmer.dart';
import 'package:unustasis/domain/scooter_state.dart';
import 'package:unustasis/domain/theme_helper.dart';

Expand Down Expand Up @@ -36,8 +36,18 @@ class ScooterVisual extends StatelessWidget {
children: [
AnimatedCrossFade(
duration: const Duration(milliseconds: 500),
firstChild: Opacity(
opacity: (context.isDarkMode ? 0.8 : 0.4),
firstChild: Shimmer.fromColors(
baseColor: context.isDarkMode
? (scanning ? Colors.black54 : Colors.black)
: Colors.black26,
highlightColor: scanning
? Colors.transparent
: context.isDarkMode
? Colors.black
: Colors.black26,
enabled: scanning,
direction: ShimmerDirection.ltr,
period: const Duration(seconds: 2),
child: const Image(
image: AssetImage("images/scooter/disconnected.webp"),
),
Expand Down Expand Up @@ -70,15 +80,6 @@ class ScooterVisual extends StatelessWidget {
],
),
),
AnimatedOpacity(
opacity: scanning ? 1 : 0,
duration: const Duration(milliseconds: 600),
child: Lottie.asset(
"assets/anim/scanning.json",
fit: BoxFit.contain,
width: 160,
),
),
//BlinkerWidget(blinkerLeft: blinkerLeft, blinkerRight: blinkerRight),
],
),
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
shimmer:
dependency: "direct main"
description:
name: shimmer
sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies:
lottie: ^3.1.0
flutter_native_splash: ^2.4.0
easy_dynamic_theme: ^2.3.1
shimmer: ^3.0.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 12d6391

Please sign in to comment.