spotube/lib/components/Shared/AnchorButton.dart
Kingkor Roy Tirtho 6b6907af3f feat(lyrics): tabs for both synced and static lyrics #182
refactor: remove code-style warnings
2022-10-24 17:59:58 +06:00

46 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class AnchorButton<T> extends HookWidget {
final String text;
final TextStyle style;
final TextAlign? textAlign;
final TextOverflow? overflow;
final void Function()? onTap;
const AnchorButton(
this.text, {
Key? key,
this.onTap,
this.textAlign,
this.overflow,
this.style = const TextStyle(),
}) : super(key: key);
@override
Widget build(BuildContext context) {
var hover = useState(false);
var tap = useState(false);
return GestureDetector(
onTapDown: (event) => tap.value = true,
onTapUp: (event) => tap.value = false,
onTap: onTap,
child: MouseRegion(
cursor: MaterialStateMouseCursor.clickable,
child: Text(
text,
style: style.copyWith(
decoration:
hover.value || tap.value ? TextDecoration.underline : null,
),
textAlign: textAlign,
overflow: overflow,
),
onEnter: (event) => hover.value = true,
onExit: (event) => hover.value = false,
),
);
}
}