mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 01:54:37 +00:00 
			
		
		
		
	feat: add same delete design in database (#6620)
* add same delete design in database * fix: remove padding when widget is null or function is null
This commit is contained in:
		
							parent
							
								
									f5e46967ec
								
							
						
					
					
						commit
						d21c0c0dfc
					
				| @ -199,22 +199,30 @@ class FieldActionCell extends StatelessWidget { | |||||||
|         (action == FieldAction.duplicate || action == FieldAction.delete)) { |         (action == FieldAction.duplicate || action == FieldAction.delete)) { | ||||||
|       enable = false; |       enable = false; | ||||||
|     } |     } | ||||||
| 
 |     return FlowyIconTextButton( | ||||||
|     return FlowyButton( |  | ||||||
|       resetHoverOnRebuild: false, |       resetHoverOnRebuild: false, | ||||||
|       disable: !enable, |       disable: !enable, | ||||||
|       text: FlowyText( |  | ||||||
|         action.title(fieldInfo), |  | ||||||
|         lineHeight: 1.0, |  | ||||||
|         color: enable ? null : Theme.of(context).disabledColor, |  | ||||||
|       ), |  | ||||||
|       onHover: (_) => popoverMutex?.close(), |       onHover: (_) => popoverMutex?.close(), | ||||||
|       onTap: () => action.run(context, viewId, fieldInfo), |       onTap: () => action.run(context, viewId, fieldInfo), | ||||||
|       leftIcon: action.leading( |       // show the error color when delete is hovered | ||||||
|         fieldInfo, |       textBuilder: (onHover) => FlowyText( | ||||||
|         enable ? null : Theme.of(context).disabledColor, |         action.title(fieldInfo), | ||||||
|  |         lineHeight: 1.0, | ||||||
|  |         color: enable | ||||||
|  |             ? action == FieldAction.delete && onHover | ||||||
|  |                 ? Theme.of(context).colorScheme.error | ||||||
|  |                 : null | ||||||
|  |             : Theme.of(context).disabledColor, | ||||||
|       ), |       ), | ||||||
|       rightIcon: action.trailing(context, fieldInfo), |       leftIconBuilder: (onHover) => action.leading( | ||||||
|  |         fieldInfo, | ||||||
|  |         enable | ||||||
|  |             ? action == FieldAction.delete && onHover | ||||||
|  |                 ? Theme.of(context).colorScheme.error | ||||||
|  |                 : null | ||||||
|  |             : Theme.of(context).disabledColor, | ||||||
|  |       ), | ||||||
|  |       rightIconBuilder: (_) => action.trailing(context, fieldInfo), | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -13,8 +13,8 @@ class FlowyIconTextButton extends StatelessWidget { | |||||||
|   final VoidCallback? onSecondaryTap; |   final VoidCallback? onSecondaryTap; | ||||||
|   final void Function(bool)? onHover; |   final void Function(bool)? onHover; | ||||||
|   final EdgeInsets? margin; |   final EdgeInsets? margin; | ||||||
|   final Widget Function(bool onHover)? leftIconBuilder; |   final Widget? Function(bool onHover)? leftIconBuilder; | ||||||
|   final Widget Function(bool onHover)? rightIconBuilder; |   final Widget? Function(bool onHover)? rightIconBuilder; | ||||||
|   final Color? hoverColor; |   final Color? hoverColor; | ||||||
|   final bool isSelected; |   final bool isSelected; | ||||||
|   final BorderRadius? radius; |   final BorderRadius? radius; | ||||||
| @ -29,6 +29,7 @@ class FlowyIconTextButton extends StatelessWidget { | |||||||
|   final double iconPadding; |   final double iconPadding; | ||||||
|   final bool expand; |   final bool expand; | ||||||
|   final Color? borderColor; |   final Color? borderColor; | ||||||
|  |   final bool resetHoverOnRebuild; | ||||||
| 
 | 
 | ||||||
|   const FlowyIconTextButton({ |   const FlowyIconTextButton({ | ||||||
|     super.key, |     super.key, | ||||||
| @ -53,6 +54,7 @@ class FlowyIconTextButton extends StatelessWidget { | |||||||
|     this.iconPadding = 6, |     this.iconPadding = 6, | ||||||
|     this.expand = false, |     this.expand = false, | ||||||
|     this.borderColor, |     this.borderColor, | ||||||
|  |     this.resetHoverOnRebuild = true, | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
| @ -64,6 +66,7 @@ class FlowyIconTextButton extends StatelessWidget { | |||||||
|       onTap: disable ? null : onTap, |       onTap: disable ? null : onTap, | ||||||
|       onSecondaryTap: disable ? null : onSecondaryTap, |       onSecondaryTap: disable ? null : onSecondaryTap, | ||||||
|       child: FlowyHover( |       child: FlowyHover( | ||||||
|  |         resetHoverOnRebuild: resetHoverOnRebuild, | ||||||
|         cursor: |         cursor: | ||||||
|             disable ? SystemMouseCursors.forbidden : SystemMouseCursors.click, |             disable ? SystemMouseCursors.forbidden : SystemMouseCursors.click, | ||||||
|         style: HoverStyle( |         style: HoverStyle( | ||||||
| @ -81,11 +84,12 @@ class FlowyIconTextButton extends StatelessWidget { | |||||||
|   Widget _render(BuildContext context, bool onHover) { |   Widget _render(BuildContext context, bool onHover) { | ||||||
|     final List<Widget> children = []; |     final List<Widget> children = []; | ||||||
| 
 | 
 | ||||||
|     if (leftIconBuilder != null) { |     final Widget? leftIcon = leftIconBuilder?.call(onHover); | ||||||
|  |     if (leftIcon != null) { | ||||||
|       children.add( |       children.add( | ||||||
|         SizedBox.fromSize( |         SizedBox.fromSize( | ||||||
|           size: leftIconSize, |           size: leftIconSize, | ||||||
|           child: leftIconBuilder!(onHover), |           child: leftIcon, | ||||||
|         ), |         ), | ||||||
|       ); |       ); | ||||||
|       children.add(HSpace(iconPadding)); |       children.add(HSpace(iconPadding)); | ||||||
| @ -97,10 +101,11 @@ class FlowyIconTextButton extends StatelessWidget { | |||||||
|       children.add(textBuilder(onHover)); |       children.add(textBuilder(onHover)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (rightIconBuilder != null) { |     final Widget? rightIcon = rightIconBuilder?.call(onHover); | ||||||
|  |     if (rightIcon != null) { | ||||||
|       children.add(HSpace(iconPadding)); |       children.add(HSpace(iconPadding)); | ||||||
|       // No need to define the size of rightIcon. Just use its intrinsic width |       // No need to define the size of rightIcon. Just use its intrinsic width | ||||||
|       children.add(rightIconBuilder!(onHover)); |       children.add(rightIcon); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Widget child = Row( |     Widget child = Row( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ahad Patel
						Ahad Patel