stack_wallet/lib/widgets/desktop/living_stack_icon.dart

67 lines
1.5 KiB
Dart
Raw Normal View History

import 'dart:io';
2022-11-28 20:25:49 +00:00
import 'package:flutter/material.dart';
2023-04-25 22:07:28 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
2022-11-28 20:25:49 +00:00
import 'package:flutter_svg/flutter_svg.dart';
2023-04-25 22:07:28 +00:00
import 'package:stackwallet/themes/theme_providers.dart';
2022-11-28 20:25:49 +00:00
2023-04-25 22:07:28 +00:00
class LivingStackIcon extends ConsumerStatefulWidget {
const LivingStackIcon({
Key? key,
this.onPressed,
}) : super(key: key);
2022-11-28 20:25:49 +00:00
final VoidCallback? onPressed;
@override
2023-04-25 22:07:28 +00:00
ConsumerState<LivingStackIcon> createState() => _LivingStackIconState();
2022-11-28 20:25:49 +00:00
}
2023-04-25 22:07:28 +00:00
class _LivingStackIconState extends ConsumerState<LivingStackIcon> {
2022-11-28 20:25:49 +00:00
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.file(
File(
ref.watch(
themeProvider.select(
(value) => value.assets.stackIcon,
),
2023-04-25 22:07:28 +00:00
),
),
2022-11-28 20:25:49 +00:00
),
),
),
),
);
}
}