TF-4229 refactor(label-dropdown): extract checkbox icon and label text widgets

This commit is contained in:
dab246
2026-01-07 16:14:04 +07:00
committed by Dat H. Pham
parent cc8ba39d19
commit 916fee92c4
@@ -93,32 +93,68 @@ class _LabelDropdownMenuItem extends StatelessWidget {
child: Row(
spacing: 16,
children: [
SvgPicture.asset(
isSelected
? imagePaths.icCheckboxSelected
: imagePaths.icCheckboxUnselected,
width: LabelDropDownStyle.checkedIconSize,
height: LabelDropDownStyle.checkedIconSize,
colorFilter: (isSelected
? LabelDropDownStyle.checkedIconColor
: LabelDropDownStyle.unCheckedIconColor)
.asFilter(),
fit: BoxFit.fill,
),
Expanded(
child: Text(
label.safeDisplayName,
style: LabelDropDownStyle.menuItemStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
_CheckboxIcon(
isSelected: isSelected,
imagePaths: imagePaths,
),
_LabelName(text: label.safeDisplayName),
],
),
);
}
}
class _CheckboxIcon extends StatelessWidget {
final bool isSelected;
final ImagePaths imagePaths;
const _CheckboxIcon({
required this.isSelected,
required this.imagePaths,
});
@override
Widget build(BuildContext context) {
return SvgPicture.asset(
_iconPath,
width: LabelDropDownStyle.checkedIconSize,
height: LabelDropDownStyle.checkedIconSize,
colorFilter: _iconColor.asFilter(),
fit: BoxFit.fill,
);
}
String get _iconPath {
return isSelected
? imagePaths.icCheckboxSelected
: imagePaths.icCheckboxUnselected;
}
Color get _iconColor {
return isSelected
? LabelDropDownStyle.checkedIconColor
: LabelDropDownStyle.unCheckedIconColor;
}
}
class _LabelName extends StatelessWidget {
final String text;
const _LabelName({required this.text});
@override
Widget build(BuildContext context) {
return Expanded(
child: Text(
text,
style: LabelDropDownStyle.menuItemStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
);
}
}
class _LabelDropdownButtonView extends StatelessWidget {
final ImagePaths imagePaths;
final Label? labelSelected;