mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Hide popup menu button in Notifications list
This commit is contained in:
		@@ -8,12 +8,14 @@ import 'package:comunic/lists/users_list.dart';
 | 
				
			|||||||
import 'package:comunic/models/notification.dart' as n;
 | 
					import 'package:comunic/models/notification.dart' as n;
 | 
				
			||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
 | 
					import 'package:comunic/ui/routes/main_route/main_route.dart';
 | 
				
			||||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
 | 
					import 'package:comunic/ui/widgets/account_image_widget.dart';
 | 
				
			||||||
 | 
					import 'package:comunic/ui/widgets/custom_list_tile.dart';
 | 
				
			||||||
import 'package:comunic/ui/widgets/safe_state.dart';
 | 
					import 'package:comunic/ui/widgets/safe_state.dart';
 | 
				
			||||||
import 'package:comunic/utils/date_utils.dart';
 | 
					import 'package:comunic/utils/date_utils.dart';
 | 
				
			||||||
import 'package:comunic/utils/intl_utils.dart';
 | 
					import 'package:comunic/utils/intl_utils.dart';
 | 
				
			||||||
import 'package:comunic/utils/navigation_utils.dart';
 | 
					import 'package:comunic/utils/navigation_utils.dart';
 | 
				
			||||||
import 'package:comunic/utils/ui_utils.dart';
 | 
					import 'package:comunic/utils/ui_utils.dart';
 | 
				
			||||||
import 'package:flutter/material.dart';
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					import 'package:flutter/rendering.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Notifications screen
 | 
					/// Notifications screen
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
@@ -283,22 +285,29 @@ class _NotificationTile extends StatelessWidget {
 | 
				
			|||||||
    if (notification.onElemType == n.NotificationElementType.GROUP_MEMBERSHIP)
 | 
					    if (notification.onElemType == n.NotificationElementType.GROUP_MEMBERSHIP)
 | 
				
			||||||
      message += groupsList[notification.onElemId].displayName;
 | 
					      message += groupsList[notification.onElemId].displayName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ListTile(
 | 
					    return CustomListTile(
 | 
				
			||||||
      leading: AccountImageWidget(
 | 
					      leading: AccountImageWidget(
 | 
				
			||||||
        user: srcUser,
 | 
					        user: srcUser,
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
      onTap: () => _onTap(context),
 | 
					      onTap: () => _onTap(context),
 | 
				
			||||||
      title: Text(message),
 | 
					      title: Text(message),
 | 
				
			||||||
      subtitle: Text(diffTimeFromNowToStr(notification.timeCreate)),
 | 
					      subtitle: Text(diffTimeFromNowToStr(notification.timeCreate)),
 | 
				
			||||||
      trailing: PopupMenuButton<_PopupMenuActions>(
 | 
					      onLongPressWithInfo: (size, offset) {
 | 
				
			||||||
        onSelected: _popupMenuAction,
 | 
					        final position = RelativeRect.fromLTRB(
 | 
				
			||||||
        itemBuilder: (c) => [
 | 
					          offset.dx - size.width,
 | 
				
			||||||
 | 
					          offset.dy,
 | 
				
			||||||
 | 
					          offset.dx,
 | 
				
			||||||
 | 
					          offset.dy + size.height,
 | 
				
			||||||
 | 
					        ); //fromSize(Rect.fromPoints(offset, Offset.zero), size);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        print(position);
 | 
				
			||||||
 | 
					        showMenu(context: context, position: position, items: [
 | 
				
			||||||
          PopupMenuItem(
 | 
					          PopupMenuItem(
 | 
				
			||||||
            child: Text(tr("Delete")),
 | 
					            child: Text(tr("Delete")),
 | 
				
			||||||
            value: _PopupMenuActions.DELETE,
 | 
					            value: _PopupMenuActions.DELETE,
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
        ],
 | 
					        ]).then(_popupMenuAction);
 | 
				
			||||||
      ),
 | 
					      },
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										70
									
								
								lib/ui/widgets/custom_list_tile.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								lib/ui/widgets/custom_list_tile.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
				
			|||||||
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// My custom list tile to add extra features to the default
 | 
				
			||||||
 | 
					/// implementation
 | 
				
			||||||
 | 
					///
 | 
				
			||||||
 | 
					/// @author Pierre HUBERT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CustomListTile extends StatelessWidget {
 | 
				
			||||||
 | 
					  final Widget leading;
 | 
				
			||||||
 | 
					  final Widget title;
 | 
				
			||||||
 | 
					  final Widget subtitle;
 | 
				
			||||||
 | 
					  final Widget trailing;
 | 
				
			||||||
 | 
					  final bool isThreeLine;
 | 
				
			||||||
 | 
					  final bool dense;
 | 
				
			||||||
 | 
					  final EdgeInsetsGeometry contentPadding;
 | 
				
			||||||
 | 
					  final bool enabled;
 | 
				
			||||||
 | 
					  final GestureTapCallback onTap;
 | 
				
			||||||
 | 
					  final GestureLongPressCallback onLongPress;
 | 
				
			||||||
 | 
					  final bool selected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Custom onLongPress function
 | 
				
			||||||
 | 
					  final Function(Size, Offset) onLongPressWithInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const CustomListTile({
 | 
				
			||||||
 | 
					    Key key,
 | 
				
			||||||
 | 
					    this.leading,
 | 
				
			||||||
 | 
					    this.title,
 | 
				
			||||||
 | 
					    this.subtitle,
 | 
				
			||||||
 | 
					    this.trailing,
 | 
				
			||||||
 | 
					    this.isThreeLine = false,
 | 
				
			||||||
 | 
					    this.dense,
 | 
				
			||||||
 | 
					    this.contentPadding,
 | 
				
			||||||
 | 
					    this.enabled = true,
 | 
				
			||||||
 | 
					    this.onTap,
 | 
				
			||||||
 | 
					    this.onLongPress,
 | 
				
			||||||
 | 
					    this.selected = false,
 | 
				
			||||||
 | 
					    this.onLongPressWithInfo,
 | 
				
			||||||
 | 
					  })  : assert(isThreeLine != null),
 | 
				
			||||||
 | 
					        assert(enabled != null),
 | 
				
			||||||
 | 
					        assert(selected != null),
 | 
				
			||||||
 | 
					        assert(!isThreeLine || subtitle != null),
 | 
				
			||||||
 | 
					        super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
 | 
					    return ListTile(
 | 
				
			||||||
 | 
					      leading: leading,
 | 
				
			||||||
 | 
					      title: title,
 | 
				
			||||||
 | 
					      subtitle: subtitle,
 | 
				
			||||||
 | 
					      trailing: trailing,
 | 
				
			||||||
 | 
					      isThreeLine: isThreeLine,
 | 
				
			||||||
 | 
					      dense: dense,
 | 
				
			||||||
 | 
					      contentPadding: contentPadding,
 | 
				
			||||||
 | 
					      enabled: enabled,
 | 
				
			||||||
 | 
					      onTap: onTap,
 | 
				
			||||||
 | 
					      onLongPress: () => _longPress(context),
 | 
				
			||||||
 | 
					      selected: selected,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void _longPress(BuildContext context) {
 | 
				
			||||||
 | 
					    RenderBox renderBox = context.findRenderObject();
 | 
				
			||||||
 | 
					    final size = renderBox.size;
 | 
				
			||||||
 | 
					    final offset = renderBox.localToGlobal(Offset(size.width, size.height));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (onLongPress != null) onLongPress();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (onLongPressWithInfo != null) onLongPressWithInfo(size, offset);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user