| 
									
										
										
										
											2022-09-19 18:38:19 +08:00
										 |  |  | // main window right pane
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  | import 'dart:async'; | 
					
						
							| 
									
										
										
										
											2022-07-22 23:12:31 +08:00
										 |  |  | import 'dart:convert'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-19 20:26:39 +08:00
										 |  |  | import 'package:flutter_hbb/common/widgets/address_book.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-23 15:12:50 +08:00
										 |  |  | import 'package:flutter_hbb/consts.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  | import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart'; | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  | import 'package:get/get.dart'; | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  | import 'package:url_launcher/url_launcher_string.dart'; | 
					
						
							| 
									
										
										
										
											2022-05-29 17:19:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  | import '../../common.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  | import '../../common/formatter/id_formatter.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-19 20:26:39 +08:00
										 |  |  | import '../../common/widgets/peer_tab_page.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-22 15:35:46 +08:00
										 |  |  | import '../../common/widgets/peers_view.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-03 22:03:31 +08:00
										 |  |  | import '../../models/platform_model.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-23 17:28:22 +08:00
										 |  |  | import '../widgets/button.dart'; | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /// Connection page for connecting to a remote peer.
 | 
					
						
							| 
									
										
										
										
											2022-08-09 20:36:52 +08:00
										 |  |  | class ConnectionPage extends StatefulWidget { | 
					
						
							| 
									
										
										
										
											2022-09-06 02:08:59 -07:00
										 |  |  |   const ConnectionPage({Key? key}) : super(key: key); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-06 02:08:59 -07:00
										 |  |  |   State<ConnectionPage> createState() => _ConnectionPageState(); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// State for the connection page.
 | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  | class _ConnectionPageState extends State<ConnectionPage> | 
					
						
							|  |  |  |     with SingleTickerProviderStateMixin { | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |   /// Controller for the id input bar.
 | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |   final _idController = IDTextEditingController(); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  |   /// Nested scroll controller
 | 
					
						
							|  |  |  |   final _scrollController = ScrollController(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |   Timer? _updateTimer; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							| 
									
										
										
										
											2022-08-08 17:53:51 +08:00
										 |  |  |     if (_idController.text.isEmpty) { | 
					
						
							|  |  |  |       () async { | 
					
						
							|  |  |  |         final lastRemoteId = await bind.mainGetLastRemoteId(); | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |         if (lastRemoteId != _idController.id) { | 
					
						
							| 
									
										
										
										
											2022-08-08 17:53:51 +08:00
										 |  |  |           setState(() { | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |             _idController.id = lastRemoteId; | 
					
						
							| 
									
										
										
										
											2022-08-08 17:53:51 +08:00
										 |  |  |           }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |     _updateTimer = Timer.periodic(Duration(seconds: 1), (timer) { | 
					
						
							|  |  |  |       updateStatus(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  |     return Column( | 
					
						
							|  |  |  |       children: [ | 
					
						
							|  |  |  |         Expanded( | 
					
						
							|  |  |  |           child: DesktopScrollWrapper( | 
					
						
							|  |  |  |             scrollController: _scrollController, | 
					
						
							|  |  |  |             child: CustomScrollView( | 
					
						
							|  |  |  |               controller: _scrollController, | 
					
						
							| 
									
										
										
										
											2022-09-28 21:21:54 +08:00
										 |  |  |               physics: NeverScrollableScrollPhysics(), | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  |               slivers: [ | 
					
						
							|  |  |  |                 SliverList( | 
					
						
							|  |  |  |                     delegate: SliverChildListDelegate([ | 
					
						
							| 
									
										
										
										
											2022-08-24 11:01:58 +08:00
										 |  |  |                   Row( | 
					
						
							|  |  |  |                     children: [ | 
					
						
							| 
									
										
										
										
											2022-09-21 17:54:47 +08:00
										 |  |  |                       _buildRemoteIDTextField(context), | 
					
						
							| 
									
										
										
										
											2022-08-24 11:01:58 +08:00
										 |  |  |                     ], | 
					
						
							|  |  |  |                   ).marginOnly(top: 22), | 
					
						
							|  |  |  |                   SizedBox(height: 12), | 
					
						
							| 
									
										
										
										
											2022-09-28 21:21:54 +08:00
										 |  |  |                   Divider().paddingOnly(right: 12), | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  |                 ])), | 
					
						
							|  |  |  |                 SliverFillRemaining( | 
					
						
							|  |  |  |                   hasScrollBody: false, | 
					
						
							|  |  |  |                   child: PeerTabPage( | 
					
						
							| 
									
										
										
										
											2022-08-24 11:01:58 +08:00
										 |  |  |                     tabs: [ | 
					
						
							|  |  |  |                       translate('Recent Sessions'), | 
					
						
							|  |  |  |                       translate('Favorites'), | 
					
						
							|  |  |  |                       translate('Discovered'), | 
					
						
							|  |  |  |                       translate('Address Book') | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                     children: [ | 
					
						
							| 
									
										
										
										
											2022-09-23 12:20:40 +08:00
										 |  |  |                       RecentPeersView( | 
					
						
							| 
									
										
										
										
											2022-10-08 19:28:20 +09:00
										 |  |  |                         menuPadding: kDesktopMenuPadding, | 
					
						
							| 
									
										
										
										
											2022-09-23 12:20:40 +08:00
										 |  |  |                       ), | 
					
						
							|  |  |  |                       FavoritePeersView( | 
					
						
							| 
									
										
										
										
											2022-10-08 19:28:20 +09:00
										 |  |  |                         menuPadding: kDesktopMenuPadding, | 
					
						
							| 
									
										
										
										
											2022-09-23 12:20:40 +08:00
										 |  |  |                       ), | 
					
						
							|  |  |  |                       DiscoveredPeersView( | 
					
						
							| 
									
										
										
										
											2022-10-08 19:28:20 +09:00
										 |  |  |                         menuPadding: kDesktopMenuPadding, | 
					
						
							| 
									
										
										
										
											2022-09-23 12:20:40 +08:00
										 |  |  |                       ), | 
					
						
							|  |  |  |                       const AddressBook( | 
					
						
							| 
									
										
										
										
											2022-10-08 19:28:20 +09:00
										 |  |  |                         menuPadding: kDesktopMenuPadding, | 
					
						
							| 
									
										
										
										
											2022-09-23 12:20:40 +08:00
										 |  |  |                       ), | 
					
						
							| 
									
										
										
										
											2022-08-24 11:01:58 +08:00
										 |  |  |                     ], | 
					
						
							| 
									
										
										
										
											2022-09-28 21:21:54 +08:00
										 |  |  |                   ).paddingOnly(right: 12.0), | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  |                 ) | 
					
						
							|  |  |  |               ], | 
					
						
							| 
									
										
										
										
											2022-09-28 21:21:54 +08:00
										 |  |  |             ).paddingOnly(left: 12.0), | 
					
						
							| 
									
										
										
										
											2022-09-28 11:20:57 +08:00
										 |  |  |           ), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         const Divider(), | 
					
						
							|  |  |  |         SizedBox(child: Obx(() => buildStatus())) | 
					
						
							|  |  |  |             .paddingOnly(bottom: 12, top: 6), | 
					
						
							|  |  |  |       ], | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Callback for the connect button.
 | 
					
						
							|  |  |  |   /// Connects to the selected peer.
 | 
					
						
							| 
									
										
										
										
											2022-05-30 13:25:06 +08:00
										 |  |  |   void onConnect({bool isFileTransfer = false}) { | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |     final id = _idController.id; | 
					
						
							| 
									
										
										
										
											2022-09-19 20:26:39 +08:00
										 |  |  |     connect(context, id, isFileTransfer: isFileTransfer); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-21 17:54:47 +08:00
										 |  |  |   /// UI for the remote ID TextField.
 | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |   /// Search for a peer and connect to it if the id exists.
 | 
					
						
							| 
									
										
										
										
											2022-09-21 17:54:47 +08:00
										 |  |  |   Widget _buildRemoteIDTextField(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2022-08-23 19:55:58 +08:00
										 |  |  |     RxBool inputFocused = false.obs; | 
					
						
							|  |  |  |     FocusNode focusNode = FocusNode(); | 
					
						
							|  |  |  |     focusNode.addListener(() { | 
					
						
							|  |  |  |       inputFocused.value = focusNode.hasFocus; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |     var w = Container( | 
					
						
							| 
									
										
										
										
											2022-08-22 17:58:48 +08:00
										 |  |  |       width: 320 + 20 * 2, | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |       padding: const EdgeInsets.fromLTRB(20, 24, 20, 22), | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |       decoration: BoxDecoration( | 
					
						
							| 
									
										
										
										
											2022-09-23 16:31:50 +08:00
										 |  |  |         color: Theme.of(context).backgroundColor, | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |         borderRadius: const BorderRadius.all(Radius.circular(13)), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       child: Ink( | 
					
						
							|  |  |  |         child: Column( | 
					
						
							|  |  |  |           children: [ | 
					
						
							|  |  |  |             Row( | 
					
						
							| 
									
										
										
										
											2022-08-23 19:55:58 +08:00
										 |  |  |               children: [ | 
					
						
							|  |  |  |                 Text( | 
					
						
							|  |  |  |                   translate('Control Remote Desktop'), | 
					
						
							| 
									
										
										
										
											2022-09-23 16:31:50 +08:00
										 |  |  |                   style: Theme.of(context) | 
					
						
							|  |  |  |                       .textTheme | 
					
						
							|  |  |  |                       .titleLarge | 
					
						
							|  |  |  |                       ?.merge(TextStyle(height: 1)), | 
					
						
							| 
									
										
										
										
											2022-08-23 19:55:58 +08:00
										 |  |  |                 ), | 
					
						
							|  |  |  |               ], | 
					
						
							|  |  |  |             ).marginOnly(bottom: 15), | 
					
						
							|  |  |  |             Row( | 
					
						
							|  |  |  |               children: [ | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |                 Expanded( | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |                   child: Obx( | 
					
						
							|  |  |  |                     () => TextField( | 
					
						
							|  |  |  |                       autocorrect: false, | 
					
						
							|  |  |  |                       enableSuggestions: false, | 
					
						
							|  |  |  |                       keyboardType: TextInputType.visiblePassword, | 
					
						
							|  |  |  |                       focusNode: focusNode, | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |                       style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |                         fontFamily: 'WorkSans', | 
					
						
							|  |  |  |                         fontSize: 22, | 
					
						
							|  |  |  |                         height: 1, | 
					
						
							|  |  |  |                       ), | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |                       maxLines: 1, | 
					
						
							| 
									
										
										
										
											2022-09-23 16:31:50 +08:00
										 |  |  |                       cursorColor: | 
					
						
							|  |  |  |                           Theme.of(context).textTheme.titleLarge?.color, | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |                       decoration: InputDecoration( | 
					
						
							|  |  |  |                           hintText: inputFocused.value | 
					
						
							|  |  |  |                               ? null | 
					
						
							|  |  |  |                               : translate('Enter Remote ID'), | 
					
						
							|  |  |  |                           border: OutlineInputBorder( | 
					
						
							|  |  |  |                               borderRadius: BorderRadius.zero, | 
					
						
							|  |  |  |                               borderSide: BorderSide( | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |                                   color: MyTheme.color(context).border!)), | 
					
						
							|  |  |  |                           enabledBorder: OutlineInputBorder( | 
					
						
							|  |  |  |                               borderRadius: BorderRadius.zero, | 
					
						
							|  |  |  |                               borderSide: BorderSide( | 
					
						
							|  |  |  |                                   color: MyTheme.color(context).border!)), | 
					
						
							|  |  |  |                           focusedBorder: const OutlineInputBorder( | 
					
						
							| 
									
										
										
										
											2022-08-23 19:55:58 +08:00
										 |  |  |                             borderRadius: BorderRadius.zero, | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |                             borderSide: | 
					
						
							|  |  |  |                                 BorderSide(color: MyTheme.button, width: 3), | 
					
						
							|  |  |  |                           ), | 
					
						
							|  |  |  |                           isDense: true, | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |                           contentPadding: const EdgeInsets.symmetric( | 
					
						
							| 
									
										
										
										
											2022-09-02 17:19:44 +08:00
										 |  |  |                               horizontal: 10, vertical: 12)), | 
					
						
							|  |  |  |                       controller: _idController, | 
					
						
							|  |  |  |                       inputFormatters: [IDTextInputFormatter()], | 
					
						
							|  |  |  |                       onSubmitted: (s) { | 
					
						
							|  |  |  |                         onConnect(); | 
					
						
							|  |  |  |                       }, | 
					
						
							|  |  |  |                     ), | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |               ], | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |             Padding( | 
					
						
							| 
									
										
										
										
											2022-08-22 17:58:48 +08:00
										 |  |  |               padding: const EdgeInsets.only(top: 13.0), | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |               child: Row( | 
					
						
							|  |  |  |                 mainAxisAlignment: MainAxisAlignment.end, | 
					
						
							|  |  |  |                 children: [ | 
					
						
							| 
									
										
										
										
											2022-09-23 17:28:22 +08:00
										 |  |  |                   Button( | 
					
						
							|  |  |  |                     isOutline: true, | 
					
						
							|  |  |  |                     onTap: () { | 
					
						
							|  |  |  |                       onConnect(isFileTransfer: true); | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                     text: "Transfer File", | 
					
						
							|  |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |                   const SizedBox( | 
					
						
							| 
									
										
										
										
											2022-08-22 17:58:48 +08:00
										 |  |  |                     width: 17, | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2022-09-23 17:28:22 +08:00
										 |  |  |                   Button(onTap: onConnect, text: "Connect"), | 
					
						
							| 
									
										
										
										
											2022-07-14 12:32:01 +08:00
										 |  |  |                 ], | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |           ], | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     return Center( | 
					
						
							| 
									
										
										
										
											2022-09-03 18:19:50 +08:00
										 |  |  |         child: Container( | 
					
						
							|  |  |  |             constraints: const BoxConstraints(maxWidth: 600), child: w)); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void dispose() { | 
					
						
							|  |  |  |     _idController.dispose(); | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |     _updateTimer?.cancel(); | 
					
						
							| 
									
										
										
										
											2022-05-29 04:39:12 +08:00
										 |  |  |     super.dispose(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |   var svcStopped = false.obs; | 
					
						
							|  |  |  |   var svcStatusCode = 0.obs; | 
					
						
							|  |  |  |   var svcIsUsingPublicServer = true.obs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget buildStatus() { | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |     final fontSize = 14.0; | 
					
						
							|  |  |  |     final textStyle = TextStyle(fontSize: fontSize); | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |     final light = Container( | 
					
						
							|  |  |  |       height: 8, | 
					
						
							|  |  |  |       width: 8, | 
					
						
							|  |  |  |       decoration: BoxDecoration( | 
					
						
							|  |  |  |         borderRadius: BorderRadius.circular(20), | 
					
						
							| 
									
										
										
										
											2022-09-23 15:12:50 +08:00
										 |  |  |         color: svcStopped.value || svcStatusCode.value == 0 | 
					
						
							|  |  |  |             ? kColorWarn | 
					
						
							|  |  |  |             : (svcStatusCode.value == 1 | 
					
						
							|  |  |  |                 ? Color.fromARGB(255, 50, 190, 166) | 
					
						
							|  |  |  |                 : Color.fromARGB(255, 224, 79, 95)), | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |       ), | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |     ).paddingSymmetric(horizontal: 12.0); | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |     if (svcStopped.value) { | 
					
						
							|  |  |  |       return Row( | 
					
						
							|  |  |  |         crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							| 
									
										
										
										
											2022-08-09 20:50:45 +08:00
										 |  |  |         children: [ | 
					
						
							|  |  |  |           light, | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |           Text(translate("Service is not running"), style: textStyle), | 
					
						
							| 
									
										
										
										
											2022-08-09 20:50:45 +08:00
										 |  |  |           TextButton( | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:43 +08:00
										 |  |  |               onPressed: () async { | 
					
						
							|  |  |  |                 bool checked = await bind.mainCheckSuperUserPermission(); | 
					
						
							|  |  |  |                 if (checked) { | 
					
						
							|  |  |  |                   bind.mainSetOption(key: "stop-service", value: ""); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |               }, | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |               child: Text(translate("Start Service"), style: textStyle)) | 
					
						
							| 
									
										
										
										
											2022-08-09 20:50:45 +08:00
										 |  |  |         ], | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       if (svcStatusCode.value == 0) { | 
					
						
							|  |  |  |         return Row( | 
					
						
							|  |  |  |           crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |           children: [ | 
					
						
							|  |  |  |             light, | 
					
						
							|  |  |  |             Text(translate("connecting_status"), style: textStyle) | 
					
						
							|  |  |  |           ], | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |         ); | 
					
						
							|  |  |  |       } else if (svcStatusCode.value == -1) { | 
					
						
							|  |  |  |         return Row( | 
					
						
							|  |  |  |           crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |           children: [ | 
					
						
							|  |  |  |             light, | 
					
						
							|  |  |  |             Text(translate("not_ready_status"), style: textStyle) | 
					
						
							|  |  |  |           ], | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return Row( | 
					
						
							|  |  |  |       crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							|  |  |  |       children: [ | 
					
						
							|  |  |  |         light, | 
					
						
							| 
									
										
										
										
											2022-09-19 19:24:51 +08:00
										 |  |  |         Text(translate('Ready'), style: textStyle), | 
					
						
							| 
									
										
										
										
											2022-09-30 16:15:21 +08:00
										 |  |  |         Offstage( | 
					
						
							|  |  |  |             offstage: !svcIsUsingPublicServer.value, | 
					
						
							|  |  |  |             child: Row( | 
					
						
							|  |  |  |               crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							|  |  |  |               children: [ | 
					
						
							|  |  |  |                 Text(', ', style: textStyle), | 
					
						
							|  |  |  |                 InkWell( | 
					
						
							|  |  |  |                   onTap: onUsePublicServerGuide, | 
					
						
							|  |  |  |                   child: Text( | 
					
						
							|  |  |  |                     translate('setup_server_tip'), | 
					
						
							|  |  |  |                     style: TextStyle( | 
					
						
							|  |  |  |                         decoration: TextDecoration.underline, | 
					
						
							|  |  |  |                         fontSize: fontSize), | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |               ], | 
					
						
							|  |  |  |             )) | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |       ], | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void onUsePublicServerGuide() { | 
					
						
							| 
									
										
										
										
											2022-09-13 21:36:38 +08:00
										 |  |  |     const url = "https://rustdesk.com/blog/id-relay-set/"; | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |     canLaunchUrlString(url).then((can) { | 
					
						
							|  |  |  |       if (can) { | 
					
						
							|  |  |  |         launchUrlString(url); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   updateStatus() async { | 
					
						
							| 
									
										
										
										
											2022-08-09 20:50:45 +08:00
										 |  |  |     svcStopped.value = await bind.mainGetOption(key: "stop-service") == "Y"; | 
					
						
							| 
									
										
										
										
											2022-08-03 22:03:31 +08:00
										 |  |  |     final status = | 
					
						
							|  |  |  |         jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>; | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |     svcStatusCode.value = status["status_num"]; | 
					
						
							| 
									
										
										
										
											2022-08-03 22:03:31 +08:00
										 |  |  |     svcIsUsingPublicServer.value = await bind.mainIsUsingPublicServer(); | 
					
						
							| 
									
										
										
										
											2022-07-25 16:23:45 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-08-02 13:10:09 +08:00
										 |  |  | } |