mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Refactored PowerClampPhase
to be more readable by extracting widgets into helper private methods to enhance readability.
This commit is contained in:
@ -12,6 +12,7 @@ class PowerClampPhase extends StatelessWidget {
|
||||
required this.value,
|
||||
this.unit,
|
||||
});
|
||||
|
||||
final String iconPath;
|
||||
final String title;
|
||||
final String value;
|
||||
@ -23,21 +24,14 @@ class PowerClampPhase extends StatelessWidget {
|
||||
flex: 5,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 4),
|
||||
decoration: containerWhiteDecoration.copyWith(
|
||||
boxShadow: const [],
|
||||
),
|
||||
decoration: containerWhiteDecoration.copyWith(boxShadow: const []),
|
||||
padding: const EdgeInsetsDirectional.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
Expanded(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: SvgPicture.asset(iconPath),
|
||||
),
|
||||
),
|
||||
_buildIcon(),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Column(
|
||||
@ -45,52 +39,8 @@ class PowerClampPhase extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Expanded(
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
title,
|
||||
style: context.textTheme.titleSmall?.copyWith(
|
||||
color: ColorsManager.lightGreyColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.textPrimaryColor.withValues(
|
||||
alpha: 0.83,
|
||||
),
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: '$value '),
|
||||
if (unit != null)
|
||||
TextSpan(
|
||||
text: unit,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.textPrimaryColor.withValues(
|
||||
alpha: 0.83,
|
||||
),
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildTitle(context),
|
||||
_buildValue(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -99,4 +49,67 @@ class PowerClampPhase extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValue(BuildContext context) {
|
||||
final textStyle = context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.textPrimaryColor.withValues(
|
||||
alpha: 0.83,
|
||||
),
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15,
|
||||
);
|
||||
|
||||
return Expanded(
|
||||
flex: 2,
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
style: textStyle,
|
||||
children: [
|
||||
TextSpan(text: '$value '),
|
||||
if (unit != null)
|
||||
TextSpan(
|
||||
text: unit,
|
||||
style: textStyle?.copyWith(
|
||||
color: ColorsManager.textPrimaryColor.withValues(
|
||||
alpha: 0.83,
|
||||
),
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTitle(BuildContext context) {
|
||||
return Expanded(
|
||||
child: FittedBox(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
title,
|
||||
style: context.textTheme.titleSmall?.copyWith(
|
||||
color: ColorsManager.lightGreyColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIcon() {
|
||||
return Expanded(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: SvgPicture.asset(iconPath),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user