2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/gestures.dart';
|
2022-09-22 23:48:50 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:stackwallet/providers/ui/color_theme_provider.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
|
2022-09-22 23:48:50 +00:00
|
|
|
class BlueTextButton extends ConsumerStatefulWidget {
|
2022-11-02 21:03:14 +00:00
|
|
|
const BlueTextButton({
|
|
|
|
Key? key,
|
|
|
|
required this.text,
|
|
|
|
this.onTap,
|
|
|
|
this.enabled = true,
|
|
|
|
}) : super(key: key);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final String text;
|
|
|
|
final VoidCallback? onTap;
|
2022-11-02 21:03:14 +00:00
|
|
|
final bool enabled;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
2022-09-22 23:48:50 +00:00
|
|
|
ConsumerState<BlueTextButton> createState() => _BlueTextButtonState();
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
|
2022-09-22 23:48:50 +00:00
|
|
|
class _BlueTextButtonState extends ConsumerState<BlueTextButton>
|
2022-08-26 08:11:35 +00:00
|
|
|
with SingleTickerProviderStateMixin {
|
2022-11-02 21:03:14 +00:00
|
|
|
AnimationController? controller;
|
|
|
|
Animation<dynamic>? animation;
|
2022-08-26 08:11:35 +00:00
|
|
|
late Color color;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
2022-11-02 21:03:14 +00:00
|
|
|
if (widget.enabled) {
|
|
|
|
color = ref.read(colorThemeProvider.state).state.buttonTextBorderless;
|
|
|
|
controller = AnimationController(
|
|
|
|
vsync: this,
|
|
|
|
duration: const Duration(milliseconds: 100),
|
|
|
|
);
|
|
|
|
animation = ColorTween(
|
|
|
|
begin: ref.read(colorThemeProvider.state).state.buttonTextBorderless,
|
|
|
|
end: ref
|
|
|
|
.read(colorThemeProvider.state)
|
|
|
|
.state
|
|
|
|
.buttonTextBorderless
|
|
|
|
.withOpacity(0.4),
|
|
|
|
).animate(controller!);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2022-11-02 21:03:14 +00:00
|
|
|
animation!.addListener(() {
|
|
|
|
setState(() {
|
|
|
|
color = animation!.value as Color;
|
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
});
|
2022-11-02 21:03:14 +00:00
|
|
|
} else {
|
|
|
|
color = ref.read(colorThemeProvider.state).state.textSubtitle1;
|
|
|
|
}
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
2022-11-02 21:03:14 +00:00
|
|
|
controller?.dispose();
|
2022-08-26 08:11:35 +00:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return RichText(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
text: TextSpan(
|
|
|
|
text: widget.text,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.link2(context).copyWith(color: color),
|
2022-11-02 21:03:14 +00:00
|
|
|
recognizer: widget.enabled
|
|
|
|
? (TapGestureRecognizer()
|
|
|
|
..onTap = () {
|
|
|
|
widget.onTap?.call();
|
|
|
|
controller?.forward().then((value) => controller?.reverse());
|
|
|
|
})
|
|
|
|
: null,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|