diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index e53371f..d163323 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -1718,6 +1718,22 @@ class MessageLookup extends MessageLookupByLibrary { "tools_vehicle_sorting_vehicle": MessageLookupByLibrary.simpleMessage( "Vehicles", ), + "user_action_unregister": MessageLookupByLibrary.simpleMessage( + "Unregister Account", + ), + "user_confirm_unregister_message": MessageLookupByLibrary.simpleMessage( + "Are you sure you want to unregister your account? If you need to log in again, you will need to link your account again.", + ), + "user_confirm_unregister_title": MessageLookupByLibrary.simpleMessage( + "Confirm Unregister", + ), + "user_not_logged_in": MessageLookupByLibrary.simpleMessage("Not Logged In"), + "user_unregister_failed": MessageLookupByLibrary.simpleMessage( + "Account unregistration failed", + ), + "user_unregister_success": MessageLookupByLibrary.simpleMessage( + "Account unregistered successfully", + ), "webview_localization_finished_invitations": MessageLookupByLibrary.simpleMessage("Finished invitations"), "webview_localization_name_member": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index 283f571..d9b947e 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -1472,6 +1472,16 @@ class MessageLookup extends MessageLookupByLibrary { ), "tools_vehicle_sorting_title": MessageLookupByLibrary.simpleMessage("载具排序"), "tools_vehicle_sorting_vehicle": MessageLookupByLibrary.simpleMessage("载具"), + "user_action_unregister": MessageLookupByLibrary.simpleMessage("注销账户"), + "user_confirm_unregister_message": MessageLookupByLibrary.simpleMessage( + "您确定要注销账户吗?此操作不可撤销,如需再次登录,需重新验证 RSI 账号。", + ), + "user_confirm_unregister_title": MessageLookupByLibrary.simpleMessage( + "确认注销", + ), + "user_not_logged_in": MessageLookupByLibrary.simpleMessage("未登录"), + "user_unregister_failed": MessageLookupByLibrary.simpleMessage("账户注销失败"), + "user_unregister_success": MessageLookupByLibrary.simpleMessage("账户注销成功"), "webview_localization_finished_invitations": MessageLookupByLibrary.simpleMessage("已完成的邀请"), "webview_localization_name_member": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index a15e33e..249b16c 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -6001,6 +6001,66 @@ class S { args: [], ); } + + /// `Not Logged In` + String get user_not_logged_in { + return Intl.message( + 'Not Logged In', + name: 'user_not_logged_in', + desc: '', + args: [], + ); + } + + /// `Unregister Account` + String get user_action_unregister { + return Intl.message( + 'Unregister Account', + name: 'user_action_unregister', + desc: '', + args: [], + ); + } + + /// `Confirm Unregister` + String get user_confirm_unregister_title { + return Intl.message( + 'Confirm Unregister', + name: 'user_confirm_unregister_title', + desc: '', + args: [], + ); + } + + /// `Are you sure you want to unregister your account? If you need to log in again, you will need to link your account again.` + String get user_confirm_unregister_message { + return Intl.message( + 'Are you sure you want to unregister your account? If you need to log in again, you will need to link your account again.', + name: 'user_confirm_unregister_message', + desc: '', + args: [], + ); + } + + /// `Account unregistered successfully` + String get user_unregister_success { + return Intl.message( + 'Account unregistered successfully', + name: 'user_unregister_success', + desc: '', + args: [], + ); + } + + /// `Account unregistration failed` + String get user_unregister_failed { + return Intl.message( + 'Account unregistration failed', + name: 'user_unregister_failed', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 4772b3d..99e35ca 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1180,5 +1180,18 @@ "tools_vehicle_sorting_search": "Search Vehicles", "@tools_vehicle_sorting_search": {}, "tools_vehicle_sorting_sorted": "Sorted Vehicles", - "@tools_vehicle_sorting_sorted": {} + "@tools_vehicle_sorting_sorted": {}, + "user_not_logged_in": "Not Logged In", + "@user_not_logged_in": {}, + "user_action_unregister": "Unregister Account", + "@user_action_unregister": {}, + "user_confirm_unregister_title": "Confirm Unregister", + "@user_confirm_unregister_title": {}, + "user_confirm_unregister_message": "Are you sure you want to unregister your account? If you need to log in again, you will need to link your account again.", + "@user_confirm_unregister_message": {}, + "user_unregister_success": "Account unregistered successfully", + "@user_unregister_success": {}, + "user_unregister_failed": "Account unregistration failed", + "@user_unregister_failed": {} } + diff --git a/lib/l10n/intl_zh_CN.arb b/lib/l10n/intl_zh_CN.arb index 24402d0..c02efa8 100644 --- a/lib/l10n/intl_zh_CN.arb +++ b/lib/l10n/intl_zh_CN.arb @@ -909,5 +909,11 @@ "tools_vehicle_sorting_info": "将左侧载具拖动到右侧列表中,这将会为载具名称增加 001、002 .. 等前缀,方便您在游戏内 UI 快速定位载具。在右侧列表上下拖动可以调整载具的顺序。", "tools_vehicle_sorting_vehicle": "载具", "tools_vehicle_sorting_search": "搜索载具", - "tools_vehicle_sorting_sorted": "已排序载具" + "tools_vehicle_sorting_sorted": "已排序载具", + "user_not_logged_in": "未登录", + "user_action_unregister": "注销账户", + "user_confirm_unregister_title": "确认注销", + "user_confirm_unregister_message": "您确定要注销账户吗?此操作不可撤销,如需再次登录,需重新验证 RSI 账号。", + "user_unregister_success": "账户注销成功", + "user_unregister_failed": "账户注销失败" } \ No newline at end of file diff --git a/lib/ui/index_ui.dart b/lib/ui/index_ui.dart index 203c3ce..9114519 100644 --- a/lib/ui/index_ui.dart +++ b/lib/ui/index_ui.dart @@ -17,6 +17,7 @@ import 'nav/nav_ui.dart'; import 'party_room/party_room_ui_model.dart'; import 'settings/settings_ui.dart'; import 'tools/tools_ui.dart'; +import 'index_ui_widgets/user_avatar_widget.dart'; class IndexUI extends HookConsumerWidget { const IndexUI({super.key}); @@ -51,6 +52,8 @@ class IndexUI extends HookConsumerWidget { actions: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ + UserAvatarWidget(onTapNavigateToPartyRoom: () => _navigateToPartyRoom(curIndex)), + const SizedBox(width: 12), IconButton( icon: Stack( children: [ @@ -144,4 +147,12 @@ class IndexUI extends HookConsumerWidget { void _goDownloader(BuildContext context) { context.push('/index/downloader'); } + + void _navigateToPartyRoom(ValueNotifier curIndexState) { + // 查找 PartyRoomUI 在菜单中的索引 + final partyRoomIndex = pageMenus.values.toList().indexWhere((element) => element.$2 is PartyRoomUI); + if (partyRoomIndex >= 0) { + curIndexState.value = partyRoomIndex; + } + } } diff --git a/lib/ui/index_ui_widgets/user_avatar_widget.dart b/lib/ui/index_ui_widgets/user_avatar_widget.dart new file mode 100644 index 0000000..221b6c1 --- /dev/null +++ b/lib/ui/index_ui_widgets/user_avatar_widget.dart @@ -0,0 +1,198 @@ +import 'package:fluent_ui/fluent_ui.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:starcitizen_doctor/app.dart'; +import 'package:starcitizen_doctor/common/conf/url_conf.dart'; +import 'package:starcitizen_doctor/provider/party_room.dart'; +import 'package:starcitizen_doctor/ui/party_room/party_room_ui_model.dart'; +import 'package:starcitizen_doctor/widgets/widgets.dart'; + +class UserAvatarWidget extends HookConsumerWidget { + final VoidCallback onTapNavigateToPartyRoom; + + const UserAvatarWidget({super.key, required this.onTapNavigateToPartyRoom}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final partyRoomState = ref.watch(partyRoomProvider); + final uiState = ref.watch(partyRoomUIModelProvider); + final isLoggedIn = partyRoomState.auth.isLoggedIn; + final userName = partyRoomState.auth.userInfo?.gameUserId ?? S.current.user_not_logged_in; + final avatarUrl = partyRoomState.auth.userInfo?.avatarUrl; + final fullAvatarUrl = (avatarUrl != null && avatarUrl.isNotEmpty) ? '${URLConf.rsiAvatarBaseUrl}$avatarUrl' : null; + final uuid = ref.read(appGlobalModelProvider).deviceUUID; + return HoverButton( + onPressed: () { + if (isLoggedIn) { + _showAccountCard(context, ref, userName, fullAvatarUrl, uuid); + } else { + onTapNavigateToPartyRoom(); + } + }, + builder: (BuildContext context, Set states) { + return Container( + decoration: BoxDecoration( + color: states.isHovered ? Colors.white.withValues(alpha: .1) : Colors.transparent, + borderRadius: BorderRadius.circular(8), + ), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + // 头像 + Container( + width: 28, + height: 28, + decoration: BoxDecoration( + color: isLoggedIn ? Colors.blue : Colors.grey, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: Colors.white.withValues(alpha: .3), width: 1), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(14), + child: uiState.isLoggingIn + ? const Padding(padding: EdgeInsets.all(4), child: ProgressRing(strokeWidth: 2)) + : (fullAvatarUrl != null + ? CacheNetImage(url: fullAvatarUrl, fit: BoxFit.cover) + : Center( + child: Icon( + isLoggedIn ? FluentIcons.contact : FluentIcons.unknown, + size: 16, + color: Colors.white, + ), + )), + ), + ), + const SizedBox(width: 8), + // 用户名 + Text( + uiState.isLoggingIn ? S.current.home_title_logging_in : userName, + style: TextStyle(fontSize: 13, color: Colors.white.withValues(alpha: isLoggedIn ? 1.0 : .6)), + ), + ], + ), + ); + }, + ); + } + + void _showAccountCard(BuildContext context, WidgetRef ref, String userName, String? avatarUrl, String? uuid) { + final targetContext = context; + final box = targetContext.findRenderObject() as RenderBox?; + final offset = box?.localToGlobal(Offset.zero) ?? Offset.zero; + + showDialog( + context: context, + barrierDismissible: true, + barrierColor: Colors.transparent, + builder: (BuildContext dialogContext) { + return Stack( + children: [ + // 透明遮罩,点击关闭 + GestureDetector( + onTap: () => Navigator.of(dialogContext).pop(), + child: Container(color: Colors.transparent), + ), + // 账户卡片 + Positioned( + left: offset.dx - 100, + top: offset.dy + (box?.size.height ?? 0) + 8, + child: Container( + width: 360, + decoration: BoxDecoration( + color: FluentTheme.of(context).micaBackgroundColor, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: Colors.white.withValues(alpha: .1), width: 1), + boxShadow: [ + BoxShadow(color: Colors.black.withValues(alpha: .3), blurRadius: 20, offset: const Offset(0, 8)), + ], + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 用户信息 + Row( + children: [ + Container( + width: 48, + height: 48, + decoration: BoxDecoration(color: Colors.blue, borderRadius: BorderRadius.circular(24)), + child: ClipRRect( + borderRadius: BorderRadius.circular(24), + child: avatarUrl != null + ? CacheNetImage(url: avatarUrl, fit: BoxFit.cover) + : const Center(child: Icon(FluentIcons.contact, size: 24, color: Colors.white)), + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + userName, + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + '$uuid', + style: TextStyle(fontSize: 12, color: Colors.white.withValues(alpha: .6)), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 16), + const Divider(), + const SizedBox(height: 8), + // 注销按钮 + SizedBox( + width: double.infinity, + child: FilledButton( + onPressed: () async { + Navigator.of(dialogContext).pop(); + await _handleUnregister(context, ref); + }, + style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.red)), + child: Text(S.current.user_action_unregister, style: const TextStyle(color: Colors.white)), + ), + ), + ], + ), + ), + ), + ), + ], + ); + }, + ); + } + + Future _handleUnregister(BuildContext context, WidgetRef ref) async { + final confirmed = await showConfirmDialogs( + context, + S.current.user_confirm_unregister_title, + Text(S.current.user_confirm_unregister_message), + constraints: const BoxConstraints(maxWidth: 400), + ); + + if (confirmed == true) { + try { + final partyRoom = ref.read(partyRoomProvider.notifier); + await partyRoom.unregister(); + if (context.mounted) { + showToast(context, S.current.user_unregister_success); + } + } catch (e) { + if (context.mounted) { + showToast(context, '${S.current.user_unregister_failed}: $e'); + } + } + } + } +} diff --git a/lib/ui/party_room/party_room_ui.dart b/lib/ui/party_room/party_room_ui.dart index ab90615..ab644e0 100644 --- a/lib/ui/party_room/party_room_ui.dart +++ b/lib/ui/party_room/party_room_ui.dart @@ -19,7 +19,7 @@ class PartyRoomUI extends HookConsumerWidget { Widget widget = const PartyRoomListPage(); // 根据状态显示不同页面 - if (!partyRoomState.client.isConnected) { + if (!partyRoomState.client.isConnected || uiState.isLoggingIn) { widget = PartyRoomConnectPage(); } else if (!partyRoomState.auth.isLoggedIn) { widget = PartyRoomRegisterPage(); diff --git a/lib/ui/party_room/party_room_ui_model.dart b/lib/ui/party_room/party_room_ui_model.dart index c1086ac..711787f 100644 --- a/lib/ui/party_room/party_room_ui_model.dart +++ b/lib/ui/party_room/party_room_ui_model.dart @@ -29,6 +29,7 @@ sealed class PartyRoomUIState with _$PartyRoomUIState { @Default(false) bool isReconnecting, @Default(0) int reconnectAttempts, @Default(false) bool isMinimized, + @Default(true) bool isLoggingIn, }) = _PartyRoomUIState; } @@ -138,6 +139,7 @@ class PartyRoomUIModel extends _$PartyRoomUIModel { // 尝试登录 try { + state = state.copyWith(isLoggingIn: true); await partyRoom.login(); // 登录成功,加载标签和房间列表 await partyRoom.loadTags(); @@ -146,6 +148,8 @@ class PartyRoomUIModel extends _$PartyRoomUIModel { } catch (e) { // 未注册,保持在连接状态 dPrint('[PartyRoomUI] Login failed, need register: $e'); + } finally { + state = state.copyWith(isLoggingIn: false); } state = state.copyWith(isConnecting: false); diff --git a/lib/ui/party_room/party_room_ui_model.freezed.dart b/lib/ui/party_room/party_room_ui_model.freezed.dart index 1dd6a9d..4d9cd5f 100644 --- a/lib/ui/party_room/party_room_ui_model.freezed.dart +++ b/lib/ui/party_room/party_room_ui_model.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$PartyRoomUIState { - bool get isConnecting; bool get showRoomList; List get roomListItems; int get currentPage; int get pageSize; int get totalRooms; String? get selectedMainTagId; String? get selectedSubTagId; String get searchOwnerName; bool get isLoading; String? get errorMessage; String get preRegisterCode; String get registerGameUserId; bool get isReconnecting; int get reconnectAttempts; bool get isMinimized; + bool get isConnecting; bool get showRoomList; List get roomListItems; int get currentPage; int get pageSize; int get totalRooms; String? get selectedMainTagId; String? get selectedSubTagId; String get searchOwnerName; bool get isLoading; String? get errorMessage; String get preRegisterCode; String get registerGameUserId; bool get isReconnecting; int get reconnectAttempts; bool get isMinimized; bool get isLoggingIn; /// Create a copy of PartyRoomUIState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $PartyRoomUIStateCopyWith get copyWith => _$PartyRoomUIStateCo @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is PartyRoomUIState&&(identical(other.isConnecting, isConnecting) || other.isConnecting == isConnecting)&&(identical(other.showRoomList, showRoomList) || other.showRoomList == showRoomList)&&const DeepCollectionEquality().equals(other.roomListItems, roomListItems)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage)&&(identical(other.pageSize, pageSize) || other.pageSize == pageSize)&&(identical(other.totalRooms, totalRooms) || other.totalRooms == totalRooms)&&(identical(other.selectedMainTagId, selectedMainTagId) || other.selectedMainTagId == selectedMainTagId)&&(identical(other.selectedSubTagId, selectedSubTagId) || other.selectedSubTagId == selectedSubTagId)&&(identical(other.searchOwnerName, searchOwnerName) || other.searchOwnerName == searchOwnerName)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.preRegisterCode, preRegisterCode) || other.preRegisterCode == preRegisterCode)&&(identical(other.registerGameUserId, registerGameUserId) || other.registerGameUserId == registerGameUserId)&&(identical(other.isReconnecting, isReconnecting) || other.isReconnecting == isReconnecting)&&(identical(other.reconnectAttempts, reconnectAttempts) || other.reconnectAttempts == reconnectAttempts)&&(identical(other.isMinimized, isMinimized) || other.isMinimized == isMinimized)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is PartyRoomUIState&&(identical(other.isConnecting, isConnecting) || other.isConnecting == isConnecting)&&(identical(other.showRoomList, showRoomList) || other.showRoomList == showRoomList)&&const DeepCollectionEquality().equals(other.roomListItems, roomListItems)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage)&&(identical(other.pageSize, pageSize) || other.pageSize == pageSize)&&(identical(other.totalRooms, totalRooms) || other.totalRooms == totalRooms)&&(identical(other.selectedMainTagId, selectedMainTagId) || other.selectedMainTagId == selectedMainTagId)&&(identical(other.selectedSubTagId, selectedSubTagId) || other.selectedSubTagId == selectedSubTagId)&&(identical(other.searchOwnerName, searchOwnerName) || other.searchOwnerName == searchOwnerName)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.preRegisterCode, preRegisterCode) || other.preRegisterCode == preRegisterCode)&&(identical(other.registerGameUserId, registerGameUserId) || other.registerGameUserId == registerGameUserId)&&(identical(other.isReconnecting, isReconnecting) || other.isReconnecting == isReconnecting)&&(identical(other.reconnectAttempts, reconnectAttempts) || other.reconnectAttempts == reconnectAttempts)&&(identical(other.isMinimized, isMinimized) || other.isMinimized == isMinimized)&&(identical(other.isLoggingIn, isLoggingIn) || other.isLoggingIn == isLoggingIn)); } @override -int get hashCode => Object.hash(runtimeType,isConnecting,showRoomList,const DeepCollectionEquality().hash(roomListItems),currentPage,pageSize,totalRooms,selectedMainTagId,selectedSubTagId,searchOwnerName,isLoading,errorMessage,preRegisterCode,registerGameUserId,isReconnecting,reconnectAttempts,isMinimized); +int get hashCode => Object.hash(runtimeType,isConnecting,showRoomList,const DeepCollectionEquality().hash(roomListItems),currentPage,pageSize,totalRooms,selectedMainTagId,selectedSubTagId,searchOwnerName,isLoading,errorMessage,preRegisterCode,registerGameUserId,isReconnecting,reconnectAttempts,isMinimized,isLoggingIn); @override String toString() { - return 'PartyRoomUIState(isConnecting: $isConnecting, showRoomList: $showRoomList, roomListItems: $roomListItems, currentPage: $currentPage, pageSize: $pageSize, totalRooms: $totalRooms, selectedMainTagId: $selectedMainTagId, selectedSubTagId: $selectedSubTagId, searchOwnerName: $searchOwnerName, isLoading: $isLoading, errorMessage: $errorMessage, preRegisterCode: $preRegisterCode, registerGameUserId: $registerGameUserId, isReconnecting: $isReconnecting, reconnectAttempts: $reconnectAttempts, isMinimized: $isMinimized)'; + return 'PartyRoomUIState(isConnecting: $isConnecting, showRoomList: $showRoomList, roomListItems: $roomListItems, currentPage: $currentPage, pageSize: $pageSize, totalRooms: $totalRooms, selectedMainTagId: $selectedMainTagId, selectedSubTagId: $selectedSubTagId, searchOwnerName: $searchOwnerName, isLoading: $isLoading, errorMessage: $errorMessage, preRegisterCode: $preRegisterCode, registerGameUserId: $registerGameUserId, isReconnecting: $isReconnecting, reconnectAttempts: $reconnectAttempts, isMinimized: $isMinimized, isLoggingIn: $isLoggingIn)'; } @@ -45,7 +45,7 @@ abstract mixin class $PartyRoomUIStateCopyWith<$Res> { factory $PartyRoomUIStateCopyWith(PartyRoomUIState value, $Res Function(PartyRoomUIState) _then) = _$PartyRoomUIStateCopyWithImpl; @useResult $Res call({ - bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized + bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized, bool isLoggingIn }); @@ -62,7 +62,7 @@ class _$PartyRoomUIStateCopyWithImpl<$Res> /// Create a copy of PartyRoomUIState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? isConnecting = null,Object? showRoomList = null,Object? roomListItems = null,Object? currentPage = null,Object? pageSize = null,Object? totalRooms = null,Object? selectedMainTagId = freezed,Object? selectedSubTagId = freezed,Object? searchOwnerName = null,Object? isLoading = null,Object? errorMessage = freezed,Object? preRegisterCode = null,Object? registerGameUserId = null,Object? isReconnecting = null,Object? reconnectAttempts = null,Object? isMinimized = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? isConnecting = null,Object? showRoomList = null,Object? roomListItems = null,Object? currentPage = null,Object? pageSize = null,Object? totalRooms = null,Object? selectedMainTagId = freezed,Object? selectedSubTagId = freezed,Object? searchOwnerName = null,Object? isLoading = null,Object? errorMessage = freezed,Object? preRegisterCode = null,Object? registerGameUserId = null,Object? isReconnecting = null,Object? reconnectAttempts = null,Object? isMinimized = null,Object? isLoggingIn = null,}) { return _then(_self.copyWith( isConnecting: null == isConnecting ? _self.isConnecting : isConnecting // ignore: cast_nullable_to_non_nullable as bool,showRoomList: null == showRoomList ? _self.showRoomList : showRoomList // ignore: cast_nullable_to_non_nullable @@ -80,6 +80,7 @@ as String,registerGameUserId: null == registerGameUserId ? _self.registerGameUse as String,isReconnecting: null == isReconnecting ? _self.isReconnecting : isReconnecting // ignore: cast_nullable_to_non_nullable as bool,reconnectAttempts: null == reconnectAttempts ? _self.reconnectAttempts : reconnectAttempts // ignore: cast_nullable_to_non_nullable as int,isMinimized: null == isMinimized ? _self.isMinimized : isMinimized // ignore: cast_nullable_to_non_nullable +as bool,isLoggingIn: null == isLoggingIn ? _self.isLoggingIn : isLoggingIn // ignore: cast_nullable_to_non_nullable as bool, )); } @@ -162,10 +163,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized, bool isLoggingIn)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _PartyRoomUIState() when $default != null: -return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that.currentPage,_that.pageSize,_that.totalRooms,_that.selectedMainTagId,_that.selectedSubTagId,_that.searchOwnerName,_that.isLoading,_that.errorMessage,_that.preRegisterCode,_that.registerGameUserId,_that.isReconnecting,_that.reconnectAttempts,_that.isMinimized);case _: +return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that.currentPage,_that.pageSize,_that.totalRooms,_that.selectedMainTagId,_that.selectedSubTagId,_that.searchOwnerName,_that.isLoading,_that.errorMessage,_that.preRegisterCode,_that.registerGameUserId,_that.isReconnecting,_that.reconnectAttempts,_that.isMinimized,_that.isLoggingIn);case _: return orElse(); } @@ -183,10 +184,10 @@ return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that. /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized, bool isLoggingIn) $default,) {final _that = this; switch (_that) { case _PartyRoomUIState(): -return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that.currentPage,_that.pageSize,_that.totalRooms,_that.selectedMainTagId,_that.selectedSubTagId,_that.searchOwnerName,_that.isLoading,_that.errorMessage,_that.preRegisterCode,_that.registerGameUserId,_that.isReconnecting,_that.reconnectAttempts,_that.isMinimized);} +return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that.currentPage,_that.pageSize,_that.totalRooms,_that.selectedMainTagId,_that.selectedSubTagId,_that.searchOwnerName,_that.isLoading,_that.errorMessage,_that.preRegisterCode,_that.registerGameUserId,_that.isReconnecting,_that.reconnectAttempts,_that.isMinimized,_that.isLoggingIn);} } /// A variant of `when` that fallback to returning `null` /// @@ -200,10 +201,10 @@ return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that. /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized, bool isLoggingIn)? $default,) {final _that = this; switch (_that) { case _PartyRoomUIState() when $default != null: -return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that.currentPage,_that.pageSize,_that.totalRooms,_that.selectedMainTagId,_that.selectedSubTagId,_that.searchOwnerName,_that.isLoading,_that.errorMessage,_that.preRegisterCode,_that.registerGameUserId,_that.isReconnecting,_that.reconnectAttempts,_that.isMinimized);case _: +return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that.currentPage,_that.pageSize,_that.totalRooms,_that.selectedMainTagId,_that.selectedSubTagId,_that.searchOwnerName,_that.isLoading,_that.errorMessage,_that.preRegisterCode,_that.registerGameUserId,_that.isReconnecting,_that.reconnectAttempts,_that.isMinimized,_that.isLoggingIn);case _: return null; } @@ -215,7 +216,7 @@ return $default(_that.isConnecting,_that.showRoomList,_that.roomListItems,_that. class _PartyRoomUIState implements PartyRoomUIState { - const _PartyRoomUIState({this.isConnecting = false, this.showRoomList = false, final List roomListItems = const [], this.currentPage = 1, this.pageSize = 20, this.totalRooms = 0, this.selectedMainTagId, this.selectedSubTagId, this.searchOwnerName = '', this.isLoading = false, this.errorMessage, this.preRegisterCode = '', this.registerGameUserId = '', this.isReconnecting = false, this.reconnectAttempts = 0, this.isMinimized = false}): _roomListItems = roomListItems; + const _PartyRoomUIState({this.isConnecting = false, this.showRoomList = false, final List roomListItems = const [], this.currentPage = 1, this.pageSize = 20, this.totalRooms = 0, this.selectedMainTagId, this.selectedSubTagId, this.searchOwnerName = '', this.isLoading = false, this.errorMessage, this.preRegisterCode = '', this.registerGameUserId = '', this.isReconnecting = false, this.reconnectAttempts = 0, this.isMinimized = false, this.isLoggingIn = true}): _roomListItems = roomListItems; @override@JsonKey() final bool isConnecting; @@ -240,6 +241,7 @@ class _PartyRoomUIState implements PartyRoomUIState { @override@JsonKey() final bool isReconnecting; @override@JsonKey() final int reconnectAttempts; @override@JsonKey() final bool isMinimized; +@override@JsonKey() final bool isLoggingIn; /// Create a copy of PartyRoomUIState /// with the given fields replaced by the non-null parameter values. @@ -251,16 +253,16 @@ _$PartyRoomUIStateCopyWith<_PartyRoomUIState> get copyWith => __$PartyRoomUIStat @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _PartyRoomUIState&&(identical(other.isConnecting, isConnecting) || other.isConnecting == isConnecting)&&(identical(other.showRoomList, showRoomList) || other.showRoomList == showRoomList)&&const DeepCollectionEquality().equals(other._roomListItems, _roomListItems)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage)&&(identical(other.pageSize, pageSize) || other.pageSize == pageSize)&&(identical(other.totalRooms, totalRooms) || other.totalRooms == totalRooms)&&(identical(other.selectedMainTagId, selectedMainTagId) || other.selectedMainTagId == selectedMainTagId)&&(identical(other.selectedSubTagId, selectedSubTagId) || other.selectedSubTagId == selectedSubTagId)&&(identical(other.searchOwnerName, searchOwnerName) || other.searchOwnerName == searchOwnerName)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.preRegisterCode, preRegisterCode) || other.preRegisterCode == preRegisterCode)&&(identical(other.registerGameUserId, registerGameUserId) || other.registerGameUserId == registerGameUserId)&&(identical(other.isReconnecting, isReconnecting) || other.isReconnecting == isReconnecting)&&(identical(other.reconnectAttempts, reconnectAttempts) || other.reconnectAttempts == reconnectAttempts)&&(identical(other.isMinimized, isMinimized) || other.isMinimized == isMinimized)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PartyRoomUIState&&(identical(other.isConnecting, isConnecting) || other.isConnecting == isConnecting)&&(identical(other.showRoomList, showRoomList) || other.showRoomList == showRoomList)&&const DeepCollectionEquality().equals(other._roomListItems, _roomListItems)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage)&&(identical(other.pageSize, pageSize) || other.pageSize == pageSize)&&(identical(other.totalRooms, totalRooms) || other.totalRooms == totalRooms)&&(identical(other.selectedMainTagId, selectedMainTagId) || other.selectedMainTagId == selectedMainTagId)&&(identical(other.selectedSubTagId, selectedSubTagId) || other.selectedSubTagId == selectedSubTagId)&&(identical(other.searchOwnerName, searchOwnerName) || other.searchOwnerName == searchOwnerName)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.preRegisterCode, preRegisterCode) || other.preRegisterCode == preRegisterCode)&&(identical(other.registerGameUserId, registerGameUserId) || other.registerGameUserId == registerGameUserId)&&(identical(other.isReconnecting, isReconnecting) || other.isReconnecting == isReconnecting)&&(identical(other.reconnectAttempts, reconnectAttempts) || other.reconnectAttempts == reconnectAttempts)&&(identical(other.isMinimized, isMinimized) || other.isMinimized == isMinimized)&&(identical(other.isLoggingIn, isLoggingIn) || other.isLoggingIn == isLoggingIn)); } @override -int get hashCode => Object.hash(runtimeType,isConnecting,showRoomList,const DeepCollectionEquality().hash(_roomListItems),currentPage,pageSize,totalRooms,selectedMainTagId,selectedSubTagId,searchOwnerName,isLoading,errorMessage,preRegisterCode,registerGameUserId,isReconnecting,reconnectAttempts,isMinimized); +int get hashCode => Object.hash(runtimeType,isConnecting,showRoomList,const DeepCollectionEquality().hash(_roomListItems),currentPage,pageSize,totalRooms,selectedMainTagId,selectedSubTagId,searchOwnerName,isLoading,errorMessage,preRegisterCode,registerGameUserId,isReconnecting,reconnectAttempts,isMinimized,isLoggingIn); @override String toString() { - return 'PartyRoomUIState(isConnecting: $isConnecting, showRoomList: $showRoomList, roomListItems: $roomListItems, currentPage: $currentPage, pageSize: $pageSize, totalRooms: $totalRooms, selectedMainTagId: $selectedMainTagId, selectedSubTagId: $selectedSubTagId, searchOwnerName: $searchOwnerName, isLoading: $isLoading, errorMessage: $errorMessage, preRegisterCode: $preRegisterCode, registerGameUserId: $registerGameUserId, isReconnecting: $isReconnecting, reconnectAttempts: $reconnectAttempts, isMinimized: $isMinimized)'; + return 'PartyRoomUIState(isConnecting: $isConnecting, showRoomList: $showRoomList, roomListItems: $roomListItems, currentPage: $currentPage, pageSize: $pageSize, totalRooms: $totalRooms, selectedMainTagId: $selectedMainTagId, selectedSubTagId: $selectedSubTagId, searchOwnerName: $searchOwnerName, isLoading: $isLoading, errorMessage: $errorMessage, preRegisterCode: $preRegisterCode, registerGameUserId: $registerGameUserId, isReconnecting: $isReconnecting, reconnectAttempts: $reconnectAttempts, isMinimized: $isMinimized, isLoggingIn: $isLoggingIn)'; } @@ -271,7 +273,7 @@ abstract mixin class _$PartyRoomUIStateCopyWith<$Res> implements $PartyRoomUISta factory _$PartyRoomUIStateCopyWith(_PartyRoomUIState value, $Res Function(_PartyRoomUIState) _then) = __$PartyRoomUIStateCopyWithImpl; @override @useResult $Res call({ - bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized + bool isConnecting, bool showRoomList, List roomListItems, int currentPage, int pageSize, int totalRooms, String? selectedMainTagId, String? selectedSubTagId, String searchOwnerName, bool isLoading, String? errorMessage, String preRegisterCode, String registerGameUserId, bool isReconnecting, int reconnectAttempts, bool isMinimized, bool isLoggingIn }); @@ -288,7 +290,7 @@ class __$PartyRoomUIStateCopyWithImpl<$Res> /// Create a copy of PartyRoomUIState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? isConnecting = null,Object? showRoomList = null,Object? roomListItems = null,Object? currentPage = null,Object? pageSize = null,Object? totalRooms = null,Object? selectedMainTagId = freezed,Object? selectedSubTagId = freezed,Object? searchOwnerName = null,Object? isLoading = null,Object? errorMessage = freezed,Object? preRegisterCode = null,Object? registerGameUserId = null,Object? isReconnecting = null,Object? reconnectAttempts = null,Object? isMinimized = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? isConnecting = null,Object? showRoomList = null,Object? roomListItems = null,Object? currentPage = null,Object? pageSize = null,Object? totalRooms = null,Object? selectedMainTagId = freezed,Object? selectedSubTagId = freezed,Object? searchOwnerName = null,Object? isLoading = null,Object? errorMessage = freezed,Object? preRegisterCode = null,Object? registerGameUserId = null,Object? isReconnecting = null,Object? reconnectAttempts = null,Object? isMinimized = null,Object? isLoggingIn = null,}) { return _then(_PartyRoomUIState( isConnecting: null == isConnecting ? _self.isConnecting : isConnecting // ignore: cast_nullable_to_non_nullable as bool,showRoomList: null == showRoomList ? _self.showRoomList : showRoomList // ignore: cast_nullable_to_non_nullable @@ -306,6 +308,7 @@ as String,registerGameUserId: null == registerGameUserId ? _self.registerGameUse as String,isReconnecting: null == isReconnecting ? _self.isReconnecting : isReconnecting // ignore: cast_nullable_to_non_nullable as bool,reconnectAttempts: null == reconnectAttempts ? _self.reconnectAttempts : reconnectAttempts // ignore: cast_nullable_to_non_nullable as int,isMinimized: null == isMinimized ? _self.isMinimized : isMinimized // ignore: cast_nullable_to_non_nullable +as bool,isLoggingIn: null == isLoggingIn ? _self.isLoggingIn : isLoggingIn // ignore: cast_nullable_to_non_nullable as bool, )); } diff --git a/lib/ui/party_room/party_room_ui_model.g.dart b/lib/ui/party_room/party_room_ui_model.g.dart index 7160239..6b26a6a 100644 --- a/lib/ui/party_room/party_room_ui_model.g.dart +++ b/lib/ui/party_room/party_room_ui_model.g.dart @@ -41,7 +41,7 @@ final class PartyRoomUIModelProvider } } -String _$partyRoomUIModelHash() => r'0e86aeb2bf3524907836e9951b04c062c84327a6'; +String _$partyRoomUIModelHash() => r'c5282725c1e078efefe0023dbedfba02091d4d8e'; abstract class _$PartyRoomUIModel extends $Notifier { PartyRoomUIState build();