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:
@ -4,6 +4,7 @@ import 'package:starcitizen_doctor/main.dart';
|
||||
import 'package:starcitizen_doctor/ui/about/about_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/about/about_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/home_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/party_room/party_room_home_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/settings/settings_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/tools/tools_ui.dart';
|
||||
@ -12,6 +13,7 @@ import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'home/home_ui_model.dart';
|
||||
import 'index_ui_model.dart';
|
||||
import 'party_room/party_room_home_ui.dart';
|
||||
|
||||
class IndexUI extends BaseUI<IndexUIModel> {
|
||||
@override
|
||||
@ -67,16 +69,21 @@ class IndexUI extends BaseUI<IndexUIModel> {
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<HomeUIModel>("home"));
|
||||
case 1:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => PartyRoomHomeUI(),
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<PartyRoomHomeUIModel>("party"));
|
||||
case 2:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => ToolsUI(),
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<ToolsUIModel>("tools"));
|
||||
case 2:
|
||||
case 3:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => SettingUI(),
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<SettingUIModel>("settings"));
|
||||
case 3:
|
||||
case 4:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => AboutUI(),
|
||||
modelCreate: () =>
|
||||
@ -88,6 +95,7 @@ class IndexUI extends BaseUI<IndexUIModel> {
|
||||
List<NavigationPaneItem> getNavigationPaneItems(IndexUIModel model) {
|
||||
final menus = {
|
||||
FluentIcons.home: "首页",
|
||||
FluentIcons.game: "大厅",
|
||||
FluentIcons.toolbox: "工具",
|
||||
FluentIcons.settings: "设置",
|
||||
FluentIcons.info: "关于",
|
||||
|
@ -10,6 +10,8 @@ import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'party_room/party_room_home_ui_model.dart';
|
||||
|
||||
class IndexUIModel extends BaseUIModel {
|
||||
int curIndex = 0;
|
||||
|
||||
@ -32,6 +34,8 @@ class IndexUIModel extends BaseUIModel {
|
||||
return SettingUIModel();
|
||||
case "about":
|
||||
return AboutUIModel();
|
||||
case "party":
|
||||
return PartyRoomHomeUIModel();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -39,9 +43,10 @@ class IndexUIModel extends BaseUIModel {
|
||||
void onIndexMenuTap(String value) {
|
||||
final index = {
|
||||
"首页": 0,
|
||||
"工具": 1,
|
||||
"设置": 2,
|
||||
"关于": 3,
|
||||
"大厅": 1,
|
||||
"工具": 2,
|
||||
"设置": 3,
|
||||
"关于": 4,
|
||||
};
|
||||
curIndex = index[value] ?? 0;
|
||||
switch (curIndex) {
|
||||
@ -49,9 +54,12 @@ class IndexUIModel extends BaseUIModel {
|
||||
getCreatedChildUIModel("home")?.reloadData();
|
||||
break;
|
||||
case 1:
|
||||
getCreatedChildUIModel("tools")?.reloadData();
|
||||
getCreatedChildUIModel("party")?.reloadData();
|
||||
break;
|
||||
case 2:
|
||||
getCreatedChildUIModel("tools")?.reloadData();
|
||||
break;
|
||||
case 3:
|
||||
getCreatedChildUIModel("settings")?.reloadData();
|
||||
break;
|
||||
}
|
||||
|
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