Merge pull request #1287 from fufesou/flutter_desktop_fullscreen
Flutter desktop fullscreen
This commit is contained in:
		
						commit
						1b5075168e
					
				| @ -27,6 +27,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> | |||||||
|   RxList<TabInfo> tabs = RxList<TabInfo>.empty(growable: true); |   RxList<TabInfo> tabs = RxList<TabInfo>.empty(growable: true); | ||||||
|   late Rx<TabController> tabController; |   late Rx<TabController> tabController; | ||||||
|   static final Rx<int> _selected = 0.obs; |   static final Rx<int> _selected = 0.obs; | ||||||
|  |   static final Rx<String> _fullscreenID = "".obs; | ||||||
|   IconData icon = Icons.desktop_windows_sharp; |   IconData icon = Icons.desktop_windows_sharp; | ||||||
| 
 | 
 | ||||||
|   var connectionMap = RxList<Widget>.empty(growable: true); |   var connectionMap = RxList<Widget>.empty(growable: true); | ||||||
| @ -70,24 +71,32 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> | |||||||
|     return Scaffold( |     return Scaffold( | ||||||
|       body: Column( |       body: Column( | ||||||
|         children: [ |         children: [ | ||||||
|           DesktopTabBar( |           Obx(() => Visibility( | ||||||
|  |               visible: _fullscreenID.value.isEmpty, | ||||||
|  |               child: DesktopTabBar( | ||||||
|                 controller: tabController, |                 controller: tabController, | ||||||
|                 tabs: tabs, |                 tabs: tabs, | ||||||
|                 onTabClose: onRemoveId, |                 onTabClose: onRemoveId, | ||||||
|                 selected: _selected, |                 selected: _selected, | ||||||
|                 dark: isDarkTheme(), |                 dark: isDarkTheme(), | ||||||
|                 mainTab: false, |                 mainTab: false, | ||||||
|           ), |               ))), | ||||||
|           Expanded( |           Expanded(child: Obx(() { | ||||||
|               child: Obx(() => TabBarView( |             WindowController.fromWindowId(windowId()) | ||||||
|  |                 .setFullscreen(_fullscreenID.value.isNotEmpty); | ||||||
|  |             return TabBarView( | ||||||
|                 controller: tabController.value, |                 controller: tabController.value, | ||||||
|                 children: tabs |                 children: tabs | ||||||
|                     .map((tab) => RemotePage( |                     .map((tab) => RemotePage( | ||||||
|                           key: ValueKey(tab.label), |                           key: ValueKey(tab.label), | ||||||
|                           id: tab.label, |                           id: tab.label, | ||||||
|                             tabBarHeight: kDesktopRemoteTabBarHeight, |                           tabBarHeight: _fullscreenID.value.isNotEmpty | ||||||
|  |                               ? 0 | ||||||
|  |                               : kDesktopRemoteTabBarHeight, | ||||||
|  |                           fullscreenID: _fullscreenID, | ||||||
|                         )) //RemotePage(key: ValueKey(e), id: e)) |                         )) //RemotePage(key: ValueKey(e), id: e)) | ||||||
|                       .toList()))), |                     .toList()); | ||||||
|  |           })), | ||||||
|         ], |         ], | ||||||
|       ), |       ), | ||||||
|     ); |     ); | ||||||
|  | |||||||
| @ -21,11 +21,16 @@ import '../../models/platform_model.dart'; | |||||||
| final initText = '\1' * 1024; | final initText = '\1' * 1024; | ||||||
| 
 | 
 | ||||||
| class RemotePage extends StatefulWidget { | class RemotePage extends StatefulWidget { | ||||||
|   RemotePage({Key? key, required this.id, required this.tabBarHeight}) |   RemotePage( | ||||||
|  |       {Key? key, | ||||||
|  |       required this.id, | ||||||
|  |       required this.tabBarHeight, | ||||||
|  |       required this.fullscreenID}) | ||||||
|       : super(key: key); |       : super(key: key); | ||||||
| 
 | 
 | ||||||
|   final String id; |   final String id; | ||||||
|   final double tabBarHeight; |   final double tabBarHeight; | ||||||
|  |   final Rx<String> fullscreenID; | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   _RemotePageState createState() => _RemotePageState(); |   _RemotePageState createState() => _RemotePageState(); | ||||||
| @ -41,6 +46,7 @@ class _RemotePageState extends State<RemotePage> | |||||||
|   final FocusNode _mobileFocusNode = FocusNode(); |   final FocusNode _mobileFocusNode = FocusNode(); | ||||||
|   final FocusNode _physicalFocusNode = FocusNode(); |   final FocusNode _physicalFocusNode = FocusNode(); | ||||||
|   var _isPhysicalMouse = false; |   var _isPhysicalMouse = false; | ||||||
|  |   var _imageFocused = false; | ||||||
| 
 | 
 | ||||||
|   late FFI _ffi; |   late FFI _ffi; | ||||||
| 
 | 
 | ||||||
| @ -238,6 +244,9 @@ class _RemotePageState extends State<RemotePage> | |||||||
|                     autofocus: true, |                     autofocus: true, | ||||||
|                     canRequestFocus: true, |                     canRequestFocus: true, | ||||||
|                     focusNode: _physicalFocusNode, |                     focusNode: _physicalFocusNode, | ||||||
|  |                     onFocusChange: (bool v) { | ||||||
|  |                       _imageFocused = v; | ||||||
|  |                     }, | ||||||
|                     onKey: (data, e) { |                     onKey: (data, e) { | ||||||
|                       final key = e.logicalKey; |                       final key = e.logicalKey; | ||||||
|                       if (e is RawKeyDownEvent) { |                       if (e is RawKeyDownEvent) { | ||||||
| @ -307,6 +316,23 @@ class _RemotePageState extends State<RemotePage> | |||||||
|                           }, |                           }, | ||||||
|                         ) |                         ) | ||||||
|                       ] + |                       ] + | ||||||
|  |                       (isWebDesktop | ||||||
|  |                           ? [] | ||||||
|  |                           : <Widget>[ | ||||||
|  |                               IconButton( | ||||||
|  |                                 color: Colors.white, | ||||||
|  |                                 icon: Icon(widget.fullscreenID.value.isEmpty | ||||||
|  |                                     ? Icons.fullscreen | ||||||
|  |                                     : Icons.close_fullscreen), | ||||||
|  |                                 onPressed: () { | ||||||
|  |                                   if (widget.fullscreenID.value.isEmpty) { | ||||||
|  |                                     widget.fullscreenID.value = widget.id; | ||||||
|  |                                   } else { | ||||||
|  |                                     widget.fullscreenID.value = ""; | ||||||
|  |                                   } | ||||||
|  |                                 }, | ||||||
|  |                               ) | ||||||
|  |                             ]) + | ||||||
|                       (isWebDesktop |                       (isWebDesktop | ||||||
|                           ? [] |                           ? [] | ||||||
|                           : _ffi.ffiModel.isPeerAndroid |                           : _ffi.ffiModel.isPeerAndroid | ||||||
| @ -434,6 +460,9 @@ class _RemotePageState extends State<RemotePage> | |||||||
|         onPointerSignal: _onPointerSignalImage, |         onPointerSignal: _onPointerSignalImage, | ||||||
|         child: MouseRegion( |         child: MouseRegion( | ||||||
|             onEnter: (evt) { |             onEnter: (evt) { | ||||||
|  |               if (!_imageFocused) { | ||||||
|  |                 _physicalFocusNode.requestFocus(); | ||||||
|  |               } | ||||||
|               _cursorOverImage.value = true; |               _cursorOverImage.value = true; | ||||||
|             }, |             }, | ||||||
|             onExit: (evt) { |             onExit: (evt) { | ||||||
|  | |||||||
| @ -50,17 +50,19 @@ class ChatPage extends StatelessWidget implements PageShape { | |||||||
|               final currentUser = chatModel.currentUser; |               final currentUser = chatModel.currentUser; | ||||||
|               return Stack( |               return Stack( | ||||||
|                 children: [ |                 children: [ | ||||||
|                   DashChat( |                   LayoutBuilder(builder: (context, constraints) { | ||||||
|  |                     return DashChat( | ||||||
|                       onSend: (chatMsg) { |                       onSend: (chatMsg) { | ||||||
|                         chatModel.send(chatMsg); |                         chatModel.send(chatMsg); | ||||||
|                       }, |                       }, | ||||||
|                       currentUser: chatModel.me, |                       currentUser: chatModel.me, | ||||||
|                     messages: |                       messages: chatModel | ||||||
|                         chatModel.messages[chatModel.currentID]?.chatMessages ?? |                               .messages[chatModel.currentID]?.chatMessages ?? | ||||||
|                           [], |                           [], | ||||||
|                       messageOptions: MessageOptions( |                       messageOptions: MessageOptions( | ||||||
|                           showOtherUsersAvatar: false, |                           showOtherUsersAvatar: false, | ||||||
|                           showTime: true, |                           showTime: true, | ||||||
|  |                           maxWidth: constraints.maxWidth * 0.7, | ||||||
|                           messageDecorationBuilder: (_, __, ___) => |                           messageDecorationBuilder: (_, __, ___) => | ||||||
|                               defaultMessageDecoration( |                               defaultMessageDecoration( | ||||||
|                                 color: MyTheme.accent80, |                                 color: MyTheme.accent80, | ||||||
| @ -69,7 +71,8 @@ class ChatPage extends StatelessWidget implements PageShape { | |||||||
|                                 borderBottomRight: 8, |                                 borderBottomRight: 8, | ||||||
|                                 borderBottomLeft: 8, |                                 borderBottomLeft: 8, | ||||||
|                               )), |                               )), | ||||||
|                   ), |                     ); | ||||||
|  |                   }), | ||||||
|                   chatModel.currentID == ChatModel.clientModeID |                   chatModel.currentID == ChatModel.clientModeID | ||||||
|                       ? SizedBox.shrink() |                       ? SizedBox.shrink() | ||||||
|                       : Padding( |                       : Padding( | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -40,7 +40,10 @@ dependencies: | |||||||
|     url_launcher: ^6.0.9 |     url_launcher: ^6.0.9 | ||||||
|     shared_preferences: ^2.0.6 |     shared_preferences: ^2.0.6 | ||||||
|     toggle_switch: ^1.4.0 |     toggle_switch: ^1.4.0 | ||||||
|     dash_chat_2: ^0.0.12 |     dash_chat_2: | ||||||
|  |         git: | ||||||
|  |           url: https://github.com/fufesou/Dash-Chat-2 | ||||||
|  |           ref: feat_maxWidth | ||||||
|     draggable_float_widget: ^0.0.2 |     draggable_float_widget: ^0.0.2 | ||||||
|     settings_ui: ^2.0.2 |     settings_ui: ^2.0.2 | ||||||
|     flutter_breadcrumb: ^1.0.1 |     flutter_breadcrumb: ^1.0.1 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user