[Party Room] 暂时搁置

This commit is contained in:
xkeyC 2024-01-29 20:37:15 +08:00
parent 828785ced4
commit 9f63fc9fe4
2 changed files with 90 additions and 87 deletions

View File

@ -24,18 +24,26 @@ class PartyRoomHomeUI extends BaseUI<PartyRoomHomeUIModel> {
@override
Widget build(BuildContext context) {
final model = ref.watch(provider);
return PageView(
controller: model.pageCtrl,
physics: const NeverScrollableScrollPhysics(),
// final model = ref.watch(provider);
return const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
super.build(context),
BaseUIContainer(
uiCreate: () => PartyRoomChatUI(),
modelCreate: () =>
model.getChildUIModelProviders<PartyRoomChatUIModel>("chat"))
Text("敬请期待!"),
],
),
);
// return PageView(
// controller: model.pageCtrl,
// physics: const NeverScrollableScrollPhysics(),
// children: [
// super.build(context),
// BaseUIContainer(
// uiCreate: () => PartyRoomChatUI(),
// modelCreate: () =>
// model.getChildUIModelProviders<PartyRoomChatUIModel>("chat"))
// ],
// );
}
@override
@ -90,6 +98,7 @@ class PartyRoomHomeUI extends BaseUI<PartyRoomHomeUIModel> {
DateTime.fromMillisecondsSinceEpoch(item.createTime.toInt());
return Tilt(
borderRadius: BorderRadius.circular(13),
clipBehavior: Clip.hardEdge,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(13),

View File

@ -45,12 +45,6 @@ class PartyRoomHomeUIModel extends BaseUIModel {
final pageCtrl = PageController();
@override
void initModel() {
super.initModel();
_loadTypes();
_touchUser();
}
@override
BaseUIModel? onCreateChildUIModel(modelKey) {
@ -63,66 +57,66 @@ class PartyRoomHomeUIModel extends BaseUIModel {
@override
Future loadData() async {
if (pingServerMessage != "") {
pingServerMessage = null;
notifyListeners();
await _pingServer();
}
await _loadPage();
// if (pingServerMessage != "") {
// pingServerMessage = null;
// notifyListeners();
// await _pingServer();
// }
// await _loadPage();
}
@override
reloadData() async {
pageNum = 0;
rooms = null;
notifyListeners();
_touchUser();
return super.reloadData();
}
// @override
// reloadData() async {
// pageNum = 0;
// rooms = null;
// notifyListeners();
// _touchUser();
// return super.reloadData();
// }
_loadPage() async {
final r = await handleError(() => PartyRoomGrpcServer.getRoomList(
RoomListPageReqData(
pageNum: Int64.tryParseInt("$pageNum"),
typeID: selectedRoomType?.id ?? "",
subTypeID: selectedRoomSubType?.id ?? "",
status: selectedStatus)));
if (r == null) return;
if (r.pageData.hasNext) {
pageNum++;
} else {
pageNum = -1;
}
rooms = r.rooms;
notifyListeners();
}
_pingServer() async {
try {
final r = await PartyRoomGrpcServer.pingServer();
dPrint(
"[PartyRoomHomeUIModel] Connected! serverVersion ==> ${r.serverVersion}");
pingServerMessage = "";
notifyListeners();
} catch (e) {
pingServerMessage = "服务器连接失败,请稍后重试。\n$e";
notifyListeners();
return;
}
}
Future<void> _loadTypes() async {
final r = await handleError(() => PartyRoomGrpcServer.getRoomTypes());
if (r == null) return;
selectedRoomType =
RoomType(id: "", name: "全部", desc: "查看所有类型的房间,寻找一起玩的伙伴。");
selectedRoomSubType = RoomSubtype(id: "", name: "全部");
roomTypes = {"": selectedRoomType!};
for (var element in r.roomTypes) {
roomTypes![element.id] = element;
}
notifyListeners();
}
// _loadPage() async {
// final r = await handleError(() => PartyRoomGrpcServer.getRoomList(
// RoomListPageReqData(
// pageNum: Int64.tryParseInt("$pageNum"),
// typeID: selectedRoomType?.id ?? "",
// subTypeID: selectedRoomSubType?.id ?? "",
// status: selectedStatus)));
// if (r == null) return;
// if (r.pageData.hasNext) {
// pageNum++;
// } else {
// pageNum = -1;
// }
// rooms = r.rooms;
// notifyListeners();
// }
//
// _pingServer() async {
// try {
// final r = await PartyRoomGrpcServer.pingServer();
// dPrint(
// "[PartyRoomHomeUIModel] Connected! serverVersion ==> ${r.serverVersion}");
// pingServerMessage = "";
// notifyListeners();
// } catch (e) {
// pingServerMessage = "服务器连接失败,请稍后重试。\n$e";
// notifyListeners();
// return;
// }
// }
//
// Future<void> _loadTypes() async {
// final r = await handleError(() => PartyRoomGrpcServer.getRoomTypes());
// if (r == null) return;
// selectedRoomType =
// RoomType(id: "", name: "全部", desc: "查看所有类型的房间,寻找一起玩的伙伴。");
// selectedRoomSubType = RoomSubtype(id: "", name: "全部");
// roomTypes = {"": selectedRoomType!};
// for (var element in r.roomTypes) {
// roomTypes![element.id] = element;
// }
// notifyListeners();
// }
Map<String, RoomSubtype>? getCurRoomSubTypes() {
if (selectedRoomType?.subTypes == null) return null;
@ -184,19 +178,19 @@ class PartyRoomHomeUIModel extends BaseUIModel {
reloadData();
}
Future<void> _touchUser() async {
if (getCreatedChildUIModel<PartyRoomChatUIModel>("chat")?.selectRoom ==
null) {
final userName = await globalUIModel.getRunningGameUser();
if (userName == null) return;
//
final room = await handleError(() =>
PartyRoomGrpcServer.touchUserRoom(userName, AppConf.deviceUUID));
dPrint("touch room == ${room?.toProto3Json()}");
if (room == null || room.id == "") return;
onTapRoom(room);
}
}
// Future<void> _touchUser() async {
// if (getCreatedChildUIModel<PartyRoomChatUIModel>("chat")?.selectRoom ==
// null) {
// final userName = await globalUIModel.getRunningGameUser();
// if (userName == null) return;
// //
// final room = await handleError(() =>
// PartyRoomGrpcServer.touchUserRoom(userName, AppConf.deviceUUID));
// dPrint("touch room == ${room?.toProto3Json()}");
// if (room == null || room.id == "") return;
// onTapRoom(room);
// }
// }
onTapRoom(RoomData item) {
getCreatedChildUIModel<PartyRoomChatUIModel>("chat", create: true)