import 'package:eitc_erm_dental_flutter/exts.dart'; import 'package:flutter/material.dart'; ///主要按钮 class MainButton extends StatelessWidget { final void Function() onPressed; final String text; final bool isOutlined; final EdgeInsets? buttonPadding; final Size? minimumSize; final Size? maximumSize; final bool fitMinimumSize; final OutlinedBorder? shape; const MainButton( {super.key, required this.text, required this.onPressed, this.buttonPadding, this.minimumSize, this.maximumSize, this.isOutlined = false, this.fitMinimumSize = false, this.shape}); @override Widget build(BuildContext context) { return isOutlined ? OutlinedButton( onPressed: onPressed, style: ButtonStyle( tapTargetSize: fitMinimumSize ? MaterialTapTargetSize.shrinkWrap : null, padding: buttonPadding == null ? null : WidgetStatePropertyAll(buttonPadding), minimumSize: minimumSize == null ? null : WidgetStatePropertyAll(minimumSize), maximumSize: maximumSize == null ? null : WidgetStatePropertyAll(maximumSize), side: WidgetStatePropertyAll( BorderSide(color: Color(0xFFD2D2D2))), shape: shape == null ? null : WidgetStatePropertyAll(shape)), child: Text( text, style: TextStyle(color: context.onSurfaceColor), )) : ElevatedButton( onPressed: onPressed, style: ButtonStyle( tapTargetSize: fitMinimumSize ? MaterialTapTargetSize.shrinkWrap : null, padding: buttonPadding == null ? null : WidgetStatePropertyAll(buttonPadding), backgroundColor: WidgetStatePropertyAll(context.primaryColor), minimumSize: minimumSize == null ? null : WidgetStatePropertyAll(minimumSize), maximumSize: maximumSize == null ? null : WidgetStatePropertyAll(maximumSize), elevation: const WidgetStatePropertyAll(0.0), shape: shape == null ? null : WidgetStatePropertyAll(shape)), child: Text( text, textAlign: TextAlign.center, style: TextStyle( color: context.onPrimaryColor, fontWeight: FontWeight.bold), )); } }