APP_NEW/lib/Component/Button/my_text_button.dart
2025-03-11 21:17:14 +08:00

102 lines
2.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lamiter/Extension/build_context.dart';
class MyTextButton extends StatelessWidget {
final double width;
final double height;
final Widget? prefixIcon;
final String text;
final double fontSize;
final bool enabled;
final Function()? onTap;
final Color? backgroundColor;
final Color? fontColor;
const MyTextButton({
super.key,
required this.width,
required this.height,
this.prefixIcon,
required this.text,
required this.fontSize,
required this.enabled,
this.onTap,
this.backgroundColor,
this.fontColor,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: enabled ? onTap : null,
child: Container(
width: width,
height: height,
decoration: BoxDecoration(
color: enabled
? backgroundColor ?? context.inverseSurface
: backgroundColor != null
? backgroundColor!.withOpacity(0.25)
: context.primary,
borderRadius: BorderRadius.circular(32.sp),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding:
EdgeInsets.only(right: prefixIcon != null ? 12.sp : 0.sp),
child: prefixIcon,
),
Text(
text,
style: context.lM!.copyWith(
fontSize: fontSize,
fontWeight: FontWeight.w900,
letterSpacing: 2.sp,
color: fontColor != null
? fontColor!.withOpacity(enabled ? 1 : 0.5)
: context.surface.withOpacity(enabled ? 1 : 0.5),
),
),
],
),
),
);
}
}
// class ValidatingButton extends StatelessWidget {
// final double width;
// final double height;
// final double borderRadius;
// const ValidatingButton({
// super.key,
// required this.width,
// required this.height,
// required this.borderRadius,
// });
// @override
// Widget build(BuildContext context) {
// return Align(
// child: Container(
// width: width,
// height: height,
// decoration: BoxDecoration(
// color: context.inverseSurface,
// borderRadius: BorderRadius.circular(borderRadius),
// ),
// child: Align(
// alignment: Alignment.center,
// child: CupertinoActivityIndicator(
// color: context.surface,
// ),
// ),
// ),
// );
// }
// }