E32221335_DIGIPLUG/lib/shared/widgets/button.dart

47 lines
1.3 KiB
Dart

import 'package:digiplug/bat_theme/bat_theme.dart';
import 'package:flutter/material.dart';
// Widget tombol utama yang konsisten di seluruh aplikasi
class AppButtonPrimary extends StatelessWidget {
const AppButtonPrimary({
super.key,
this.onPressed,
required this.label,
this.btnColor,
});
final VoidCallback? onPressed;
final String label;
final Color? btnColor;
@override
Widget build(BuildContext context) {
// Mengambil data tema dari BatThemeData
var theme = BatThemeData.of(context);
// Menentukan warna latar belakang tombol
final effectiveBackgroundColor = btnColor ?? theme.buttonStyle.color;
return SizedBox(
width: double.infinity,
child: TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
foregroundColor: theme.buttonStyle.childColor,
backgroundColor: effectiveBackgroundColor,
padding: theme.buttonStyle.padding,
shape: RoundedRectangleBorder(
side: BorderSide.none,
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
label,
style: theme.typography.bodyCopyMedium
.copyWith(color: theme.buttonStyle.childColor),
),
),
);
}
}