62 lines
1.6 KiB
Dart
62 lines
1.6 KiB
Dart
import 'package:chat/configs/app_colors.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class CustomPrimaryButton extends StatelessWidget {
|
|
final VoidCallback? onPressed;
|
|
final String text;
|
|
final double padding;
|
|
|
|
const CustomPrimaryButton({
|
|
Key? key,
|
|
required this.text,
|
|
this.onPressed,
|
|
this.padding = 0,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
onPressed: onPressed,
|
|
style: ButtonStyle(
|
|
padding: MaterialStateProperty.resolveWith(
|
|
(states) {
|
|
return EdgeInsets.all(padding);
|
|
},
|
|
),
|
|
shape: MaterialStateProperty.all(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(32),
|
|
),
|
|
),
|
|
backgroundColor: MaterialStateProperty.resolveWith(
|
|
(states) {
|
|
if (states.contains(MaterialState.disabled)) {
|
|
return AppColors.primary.withAlpha(128);
|
|
} else {
|
|
return AppColors.primary;
|
|
}
|
|
},
|
|
),
|
|
foregroundColor: MaterialStateProperty.resolveWith(
|
|
(states) {
|
|
if (states.contains(MaterialState.disabled)) {
|
|
return AppColors.white;
|
|
} else {
|
|
return AppColors.white;
|
|
}
|
|
},
|
|
),
|
|
),
|
|
child: Text(
|
|
text,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|