UI optimization
This commit is contained in:
parent
2d31e44b54
commit
67a3db7378
@ -89,14 +89,13 @@ class ServerModel with ChangeNotifier {
|
|||||||
}();
|
}();
|
||||||
|
|
||||||
Timer.periodic(Duration(seconds: 1), (timer) {
|
Timer.periodic(Duration(seconds: 1), (timer) {
|
||||||
var update = false;
|
|
||||||
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
|
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
|
||||||
if (status > 0) {
|
if (status > 0) {
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
if (status != _connectStatus) {
|
if (status != _connectStatus) {
|
||||||
_connectStatus = status;
|
_connectStatus = status;
|
||||||
update = true;
|
notifyListeners();
|
||||||
}
|
}
|
||||||
final res =
|
final res =
|
||||||
FFI.getByName('check_clients_length', _clients.length.toString());
|
FFI.getByName('check_clients_length', _clients.length.toString());
|
||||||
@ -105,25 +104,28 @@ class ServerModel with ChangeNotifier {
|
|||||||
updateClientState(res);
|
updateClientState(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
final temporaryPassword = FFI.getByName("temporary_password");
|
updatePasswordModel();
|
||||||
final verificationMethod = FFI.getByName("option", "verification-method");
|
|
||||||
if (_serverPasswd.text != temporaryPassword) {
|
|
||||||
_serverPasswd.text = temporaryPassword;
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_verificationMethod != verificationMethod) {
|
|
||||||
debugPrint("_verificationMethod changed: $verificationMethod");
|
|
||||||
_verificationMethod = verificationMethod;
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update) {
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePasswordModel() {
|
||||||
|
var update = false;
|
||||||
|
final temporaryPassword = FFI.getByName("temporary_password");
|
||||||
|
final verificationMethod = FFI.getByName("option", "verification-method");
|
||||||
|
if (_serverPasswd.text != temporaryPassword) {
|
||||||
|
_serverPasswd.text = temporaryPassword;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_verificationMethod != verificationMethod) {
|
||||||
|
_verificationMethod = verificationMethod;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
if (update) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleAudio() async {
|
toggleAudio() async {
|
||||||
if (!_audioOk && !await PermissionManager.check("audio")) {
|
if (!_audioOk && !await PermissionManager.check("audio")) {
|
||||||
final res = await PermissionManager.request("audio");
|
final res = await PermissionManager.request("audio");
|
||||||
|
@ -26,43 +26,66 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
return [
|
return [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(translate("Change ID")),
|
child: Text(translate("Change ID")),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
value: "changeID",
|
value: "changeID",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(translate("Set permanent password")),
|
child: Text(translate("Set permanent password")),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
value: "setPermanentPassword",
|
value: "setPermanentPassword",
|
||||||
enabled:
|
enabled:
|
||||||
FFI.serverModel.verificationMethod != kUseTemporaryPassword,
|
FFI.serverModel.verificationMethod != kUseTemporaryPassword,
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(translate("Set temporary password length")),
|
child: Text(translate("Set temporary password length")),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
value: "setTemporaryPasswordLength",
|
value: "setTemporaryPasswordLength",
|
||||||
enabled:
|
enabled:
|
||||||
FFI.serverModel.verificationMethod != kUsePermanentPassword,
|
FFI.serverModel.verificationMethod != kUsePermanentPassword,
|
||||||
),
|
),
|
||||||
const PopupMenuDivider(),
|
const PopupMenuDivider(),
|
||||||
CheckedPopupMenuItem(
|
PopupMenuItem(
|
||||||
checked:
|
padding: EdgeInsets.symmetric(horizontal: 0.0),
|
||||||
FFI.serverModel.verificationMethod == kUseTemporaryPassword,
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
value: kUseTemporaryPassword,
|
value: kUseTemporaryPassword,
|
||||||
child: Text(translate("Use temporary password")),
|
child: Container(
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(translate("Use temporary password")),
|
||||||
|
trailing: Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: FFI.serverModel.verificationMethod ==
|
||||||
|
kUseTemporaryPassword
|
||||||
|
? null
|
||||||
|
: Color(0xFFFFFFFF),
|
||||||
|
))),
|
||||||
),
|
),
|
||||||
CheckedPopupMenuItem(
|
PopupMenuItem(
|
||||||
checked:
|
padding: EdgeInsets.symmetric(horizontal: 0.0),
|
||||||
FFI.serverModel.verificationMethod == kUsePermanentPassword,
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
value: kUsePermanentPassword,
|
value: kUsePermanentPassword,
|
||||||
child: Text(translate("Use permanent password")),
|
child: ListTile(
|
||||||
|
title: Text(translate("Use permanent password")),
|
||||||
|
trailing: Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: FFI.serverModel.verificationMethod ==
|
||||||
|
kUsePermanentPassword
|
||||||
|
? null
|
||||||
|
: Color(0xFFFFFFFF),
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
CheckedPopupMenuItem(
|
PopupMenuItem(
|
||||||
checked: FFI.serverModel.verificationMethod !=
|
padding: EdgeInsets.symmetric(horizontal: 0.0),
|
||||||
kUseTemporaryPassword &&
|
|
||||||
FFI.serverModel.verificationMethod != kUsePermanentPassword,
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
value: kUseBothPasswords,
|
value: kUseBothPasswords,
|
||||||
child: Text(translate("Use both passwords")),
|
child: ListTile(
|
||||||
|
title: Text(translate("Use both passwords")),
|
||||||
|
trailing: Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: FFI.serverModel.verificationMethod !=
|
||||||
|
kUseTemporaryPassword &&
|
||||||
|
FFI.serverModel.verificationMethod !=
|
||||||
|
kUsePermanentPassword
|
||||||
|
? null
|
||||||
|
: Color(0xFFFFFFFF),
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
@ -80,6 +103,7 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
..["name"] = "verification-method"
|
..["name"] = "verification-method"
|
||||||
..["value"] = value;
|
..["value"] = value;
|
||||||
FFI.setByName('option', jsonEncode(msg));
|
FFI.setByName('option', jsonEncode(msg));
|
||||||
|
FFI.serverModel.updatePasswordModel();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
@ -120,6 +120,10 @@ void setTemporaryPasswordLengthDialog() {
|
|||||||
..["value"] = newValue;
|
..["value"] = newValue;
|
||||||
FFI.setByName("option", jsonEncode(msg));
|
FFI.setByName("option", jsonEncode(msg));
|
||||||
FFI.setByName("temporary_password");
|
FFI.setByName("temporary_password");
|
||||||
|
Future.delayed(Duration(milliseconds: 200), () {
|
||||||
|
close();
|
||||||
|
showSuccess();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate("Set temporary password length")),
|
title: Text(translate("Set temporary password length")),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user