Files
tm_app/lib/views/login/widgets/login_button.dart
T
2025-08-10 14:42:04 +03:30

87 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/constants/strings.dart';
import '../../../core/theme/colors.dart';
import '../../../core/utils/size_config.dart';
class BaseButton extends StatelessWidget {
final bool isEnabled;
final VoidCallback? onPressed;
final String? text;
final Color? textColor;
final Color? backgroundColor;
final Color? borderColor;
final double? borderWidth;
final double? borderRadius;
final double? elevation;
final double? width;
final bool isLoading;
const BaseButton({
required this.isEnabled,
required this.onPressed,
this.text,
this.textColor,
this.backgroundColor,
this.borderColor,
this.borderWidth,
this.borderRadius,
this.elevation,
this.width,
this.isLoading = false,
super.key,
});
@override
Widget build(BuildContext context) {
return isLoading
? Container(
width: double.infinity,
height: 55.0.h(),
decoration: BoxDecoration(
color: AppColors.mainBlue,
borderRadius: BorderRadius.circular(28.0.w()),
),
child: Center(
child: SizedBox(
width: 30.0.w(),
height: 30.0.w(),
child: CircularProgressIndicator(
strokeWidth: 4.0,
color: AppColors.white,
),
),
),
)
: SizedBox(
width: width ?? double.infinity,
height: 55.0.h(),
child: ElevatedButton(
onPressed: isEnabled ? onPressed : null,
style: ElevatedButton.styleFrom(
backgroundColor:
backgroundColor ??
(isEnabled ? AppColors.mainBlue : AppColors.backgroundColor),
foregroundColor: textColor ?? AppColors.backgroundColor,
elevation: elevation ?? 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius ?? 28.0.w()),
side: BorderSide(
color: borderColor ?? Colors.transparent,
width: borderWidth ?? 0,
),
),
),
child: Text(
text ?? AppStrings.loginButton,
style: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.bold,
color: textColor ?? AppColors.backgroundColor,
),
),
),
);
}
}