mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Simplify code
This commit is contained in:
		@@ -292,15 +292,7 @@ class _NotificationTile extends StatelessWidget {
 | 
			
		||||
      onTap: () => _onTap(context),
 | 
			
		||||
      title: Text(message),
 | 
			
		||||
      subtitle: Text(diffTimeFromNowToStr(notification.timeCreate)),
 | 
			
		||||
      onLongPressWithInfo: (size, offset) {
 | 
			
		||||
        final position = RelativeRect.fromLTRB(
 | 
			
		||||
          offset.dx - size.width,
 | 
			
		||||
          offset.dy,
 | 
			
		||||
          offset.dx,
 | 
			
		||||
          offset.dy + size.height,
 | 
			
		||||
        ); //fromSize(Rect.fromPoints(offset, Offset.zero), size);*/
 | 
			
		||||
 | 
			
		||||
        print(position);
 | 
			
		||||
      onLongPressOpenMenu: (position) {
 | 
			
		||||
        showMenu(context: context, position: position, items: [
 | 
			
		||||
          PopupMenuItem(
 | 
			
		||||
            child: Text(tr("Delete")),
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,9 @@ class CustomListTile extends StatelessWidget {
 | 
			
		||||
  /// Custom onLongPress function
 | 
			
		||||
  final Function(Size, Offset) onLongPressWithInfo;
 | 
			
		||||
 | 
			
		||||
  /// Show menu onLongPress
 | 
			
		||||
  final Function(RelativeRect) onLongPressOpenMenu;
 | 
			
		||||
 | 
			
		||||
  const CustomListTile({
 | 
			
		||||
    Key key,
 | 
			
		||||
    this.leading,
 | 
			
		||||
@@ -35,6 +38,7 @@ class CustomListTile extends StatelessWidget {
 | 
			
		||||
    this.onLongPress,
 | 
			
		||||
    this.selected = false,
 | 
			
		||||
    this.onLongPressWithInfo,
 | 
			
		||||
    this.onLongPressOpenMenu,
 | 
			
		||||
  })  : assert(isThreeLine != null),
 | 
			
		||||
        assert(enabled != null),
 | 
			
		||||
        assert(selected != null),
 | 
			
		||||
@@ -59,12 +63,25 @@ class CustomListTile extends StatelessWidget {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  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);
 | 
			
		||||
    if (onLongPressWithInfo != null || onLongPressOpenMenu != null) {
 | 
			
		||||
      RenderBox renderBox = context.findRenderObject();
 | 
			
		||||
      final size = renderBox.size;
 | 
			
		||||
      final offset = renderBox.localToGlobal(Offset(size.width, size.height));
 | 
			
		||||
 | 
			
		||||
      if (onLongPressWithInfo != null) onLongPressWithInfo(size, offset);
 | 
			
		||||
 | 
			
		||||
      if (onLongPressOpenMenu != null) {
 | 
			
		||||
        final position = RelativeRect.fromLTRB(
 | 
			
		||||
          offset.dx - size.width,
 | 
			
		||||
          offset.dy,
 | 
			
		||||
          offset.dx,
 | 
			
		||||
          offset.dy + size.height,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        onLongPressOpenMenu(position);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user