| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2022-05-24 23:33:00 +08:00
										 |  |  | import 'package:flutter_hbb/mobile/widgets/dialog.dart'; | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  | import 'package:provider/provider.dart'; | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-24 23:33:00 +08:00
										 |  |  | import '../../common.dart'; | 
					
						
							| 
									
										
										
										
											2022-09-16 21:52:08 +08:00
										 |  |  | import '../../common/widgets/dialog.dart'; | 
					
						
							| 
									
										
										
										
											2022-08-08 22:27:27 +08:00
										 |  |  | import '../../models/platform_model.dart'; | 
					
						
							| 
									
										
										
										
											2022-05-24 23:33:00 +08:00
										 |  |  | import '../../models/server_model.dart'; | 
					
						
							| 
									
										
										
										
											2022-02-28 18:29:25 +08:00
										 |  |  | import 'home_page.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-09 20:36:52 +08:00
										 |  |  | class ServerPage extends StatefulWidget implements PageShape { | 
					
						
							| 
									
										
										
										
											2022-02-28 18:29:25 +08:00
										 |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-03-23 15:28:21 +08:00
										 |  |  |   final title = translate("Share Screen"); | 
					
						
							| 
									
										
										
										
											2022-02-28 18:29:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   final icon = const Icon(Icons.mobile_screen_share); | 
					
						
							| 
									
										
										
										
											2022-02-28 18:29:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   final appBarActions = [ | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |     PopupMenuButton<String>( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |         icon: const Icon(Icons.more_vert), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |         itemBuilder: (context) { | 
					
						
							|  |  |  |           return [ | 
					
						
							|  |  |  |             PopupMenuItem( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(horizontal: 16.0), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |               value: "changeID", | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               child: Text(translate("Change ID")), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |             ), | 
					
						
							|  |  |  |             PopupMenuItem( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(horizontal: 16.0), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |               value: "setPermanentPassword", | 
					
						
							|  |  |  |               enabled: | 
					
						
							| 
									
										
										
										
											2022-08-01 10:44:05 +08:00
										 |  |  |                   gFFI.serverModel.verificationMethod != kUseTemporaryPassword, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               child: Text(translate("Set permanent password")), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |             ), | 
					
						
							|  |  |  |             PopupMenuItem( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(horizontal: 16.0), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |               value: "setTemporaryPasswordLength", | 
					
						
							|  |  |  |               enabled: | 
					
						
							| 
									
										
										
										
											2022-08-01 10:44:05 +08:00
										 |  |  |                   gFFI.serverModel.verificationMethod != kUsePermanentPassword, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               child: Text(translate("Set temporary password length")), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |             const PopupMenuDivider(), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |             PopupMenuItem( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(horizontal: 0.0), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |               value: kUseTemporaryPassword, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               child: ListTile( | 
					
						
							|  |  |  |                   title: Text(translate("Use temporary password")), | 
					
						
							|  |  |  |                   trailing: Icon( | 
					
						
							|  |  |  |                     Icons.check, | 
					
						
							|  |  |  |                     color: gFFI.serverModel.verificationMethod == | 
					
						
							|  |  |  |                             kUseTemporaryPassword | 
					
						
							|  |  |  |                         ? null | 
					
						
							|  |  |  |                         : Colors.transparent, | 
					
						
							|  |  |  |                   )), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |             PopupMenuItem( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(horizontal: 0.0), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |               value: kUsePermanentPassword, | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |               child: ListTile( | 
					
						
							|  |  |  |                   title: Text(translate("Use permanent password")), | 
					
						
							|  |  |  |                   trailing: Icon( | 
					
						
							|  |  |  |                     Icons.check, | 
					
						
							| 
									
										
										
										
											2022-08-01 10:44:05 +08:00
										 |  |  |                     color: gFFI.serverModel.verificationMethod == | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |                             kUsePermanentPassword | 
					
						
							|  |  |  |                         ? null | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                         : Colors.transparent, | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |                   )), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |             PopupMenuItem( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(horizontal: 0.0), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |               value: kUseBothPasswords, | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |               child: ListTile( | 
					
						
							|  |  |  |                   title: Text(translate("Use both passwords")), | 
					
						
							|  |  |  |                   trailing: Icon( | 
					
						
							|  |  |  |                     Icons.check, | 
					
						
							| 
									
										
										
										
											2022-08-01 10:44:05 +08:00
										 |  |  |                     color: gFFI.serverModel.verificationMethod != | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |                                 kUseTemporaryPassword && | 
					
						
							| 
									
										
										
										
											2022-08-01 10:44:05 +08:00
										 |  |  |                             gFFI.serverModel.verificationMethod != | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |                                 kUsePermanentPassword | 
					
						
							|  |  |  |                         ? null | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                         : Colors.transparent, | 
					
						
							| 
									
										
										
										
											2022-07-29 22:07:45 +08:00
										 |  |  |                   )), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |           ]; | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         onSelected: (value) { | 
					
						
							|  |  |  |           if (value == "changeID") { | 
					
						
							| 
									
										
										
										
											2022-09-16 21:52:08 +08:00
										 |  |  |             changeIdDialog(); | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |           } else if (value == "setPermanentPassword") { | 
					
						
							| 
									
										
										
										
											2022-08-12 18:42:02 +08:00
										 |  |  |             setPermanentPasswordDialog(gFFI.dialogManager); | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |           } else if (value == "setTemporaryPasswordLength") { | 
					
						
							| 
									
										
										
										
											2022-08-12 18:42:02 +08:00
										 |  |  |             setTemporaryPasswordLengthDialog(gFFI.dialogManager); | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |           } else if (value == kUsePermanentPassword || | 
					
						
							|  |  |  |               value == kUseTemporaryPassword || | 
					
						
							|  |  |  |               value == kUseBothPasswords) { | 
					
						
							| 
									
										
										
										
											2022-08-08 22:27:27 +08:00
										 |  |  |             bind.mainSetOption(key: "verification-method", value: value); | 
					
						
							| 
									
										
										
										
											2022-08-01 10:44:05 +08:00
										 |  |  |             gFFI.serverModel.updatePasswordModel(); | 
					
						
							| 
									
										
										
										
											2022-03-30 23:09:19 +08:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-04-04 01:38:53 +08:00
										 |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-02-28 18:29:25 +08:00
										 |  |  |   ]; | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   ServerPage({Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-09 20:36:52 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   State<StatefulWidget> createState() => _ServerPageState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _ServerPageState extends State<ServerPage> { | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							|  |  |  |     gFFI.serverModel.checkAndroidPermission(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2022-02-08 22:45:48 +08:00
										 |  |  |     checkService(); | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |     return ChangeNotifierProvider.value( | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |         value: gFFI.serverModel, | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |         child: Consumer<ServerModel>( | 
					
						
							|  |  |  |             builder: (context, serverModel, child) => SingleChildScrollView( | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |                   controller: gFFI.serverModel.controller, | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |                   child: Center( | 
					
						
							|  |  |  |                     child: Column( | 
					
						
							|  |  |  |                       mainAxisAlignment: MainAxisAlignment.start, | 
					
						
							|  |  |  |                       children: [ | 
					
						
							|  |  |  |                         ServerInfo(), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                         const PermissionChecker(), | 
					
						
							|  |  |  |                         const ConnectionManager(), | 
					
						
							|  |  |  |                         SizedBox.fromSize(size: const Size(0, 15.0)), | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |                       ], | 
					
						
							|  |  |  |                     ), | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                 ))); | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  | void checkService() async { | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |   gFFI.invokeMethod("check_service"); // jvm
 | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |   // for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
 | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |   if (PermissionManager.isWaitingFile() && !gFFI.serverModel.fileOk) { | 
					
						
							| 
									
										
										
										
											2022-04-12 20:54:29 +08:00
										 |  |  |     PermissionManager.complete("file", await PermissionManager.check("file")); | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |     debugPrint("file permission finished"); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-02-08 22:45:48 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  | class ServerInfo extends StatelessWidget { | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |   final model = gFFI.serverModel; | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |   final emptyController = TextEditingController(text: "-"); | 
					
						
							| 
									
										
										
										
											2022-03-19 23:28:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   ServerInfo({Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |     final isPermanent = model.verificationMethod == kUsePermanentPassword; | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |     return model.isStart | 
					
						
							|  |  |  |         ? PaddingCard( | 
					
						
							|  |  |  |             child: Column( | 
					
						
							|  |  |  |             mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |             children: [ | 
					
						
							|  |  |  |               TextFormField( | 
					
						
							|  |  |  |                 readOnly: true, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                 style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                     fontSize: 25.0, | 
					
						
							|  |  |  |                     fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |                     color: MyTheme.accent), | 
					
						
							|  |  |  |                 controller: model.serverId, | 
					
						
							|  |  |  |                 decoration: InputDecoration( | 
					
						
							|  |  |  |                   icon: const Icon(Icons.perm_identity), | 
					
						
							|  |  |  |                   labelText: translate("ID"), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                   labelStyle: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                       fontWeight: FontWeight.bold, color: MyTheme.accent80), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                 ), | 
					
						
							|  |  |  |                 onSaved: (String? value) {}, | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |               TextFormField( | 
					
						
							|  |  |  |                 readOnly: true, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                 style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                     fontSize: 25.0, | 
					
						
							|  |  |  |                     fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |                     color: MyTheme.accent), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |                 controller: isPermanent ? emptyController : model.serverPasswd, | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                 decoration: InputDecoration( | 
					
						
							|  |  |  |                     icon: const Icon(Icons.lock), | 
					
						
							|  |  |  |                     labelText: translate("Password"), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                     labelStyle: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                         fontWeight: FontWeight.bold, color: MyTheme.accent80), | 
					
						
							| 
									
										
										
										
											2022-07-29 18:34:25 +08:00
										 |  |  |                     suffix: isPermanent | 
					
						
							|  |  |  |                         ? null | 
					
						
							|  |  |  |                         : IconButton( | 
					
						
							|  |  |  |                             icon: const Icon(Icons.refresh), | 
					
						
							| 
									
										
										
										
											2022-08-08 22:27:27 +08:00
										 |  |  |                             onPressed: () => | 
					
						
							|  |  |  |                                 bind.mainUpdateTemporaryPassword())), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                 onSaved: (String? value) {}, | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |           )) | 
					
						
							|  |  |  |         : PaddingCard( | 
					
						
							|  |  |  |             child: Column( | 
					
						
							|  |  |  |             crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							|  |  |  |             children: [ | 
					
						
							|  |  |  |               Center( | 
					
						
							|  |  |  |                   child: Row( | 
					
						
							|  |  |  |                 children: [ | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                   const Icon(Icons.warning_amber_sharp, | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                       color: Colors.redAccent, size: 24), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                   const SizedBox(width: 10), | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |                   Expanded( | 
					
						
							|  |  |  |                       child: Text( | 
					
						
							| 
									
										
										
										
											2022-03-23 15:28:21 +08:00
										 |  |  |                     translate("Service is not running"), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                     style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                       fontFamily: 'WorkSans', | 
					
						
							|  |  |  |                       fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |                       fontSize: 18, | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                       color: MyTheme.accent, | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                     ), | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |                   )) | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                 ], | 
					
						
							|  |  |  |               )), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               const SizedBox(height: 5), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |               Center( | 
					
						
							|  |  |  |                   child: Text( | 
					
						
							| 
									
										
										
										
											2022-03-23 15:28:21 +08:00
										 |  |  |                 translate("android_start_service_tip"), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                 style: const TextStyle(fontSize: 12, color: MyTheme.darkGray), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |               )) | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |           )); | 
					
						
							| 
									
										
										
										
											2022-02-09 17:04:13 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class PermissionChecker extends StatefulWidget { | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   const PermissionChecker({Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   State<PermissionChecker> createState() => _PermissionCheckerState(); | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _PermissionCheckerState extends State<PermissionChecker> { | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  |     final serverModel = Provider.of<ServerModel>(context); | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |     final hasAudioPermission = androidVersion >= 30; | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |     final String status; | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |     if (serverModel.connectStatus == -1) { | 
					
						
							|  |  |  |       status = 'not_ready_status'; | 
					
						
							|  |  |  |     } else if (serverModel.connectStatus == 0) { | 
					
						
							|  |  |  |       status = 'connecting_status'; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       status = 'Ready'; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |     return PaddingCard( | 
					
						
							| 
									
										
										
										
											2022-04-20 15:45:51 +08:00
										 |  |  |         title: translate("Permissions"), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |         child: Column( | 
					
						
							|  |  |  |           crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |           children: [ | 
					
						
							|  |  |  |             PermissionRow(translate("Screen Capture"), serverModel.mediaOk, | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |                 serverModel.toggleService), | 
					
						
							| 
									
										
										
										
											2022-04-20 15:45:51 +08:00
										 |  |  |             PermissionRow(translate("Input Control"), serverModel.inputOk, | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |                 serverModel.toggleInput), | 
					
						
							| 
									
										
										
										
											2022-06-08 22:35:06 +08:00
										 |  |  |             PermissionRow(translate("Transfer File"), serverModel.fileOk, | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                 serverModel.toggleFile), | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |             hasAudioPermission | 
					
						
							|  |  |  |                 ? PermissionRow(translate("Audio Capture"), serverModel.audioOk, | 
					
						
							|  |  |  |                     serverModel.toggleAudio) | 
					
						
							|  |  |  |                 : Text( | 
					
						
							|  |  |  |                     "* ${translate("android_version_audio_tip")}", | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                     style: const TextStyle(color: MyTheme.darkGray), | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |             const SizedBox(height: 8), | 
					
						
							| 
									
										
										
										
											2022-04-12 22:38:39 +08:00
										 |  |  |             Row( | 
					
						
							|  |  |  |               crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							|  |  |  |               children: [ | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |                 Expanded( | 
					
						
							|  |  |  |                     flex: 0, | 
					
						
							|  |  |  |                     child: serverModel.mediaOk | 
					
						
							|  |  |  |                         ? ElevatedButton.icon( | 
					
						
							|  |  |  |                             style: ButtonStyle( | 
					
						
							|  |  |  |                                 backgroundColor: | 
					
						
							|  |  |  |                                     MaterialStateProperty.all(Colors.red)), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                             icon: const Icon(Icons.stop), | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |                             onPressed: serverModel.toggleService, | 
					
						
							|  |  |  |                             label: Text(translate("Stop service"))) | 
					
						
							|  |  |  |                         : ElevatedButton.icon( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                             icon: const Icon(Icons.play_arrow), | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |                             onPressed: serverModel.toggleService, | 
					
						
							|  |  |  |                             label: Text(translate("Start Service")))), | 
					
						
							|  |  |  |                 Expanded( | 
					
						
							|  |  |  |                     child: serverModel.mediaOk | 
					
						
							|  |  |  |                         ? Row( | 
					
						
							|  |  |  |                             children: [ | 
					
						
							|  |  |  |                               Expanded( | 
					
						
							|  |  |  |                                   flex: 0, | 
					
						
							|  |  |  |                                   child: Padding( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                                       padding: const EdgeInsets.only( | 
					
						
							|  |  |  |                                           left: 20, right: 5), | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |                                       child: Icon(Icons.circle, | 
					
						
							|  |  |  |                                           color: serverModel.connectStatus > 0 | 
					
						
							|  |  |  |                                               ? Colors.greenAccent | 
					
						
							|  |  |  |                                               : Colors.deepOrangeAccent, | 
					
						
							|  |  |  |                                           size: 10))), | 
					
						
							|  |  |  |                               Expanded( | 
					
						
							|  |  |  |                                   child: Text(translate(status), | 
					
						
							|  |  |  |                                       softWrap: true, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                                       style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |                                           fontSize: 14.0, | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                                           fontWeight: FontWeight.w500, | 
					
						
							|  |  |  |                                           color: MyTheme.accent80))) | 
					
						
							| 
									
										
										
										
											2022-04-17 11:34:46 +08:00
										 |  |  |                             ], | 
					
						
							|  |  |  |                           ) | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                         : const SizedBox.shrink()) | 
					
						
							| 
									
										
										
										
											2022-04-12 22:38:39 +08:00
										 |  |  |               ], | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |           ], | 
					
						
							|  |  |  |         )); | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class PermissionRow extends StatelessWidget { | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   const PermissionRow(this.name, this.isOk, this.onPressed, {Key? key}) | 
					
						
							|  |  |  |       : super(key: key); | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   final String name; | 
					
						
							|  |  |  |   final bool isOk; | 
					
						
							|  |  |  |   final VoidCallback onPressed; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return Row( | 
					
						
							|  |  |  |       children: [ | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |         Expanded( | 
					
						
							|  |  |  |             flex: 5, | 
					
						
							|  |  |  |             child: FittedBox( | 
					
						
							|  |  |  |                 fit: BoxFit.scaleDown, | 
					
						
							|  |  |  |                 alignment: Alignment.centerLeft, | 
					
						
							| 
									
										
										
										
											2022-09-29 13:07:20 +08:00
										 |  |  |                 child: | 
					
						
							|  |  |  |                     Text(name, style: Theme.of(context).textTheme.labelLarge))), | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |         Expanded( | 
					
						
							|  |  |  |           flex: 2, | 
					
						
							|  |  |  |           child: FittedBox( | 
					
						
							|  |  |  |               fit: BoxFit.scaleDown, | 
					
						
							| 
									
										
										
										
											2022-02-25 22:16:51 +08:00
										 |  |  |               child: Text(isOk ? translate("ON") : translate("OFF"), | 
					
						
							|  |  |  |                   style: TextStyle( | 
					
						
							|  |  |  |                       fontSize: 16.0, | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |                       color: isOk ? Colors.green : Colors.grey))), | 
					
						
							| 
									
										
										
										
											2022-02-25 22:16:51 +08:00
										 |  |  |         ), | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |         Expanded( | 
					
						
							|  |  |  |             flex: 3, | 
					
						
							|  |  |  |             child: FittedBox( | 
					
						
							|  |  |  |                 fit: BoxFit.scaleDown, | 
					
						
							|  |  |  |                 alignment: Alignment.centerRight, | 
					
						
							|  |  |  |                 child: TextButton( | 
					
						
							|  |  |  |                     onPressed: onPressed, | 
					
						
							|  |  |  |                     child: Text( | 
					
						
							|  |  |  |                       translate(isOk ? "CLOSE" : "OPEN"), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                       style: const TextStyle(fontWeight: FontWeight.bold), | 
					
						
							| 
									
										
										
										
											2022-08-04 17:24:02 +08:00
										 |  |  |                     )))), | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  |       ], | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  | class ConnectionManager extends StatelessWidget { | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   const ConnectionManager({Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     final serverModel = Provider.of<ServerModel>(context); | 
					
						
							| 
									
										
										
										
											2022-03-19 23:28:29 +08:00
										 |  |  |     return Column( | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |         children: serverModel.clients | 
					
						
							|  |  |  |             .map((client) => PaddingCard( | 
					
						
							|  |  |  |                 title: translate(client.isFileTransfer | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |                     ? "File Connection" | 
					
						
							|  |  |  |                     : "Screen Connection"), | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                 titleIcon: client.isFileTransfer | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |                     ? Icons.folder_outlined | 
					
						
							|  |  |  |                     : Icons.mobile_screen_share, | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                 child: Column( | 
					
						
							|  |  |  |                   crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |                   children: [ | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |                     Row( | 
					
						
							|  |  |  |                       mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
					
						
							|  |  |  |                       children: [ | 
					
						
							| 
									
										
										
										
											2022-09-29 21:53:50 +08:00
										 |  |  |                         Expanded(child: ClientInfo(client)), | 
					
						
							| 
									
										
										
										
											2022-04-28 22:44:54 +08:00
										 |  |  |                         Expanded( | 
					
						
							|  |  |  |                             flex: -1, | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                             child: client.isFileTransfer || !client.authorized | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                                 ? const SizedBox.shrink() | 
					
						
							| 
									
										
										
										
											2022-04-28 22:44:54 +08:00
										 |  |  |                                 : IconButton( | 
					
						
							|  |  |  |                                     onPressed: () { | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                                       gFFI.chatModel.changeCurrentID(client.id); | 
					
						
							| 
									
										
										
										
											2022-04-28 22:44:54 +08:00
										 |  |  |                                       final bar = | 
					
						
							|  |  |  |                                           navigationBarKey.currentWidget; | 
					
						
							|  |  |  |                                       if (bar != null) { | 
					
						
							|  |  |  |                                         bar as BottomNavigationBar; | 
					
						
							|  |  |  |                                         bar.onTap!(1); | 
					
						
							|  |  |  |                                       } | 
					
						
							|  |  |  |                                     }, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                                     icon: const Icon( | 
					
						
							| 
									
										
										
										
											2022-04-28 22:44:54 +08:00
										 |  |  |                                       Icons.chat, | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                                       color: MyTheme.accent, | 
					
						
							| 
									
										
										
										
											2022-04-28 22:44:54 +08:00
										 |  |  |                                     ))) | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |                       ], | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                     ), | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                     client.authorized | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                         ? const SizedBox.shrink() | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                         : Text( | 
					
						
							|  |  |  |                             translate("android_new_connection_tip"), | 
					
						
							| 
									
										
										
										
											2022-09-26 11:21:40 +08:00
										 |  |  |                             style: Theme.of(globalKey.currentContext!) | 
					
						
							|  |  |  |                                 .textTheme | 
					
						
							|  |  |  |                                 .bodyMedium, | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                           ), | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                     client.authorized | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                         ? ElevatedButton.icon( | 
					
						
							|  |  |  |                             style: ButtonStyle( | 
					
						
							|  |  |  |                                 backgroundColor: | 
					
						
							|  |  |  |                                     MaterialStateProperty.all(Colors.red)), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                             icon: const Icon(Icons.close), | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                             onPressed: () { | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                               bind.cmCloseConnection(connId: client.id); | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |                               gFFI.invokeMethod( | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                                   "cancel_notification", client.id); | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                             }, | 
					
						
							|  |  |  |                             label: Text(translate("Close"))) | 
					
						
							|  |  |  |                         : Row(children: [ | 
					
						
							|  |  |  |                             TextButton( | 
					
						
							|  |  |  |                                 child: Text(translate("Dismiss")), | 
					
						
							|  |  |  |                                 onPressed: () { | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                                   serverModel.sendLoginResponse(client, false); | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                                 }), | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                             const SizedBox(width: 20), | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                             ElevatedButton( | 
					
						
							|  |  |  |                                 child: Text(translate("Accept")), | 
					
						
							|  |  |  |                                 onPressed: () { | 
					
						
							| 
									
										
										
										
											2022-08-22 20:18:31 +08:00
										 |  |  |                                   serverModel.sendLoginResponse(client, true); | 
					
						
							| 
									
										
										
										
											2022-04-19 21:15:19 +08:00
										 |  |  |                                 }), | 
					
						
							|  |  |  |                           ]), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |                   ], | 
					
						
							|  |  |  |                 ))) | 
					
						
							|  |  |  |             .toList()); | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  | class PaddingCard extends StatelessWidget { | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |   const PaddingCard({Key? key, required this.child, this.title, this.titleIcon}) | 
					
						
							|  |  |  |       : super(key: key); | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |   final String? title; | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |   final IconData? titleIcon; | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |   final Widget child; | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     final children = [child]; | 
					
						
							|  |  |  |     if (title != null) { | 
					
						
							|  |  |  |       children.insert( | 
					
						
							|  |  |  |           0, | 
					
						
							|  |  |  |           Padding( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |               padding: const EdgeInsets.symmetric(vertical: 5.0), | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |               child: Row( | 
					
						
							|  |  |  |                 children: [ | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |                   titleIcon != null | 
					
						
							|  |  |  |                       ? Padding( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                           padding: const EdgeInsets.only(right: 10), | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                           child: | 
					
						
							|  |  |  |                               Icon(titleIcon, color: MyTheme.accent, size: 30)) | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                       : const SizedBox.shrink(), | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |                   Text( | 
					
						
							|  |  |  |                     title!, | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |                     style: const TextStyle( | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |                       fontFamily: 'WorkSans', | 
					
						
							|  |  |  |                       fontWeight: FontWeight.bold, | 
					
						
							| 
									
										
										
										
											2022-03-23 16:28:37 +08:00
										 |  |  |                       fontSize: 20, | 
					
						
							| 
									
										
										
										
											2022-09-23 17:16:25 +08:00
										 |  |  |                       color: MyTheme.accent, | 
					
						
							| 
									
										
										
										
											2022-03-22 21:47:42 +08:00
										 |  |  |                     ), | 
					
						
							|  |  |  |                   ) | 
					
						
							|  |  |  |                 ], | 
					
						
							| 
									
										
										
										
											2022-03-25 16:34:27 +08:00
										 |  |  |               ))); | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |     return SizedBox( | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |         width: double.maxFinite, | 
					
						
							|  |  |  |         child: Card( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |           margin: const EdgeInsets.fromLTRB(15.0, 15.0, 15.0, 0), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |           child: Padding( | 
					
						
							| 
									
										
										
										
											2022-09-16 20:43:15 +08:00
										 |  |  |             padding: | 
					
						
							|  |  |  |                 const EdgeInsets.symmetric(vertical: 15.0, horizontal: 30.0), | 
					
						
							| 
									
										
										
										
											2022-03-22 16:40:23 +08:00
										 |  |  |             child: Column( | 
					
						
							|  |  |  |               crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |               children: children, | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         )); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-02-02 17:25:56 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 21:53:50 +08:00
										 |  |  | class ClientInfo extends StatelessWidget { | 
					
						
							|  |  |  |   final Client client; | 
					
						
							|  |  |  |   ClientInfo(this.client); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return Padding( | 
					
						
							|  |  |  |         padding: const EdgeInsets.symmetric(vertical: 8), | 
					
						
							|  |  |  |         child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ | 
					
						
							|  |  |  |           Row( | 
					
						
							|  |  |  |             children: [ | 
					
						
							|  |  |  |               Expanded( | 
					
						
							|  |  |  |                   flex: -1, | 
					
						
							|  |  |  |                   child: Padding( | 
					
						
							|  |  |  |                       padding: const EdgeInsets.only(right: 12), | 
					
						
							|  |  |  |                       child: CircleAvatar( | 
					
						
							|  |  |  |                           backgroundColor: | 
					
						
							|  |  |  |                               str2color(client.name).withOpacity(0.7), | 
					
						
							|  |  |  |                           child: Text(client.name[0])))), | 
					
						
							|  |  |  |               Expanded( | 
					
						
							|  |  |  |                   child: Column( | 
					
						
							|  |  |  |                       crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |                       mainAxisAlignment: MainAxisAlignment.center, | 
					
						
							|  |  |  |                       children: [ | 
					
						
							|  |  |  |                     Text(client.name, | 
					
						
							|  |  |  |                         style: const TextStyle( | 
					
						
							|  |  |  |                             color: MyTheme.idColor, fontSize: 18)), | 
					
						
							|  |  |  |                     const SizedBox(width: 8), | 
					
						
							|  |  |  |                     Text(client.peerId, | 
					
						
							|  |  |  |                         style: const TextStyle( | 
					
						
							|  |  |  |                             color: MyTheme.idColor, fontSize: 10)) | 
					
						
							|  |  |  |                   ])) | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ])); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-01-23 21:37:19 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-02-10 02:07:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-23 14:12:30 +08:00
										 |  |  | void androidChannelInit() { | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |   gFFI.setMethodCallHandler((method, arguments) { | 
					
						
							| 
									
										
										
										
											2022-02-25 21:54:05 +08:00
										 |  |  |     debugPrint("flutter got android msg,$method,$arguments"); | 
					
						
							| 
									
										
										
										
											2022-02-10 02:07:53 +08:00
										 |  |  |     try { | 
					
						
							|  |  |  |       switch (method) { | 
					
						
							|  |  |  |         case "start_capture": | 
					
						
							|  |  |  |           { | 
					
						
							| 
									
										
										
										
											2022-08-12 18:42:02 +08:00
										 |  |  |             gFFI.dialogManager.dismissAll(); | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |             gFFI.serverModel.updateClientState(); | 
					
						
							| 
									
										
										
										
											2022-02-10 02:07:53 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |         case "on_state_changed": | 
					
						
							| 
									
										
										
										
											2022-02-10 02:07:53 +08:00
										 |  |  |           { | 
					
						
							|  |  |  |             var name = arguments["name"] as String; | 
					
						
							|  |  |  |             var value = arguments["value"] as String == "true"; | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |             debugPrint("from jvm:on_state_changed,$name:$value"); | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |             gFFI.serverModel.changeStatue(name, value); | 
					
						
							| 
									
										
										
										
											2022-02-10 02:07:53 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-04-04 14:54:00 +08:00
										 |  |  |         case "on_android_permission_result": | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             var type = arguments["type"] as String; | 
					
						
							|  |  |  |             var result = arguments["result"] as bool; | 
					
						
							|  |  |  |             PermissionManager.complete(type, result); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-04-12 20:54:29 +08:00
										 |  |  |         case "on_media_projection_canceled": | 
					
						
							|  |  |  |           { | 
					
						
							| 
									
										
										
										
											2022-06-13 21:07:26 +08:00
										 |  |  |             gFFI.serverModel.stopService(); | 
					
						
							| 
									
										
										
										
											2022-04-12 20:54:29 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-02-10 02:07:53 +08:00
										 |  |  |       } | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |       debugPrint("MethodCallHandler err:$e"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return ""; | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |