TW-4308 Add labels for several messages part 2 (#4431)
Add ChooseLabelModal, delegate, and update label UI components Wire add-labels action across Thread, Search, and Dashboard
This commit is contained in:
@@ -18,6 +18,8 @@ class LabelListItem extends StatefulWidget {
|
||||
final bool isSelected;
|
||||
final bool shouldAskReadOnly;
|
||||
final bool isMobileResponsive;
|
||||
final bool enableSelectedIcon;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final OnOpenLabelCallback onOpenLabelCallback;
|
||||
final OnOpenLabelContextMenuAction? onOpenContextMenu;
|
||||
final OnLongPressLabelItemAction? onLongPressLabelItemAction;
|
||||
@@ -31,6 +33,8 @@ class LabelListItem extends StatefulWidget {
|
||||
this.isSelected = false,
|
||||
this.shouldAskReadOnly = false,
|
||||
this.isMobileResponsive = false,
|
||||
this.enableSelectedIcon = false,
|
||||
this.padding,
|
||||
this.onOpenContextMenu,
|
||||
this.onLongPressLabelItemAction,
|
||||
});
|
||||
@@ -62,7 +66,7 @@ class _LabelListItemState extends State<LabelListItem> {
|
||||
),
|
||||
);
|
||||
|
||||
_itemPadding = EdgeInsetsDirectional.symmetric(
|
||||
_itemPadding = widget.padding ?? EdgeInsetsDirectional.symmetric(
|
||||
horizontal: isDesktop
|
||||
? MailboxItemWidgetStyles.itemPadding
|
||||
: MailboxItemWidgetStyles.mobileItemPadding,
|
||||
@@ -103,8 +107,8 @@ class _LabelListItemState extends State<LabelListItem> {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius: _borderRadius,
|
||||
onHover: _handleHoverChanged,
|
||||
borderRadius: widget.enableSelectedIcon ? null : _borderRadius,
|
||||
onHover: widget.enableSelectedIcon ? null : _handleHoverChanged,
|
||||
onTap: () => widget.onOpenLabelCallback(widget.label),
|
||||
onLongPress: _isOnLongPressActive
|
||||
? () => widget.onLongPressLabelItemAction?.call(widget.label)
|
||||
@@ -113,11 +117,23 @@ class _LabelListItemState extends State<LabelListItem> {
|
||||
height: _itemHeight,
|
||||
padding: _itemPadding,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: _borderRadius,
|
||||
borderRadius: widget.enableSelectedIcon ? null : _borderRadius,
|
||||
color: _backgroundColorItem,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (widget.enableSelectedIcon)
|
||||
_SelectedIcon(
|
||||
icon: widget.isSelected
|
||||
? widget.imagePaths.icCheckboxSelected
|
||||
: widget.imagePaths.icCheckboxUnselected,
|
||||
color: widget.isSelected
|
||||
? AppColor.primaryMain
|
||||
: AppColor.steelGray200,
|
||||
onSelectAction: () => widget.onOpenLabelCallback(
|
||||
widget.label,
|
||||
),
|
||||
),
|
||||
_LabelIcon(
|
||||
icon: widget.imagePaths.icLabel,
|
||||
color: widget.label.backgroundColor,
|
||||
@@ -143,7 +159,9 @@ class _LabelListItemState extends State<LabelListItem> {
|
||||
}
|
||||
|
||||
Color get _backgroundColorItem =>
|
||||
widget.isSelected ? AppColor.blue100 : Colors.transparent;
|
||||
widget.isSelected && !widget.enableSelectedIcon
|
||||
? AppColor.blue100
|
||||
: Colors.transparent;
|
||||
|
||||
Color _menuButtonBackgroundColor(BuildContext context) {
|
||||
if (_isContextMenuVisible) {
|
||||
@@ -202,6 +220,30 @@ class _LabelIcon extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _SelectedIcon extends StatelessWidget {
|
||||
final String icon;
|
||||
final Color? color;
|
||||
final VoidCallback onSelectAction;
|
||||
|
||||
const _SelectedIcon({
|
||||
required this.icon,
|
||||
required this.color,
|
||||
required this.onSelectAction,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TMailButtonWidget.fromIcon(
|
||||
icon: icon,
|
||||
iconColor: color,
|
||||
iconSize: 20,
|
||||
padding: const EdgeInsets.all(10),
|
||||
backgroundColor: Colors.transparent,
|
||||
onTapActionCallback: onSelectAction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ContextMenuButton extends StatelessWidget {
|
||||
final bool visible;
|
||||
final Color backgroundColor;
|
||||
|
||||
Reference in New Issue
Block a user