[Party Room] 创建,列表展示

This commit is contained in:
2024-01-13 20:00:06 +08:00
parent fbdfd61c09
commit 839125528b
7 changed files with 203 additions and 9 deletions

View File

@ -1,3 +1,6 @@
import 'dart:convert';
import 'dart:math';
import 'package:flutter/services.dart';
import 'package:starcitizen_doctor/base/ui.dart';
import 'package:starcitizen_doctor/generated/grpc/party_room_server/index.pb.dart';
@ -119,6 +122,15 @@ class PartyRoomCreateDialogUI extends BaseUI<PartyRoomCreateDialogUIModel> {
);
}
Color generateColorFromSeed(String seed) {
int hash = utf8
.encode(seed)
.fold(0, (previousValue, element) => 31 * previousValue + element);
Random random = Random(hash);
return Color.fromARGB(
255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
}
List<Widget> makeSubTypeSelectWidgets(
BuildContext context, PartyRoomCreateDialogUIModel model) {
bool isItemSelected(RoomSubtype subtype) {
@ -135,7 +147,7 @@ class PartyRoomCreateDialogUI extends BaseUI<PartyRoomCreateDialogUIModel> {
Container(
decoration: BoxDecoration(
color: isItemSelected(item)
? Colors.green
? generateColorFromSeed(item.name).withOpacity(.4)
: FluentTheme.of(context).cardColor,
borderRadius: BorderRadius.circular(1000)),
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 12),

View File

@ -67,6 +67,7 @@ class PartyRoomCreateDialogUIModel extends BaseUIModel {
roomSubTypeIds: [for (var value in selectedSubType) value.id],
owner: userName,
deviceUUID: AppConf.deviceUUID,
maxPlayer: maxPlayer,
announcement: announcementCtrl.text.trim())));
isWorking = false;
notifyListeners();