修复资料卡问题
This commit is contained in:
parent
bae5ee44af
commit
a44bdd7287
@ -13,7 +13,6 @@ import '../../../ui_kit/components/sc_page_list.dart';
|
||||
import '../../../ui_kit/components/sc_tts.dart';
|
||||
import '../../../ui_kit/components/text/sc_text.dart';
|
||||
import '../../../ui_kit/widgets/id/sc_special_id_badge.dart';
|
||||
import '../../../shared/tools/sc_lk_dialog_util.dart';
|
||||
import '../../../ui_kit/widgets/badge/sc_user_badge_strip.dart';
|
||||
import '../../../ui_kit/widgets/room/room_user_info_card.dart';
|
||||
|
||||
@ -44,7 +43,7 @@ class _RoomOnlinePageState
|
||||
if (dialogContext == null) {
|
||||
return;
|
||||
}
|
||||
showBottomInBottomDialog(dialogContext, RoomUserInfoCard(userId: userId));
|
||||
RoomUserInfoCard.showPreloaded(dialogContext, userId: userId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_room_repository_imp.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_room_repository_imp.dart';
|
||||
import 'package:yumi/main.dart';
|
||||
|
||||
import 'package:yumi/app_localizations.dart';
|
||||
@ -13,7 +13,6 @@ import 'package:yumi/ui_kit/components/sc_compontent.dart';
|
||||
import 'package:yumi/ui_kit/components/sc_page_list.dart';
|
||||
import 'package:yumi/ui_kit/components/text/sc_text.dart';
|
||||
import 'package:yumi/ui_kit/components/sc_tts.dart';
|
||||
import 'package:yumi/shared/tools/sc_lk_dialog_util.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/room_gift_rank_res.dart';
|
||||
import 'package:yumi/ui_kit/widgets/id/sc_special_id_badge.dart';
|
||||
import 'package:yumi/ui_kit/widgets/room/room_user_info_card.dart';
|
||||
@ -98,11 +97,11 @@ class _RoomGiftRankTabPageState
|
||||
// headdress: userInfo.userProfile?.getHeaddress()?.sourceUrl,
|
||||
),
|
||||
onTap: () {
|
||||
showBottomInBottomDialog(
|
||||
navigatorKey.currentState!.context,
|
||||
RoomUserInfoCard(userId: userProfile?.id),
|
||||
);
|
||||
SmartDialog.dismiss(tag: "showRoomGiftRankPage");
|
||||
RoomUserInfoCard.showPreloaded(
|
||||
navigatorKey.currentState!.context,
|
||||
userId: userProfile?.id,
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 3.w),
|
||||
@ -119,7 +118,7 @@ class _RoomGiftRankTabPageState
|
||||
needScroll:
|
||||
(userProfile?.userNickname?.characters.length ??
|
||||
0) >
|
||||
14,
|
||||
14,
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -137,7 +136,7 @@ class _RoomGiftRankTabPageState
|
||||
animationHeight: 24.w,
|
||||
showTextBesideAnimated: true,
|
||||
animatedTextSpacing: 0,
|
||||
showAnimatedGradientText:
|
||||
showAnimatedGradientText:
|
||||
userProfile
|
||||
?.shouldShowColoredSpecialIdText() ??
|
||||
false,
|
||||
@ -195,24 +194,24 @@ class _RoomGiftRankTabPageState
|
||||
SocialChatUserProfile? _mergeCurrentUserVip(
|
||||
SocialChatUserProfile? profile,
|
||||
) {
|
||||
if (profile == null || profile.vipLevelForColoredId > 0) {
|
||||
return profile;
|
||||
}
|
||||
final currentProfile = AccountStorage().getCurrentUser()?.userProfile;
|
||||
if (currentProfile == null ||
|
||||
currentProfile.vipLevelForColoredId <= 0 ||
|
||||
currentProfile.id != profile.id) {
|
||||
return profile;
|
||||
}
|
||||
return profile.copyWith(
|
||||
vipLevel:
|
||||
currentProfile.vipLevel ??
|
||||
currentProfile.vipLevelForColoredId.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
empty() {
|
||||
if (profile == null || profile.vipLevelForColoredId > 0) {
|
||||
return profile;
|
||||
}
|
||||
final currentProfile = AccountStorage().getCurrentUser()?.userProfile;
|
||||
if (currentProfile == null ||
|
||||
currentProfile.vipLevelForColoredId <= 0 ||
|
||||
currentProfile.id != profile.id) {
|
||||
return profile;
|
||||
}
|
||||
return profile.copyWith(
|
||||
vipLevel:
|
||||
currentProfile.vipLevel ??
|
||||
currentProfile.vipLevelForColoredId.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
empty() {
|
||||
return mainEmpty(
|
||||
image: Image.asset(
|
||||
'sc_images/general/sc_icon_loading.png',
|
||||
|
||||
@ -5197,10 +5197,7 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
if (clickUser.id ==
|
||||
AccountStorage().getCurrentUser()?.userProfile?.id) {
|
||||
///是自己,直接打开资料卡
|
||||
showBottomInBottomDialog(
|
||||
context!,
|
||||
RoomUserInfoCard(userId: clickUser.id),
|
||||
);
|
||||
RoomUserInfoCard.showPreloaded(context!, userId: clickUser.id);
|
||||
} else {
|
||||
showBottomInBottomDialog(
|
||||
context!,
|
||||
@ -5441,10 +5438,7 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
if (normalizedUserId.isEmpty) {
|
||||
return;
|
||||
}
|
||||
showBottomInBottomDialog(
|
||||
context!,
|
||||
RoomUserInfoCard(userId: normalizedUserId),
|
||||
);
|
||||
RoomUserInfoCard.showPreloaded(context!, userId: normalizedUserId);
|
||||
}
|
||||
|
||||
addSoundVoiceChangeListener(OnSoundVoiceChange onSoundVoiceChange) {
|
||||
|
||||
@ -250,7 +250,7 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
return sessionSerial;
|
||||
}
|
||||
|
||||
Future<void> roomUserCard(
|
||||
Future<RoomUserCardRes?> roomUserCard(
|
||||
String roomId,
|
||||
String userId, {
|
||||
int? sessionSerial,
|
||||
@ -272,36 +272,31 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
isUserCardLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
RoomUserCardRes? card = await SCChatRoomRepository().roomUserCard(
|
||||
normalizedRoomId,
|
||||
normalizedUserId,
|
||||
final card = await _loadHydratedRoomUserCard(
|
||||
roomId: normalizedRoomId,
|
||||
userId: normalizedUserId,
|
||||
);
|
||||
if (requestSerial != _userCardRequestSerial) {
|
||||
return;
|
||||
if (requestSerial != _userCardRequestSerial ||
|
||||
activeSessionSerial != _activeUserCardSessionSerial) {
|
||||
return null;
|
||||
}
|
||||
userCardInfo = card;
|
||||
userCardLoadError = null;
|
||||
isUserCardLoading = false;
|
||||
isUserCardRelationLoading = card.userProfile != null;
|
||||
isUserCardRelationLoading = false;
|
||||
notifyListeners();
|
||||
unawaited(
|
||||
_hydrateRoomUserCard(
|
||||
card: card,
|
||||
userId: normalizedUserId,
|
||||
requestSerial: requestSerial,
|
||||
sessionSerial: activeSessionSerial,
|
||||
),
|
||||
);
|
||||
return card;
|
||||
} catch (error, stackTrace) {
|
||||
if (requestSerial != _userCardRequestSerial) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
userCardInfo = null;
|
||||
userCardLoadError = error;
|
||||
isUserCardRelationLoading = false;
|
||||
_debugProfileLoadFailure(
|
||||
scope: 'roomCard',
|
||||
userId: normalizedUserId,
|
||||
@ -314,6 +309,23 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<RoomUserCardRes?> preloadRoomUserCardForOpen(
|
||||
String roomId,
|
||||
String userId, {
|
||||
int? sessionSerial,
|
||||
}) {
|
||||
return roomUserCard(roomId, userId, sessionSerial: sessionSerial);
|
||||
}
|
||||
|
||||
Future<RoomUserCardRes?> _loadHydratedRoomUserCard({
|
||||
required String roomId,
|
||||
required String userId,
|
||||
}) async {
|
||||
final card = await SCChatRoomRepository().roomUserCard(roomId, userId);
|
||||
return _withCurrentVipLevelForCard(card, userId);
|
||||
}
|
||||
|
||||
Future<void> _hydrateUserInfoById({
|
||||
@ -340,38 +352,6 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _hydrateRoomUserCard({
|
||||
required RoomUserCardRes? card,
|
||||
required String userId,
|
||||
required int requestSerial,
|
||||
required int sessionSerial,
|
||||
}) async {
|
||||
try {
|
||||
final hydratedCard = await _withCurrentVipLevelForCard(card, userId);
|
||||
if (requestSerial != _userCardRequestSerial ||
|
||||
sessionSerial != _activeUserCardSessionSerial ||
|
||||
hydratedCard == null) {
|
||||
return;
|
||||
}
|
||||
userCardInfo = hydratedCard;
|
||||
userCardLoadError = null;
|
||||
isUserCardRelationLoading = false;
|
||||
notifyListeners();
|
||||
} catch (error, stackTrace) {
|
||||
if (requestSerial == _userCardRequestSerial &&
|
||||
sessionSerial == _activeUserCardSessionSerial) {
|
||||
isUserCardRelationLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
_debugProfileLoadFailure(
|
||||
scope: 'roomCardHydrate',
|
||||
userId: userId,
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void clearRoomUserCard({int? sessionSerial}) {
|
||||
if (sessionSerial != null &&
|
||||
sessionSerial != _activeUserCardSessionSerial) {
|
||||
|
||||
@ -9,7 +9,6 @@ import 'package:yumi/ui_kit/widgets/room/room_user_info_card.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:yumi/app/constants/sc_room_msg_type.dart';
|
||||
import 'package:yumi/app/constants/sc_screen.dart';
|
||||
import 'package:yumi/shared/tools/sc_lk_dialog_util.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/mic_res.dart';
|
||||
import 'package:yumi/services/audio/rtc_manager.dart';
|
||||
@ -266,10 +265,7 @@ class EmptyMaiSelect extends StatelessWidget {
|
||||
context,
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
showBottomInBottomDialog(
|
||||
context,
|
||||
RoomUserInfoCard(userId: clickUser?.id),
|
||||
);
|
||||
RoomUserInfoCard.showPreloaded(context, userId: clickUser?.id);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -48,8 +48,91 @@ import '../../../modules/chat/chat_route.dart';
|
||||
|
||||
class RoomUserInfoCard extends StatefulWidget {
|
||||
final String? userId;
|
||||
final String? roomId;
|
||||
final int? sessionSerial;
|
||||
final bool preloaded;
|
||||
|
||||
const RoomUserInfoCard({super.key, this.userId});
|
||||
const RoomUserInfoCard({
|
||||
super.key,
|
||||
this.userId,
|
||||
this.roomId,
|
||||
this.sessionSerial,
|
||||
this.preloaded = false,
|
||||
});
|
||||
|
||||
static int _openRequestSerial = 0;
|
||||
|
||||
static Future<void> showPreloaded(
|
||||
BuildContext context, {
|
||||
required String? userId,
|
||||
}) async {
|
||||
final normalizedUserId = (userId ?? '').trim();
|
||||
if (normalizedUserId.isEmpty) {
|
||||
return;
|
||||
}
|
||||
final openSerial = ++_openRequestSerial;
|
||||
final sourceRoomId = _resolveCurrentRoomId(context);
|
||||
final dialogContext = navigatorKey.currentState?.context ?? context;
|
||||
final userProvider = Provider.of<SocialChatUserProfileManager>(
|
||||
dialogContext,
|
||||
listen: false,
|
||||
);
|
||||
final roomId =
|
||||
sourceRoomId.isNotEmpty
|
||||
? sourceRoomId
|
||||
: _resolveCurrentRoomId(dialogContext);
|
||||
final sessionSerial = userProvider.beginRoomUserCardSession();
|
||||
SCLoadingManager.show();
|
||||
room_card.RoomUserCardRes? card;
|
||||
try {
|
||||
card = await userProvider.preloadRoomUserCardForOpen(
|
||||
roomId,
|
||||
normalizedUserId,
|
||||
sessionSerial: sessionSerial,
|
||||
);
|
||||
} finally {
|
||||
if (openSerial == _openRequestSerial) {
|
||||
SCLoadingManager.hide();
|
||||
}
|
||||
}
|
||||
if (openSerial != _openRequestSerial) {
|
||||
return;
|
||||
}
|
||||
final latestDialogContext = navigatorKey.currentState?.context ?? context;
|
||||
if (!latestDialogContext.mounted) {
|
||||
userProvider.clearRoomUserCard(sessionSerial: sessionSerial);
|
||||
return;
|
||||
}
|
||||
if (card == null) {
|
||||
userProvider.clearRoomUserCard(sessionSerial: sessionSerial);
|
||||
SCTts.show(
|
||||
SCAppLocalizations.of(latestDialogContext)?.loadingFailedClickToRetry ??
|
||||
'Loading failed, click to retry',
|
||||
);
|
||||
return;
|
||||
}
|
||||
showBottomInBottomDialog(
|
||||
latestDialogContext,
|
||||
RoomUserInfoCard(
|
||||
userId: normalizedUserId,
|
||||
roomId: roomId,
|
||||
sessionSerial: sessionSerial,
|
||||
preloaded: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String _resolveCurrentRoomId(BuildContext context) {
|
||||
try {
|
||||
return Provider.of<RtcProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).currenRoom?.roomProfile?.roomProfile?.id ??
|
||||
"";
|
||||
} catch (_) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
State<RoomUserInfoCard> createState() => _RoomUserInfoCardState();
|
||||
@ -76,12 +159,16 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
_loadRoomUserCard();
|
||||
});
|
||||
roomId = widget.roomId?.trim() ?? "";
|
||||
_userCardSessionSerial = widget.sessionSerial;
|
||||
if (!widget.preloaded) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
_loadRoomUserCard();
|
||||
});
|
||||
}
|
||||
SCAccountRepository().userIdentity(userId: widget.userId).then((v) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
@ -96,12 +183,7 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
roomId =
|
||||
Provider.of<RtcProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).currenRoom?.roomProfile?.roomProfile?.id ??
|
||||
"";
|
||||
roomId = RoomUserInfoCard._resolveCurrentRoomId(context);
|
||||
final sessionSerial = userProvider?.beginRoomUserCardSession();
|
||||
_userCardSessionSerial = sessionSerial;
|
||||
userProvider?.roomUserCard(
|
||||
@ -244,12 +326,13 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
||||
required bool relationLoading,
|
||||
}) {
|
||||
final defaultSheetHeight = screenHeight * _profileSheetHeightFactor;
|
||||
final compactBadgeHeightDelta = 10.w;
|
||||
if (relationLoading) {
|
||||
return defaultSheetHeight;
|
||||
return defaultSheetHeight + compactBadgeHeightDelta;
|
||||
}
|
||||
final hasCpRelation = _hasCpRelation(profile);
|
||||
final hasCloseFriends = _closeFriendProfileData(profile).isNotEmpty;
|
||||
var resolvedHeight = defaultSheetHeight;
|
||||
var resolvedHeight = defaultSheetHeight + compactBadgeHeightDelta;
|
||||
if (!hasCpRelation) {
|
||||
resolvedHeight -= 126.w;
|
||||
}
|
||||
@ -602,16 +685,16 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
||||
) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 20.w,
|
||||
height: 30.w,
|
||||
child: Center(
|
||||
child: SCUserBadgeStrip(
|
||||
userId: userId,
|
||||
fallbackBadges: _roomCardFallbackBadges(ref, profile),
|
||||
displayScope: SCUserBadgeDisplayScope.short,
|
||||
height: 20.w,
|
||||
badgeHeight: 20.w,
|
||||
longBadgeWidth: 44.w,
|
||||
spacing: 5.w,
|
||||
height: 30.w,
|
||||
badgeHeight: 28.w,
|
||||
longBadgeWidth: 62.w,
|
||||
spacing: 6.w,
|
||||
maxBadges: 3,
|
||||
wrap: false,
|
||||
reserveSpace: false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user