android rendezvous server status
This commit is contained in:
parent
7177a566ae
commit
cabb39005b
@ -137,6 +137,7 @@ class CustomAlertDialog extends StatelessWidget {
|
|||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: onWillPop ?? () async => false,
|
onWillPop: onWillPop ?? () async => false,
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
|
scrollable: true,
|
||||||
title: title,
|
title: title,
|
||||||
contentPadding: EdgeInsets.symmetric(
|
contentPadding: EdgeInsets.symmetric(
|
||||||
horizontal: contentPadding ?? 25, vertical: 10),
|
horizontal: contentPadding ?? 25, vertical: 10),
|
||||||
|
|||||||
@ -6,15 +6,17 @@ import '../common.dart';
|
|||||||
import '../pages/server_page.dart';
|
import '../pages/server_page.dart';
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
|
|
||||||
final _emptyIdShow = translate("connecting_status");
|
final _emptyIdShow = translate("Generating ...");
|
||||||
|
|
||||||
class ServerModel with ChangeNotifier {
|
class ServerModel with ChangeNotifier {
|
||||||
Timer? _interval;
|
Timer? _interval;
|
||||||
bool _isStart = false;
|
bool _isStart = false; // Android MainService status
|
||||||
bool _mediaOk = false;
|
bool _mediaOk = false;
|
||||||
bool _inputOk = false;
|
bool _inputOk = false;
|
||||||
bool _audioOk = false;
|
bool _audioOk = false;
|
||||||
bool _fileOk = false;
|
bool _fileOk = false;
|
||||||
|
int _connectStatus = 0; // Rendezvous Server status
|
||||||
|
|
||||||
final _serverId = TextEditingController(text: _emptyIdShow);
|
final _serverId = TextEditingController(text: _emptyIdShow);
|
||||||
final _serverPasswd = TextEditingController(text: "");
|
final _serverPasswd = TextEditingController(text: "");
|
||||||
|
|
||||||
@ -30,6 +32,8 @@ class ServerModel with ChangeNotifier {
|
|||||||
|
|
||||||
bool get fileOk => _fileOk;
|
bool get fileOk => _fileOk;
|
||||||
|
|
||||||
|
int get connectStatus => _connectStatus;
|
||||||
|
|
||||||
TextEditingController get serverId => _serverId;
|
TextEditingController get serverId => _serverId;
|
||||||
|
|
||||||
TextEditingController get serverPasswd => _serverPasswd;
|
TextEditingController get serverPasswd => _serverPasswd;
|
||||||
@ -80,6 +84,17 @@ class ServerModel with ChangeNotifier {
|
|||||||
FFI.setByName('option', jsonEncode(res)); // input false by default
|
FFI.setByName('option', jsonEncode(res)); // input false by default
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
Timer.periodic(Duration(seconds: 1), (timer) {
|
||||||
|
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
|
||||||
|
if (status > 0) {
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
if (status != _connectStatus) {
|
||||||
|
_connectStatus = status;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleAudio() async {
|
toggleAudio() async {
|
||||||
|
|||||||
@ -189,6 +189,14 @@ class _PermissionCheckerState extends State<PermissionChecker> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final serverModel = Provider.of<ServerModel>(context);
|
final serverModel = Provider.of<ServerModel>(context);
|
||||||
final hasAudioPermission = androidVersion >= 30;
|
final hasAudioPermission = androidVersion >= 30;
|
||||||
|
final status;
|
||||||
|
if (serverModel.connectStatus == -1) {
|
||||||
|
status = 'not_ready_status';
|
||||||
|
} else if (serverModel.connectStatus == 0) {
|
||||||
|
status = 'connecting_status';
|
||||||
|
} else {
|
||||||
|
status = 'Ready';
|
||||||
|
}
|
||||||
return PaddingCard(
|
return PaddingCard(
|
||||||
title: translate("Configuration Permissions"),
|
title: translate("Configuration Permissions"),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -211,31 +219,43 @@ class _PermissionCheckerState extends State<PermissionChecker> {
|
|||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
serverModel.mediaOk
|
Expanded(
|
||||||
? ElevatedButton.icon(
|
flex: 0,
|
||||||
style: ButtonStyle(
|
child: serverModel.mediaOk
|
||||||
backgroundColor:
|
? ElevatedButton.icon(
|
||||||
MaterialStateProperty.all(Colors.red)),
|
style: ButtonStyle(
|
||||||
icon: Icon(Icons.stop),
|
backgroundColor:
|
||||||
onPressed: serverModel.toggleService,
|
MaterialStateProperty.all(Colors.red)),
|
||||||
label: Text(translate("Stop service")))
|
icon: Icon(Icons.stop),
|
||||||
: ElevatedButton.icon(
|
onPressed: serverModel.toggleService,
|
||||||
icon: Icon(Icons.play_arrow),
|
label: Text(translate("Stop service")))
|
||||||
onPressed: serverModel.toggleService,
|
: ElevatedButton.icon(
|
||||||
label: Text(translate("Start Service"))),
|
icon: Icon(Icons.play_arrow),
|
||||||
serverModel.mediaOk
|
onPressed: serverModel.toggleService,
|
||||||
? Row(
|
label: Text(translate("Start Service")))),
|
||||||
children: [
|
Expanded(
|
||||||
Padding(
|
child: serverModel.mediaOk
|
||||||
padding: EdgeInsets.only(left: 20, right: 5),
|
? Row(
|
||||||
child: Icon(Icons.circle,
|
children: [
|
||||||
color: Colors.greenAccent, size: 10)),
|
Expanded(
|
||||||
Text(translate("Ready"),
|
flex: 0,
|
||||||
style: TextStyle(
|
child: Padding(
|
||||||
fontSize: 16.0, color: MyTheme.accent50))
|
padding:
|
||||||
],
|
EdgeInsets.only(left: 20, right: 5),
|
||||||
)
|
child: Icon(Icons.circle,
|
||||||
: SizedBox.shrink()
|
color: serverModel.connectStatus > 0
|
||||||
|
? Colors.greenAccent
|
||||||
|
: Colors.deepOrangeAccent,
|
||||||
|
size: 10))),
|
||||||
|
Expanded(
|
||||||
|
child: Text(translate(status),
|
||||||
|
softWrap: true,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
color: MyTheme.accent50)))
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: SizedBox.shrink())
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user