| 
									
										
										
										
											2022-09-19 10:14:14 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter_hbb/common.dart'; | 
					
						
							|  |  |  | import 'package:flutter_hbb/consts.dart'; | 
					
						
							|  |  |  | import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart'; | 
					
						
							|  |  |  | import 'package:flutter_hbb/desktop/pages/desktop_setting_page.dart'; | 
					
						
							|  |  |  | import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart'; | 
					
						
							| 
									
										
										
										
											2022-11-01 17:01:43 +08:00
										 |  |  | import 'package:flutter_hbb/models/state_model.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-26 23:28:08 +08:00
										 |  |  | import 'package:get/get.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-22 13:51:05 +08:00
										 |  |  | import 'package:window_manager/window_manager.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 17:27:30 +08:00
										 |  |  | import '../../common/shared_state.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  | class DesktopTabPage extends StatefulWidget { | 
					
						
							|  |  |  |   const DesktopTabPage({Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   State<DesktopTabPage> createState() => _DesktopTabPageState(); | 
					
						
							| 
									
										
										
										
											2022-09-23 18:28:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   static void onAddSetting({int initialPage = 0}) { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       DesktopTabController tabController = Get.find(); | 
					
						
							|  |  |  |       tabController.add(TabInfo( | 
					
						
							|  |  |  |           key: kTabLabelSettingPage, | 
					
						
							| 
									
										
										
										
											2023-01-30 17:10:05 +01:00
										 |  |  |           label: translate(kTabLabelSettingPage), | 
					
						
							| 
									
										
										
										
											2022-09-23 18:28:40 +08:00
										 |  |  |           selectedIcon: Icons.build_sharp, | 
					
						
							|  |  |  |           unselectedIcon: Icons.build_outlined, | 
					
						
							|  |  |  |           page: DesktopSettingPage( | 
					
						
							|  |  |  |             key: const ValueKey(kTabLabelSettingPage), | 
					
						
							|  |  |  |             initialPage: initialPage, | 
					
						
							|  |  |  |           ))); | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							| 
									
										
										
										
											2022-12-09 10:49:47 +08:00
										 |  |  |       debugPrintStack(label: '$e'); | 
					
						
							| 
									
										
										
										
											2022-09-23 18:28:40 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-18 10:54:09 +08:00
										 |  |  | class _DesktopTabPageState extends State<DesktopTabPage> { | 
					
						
							| 
									
										
										
										
											2022-09-01 21:18:53 +08:00
										 |  |  |   final tabController = DesktopTabController(tabType: DesktopTabType.main); | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							| 
									
										
										
										
											2022-09-23 18:28:40 +08:00
										 |  |  |     Get.put<DesktopTabController>(tabController); | 
					
						
							| 
									
										
										
										
											2022-10-08 17:27:30 +08:00
										 |  |  |     RemoteCountState.init(); | 
					
						
							| 
									
										
										
										
											2022-08-26 12:14:14 +08:00
										 |  |  |     tabController.add(TabInfo( | 
					
						
							| 
									
										
										
										
											2022-08-24 20:12:04 +08:00
										 |  |  |         key: kTabLabelHomePage, | 
					
						
							| 
									
										
										
										
											2023-01-30 17:10:05 +01:00
										 |  |  |         label: translate(kTabLabelHomePage), | 
					
						
							| 
									
										
										
										
											2022-08-24 20:12:04 +08:00
										 |  |  |         selectedIcon: Icons.home_sharp, | 
					
						
							|  |  |  |         unselectedIcon: Icons.home_outlined, | 
					
						
							|  |  |  |         closable: false, | 
					
						
							| 
									
										
										
										
											2022-08-26 12:14:14 +08:00
										 |  |  |         page: DesktopHomePage( | 
					
						
							|  |  |  |           key: const ValueKey(kTabLabelHomePage), | 
					
						
							|  |  |  |         ))); | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-23 18:28:40 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   void dispose() { | 
					
						
							|  |  |  |     super.dispose(); | 
					
						
							|  |  |  |     Get.delete<DesktopTabController>(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2022-09-19 10:14:14 +08:00
										 |  |  |     final tabWidget = Container( | 
					
						
							|  |  |  |       child: Overlay(initialEntries: [ | 
					
						
							|  |  |  |         OverlayEntry(builder: (context) { | 
					
						
							|  |  |  |           gFFI.dialogManager.setOverlayState(Overlay.of(context)); | 
					
						
							|  |  |  |           return Scaffold( | 
					
						
							| 
									
										
										
										
											2022-09-23 16:31:50 +08:00
										 |  |  |               backgroundColor: Theme.of(context).backgroundColor, | 
					
						
							| 
									
										
										
										
											2022-09-19 10:14:14 +08:00
										 |  |  |               body: DesktopTab( | 
					
						
							|  |  |  |                 controller: tabController, | 
					
						
							|  |  |  |                 tail: ActionIcon( | 
					
						
							|  |  |  |                   message: 'Settings', | 
					
						
							|  |  |  |                   icon: IconFont.menu, | 
					
						
							| 
									
										
										
										
											2022-09-23 18:28:40 +08:00
										 |  |  |                   onTap: DesktopTabPage.onAddSetting, | 
					
						
							| 
									
										
										
										
											2022-09-19 10:14:14 +08:00
										 |  |  |                   isClose: false, | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |               )); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |       ]), | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2022-09-19 11:09:29 +08:00
										 |  |  |     return Platform.isMacOS | 
					
						
							| 
									
										
										
										
											2022-09-19 10:14:14 +08:00
										 |  |  |         ? tabWidget | 
					
						
							| 
									
										
										
										
											2022-11-01 18:16:52 +08:00
										 |  |  |         : Obx( | 
					
						
							|  |  |  |             () => DragToResizeArea( | 
					
						
							|  |  |  |               resizeEdgeSize: stateGlobal.resizeEdgeSize.value, | 
					
						
							|  |  |  |               child: tabWidget, | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |           ); | 
					
						
							| 
									
										
										
										
											2022-08-11 16:03:04 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } |