UI optimization

This commit is contained in:
csf
2022-07-29 22:07:45 +08:00
parent 2d31e44b54
commit 67a3db7378
3 changed files with 64 additions and 34 deletions

View File

@@ -89,14 +89,13 @@ class ServerModel with ChangeNotifier {
}();
Timer.periodic(Duration(seconds: 1), (timer) {
var update = false;
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
if (status > 0) {
status = 1;
}
if (status != _connectStatus) {
_connectStatus = status;
update = true;
notifyListeners();
}
final res =
FFI.getByName('check_clients_length', _clients.length.toString());
@@ -105,25 +104,28 @@ class ServerModel with ChangeNotifier {
updateClientState(res);
}
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) {
debugPrint("_verificationMethod changed: $verificationMethod");
_verificationMethod = verificationMethod;
update = true;
}
if (update) {
notifyListeners();
}
updatePasswordModel();
});
}
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 {
if (!_audioOk && !await PermissionManager.check("audio")) {
final res = await PermissionManager.request("audio");