desktop hover color for blue text button

This commit is contained in:
julian 2022-11-29 12:08:10 -06:00
parent 1623a4a63c
commit 07ba82ace0

View file

@ -3,6 +3,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/providers/ui/color_theme_provider.dart';
import 'package:stackwallet/utilities/text_styles.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 { class BlueTextButton extends ConsumerStatefulWidget {
const BlueTextButton({ const BlueTextButton({
@ -28,6 +32,8 @@ class _BlueTextButtonState extends ConsumerState<BlueTextButton>
Animation<dynamic>? animation; Animation<dynamic>? animation;
late Color color; late Color color;
bool _hovering = false;
@override @override
void initState() { void initState() {
if (widget.enabled) { if (widget.enabled) {
@ -65,7 +71,28 @@ class _BlueTextButtonState extends ConsumerState<BlueTextButton>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RichText( 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<StackColors>()!
.highlight
.withOpacity(_hovering ? 0.3 : 0),
child: child,
),
),
);
},
child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
text: widget.text, text: widget.text,
@ -85,6 +112,7 @@ class _BlueTextButtonState extends ConsumerState<BlueTextButton>
}) })
: null, : null,
), ),
),
); );
} }
} }