Line data Source code
1 : import 'package:application_icon/application_icon.dart';
2 : import 'package:flutter/material.dart';
3 : import 'package:flutter/services.dart';
4 : import 'package:pal/src/theme.dart';
5 : import 'package:pal/src/ui/shared/widgets/circle_button.dart';
6 :
7 : class AnimatedAppIcon extends AnimatedWidget {
8 : final double radius;
9 : final Function onTap;
10 : final bool isSendingAppIcon;
11 : final AnimationController animationController;
12 : final bool testMode;
13 :
14 1 : AnimatedAppIcon({
15 : Key key,
16 : @required this.radius,
17 : @required this.animationController,
18 : this.onTap,
19 : this.isSendingAppIcon = false,
20 : this.testMode = false,
21 1 : }) : super(key: key, listenable: animationController);
22 :
23 1 : @override
24 : Widget build(BuildContext context) {
25 1 : return ScaleTransition(
26 2 : scale: Tween(begin: 0.0, end: 1.0).animate(
27 1 : CurvedAnimation(
28 1 : parent: animationController,
29 : curve: Curves.elasticOut,
30 : ),
31 : ),
32 1 : child: Container(
33 2 : width: radius * 2,
34 2 : height: radius * 2,
35 1 : decoration: BoxDecoration(
36 : shape: BoxShape.circle,
37 1 : boxShadow: [
38 1 : BoxShadow(
39 1 : color: Colors.black.withOpacity(0.15),
40 : spreadRadius: 4,
41 : blurRadius: 4,
42 1 : offset: Offset(0, 2),
43 : ),
44 : ],
45 : ),
46 1 : child: Stack(
47 1 : children: [
48 3 : ClipOval(child: !testMode ? AppIconImage() : Container()),
49 1 : Align(
50 : alignment: Alignment.bottomRight,
51 1 : child: CircleIconButton(
52 1 : key: ValueKey(
53 : 'pal_AppSettingsPage_AnimatedAppIcon_RefreshButton'),
54 1 : isLoading: isSendingAppIcon,
55 1 : icon: Icon(
56 : Icons.refresh,
57 3 : color: PalTheme.of(context).colors.light,
58 : ),
59 3 : backgroundColor: PalTheme.of(context).colors.dark,
60 1 : onTapCallback: !isSendingAppIcon
61 1 : ? () {
62 1 : if (onTap != null) {
63 1 : HapticFeedback.selectionClick();
64 2 : onTap();
65 : }
66 : }
67 : : null,
68 : ),
69 : )
70 : ],
71 : ),
72 : ),
73 : );
74 : }
75 : }
|