TF-4229 refactor(label-dropdown): extract checkbox icon and label text widgets
This commit is contained in:
+55
-19
@@ -93,32 +93,68 @@ class _LabelDropdownMenuItem extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
_CheckboxIcon(
|
||||||
isSelected
|
isSelected: isSelected,
|
||||||
? imagePaths.icCheckboxSelected
|
imagePaths: imagePaths,
|
||||||
: 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,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
_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 {
|
class _LabelDropdownButtonView extends StatelessWidget {
|
||||||
final ImagePaths imagePaths;
|
final ImagePaths imagePaths;
|
||||||
final Label? labelSelected;
|
final Label? labelSelected;
|
||||||
|
|||||||
Reference in New Issue
Block a user