[Party Room] 房间类型相关

This commit is contained in:
xkeyC 2024-01-07 18:52:06 +08:00
parent 7240878148
commit ab6e660ea0
9 changed files with 603 additions and 7 deletions

View File

@ -74,7 +74,12 @@ class BaseUIModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
return null; return null;
} }
if (!noAlert) showToast(context!, errorOverride ?? errorMsg); if (!noAlert) {
showToast(context!, errorOverride ?? errorMsg,
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context!).size.width * .6,
),title: "出现错误!");
}
} }
return null; return null;
} }

View File

@ -12,9 +12,9 @@ void dPrint(src) {
} }
Future showToast(BuildContext context, String msg, Future showToast(BuildContext context, String msg,
{BoxConstraints? constraints}) async { {BoxConstraints? constraints, String? title}) async {
return showBaseDialog(context, return showBaseDialog(context,
title: "提示", title: title ?? "提示",
content: Text(msg), content: Text(msg),
actions: [ actions: [
FilledButton( FilledButton(

View File

@ -14,6 +14,40 @@ import 'dart:core' as $core;
import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:fixnum/fixnum.dart' as $fixnum;
import 'package:protobuf/protobuf.dart' as $pb; import 'package:protobuf/protobuf.dart' as $pb;
export 'index.pbenum.dart';
class Empty extends $pb.GeneratedMessage {
factory Empty() => create();
Empty._() : super();
factory Empty.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory Empty.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Empty', createEmptyInstance: create)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
Empty clone() => Empty()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
Empty copyWith(void Function(Empty) updates) => super.copyWith((message) => updates(message as Empty)) as Empty;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static Empty create() => Empty._();
Empty createEmptyInstance() => create();
static $pb.PbList<Empty> createRepeated() => $pb.PbList<Empty>();
@$core.pragma('dart2js:noInline')
static Empty getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Empty>(create);
static Empty? _defaultInstance;
}
class PingData extends $pb.GeneratedMessage { class PingData extends $pb.GeneratedMessage {
factory PingData({ factory PingData({
$core.String? data, $core.String? data,
@ -92,6 +126,214 @@ class PingData extends $pb.GeneratedMessage {
void clearServerVersion() => clearField(3); void clearServerVersion() => clearField(3);
} }
class RoomTypesData extends $pb.GeneratedMessage {
factory RoomTypesData({
$core.Iterable<RoomType>? roomTypes,
}) {
final $result = create();
if (roomTypes != null) {
$result.roomTypes.addAll(roomTypes);
}
return $result;
}
RoomTypesData._() : super();
factory RoomTypesData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory RoomTypesData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'RoomTypesData', createEmptyInstance: create)
..pc<RoomType>(1, _omitFieldNames ? '' : 'roomTypes', $pb.PbFieldType.PM, protoName: 'roomTypes', subBuilder: RoomType.create)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
RoomTypesData clone() => RoomTypesData()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
RoomTypesData copyWith(void Function(RoomTypesData) updates) => super.copyWith((message) => updates(message as RoomTypesData)) as RoomTypesData;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static RoomTypesData create() => RoomTypesData._();
RoomTypesData createEmptyInstance() => create();
static $pb.PbList<RoomTypesData> createRepeated() => $pb.PbList<RoomTypesData>();
@$core.pragma('dart2js:noInline')
static RoomTypesData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RoomTypesData>(create);
static RoomTypesData? _defaultInstance;
@$pb.TagNumber(1)
$core.List<RoomType> get roomTypes => $_getList(0);
}
class RoomType extends $pb.GeneratedMessage {
factory RoomType({
$core.String? id,
$core.String? name,
$core.String? icon,
$core.String? desc,
$core.Iterable<RoomSubtype>? subTypes,
}) {
final $result = create();
if (id != null) {
$result.id = id;
}
if (name != null) {
$result.name = name;
}
if (icon != null) {
$result.icon = icon;
}
if (desc != null) {
$result.desc = desc;
}
if (subTypes != null) {
$result.subTypes.addAll(subTypes);
}
return $result;
}
RoomType._() : super();
factory RoomType.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory RoomType.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'RoomType', createEmptyInstance: create)
..aOS(1, _omitFieldNames ? '' : 'id')
..aOS(2, _omitFieldNames ? '' : 'name')
..aOS(3, _omitFieldNames ? '' : 'icon')
..aOS(4, _omitFieldNames ? '' : 'desc')
..pc<RoomSubtype>(5, _omitFieldNames ? '' : 'subTypes', $pb.PbFieldType.PM, protoName: 'subTypes', subBuilder: RoomSubtype.create)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
RoomType clone() => RoomType()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
RoomType copyWith(void Function(RoomType) updates) => super.copyWith((message) => updates(message as RoomType)) as RoomType;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static RoomType create() => RoomType._();
RoomType createEmptyInstance() => create();
static $pb.PbList<RoomType> createRepeated() => $pb.PbList<RoomType>();
@$core.pragma('dart2js:noInline')
static RoomType getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RoomType>(create);
static RoomType? _defaultInstance;
@$pb.TagNumber(1)
$core.String get id => $_getSZ(0);
@$pb.TagNumber(1)
set id($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasId() => $_has(0);
@$pb.TagNumber(1)
void clearId() => clearField(1);
@$pb.TagNumber(2)
$core.String get name => $_getSZ(1);
@$pb.TagNumber(2)
set name($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasName() => $_has(1);
@$pb.TagNumber(2)
void clearName() => clearField(2);
@$pb.TagNumber(3)
$core.String get icon => $_getSZ(2);
@$pb.TagNumber(3)
set icon($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasIcon() => $_has(2);
@$pb.TagNumber(3)
void clearIcon() => clearField(3);
@$pb.TagNumber(4)
$core.String get desc => $_getSZ(3);
@$pb.TagNumber(4)
set desc($core.String v) { $_setString(3, v); }
@$pb.TagNumber(4)
$core.bool hasDesc() => $_has(3);
@$pb.TagNumber(4)
void clearDesc() => clearField(4);
@$pb.TagNumber(5)
$core.List<RoomSubtype> get subTypes => $_getList(4);
}
class RoomSubtype extends $pb.GeneratedMessage {
factory RoomSubtype({
$core.String? id,
$core.String? name,
}) {
final $result = create();
if (id != null) {
$result.id = id;
}
if (name != null) {
$result.name = name;
}
return $result;
}
RoomSubtype._() : super();
factory RoomSubtype.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory RoomSubtype.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'RoomSubtype', createEmptyInstance: create)
..aOS(1, _omitFieldNames ? '' : 'id')
..aOS(2, _omitFieldNames ? '' : 'name')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
RoomSubtype clone() => RoomSubtype()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
RoomSubtype copyWith(void Function(RoomSubtype) updates) => super.copyWith((message) => updates(message as RoomSubtype)) as RoomSubtype;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static RoomSubtype create() => RoomSubtype._();
RoomSubtype createEmptyInstance() => create();
static $pb.PbList<RoomSubtype> createRepeated() => $pb.PbList<RoomSubtype>();
@$core.pragma('dart2js:noInline')
static RoomSubtype getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RoomSubtype>(create);
static RoomSubtype? _defaultInstance;
@$pb.TagNumber(1)
$core.String get id => $_getSZ(0);
@$pb.TagNumber(1)
set id($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasId() => $_has(0);
@$pb.TagNumber(1)
void clearId() => clearField(1);
@$pb.TagNumber(2)
$core.String get name => $_getSZ(1);
@$pb.TagNumber(2)
set name($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasName() => $_has(1);
@$pb.TagNumber(2)
void clearName() => clearField(2);
}
const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names');
const _omitMessageNames = $core.bool.fromEnvironment('protobuf.omit_message_names'); const _omitMessageNames = $core.bool.fromEnvironment('protobuf.omit_message_names');

View File

@ -9,3 +9,55 @@
// ignore_for_file: non_constant_identifier_names, prefer_final_fields // ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import // ignore_for_file: unnecessary_import, unnecessary_this, unused_import
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class RoomStatus extends $pb.ProtobufEnum {
static const RoomStatus All = RoomStatus._(0, _omitEnumNames ? '' : 'All');
static const RoomStatus Open = RoomStatus._(1, _omitEnumNames ? '' : 'Open');
static const RoomStatus Private = RoomStatus._(2, _omitEnumNames ? '' : 'Private');
static const RoomStatus Full = RoomStatus._(3, _omitEnumNames ? '' : 'Full');
static const RoomStatus Closed = RoomStatus._(4, _omitEnumNames ? '' : 'Closed');
static const RoomStatus WillOffline = RoomStatus._(5, _omitEnumNames ? '' : 'WillOffline');
static const RoomStatus Offline = RoomStatus._(6, _omitEnumNames ? '' : 'Offline');
static const $core.List<RoomStatus> values = <RoomStatus> [
All,
Open,
Private,
Full,
Closed,
WillOffline,
Offline,
];
static final $core.Map<$core.int, RoomStatus> _byValue = $pb.ProtobufEnum.initByValue(values);
static RoomStatus? valueOf($core.int value) => _byValue[value];
const RoomStatus._($core.int v, $core.String n) : super(v, n);
}
class RoomSortType extends $pb.ProtobufEnum {
static const RoomSortType Default = RoomSortType._(0, _omitEnumNames ? '' : 'Default');
static const RoomSortType MostPlayerNumber = RoomSortType._(1, _omitEnumNames ? '' : 'MostPlayerNumber');
static const RoomSortType MinimumPlayerNumber = RoomSortType._(2, _omitEnumNames ? '' : 'MinimumPlayerNumber');
static const RoomSortType RecentlyCreated = RoomSortType._(3, _omitEnumNames ? '' : 'RecentlyCreated');
static const RoomSortType OldestCreated = RoomSortType._(4, _omitEnumNames ? '' : 'OldestCreated');
static const $core.List<RoomSortType> values = <RoomSortType> [
Default,
MostPlayerNumber,
MinimumPlayerNumber,
RecentlyCreated,
OldestCreated,
];
static final $core.Map<$core.int, RoomSortType> _byValue = $pb.ProtobufEnum.initByValue(values);
static RoomSortType? valueOf($core.int value) => _byValue[value];
const RoomSortType._($core.int v, $core.String n) : super(v, n);
}
const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names');

View File

@ -25,6 +25,10 @@ class IndexServiceClient extends $grpc.Client {
'/IndexService/PingServer', '/IndexService/PingServer',
($0.PingData value) => value.writeToBuffer(), ($0.PingData value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.PingData.fromBuffer(value)); ($core.List<$core.int> value) => $0.PingData.fromBuffer(value));
static final _$getRoomTypes = $grpc.ClientMethod<$0.Empty, $0.RoomTypesData>(
'/IndexService/GetRoomTypes',
($0.Empty value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.RoomTypesData.fromBuffer(value));
IndexServiceClient($grpc.ClientChannel channel, IndexServiceClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options, {$grpc.CallOptions? options,
@ -35,6 +39,10 @@ class IndexServiceClient extends $grpc.Client {
$grpc.ResponseFuture<$0.PingData> pingServer($0.PingData request, {$grpc.CallOptions? options}) { $grpc.ResponseFuture<$0.PingData> pingServer($0.PingData request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$pingServer, request, options: options); return $createUnaryCall(_$pingServer, request, options: options);
} }
$grpc.ResponseFuture<$0.RoomTypesData> getRoomTypes($0.Empty request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$getRoomTypes, request, options: options);
}
} }
@$pb.GrpcServiceName('IndexService') @$pb.GrpcServiceName('IndexService')
@ -49,11 +57,23 @@ abstract class IndexServiceBase extends $grpc.Service {
false, false,
($core.List<$core.int> value) => $0.PingData.fromBuffer(value), ($core.List<$core.int> value) => $0.PingData.fromBuffer(value),
($0.PingData value) => value.writeToBuffer())); ($0.PingData value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.Empty, $0.RoomTypesData>(
'GetRoomTypes',
getRoomTypes_Pre,
false,
false,
($core.List<$core.int> value) => $0.Empty.fromBuffer(value),
($0.RoomTypesData value) => value.writeToBuffer()));
} }
$async.Future<$0.PingData> pingServer_Pre($grpc.ServiceCall call, $async.Future<$0.PingData> request) async { $async.Future<$0.PingData> pingServer_Pre($grpc.ServiceCall call, $async.Future<$0.PingData> request) async {
return pingServer(call, await request); return pingServer(call, await request);
} }
$async.Future<$0.PingData> pingServer($grpc.ServiceCall call, $0.PingData request); $async.Future<$0.RoomTypesData> getRoomTypes_Pre($grpc.ServiceCall call, $async.Future<$0.Empty> request) async {
return getRoomTypes(call, await request);
}
$async.Future<$0.PingData> pingServer($grpc.ServiceCall call, $0.PingData request);
$async.Future<$0.RoomTypesData> getRoomTypes($grpc.ServiceCall call, $0.Empty request);
} }

View File

@ -13,6 +13,52 @@ import 'dart:convert' as $convert;
import 'dart:core' as $core; import 'dart:core' as $core;
import 'dart:typed_data' as $typed_data; import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use roomStatusDescriptor instead')
const RoomStatus$json = {
'1': 'RoomStatus',
'2': [
{'1': 'All', '2': 0},
{'1': 'Open', '2': 1},
{'1': 'Private', '2': 2},
{'1': 'Full', '2': 3},
{'1': 'Closed', '2': 4},
{'1': 'WillOffline', '2': 5},
{'1': 'Offline', '2': 6},
],
};
/// Descriptor for `RoomStatus`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List roomStatusDescriptor = $convert.base64Decode(
'CgpSb29tU3RhdHVzEgcKA0FsbBAAEggKBE9wZW4QARILCgdQcml2YXRlEAISCAoERnVsbBADEg'
'oKBkNsb3NlZBAEEg8KC1dpbGxPZmZsaW5lEAUSCwoHT2ZmbGluZRAG');
@$core.Deprecated('Use roomSortTypeDescriptor instead')
const RoomSortType$json = {
'1': 'RoomSortType',
'2': [
{'1': 'Default', '2': 0},
{'1': 'MostPlayerNumber', '2': 1},
{'1': 'MinimumPlayerNumber', '2': 2},
{'1': 'RecentlyCreated', '2': 3},
{'1': 'OldestCreated', '2': 4},
],
};
/// Descriptor for `RoomSortType`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List roomSortTypeDescriptor = $convert.base64Decode(
'CgxSb29tU29ydFR5cGUSCwoHRGVmYXVsdBAAEhQKEE1vc3RQbGF5ZXJOdW1iZXIQARIXChNNaW'
'5pbXVtUGxheWVyTnVtYmVyEAISEwoPUmVjZW50bHlDcmVhdGVkEAMSEQoNT2xkZXN0Q3JlYXRl'
'ZBAE');
@$core.Deprecated('Use emptyDescriptor instead')
const Empty$json = {
'1': 'Empty',
};
/// Descriptor for `Empty`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List emptyDescriptor = $convert.base64Decode(
'CgVFbXB0eQ==');
@$core.Deprecated('Use pingDataDescriptor instead') @$core.Deprecated('Use pingDataDescriptor instead')
const PingData$json = { const PingData$json = {
'1': 'PingData', '1': 'PingData',
@ -28,3 +74,47 @@ final $typed_data.Uint8List pingDataDescriptor = $convert.base64Decode(
'CghQaW5nRGF0YRISCgRkYXRhGAEgASgJUgRkYXRhEiQKDWNsaWVudFZlcnNpb24YAiABKBJSDW' 'CghQaW5nRGF0YRISCgRkYXRhGAEgASgJUgRkYXRhEiQKDWNsaWVudFZlcnNpb24YAiABKBJSDW'
'NsaWVudFZlcnNpb24SJAoNc2VydmVyVmVyc2lvbhgDIAEoElINc2VydmVyVmVyc2lvbg=='); 'NsaWVudFZlcnNpb24SJAoNc2VydmVyVmVyc2lvbhgDIAEoElINc2VydmVyVmVyc2lvbg==');
@$core.Deprecated('Use roomTypesDataDescriptor instead')
const RoomTypesData$json = {
'1': 'RoomTypesData',
'2': [
{'1': 'roomTypes', '3': 1, '4': 3, '5': 11, '6': '.RoomType', '10': 'roomTypes'},
],
};
/// Descriptor for `RoomTypesData`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List roomTypesDataDescriptor = $convert.base64Decode(
'Cg1Sb29tVHlwZXNEYXRhEicKCXJvb21UeXBlcxgBIAMoCzIJLlJvb21UeXBlUglyb29tVHlwZX'
'M=');
@$core.Deprecated('Use roomTypeDescriptor instead')
const RoomType$json = {
'1': 'RoomType',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
{'1': 'icon', '3': 3, '4': 1, '5': 9, '10': 'icon'},
{'1': 'desc', '3': 4, '4': 1, '5': 9, '10': 'desc'},
{'1': 'subTypes', '3': 5, '4': 3, '5': 11, '6': '.RoomSubtype', '10': 'subTypes'},
],
};
/// Descriptor for `RoomType`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List roomTypeDescriptor = $convert.base64Decode(
'CghSb29tVHlwZRIOCgJpZBgBIAEoCVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZRISCgRpY29uGA'
'MgASgJUgRpY29uEhIKBGRlc2MYBCABKAlSBGRlc2MSKAoIc3ViVHlwZXMYBSADKAsyDC5Sb29t'
'U3VidHlwZVIIc3ViVHlwZXM=');
@$core.Deprecated('Use roomSubtypeDescriptor instead')
const RoomSubtype$json = {
'1': 'RoomSubtype',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
],
};
/// Descriptor for `RoomSubtype`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List roomSubtypeDescriptor = $convert.base64Decode(
'CgtSb29tU3VidHlwZRIOCgJpZBgBIAEoCVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZQ==');

View File

@ -1,6 +1,5 @@
import 'package:fixnum/fixnum.dart'; import 'package:fixnum/fixnum.dart';
import 'package:grpc/grpc.dart'; import 'package:grpc/grpc.dart';
import 'package:starcitizen_doctor/base/ui.dart';
import 'package:starcitizen_doctor/generated/grpc/party_room_server/index.pbgrpc.dart'; import 'package:starcitizen_doctor/generated/grpc/party_room_server/index.pbgrpc.dart';
class PartyRoomGrpcServer { class PartyRoomGrpcServer {
@ -20,7 +19,11 @@ class PartyRoomGrpcServer {
static Future<PingData> pingServer() async { static Future<PingData> pingServer() async {
final r = await _indexService.pingServer(PingData( final r = await _indexService.pingServer(PingData(
data: "PING", clientVersion: Int64.parseInt(clientVersion.toString()))); data: "PING", clientVersion: Int64.parseInt(clientVersion.toString())));
dPrint(r.writeToJson()); return r;
}
static Future<RoomTypesData> getRoomTypes() async {
final r = await _indexService.getRoomTypes(Empty());
return r; return r;
} }
} }

View File

@ -1,4 +1,5 @@
import 'package:starcitizen_doctor/base/ui.dart'; import 'package:starcitizen_doctor/base/ui.dart';
import 'package:starcitizen_doctor/generated/grpc/party_room_server/index.pb.dart';
import 'party_room_home_ui_model.dart'; import 'party_room_home_ui_model.dart';
@ -11,8 +12,113 @@ class PartyRoomHomeUI extends BaseUI<PartyRoomHomeUIModel> {
child: Text("${model.pingServerMessage}"), child: Text("${model.pingServerMessage}"),
); );
} }
return Center( if (model.roomTypes == null) return makeLoading(context);
child: Text("PartyRoom"), return Column(
children: [
makeHeader(context, model),
],
);
}
Widget makeHeader(BuildContext context, PartyRoomHomeUIModel model) {
final subTypes = model.getCurRoomSubTypes();
return Container(
padding: const EdgeInsets.only(left: 24, right: 24, top: 16, bottom: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Text("房间类型:"),
SizedBox(
height: 36,
child: ComboBox<RoomType>(
value: model.selectedRoomType,
items: [
for (final t in model.roomTypes!.entries)
ComboBoxItem(
value: t.value,
child: Text(t.value.name),
)
],
onChanged: model.onChangeRoomType)),
if (subTypes != null) ...[
const SizedBox(width: 24),
const Text("子类型:"),
SizedBox(
height: 36,
child: ComboBox<RoomSubtype>(
value: model.selectedRoomSubType,
items: [
for (final t in subTypes.entries)
ComboBoxItem(
value: t.value,
child: Text(t.value.name),
)
],
onChanged: model.onChangeRoomSubType)),
],
const SizedBox(width: 24),
const Text("房间状态:"),
SizedBox(
height: 36,
child: ComboBox<RoomStatus>(
value: model.selectedStatus,
items: [
for (final t in model.roomStatus.entries)
ComboBoxItem(
value: t.key,
child: Text(t.value),
)
],
onChanged: model.onChangeRoomStatus)),
const SizedBox(width: 24),
const Text("排序:"),
SizedBox(
height: 36,
child: ComboBox<RoomSortType>(
value: model.selectedSortType,
items: [
for (final t in model.roomSorts.entries)
ComboBoxItem(
value: t.key,
child: Text(t.value),
)
],
onChanged: model.onChangeRoomSort)),
const Spacer(),
Button(
onPressed: () {},
child: const Padding(
padding: EdgeInsets.all(6),
child: Icon(FluentIcons.refresh),
),
),
const SizedBox(width: 12),
Button(
onPressed: () {},
child: const Padding(
padding: EdgeInsets.all(3),
child: Row(
children: [
Icon(FluentIcons.add),
SizedBox(width: 6),
Text("创建房间")
],
),
),
),
],
),
const SizedBox(
height: 6,
),
Text(
model.selectedRoomType?.desc ?? "",
style: TextStyle(fontSize: 13, color: Colors.white.withOpacity(.4)),
),
],
),
); );
} }

View File

@ -1,9 +1,37 @@
import 'package:starcitizen_doctor/base/ui_model.dart'; import 'package:starcitizen_doctor/base/ui_model.dart';
import 'package:starcitizen_doctor/generated/grpc/party_room_server/index.pb.dart';
import 'package:starcitizen_doctor/grpc/party_room_server.dart'; import 'package:starcitizen_doctor/grpc/party_room_server.dart';
class PartyRoomHomeUIModel extends BaseUIModel { class PartyRoomHomeUIModel extends BaseUIModel {
String? pingServerMessage; String? pingServerMessage;
Map<String?, RoomType>? roomTypes;
RoomType? selectedRoomType;
RoomSubtype? selectedRoomSubType;
final roomStatus = <RoomStatus, String>{
RoomStatus.All: "全部",
RoomStatus.Open: "开启中",
RoomStatus.Full: "已满员",
RoomStatus.Closed: "已封闭",
RoomStatus.WillOffline: "房主离线",
RoomStatus.Offline: "已离线",
};
RoomStatus selectedStatus = RoomStatus.All;
final roomSorts = <RoomSortType, String>{
RoomSortType.Default: "默认",
RoomSortType.MostPlayerNumber: "最多玩家",
RoomSortType.MinimumPlayerNumber: "最少玩家",
RoomSortType.RecentlyCreated: "最近创建",
RoomSortType.OldestCreated: "最久创建",
};
RoomSortType selectedSortType = RoomSortType.Default;
@override @override
Future loadData() async { Future loadData() async {
if (pingServerMessage != "") { if (pingServerMessage != "") {
@ -11,6 +39,7 @@ class PartyRoomHomeUIModel extends BaseUIModel {
notifyListeners(); notifyListeners();
} }
await _pingServer(); await _pingServer();
await _loadTypes();
} }
_pingServer() async { _pingServer() async {
@ -26,4 +55,53 @@ class PartyRoomHomeUIModel extends BaseUIModel {
return; return;
} }
} }
_loadTypes() async {
final r = await handleError(() => PartyRoomGrpcServer.getRoomTypes());
if (r == null) return;
selectedRoomType =
RoomType(id: null, name: "全部", desc: "查看所有类型的房间,寻找一起玩的伙伴。");
selectedRoomSubType = RoomSubtype(id: "all", name: "全部");
roomTypes = {null: selectedRoomType!};
for (var element in r.roomTypes) {
roomTypes![element.id] = element;
}
notifyListeners();
}
Map<String, RoomSubtype>? getCurRoomSubTypes() {
if (selectedRoomType?.subTypes == null) return null;
Map<String, RoomSubtype> types = {};
for (var element in selectedRoomType!.subTypes) {
types[element.id] = element;
}
if (types.isEmpty) return null;
final allSubType = RoomSubtype(id: "all", name: "全部");
selectedRoomSubType ??= allSubType;
return {"all": allSubType}..addAll(types);
}
void onChangeRoomType(RoomType? value) {
selectedRoomType = value;
selectedRoomSubType = null;
notifyListeners();
}
void onChangeRoomStatus(RoomStatus? value) {
if (value == null) return;
selectedStatus = value;
notifyListeners();
}
void onChangeRoomSort(RoomSortType? value) {
if (value == null) return;
selectedSortType = value;
notifyListeners();
}
void onChangeRoomSubType(RoomSubtype? value) {
if (value == null) return;
selectedRoomSubType = value;
notifyListeners();
}
} }