just format

This commit is contained in:
csf 2022-04-13 15:33:23 +08:00
parent bb21435faa
commit ba2b30f488

View File

@ -50,8 +50,9 @@ class ServerModel with ChangeNotifier {
// audio // audio
if (androidVersion < 30 || !await PermissionManager.check("audio")) { if (androidVersion < 30 || !await PermissionManager.check("audio")) {
_audioOk = false; _audioOk = false;
FFI.setByName('option', jsonEncode( FFI.setByName(
Map() 'option',
jsonEncode(Map()
..["name"] = "enable-audio" ..["name"] = "enable-audio"
..["value"] = "N")); ..["value"] = "N"));
} else { } else {
@ -62,8 +63,9 @@ class ServerModel with ChangeNotifier {
// file // file
if (!await PermissionManager.check("file")) { if (!await PermissionManager.check("file")) {
_fileOk = false; _fileOk = false;
FFI.setByName('option', jsonEncode( FFI.setByName(
Map() 'option',
jsonEncode(Map()
..["name"] = "enable-file-transfer" ..["name"] = "enable-file-transfer"
..["value"] = "N")); ..["value"] = "N"));
} else { } else {
@ -124,7 +126,8 @@ class ServerModel with ChangeNotifier {
toggleService() async { toggleService() async {
if (_isStart) { if (_isStart) {
final res = await DialogManager.show<bool>((setState, close) => CustomAlertDialog( final res =
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
title: Row(children: [ title: Row(children: [
Icon(Icons.warning_amber_sharp, Icon(Icons.warning_amber_sharp,
color: Colors.redAccent, size: 28), color: Colors.redAccent, size: 28),
@ -133,15 +136,20 @@ class ServerModel with ChangeNotifier {
]), ]),
content: Text(translate("android_stop_service_tip")), content: Text(translate("android_stop_service_tip")),
actions: [ actions: [
TextButton(onPressed: ()=>close(), child: Text(translate("Cancel"))), TextButton(
ElevatedButton(onPressed: ()=>close(true), child: Text(translate("OK"))), onPressed: () => close(),
child: Text(translate("Cancel"))),
ElevatedButton(
onPressed: () => close(true),
child: Text(translate("OK"))),
], ],
)); ));
if (res == true) { if (res == true) {
stopService(); stopService();
} }
} else { } else {
final res = await DialogManager.show<bool>((setState, close) => CustomAlertDialog( final res =
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
title: Row(children: [ title: Row(children: [
Icon(Icons.warning_amber_sharp, Icon(Icons.warning_amber_sharp,
color: Colors.redAccent, size: 28), color: Colors.redAccent, size: 28),
@ -150,8 +158,12 @@ class ServerModel with ChangeNotifier {
]), ]),
content: Text(translate("android_service_will_start_tip")), content: Text(translate("android_service_will_start_tip")),
actions: [ actions: [
TextButton(onPressed: ()=>close(), child: Text(translate("Cancel"))), TextButton(
ElevatedButton(onPressed: ()=>close(true), child: Text(translate("OK"))), onPressed: () => close(),
child: Text(translate("Cancel"))),
ElevatedButton(
onPressed: () => close(true),
child: Text(translate("OK"))),
], ],
)); ));
if (res == true) { if (res == true) {
@ -240,7 +252,6 @@ class ServerModel with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
changeStatue(String name, bool value) { changeStatue(String name, bool value) {
debugPrint("changeStatue value $value"); debugPrint("changeStatue value $value");
switch (name) { switch (name) {
@ -283,11 +294,14 @@ class ServerModel with ChangeNotifier {
final client = Client.fromJson(jsonDecode(evt["client"])); final client = Client.fromJson(jsonDecode(evt["client"]));
final Map<String, dynamic> response = Map(); final Map<String, dynamic> response = Map();
response["id"] = client.id; response["id"] = client.id;
DialogManager.show((setState, close) => CustomAlertDialog( DialogManager.show(
(setState, close) => CustomAlertDialog(
title: Row( title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(translate(client.isFileTransfer?"File Connection":"Screen Connection")), Text(translate(client.isFileTransfer
? "File Connection"
: "Screen Connection")),
IconButton(onPressed: close, icon: Icon(Icons.close)) IconButton(onPressed: close, icon: Icon(Icons.close))
]), ]),
content: Column( content: Column(
@ -297,7 +311,10 @@ class ServerModel with ChangeNotifier {
children: [ children: [
Text(translate("Do you accept?")), Text(translate("Do you accept?")),
clientInfo(client), clientInfo(client),
Text(translate("android_new_connection_tip"),style: TextStyle(color: Colors.black54),), Text(
translate("android_new_connection_tip"),
style: TextStyle(color: Colors.black54),
),
], ],
), ),
actions: [ actions: [
@ -322,7 +339,10 @@ class ServerModel with ChangeNotifier {
notifyListeners(); notifyListeners();
close(); close();
}), }),
],onWillPop: ()async=>true,),barrierDismissible: true); ],
onWillPop: () async => true,
),
barrierDismissible: true);
} catch (e) { } catch (e) {
debugPrint("loginRequest failed,error:$e"); debugPrint("loginRequest failed,error:$e");
} }
@ -335,9 +355,7 @@ class ServerModel with ChangeNotifier {
DialogManager.reset(); DialogManager.reset();
_clients[client.id] = client; _clients[client.id] = client;
notifyListeners(); notifyListeners();
}catch(e){ } catch (e) {}
}
} }
void onClientRemove(Map<String, dynamic> evt) { void onClientRemove(Map<String, dynamic> evt) {
@ -375,7 +393,8 @@ class Client {
bool audio = false; bool audio = false;
late ChatUser chatUser; late ChatUser chatUser;
Client(this.authorized, this.isFileTransfer, this.name, this.peerId,this.keyboard,this.clipboard,this.audio); Client(this.authorized, this.isFileTransfer, this.name, this.peerId,
this.keyboard, this.clipboard, this.audio);
Client.fromJson(Map<String, dynamic> json) { Client.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];