mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-29 21:55:58 +00:00
animated desktop stack icon
This commit is contained in:
parent
1ef7e849ee
commit
c3921b01de
3 changed files with 58 additions and 4 deletions
|
@ -9,6 +9,7 @@ import 'package:stackwallet/providers/providers.dart';
|
|||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/desktop/living_stack_icon.dart';
|
||||
|
||||
enum DesktopMenuItemId {
|
||||
myStack,
|
||||
|
@ -103,9 +104,8 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
|||
AnimatedContainer(
|
||||
duration: duration,
|
||||
width: _width == expandedWidth ? 70 : 32,
|
||||
height: 70, //_width == expandedWidth ? 70 : 32,
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.stackIcon(context),
|
||||
child: LivingStackIcon(
|
||||
onPressed: toggleMinimize,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
|
|
@ -77,7 +77,7 @@ class _DesktopMenuItemState<T> extends State<DesktopMenuItem<T>>
|
|||
animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: duration,
|
||||
);
|
||||
)..forward();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
|
54
lib/widgets/desktop/living_stack_icon.dart
Normal file
54
lib/widgets/desktop/living_stack_icon.dart
Normal file
|
@ -0,0 +1,54 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
||||
class LivingStackIcon extends StatefulWidget {
|
||||
const LivingStackIcon({Key? key, this.onPressed,}) : super(key: key);
|
||||
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
State<LivingStackIcon> createState() => _LivingStackIconState();
|
||||
}
|
||||
|
||||
class _LivingStackIconState extends State<LivingStackIcon> {
|
||||
bool _hovering = false;
|
||||
|
||||
late final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
onPressed = widget.onPressed;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 76,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
onEnter: (_) {
|
||||
setState(() {
|
||||
_hovering = true;
|
||||
});
|
||||
},
|
||||
onExit: (_) {
|
||||
setState(() {
|
||||
_hovering = false;
|
||||
});
|
||||
},
|
||||
child: GestureDetector(
|
||||
onTap: () => onPressed?.call(),
|
||||
child: AnimatedScale(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
scale: _hovering ? 1.2 : 1,
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.stackIcon(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue