From 07ba82ace03b121844c8293a346e9fec6c1a7445 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 29 Nov 2022 12:08:10 -0600 Subject: [PATCH] desktop hover color for blue text button --- .../custom_buttons/blue_text_button.dart | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/lib/widgets/custom_buttons/blue_text_button.dart b/lib/widgets/custom_buttons/blue_text_button.dart index a87d1e6b2..7877ddcde 100644 --- a/lib/widgets/custom_buttons/blue_text_button.dart +++ b/lib/widgets/custom_buttons/blue_text_button.dart @@ -3,6 +3,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; class BlueTextButton extends ConsumerStatefulWidget { const BlueTextButton({ @@ -28,6 +32,8 @@ class _BlueTextButtonState extends ConsumerState Animation? animation; late Color color; + bool _hovering = false; + @override void initState() { if (widget.enabled) { @@ -65,25 +71,47 @@ class _BlueTextButtonState extends ConsumerState @override Widget build(BuildContext context) { - return RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: widget.text, - style: widget.textSize == null - ? STextStyles.link2(context).copyWith( - color: color, - ) - : STextStyles.link2(context).copyWith( - color: color, - fontSize: widget.textSize, - ), - recognizer: widget.enabled - ? (TapGestureRecognizer() - ..onTap = () { - widget.onTap?.call(); - controller?.forward().then((value) => controller?.reverse()); - }) - : null, + return ConditionalParent( + condition: Util.isDesktop, + builder: (child) { + return MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (_) => setState(() => _hovering = true), + onExit: (_) => setState(() => _hovering = false), + child: GestureDetector( + onTap: widget.onTap, + child: RoundedContainer( + radiusMultiplier: 20, + padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10), + color: Theme.of(context) + .extension()! + .highlight + .withOpacity(_hovering ? 0.3 : 0), + child: child, + ), + ), + ); + }, + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: widget.text, + style: widget.textSize == null + ? STextStyles.link2(context).copyWith( + color: color, + ) + : STextStyles.link2(context).copyWith( + color: color, + fontSize: widget.textSize, + ), + recognizer: widget.enabled + ? (TapGestureRecognizer() + ..onTap = () { + widget.onTap?.call(); + controller?.forward().then((value) => controller?.reverse()); + }) + : null, + ), ), ); }