78 lines
2.4 KiB
Dart
78 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:rasadyar_app/presentation/common/app_color.dart';
|
|
import 'package:rasadyar_app/presentation/common/app_fonts.dart';
|
|
|
|
class RTextButton extends StatefulWidget {
|
|
RTextButton({
|
|
super.key,
|
|
required this.text,
|
|
required this.onPressed,
|
|
foregroundColor,
|
|
backgroundColor,
|
|
borderColor,
|
|
disabledBackgroundColor,
|
|
radius,
|
|
textStyle,
|
|
this.width = 150.0,
|
|
this.height = 56.0,
|
|
});
|
|
|
|
final String text;
|
|
final VoidCallback? onPressed;
|
|
final double width;
|
|
final double height;
|
|
Color? foregroundColor;
|
|
Color? backgroundColor;
|
|
Color? borderColor;
|
|
|
|
Color? disabledBackgroundColor;
|
|
double? radius;
|
|
TextStyle? textStyle;
|
|
|
|
@override
|
|
State<RTextButton> createState() => _RTextButtonState();
|
|
}
|
|
|
|
class _RTextButtonState extends State<RTextButton> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TextButton(
|
|
style: ButtonStyle(
|
|
side: WidgetStatePropertyAll(BorderSide.none),
|
|
backgroundColor: WidgetStateProperty.resolveWith<Color?>((states) {
|
|
if (states.contains(WidgetState.pressed)) {
|
|
return widget.backgroundColor ?? AppColor.blueNormal;
|
|
} else if (states.contains(WidgetState.hovered)) {
|
|
return widget.backgroundColor?.withAlpha(38) ?? AppColor.blueNormal.withAlpha(38);
|
|
} else if (states.contains(WidgetState.disabled)) {
|
|
return widget.disabledBackgroundColor ?? Colors.transparent;
|
|
}
|
|
return Colors.transparent;
|
|
}),
|
|
foregroundColor: WidgetStateProperty.resolveWith<Color?>((states) {
|
|
if (states.contains(WidgetState.pressed)) {
|
|
return Colors.white;
|
|
} else if (states.contains(WidgetState.disabled)) {
|
|
return AppColor.blueNormal.withAlpha(38);
|
|
}
|
|
return AppColor.blueNormal;
|
|
}),
|
|
|
|
shape: WidgetStatePropertyAll(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(widget.radius ?? 8),
|
|
),
|
|
),
|
|
fixedSize: WidgetStatePropertyAll(Size(widget.width, widget.height)),
|
|
padding: WidgetStatePropertyAll(EdgeInsets.zero),
|
|
textStyle: WidgetStatePropertyAll(
|
|
widget.textStyle ??
|
|
AppFonts.yekan24Regular.copyWith(color: AppColor.blueNormal),
|
|
),
|
|
),
|
|
onPressed:widget.onPressed,
|
|
child: Text(widget.text),
|
|
);
|
|
}
|
|
}
|