TF-4383 Handle read only labels
This commit is contained in:
@@ -413,6 +413,7 @@ abstract class BaseMailboxView extends GetWidget<MailboxController>
|
||||
if (isLabelAvailable) {
|
||||
final labelListExpandMode = labelController.labelListExpandMode.value;
|
||||
final labels = labelController.labels;
|
||||
final shouldAskReadOnly = labelController.shouldAskReadOnly;
|
||||
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
@@ -421,6 +422,7 @@ abstract class BaseMailboxView extends GetWidget<MailboxController>
|
||||
labels: labels,
|
||||
imagePaths: controller.imagePaths,
|
||||
isDesktop: isDesktop,
|
||||
shouldAskReadOnly: shouldAskReadOnly,
|
||||
labelIdSelected: labelIdSelected,
|
||||
isMobileResponsive: isMobileResponsive,
|
||||
onOpenLabelCallback: (label) => controller.openMailbox(
|
||||
|
||||
@@ -16,6 +16,7 @@ class LabelListItem extends StatefulWidget {
|
||||
final ImagePaths imagePaths;
|
||||
final bool isDesktop;
|
||||
final bool isSelected;
|
||||
final bool shouldAskReadOnly;
|
||||
final bool isMobileResponsive;
|
||||
final OnOpenLabelCallback onOpenLabelCallback;
|
||||
final OnOpenLabelContextMenuAction? onOpenContextMenu;
|
||||
@@ -28,6 +29,7 @@ class LabelListItem extends StatefulWidget {
|
||||
required this.onOpenLabelCallback,
|
||||
this.isDesktop = false,
|
||||
this.isSelected = false,
|
||||
this.shouldAskReadOnly = false,
|
||||
this.isMobileResponsive = false,
|
||||
this.onOpenContextMenu,
|
||||
this.onLongPressLabelItemAction,
|
||||
@@ -75,7 +77,26 @@ class _LabelListItemState extends State<LabelListItem> {
|
||||
: MailboxItemWidgetStyles.mobileLabelIconSpace;
|
||||
}
|
||||
|
||||
bool get _isMenuButtonVisible => _isContextMenuVisible || _isItemHovered;
|
||||
bool get _isMenuButtonVisible {
|
||||
final isActive = _isContextMenuVisible || _isItemHovered;
|
||||
|
||||
if (!widget.shouldAskReadOnly) {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
return isActive && !widget.label.isReadOnly;
|
||||
}
|
||||
|
||||
bool get _isOnLongPressActive {
|
||||
final isTouchPlatform =
|
||||
PlatformInfo.isWebTouchDevice || PlatformInfo.isMobile;
|
||||
|
||||
if (!widget.shouldAskReadOnly) {
|
||||
return isTouchPlatform;
|
||||
}
|
||||
|
||||
return isTouchPlatform && !widget.label.isReadOnly;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -85,7 +106,7 @@ class _LabelListItemState extends State<LabelListItem> {
|
||||
borderRadius: _borderRadius,
|
||||
onHover: _handleHoverChanged,
|
||||
onTap: () => widget.onOpenLabelCallback(widget.label),
|
||||
onLongPress: PlatformInfo.isWebTouchDevice || PlatformInfo.isMobile
|
||||
onLongPress: _isOnLongPressActive
|
||||
? () => widget.onLongPressLabelItemAction?.call(widget.label)
|
||||
: null,
|
||||
child: Container(
|
||||
|
||||
@@ -9,6 +9,7 @@ class LabelListView extends StatelessWidget {
|
||||
final List<Label> labels;
|
||||
final ImagePaths imagePaths;
|
||||
final bool isDesktop;
|
||||
final bool shouldAskReadOnly;
|
||||
final Id? labelIdSelected;
|
||||
final OnOpenLabelCallback onOpenLabelCallback;
|
||||
final bool isMobileResponsive;
|
||||
@@ -21,6 +22,7 @@ class LabelListView extends StatelessWidget {
|
||||
required this.imagePaths,
|
||||
required this.onOpenLabelCallback,
|
||||
this.isDesktop = false,
|
||||
this.shouldAskReadOnly = false,
|
||||
this.labelIdSelected,
|
||||
this.isMobileResponsive = false,
|
||||
this.onOpenContextMenu,
|
||||
@@ -42,6 +44,7 @@ class LabelListView extends StatelessWidget {
|
||||
imagePaths: imagePaths,
|
||||
isSelected: label.id == labelIdSelected,
|
||||
isDesktop: isDesktop,
|
||||
shouldAskReadOnly: shouldAskReadOnly,
|
||||
onOpenLabelCallback: onOpenLabelCallback,
|
||||
isMobileResponsive: isMobileResponsive,
|
||||
onOpenContextMenu: onOpenContextMenu,
|
||||
|
||||
Reference in New Issue
Block a user