mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 11:24:46 +08:00
add Party Room Module
This commit is contained in:
22
lib/ui/party_room/party_room_home_ui.dart
Normal file
22
lib/ui/party_room/party_room_home_ui.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:starcitizen_doctor/base/ui.dart';
|
||||
|
||||
import 'party_room_home_ui_model.dart';
|
||||
|
||||
class PartyRoomHomeUI extends BaseUI<PartyRoomHomeUIModel> {
|
||||
@override
|
||||
Widget? buildBody(BuildContext context, PartyRoomHomeUIModel model) {
|
||||
if (model.pingServerMessage == null) return makeLoading(context);
|
||||
if (model.pingServerMessage!.isNotEmpty) {
|
||||
return Center(
|
||||
child: Text("${model.pingServerMessage}"),
|
||||
);
|
||||
}
|
||||
return Center(
|
||||
child: Text("PartyRoom"),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String getUITitle(BuildContext context, PartyRoomHomeUIModel model) =>
|
||||
"PartyRoom";
|
||||
}
|
29
lib/ui/party_room/party_room_home_ui_model.dart
Normal file
29
lib/ui/party_room/party_room_home_ui_model.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:starcitizen_doctor/base/ui_model.dart';
|
||||
import 'package:starcitizen_doctor/grpc/party_room_server.dart';
|
||||
|
||||
class PartyRoomHomeUIModel extends BaseUIModel {
|
||||
String? pingServerMessage;
|
||||
|
||||
@override
|
||||
Future loadData() async {
|
||||
if (pingServerMessage != "") {
|
||||
pingServerMessage = null;
|
||||
notifyListeners();
|
||||
}
|
||||
await _pingServer();
|
||||
}
|
||||
|
||||
_pingServer() async {
|
||||
try {
|
||||
final r = await PartyRoomGrpcServer.pingServer();
|
||||
dPrint(
|
||||
"[PartyRoomHomeUIModel] Connected! serverVersion ==> ${r.serverVersion}");
|
||||
pingServerMessage = "";
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
pingServerMessage = "服务器连接失败,请稍后重试。\n$e";
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user