mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 18:29:39 +00:00
add disabled state to ButtonContentWidget, When disabled, the entire button becomes opaque
This commit is contained in:
@ -6,55 +6,64 @@ class ButtonContentWidget extends StatelessWidget {
|
|||||||
final IconData? icon;
|
final IconData? icon;
|
||||||
final String label;
|
final String label;
|
||||||
final String? svgAssets;
|
final String? svgAssets;
|
||||||
|
final bool disabled;
|
||||||
|
|
||||||
const ButtonContentWidget(
|
const ButtonContentWidget({
|
||||||
{Key? key, this.icon, required this.label, this.svgAssets})
|
Key? key,
|
||||||
: super(key: key);
|
this.icon,
|
||||||
|
required this.label,
|
||||||
|
this.svgAssets,
|
||||||
|
this.disabled = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
return SizedBox(
|
return Opacity(
|
||||||
width: screenWidth * 0.25,
|
opacity: disabled ? 0.5 : 1.0,
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
decoration: BoxDecoration(
|
width: screenWidth * 0.25,
|
||||||
color: ColorsManager.textFieldGreyColor,
|
child: Container(
|
||||||
border: Border.all(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.neutralGray,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
width: 3.0,
|
border: Border.all(
|
||||||
|
color: ColorsManager.neutralGray,
|
||||||
|
width: 3.0,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(20),
|
child: Padding(
|
||||||
),
|
padding:
|
||||||
child: Padding(
|
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
|
child: Row(
|
||||||
child: Row(
|
children: [
|
||||||
children: [
|
if (icon != null)
|
||||||
if (icon != null)
|
Icon(
|
||||||
Icon(
|
icon,
|
||||||
icon,
|
color: ColorsManager.spaceColor,
|
||||||
color: ColorsManager.spaceColor,
|
),
|
||||||
),
|
if (svgAssets != null)
|
||||||
if (svgAssets != null)
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(left: 6.0),
|
||||||
padding: const EdgeInsets.only(left: 6.0),
|
child: SvgPicture.asset(
|
||||||
child: SvgPicture.asset(
|
svgAssets!,
|
||||||
svgAssets!,
|
width: screenWidth * 0.015, // Adjust icon size
|
||||||
width: screenWidth * 0.015, // Adjust icon size
|
height: screenWidth * 0.015,
|
||||||
height: screenWidth * 0.015,
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
],
|
||||||
Expanded(
|
),
|
||||||
child: Text(
|
|
||||||
label,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user