add minimize button on fullscreen toolbar
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
		
							parent
							
								
									5d6b1223cc
								
							
						
					
					
						commit
						4d2036512a
					
				| @ -1389,6 +1389,13 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async { | |||||||
|       isMaximized = await wc.isMaximized(); |       isMaximized = await wc.isMaximized(); | ||||||
|       break; |       break; | ||||||
|   } |   } | ||||||
|  |   if (Platform.isWindows) { | ||||||
|  |     const kMinOffset = -10000; | ||||||
|  |     if (position.dx < kMinOffset || position.dy < kMinOffset) { | ||||||
|  |       debugPrint("Invalid position: $position, ignore saving position"); | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   final pos = LastWindowPosition( |   final pos = LastWindowPosition( | ||||||
|       sz.width, sz.height, position.dx, position.dy, isMaximized); |       sz.width, sz.height, position.dx, position.dy, isMaximized); | ||||||
|  | |||||||
| @ -360,6 +360,9 @@ class _RemoteToolbarState extends State<RemoteToolbar> { | |||||||
| 
 | 
 | ||||||
|   triggerAutoHide() => _debouncerHide.value = _debouncerHide.value + 1; |   triggerAutoHide() => _debouncerHide.value = _debouncerHide.value + 1; | ||||||
| 
 | 
 | ||||||
|  |   void _minimize() async => | ||||||
|  |       await WindowController.fromWindowId(windowId).minimize(); | ||||||
|  | 
 | ||||||
|   @override |   @override | ||||||
|   initState() { |   initState() { | ||||||
|     super.initState(); |     super.initState(); | ||||||
| @ -467,6 +470,12 @@ class _RemoteToolbarState extends State<RemoteToolbar> { | |||||||
|       toolbarItems.add(_VoiceCallMenu(id: widget.id, ffi: widget.ffi)); |       toolbarItems.add(_VoiceCallMenu(id: widget.id, ffi: widget.ffi)); | ||||||
|     } |     } | ||||||
|     toolbarItems.add(_RecordMenu(ffi: widget.ffi)); |     toolbarItems.add(_RecordMenu(ffi: widget.ffi)); | ||||||
|  |     if (!isWebDesktop) { | ||||||
|  |       toolbarItems.add(_MinimizeMenu( | ||||||
|  |         state: widget.state, | ||||||
|  |         onPressed: _minimize, | ||||||
|  |       )); | ||||||
|  |     } | ||||||
|     toolbarItems.add(_CloseMenu(id: widget.id, ffi: widget.ffi)); |     toolbarItems.add(_CloseMenu(id: widget.id, ffi: widget.ffi)); | ||||||
|     return Column( |     return Column( | ||||||
|       mainAxisSize: MainAxisSize.min, |       mainAxisSize: MainAxisSize.min, | ||||||
| @ -549,6 +558,30 @@ class _PinMenu extends StatelessWidget { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | class _MinimizeMenu extends StatelessWidget { | ||||||
|  |   final ToolbarState state; | ||||||
|  |   final Function() onPressed; | ||||||
|  |   bool get isFullscreen => stateGlobal.fullscreen; | ||||||
|  |   const _MinimizeMenu({ | ||||||
|  |     Key? key, | ||||||
|  |     required this.state, | ||||||
|  |     required this.onPressed, | ||||||
|  |   }) : super(key: key); | ||||||
|  | 
 | ||||||
|  |   @override | ||||||
|  |   Widget build(BuildContext context) { | ||||||
|  |     return Offstage( | ||||||
|  |         offstage: !isFullscreen, | ||||||
|  |         child: _IconMenuButton( | ||||||
|  |           assetName: 'assets/minimize_black_24dp.svg', | ||||||
|  |           tooltip: 'Minimize', | ||||||
|  |           onPressed: onPressed, | ||||||
|  |           color: _ToolbarTheme.blueColor, | ||||||
|  |           hoverColor: _ToolbarTheme.hoverBlueColor, | ||||||
|  |         )); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| class _FullscreenMenu extends StatelessWidget { | class _FullscreenMenu extends StatelessWidget { | ||||||
|   final ToolbarState state; |   final ToolbarState state; | ||||||
|   final Function(bool) setFullscreen; |   final Function(bool) setFullscreen; | ||||||
| @ -1597,11 +1630,11 @@ class _IconMenuButtonState extends State<_IconMenuButton> { | |||||||
|     final icon = widget.icon ?? |     final icon = widget.icon ?? | ||||||
|         SvgPicture.asset( |         SvgPicture.asset( | ||||||
|           widget.assetName!, |           widget.assetName!, | ||||||
|           color: Colors.white, |           colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn), | ||||||
|           width: _ToolbarTheme.buttonSize, |           width: _ToolbarTheme.buttonSize, | ||||||
|           height: _ToolbarTheme.buttonSize, |           height: _ToolbarTheme.buttonSize, | ||||||
|         ); |         ); | ||||||
|     final button = SizedBox( |     var button = SizedBox( | ||||||
|       width: _ToolbarTheme.buttonSize, |       width: _ToolbarTheme.buttonSize, | ||||||
|       height: _ToolbarTheme.buttonSize, |       height: _ToolbarTheme.buttonSize, | ||||||
|       child: MenuItemButton( |       child: MenuItemButton( | ||||||
| @ -1625,6 +1658,12 @@ class _IconMenuButtonState extends State<_IconMenuButton> { | |||||||
|     ).marginSymmetric( |     ).marginSymmetric( | ||||||
|         horizontal: widget.hMargin ?? _ToolbarTheme.buttonHMargin, |         horizontal: widget.hMargin ?? _ToolbarTheme.buttonHMargin, | ||||||
|         vertical: widget.vMargin ?? _ToolbarTheme.buttonVMargin); |         vertical: widget.vMargin ?? _ToolbarTheme.buttonVMargin); | ||||||
|  |     if (widget.tooltip != null) { | ||||||
|  |       button = Tooltip( | ||||||
|  |         message: widget.tooltip!, | ||||||
|  |         child: button, | ||||||
|  |       ); | ||||||
|  |     } | ||||||
|     if (widget.topLevel) { |     if (widget.topLevel) { | ||||||
|       return MenuBar(children: [button]); |       return MenuBar(children: [button]); | ||||||
|     } else { |     } else { | ||||||
|  | |||||||
| @ -65,7 +65,7 @@ class StateGlobal { | |||||||
|               ? kMaximizeEdgeSize |               ? kMaximizeEdgeSize | ||||||
|               : kWindowEdgeSize; |               : kWindowEdgeSize; | ||||||
|       print( |       print( | ||||||
|           "fullscreen: ${fullscreen}, resizeEdgeSize: ${_resizeEdgeSize.value}"); |           "fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}"); | ||||||
|       _windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth; |       _windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth; | ||||||
|       WindowController.fromWindowId(windowId) |       WindowController.fromWindowId(windowId) | ||||||
|           .setFullscreen(_fullscreen) |           .setFullscreen(_fullscreen) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user