fix: filter long badges from honor wall
This commit is contained in:
parent
e5fdb78fd6
commit
e196d55a27
@ -14,6 +14,7 @@ import '../../../ui_kit/components/sc_tts.dart';
|
|||||||
import '../../../ui_kit/components/text/sc_text.dart';
|
import '../../../ui_kit/components/text/sc_text.dart';
|
||||||
import '../../../ui_kit/widgets/id/sc_special_id_badge.dart';
|
import '../../../ui_kit/widgets/id/sc_special_id_badge.dart';
|
||||||
import '../../../shared/tools/sc_lk_dialog_util.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';
|
import '../../../ui_kit/widgets/room/room_user_info_card.dart';
|
||||||
|
|
||||||
///房间用户在线列表
|
///房间用户在线列表
|
||||||
@ -107,84 +108,105 @@ class _RoomOnlinePageState
|
|||||||
_openUserCard(userInfo);
|
_openUserCard(userInfo);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(width: 3.w),
|
SizedBox(width: 8.w),
|
||||||
Column(
|
Expanded(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Row(
|
||||||
msgRoleTag(userInfo.roles ?? "", width: 20.w, height: 20.w),
|
children: [
|
||||||
SizedBox(width: 3.w),
|
msgRoleTag(
|
||||||
socialchatNickNameText(
|
userInfo.roles ?? "",
|
||||||
textColor: Colors.black,
|
width: 20.w,
|
||||||
maxWidth: 200.w,
|
height: 20.w,
|
||||||
userInfo.userNickname ?? "",
|
|
||||||
fontSize: 14.sp,
|
|
||||||
type: userInfo.getVIP()?.name ?? "",
|
|
||||||
needScroll:
|
|
||||||
(userInfo.userNickname?.characters.length ?? 0) > 16,
|
|
||||||
),
|
|
||||||
getVIPBadge(
|
|
||||||
userInfo.getVIP()?.name,
|
|
||||||
width: 45.w,
|
|
||||||
height: 25.w,
|
|
||||||
),
|
|
||||||
// ListView.separated(
|
|
||||||
// scrollDirection: Axis.horizontal,
|
|
||||||
// shrinkWrap: true,
|
|
||||||
// itemCount: userInfo.wearBadge?.length ?? 0,
|
|
||||||
// itemBuilder: (context, index) {
|
|
||||||
// return netImage(
|
|
||||||
// width: 25.w,
|
|
||||||
// height: 25.w,
|
|
||||||
// url: userInfo.wearBadge?[index].selectUrl ?? "",
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// separatorBuilder: (BuildContext context, int index) {
|
|
||||||
// return SizedBox(width: 5.w);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(height: 3.w),
|
|
||||||
GestureDetector(
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 3.w),
|
|
||||||
child: SCSpecialIdBadge(
|
|
||||||
idText: userInfo.getID(),
|
|
||||||
showAnimated: userInfo.hasSpecialId(),
|
|
||||||
assetPath: SCSpecialIdAssets.userId,
|
|
||||||
animationWidth: 62.w,
|
|
||||||
animationHeight: 24.w,
|
|
||||||
showTextBesideAnimated: true,
|
|
||||||
animatedTextSpacing: 0,
|
|
||||||
showAnimatedGradientText:
|
|
||||||
userInfo.shouldShowColoredSpecialIdText(),
|
|
||||||
animationTextStyle: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 12.sp,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
),
|
||||||
normalTextStyle: TextStyle(
|
SizedBox(width: 3.w),
|
||||||
color: Colors.black,
|
socialchatNickNameText(
|
||||||
fontSize: 12.sp,
|
textColor: Colors.black,
|
||||||
fontWeight: FontWeight.bold,
|
maxWidth: 132.w,
|
||||||
|
userInfo.userNickname ?? "",
|
||||||
|
fontSize: 14.sp,
|
||||||
|
type: userInfo.getVIP()?.name ?? "",
|
||||||
|
needScroll:
|
||||||
|
(userInfo.userNickname?.characters.length ?? 0) >
|
||||||
|
16,
|
||||||
),
|
),
|
||||||
showCopyIcon: true,
|
getVIPBadge(
|
||||||
showCopyIconWhenAnimated: true,
|
userInfo.vipLevel ?? userInfo.getVIP()?.name,
|
||||||
copyIconSize: 12.w,
|
width: 45.w,
|
||||||
copyIconSpacing: 5.w,
|
height: 25.w,
|
||||||
animationFit: BoxFit.contain,
|
),
|
||||||
),
|
SizedBox(width: 3.w),
|
||||||
|
getWealthLevel(
|
||||||
|
userInfo.wealthLevel ?? 0,
|
||||||
|
width: 42.w,
|
||||||
|
height: 20.w,
|
||||||
|
fontSize: 9.sp,
|
||||||
|
),
|
||||||
|
SizedBox(width: 2.w),
|
||||||
|
getUserLevel(
|
||||||
|
userInfo.charmLevel ?? 0,
|
||||||
|
width: 42.w,
|
||||||
|
height: 20.w,
|
||||||
|
fontSize: 9.sp,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
SizedBox(height: 3.w),
|
||||||
Clipboard.setData(ClipboardData(text: userInfo.getID()));
|
GestureDetector(
|
||||||
SCTts.show(
|
child: Container(
|
||||||
SCAppLocalizations.of(context)!.copiedToClipboard,
|
padding: EdgeInsets.symmetric(vertical: 3.w),
|
||||||
);
|
child: SCSpecialIdBadge(
|
||||||
},
|
idText: userInfo.getID(),
|
||||||
),
|
showAnimated: userInfo.hasSpecialId(),
|
||||||
],
|
assetPath: SCSpecialIdAssets.userId,
|
||||||
|
animationWidth: 62.w,
|
||||||
|
animationHeight: 24.w,
|
||||||
|
showTextBesideAnimated: true,
|
||||||
|
animatedTextSpacing: 0,
|
||||||
|
showAnimatedGradientText:
|
||||||
|
userInfo.shouldShowColoredSpecialIdText(),
|
||||||
|
animationTextStyle: TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 12.sp,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
normalTextStyle: TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 12.sp,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
showCopyIcon: true,
|
||||||
|
showCopyIconWhenAnimated: true,
|
||||||
|
copyIconSize: 12.w,
|
||||||
|
copyIconSpacing: 5.w,
|
||||||
|
animationFit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Clipboard.setData(ClipboardData(text: userInfo.getID()));
|
||||||
|
SCTts.show(
|
||||||
|
SCAppLocalizations.of(context)!.copiedToClipboard,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(height: 2.w),
|
||||||
|
SCUserBadgeStrip(
|
||||||
|
userId: userInfo.id,
|
||||||
|
fallbackBadges:
|
||||||
|
userInfo.wearBadge
|
||||||
|
?.where((item) => item.use ?? false)
|
||||||
|
.toList() ??
|
||||||
|
const <WearBadge>[],
|
||||||
|
height: 23.w,
|
||||||
|
badgeHeight: 21.w,
|
||||||
|
longBadgeWidth: 51.w,
|
||||||
|
spacing: 4.5.w,
|
||||||
|
maxBadges: 8,
|
||||||
|
reserveSpace: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -65,6 +65,7 @@ class _PersonDetailPageState extends State<PersonDetailPage> {
|
|||||||
|
|
||||||
Map<String, SCUserCounterRes> counterMap = {};
|
Map<String, SCUserCounterRes> counterMap = {};
|
||||||
List<SocialChatGiftRes> giftWallList = [];
|
List<SocialChatGiftRes> giftWallList = [];
|
||||||
|
List<WearBadge> honorWallBadges = [];
|
||||||
|
|
||||||
// 添加滚动控制器
|
// 添加滚动控制器
|
||||||
final ScrollController _scrollController = ScrollController();
|
final ScrollController _scrollController = ScrollController();
|
||||||
@ -134,6 +135,7 @@ class _PersonDetailPageState extends State<PersonDetailPage> {
|
|||||||
isBlacklistLoading = false;
|
isBlacklistLoading = false;
|
||||||
}
|
}
|
||||||
userCounter(widget.tageId);
|
userCounter(widget.tageId);
|
||||||
|
_loadHonorWall();
|
||||||
_loadGiftWall();
|
_loadGiftWall();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +161,26 @@ class _PersonDetailPageState extends State<PersonDetailPage> {
|
|||||||
.catchError((e) {});
|
.catchError((e) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _loadHonorWall() {
|
||||||
|
final userId = widget.tageId.trim();
|
||||||
|
if (userId.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final currentUserId =
|
||||||
|
AccountStorage().getCurrentUser()?.userProfile?.id?.trim() ?? "";
|
||||||
|
final future =
|
||||||
|
currentUserId.isNotEmpty && currentUserId == userId
|
||||||
|
? SCAccountRepository().currentUserBadges()
|
||||||
|
: SCAccountRepository().otherUserBadges(userId);
|
||||||
|
future
|
||||||
|
.then((result) {
|
||||||
|
if (!mounted) return;
|
||||||
|
honorWallBadges = result.honorWallBadges;
|
||||||
|
setState(() {});
|
||||||
|
})
|
||||||
|
.catchError((e) {});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_scrollController.dispose();
|
_scrollController.dispose();
|
||||||
@ -658,8 +680,19 @@ class _PersonDetailPageState extends State<PersonDetailPage> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 12.w),
|
SizedBox(height: 12.w),
|
||||||
_buildWallGrid(
|
_buildWallGrid(
|
||||||
itemCount: _wallPreviewItemCount,
|
itemCount:
|
||||||
itemBuilder: (_) => _buildHonorPlaceholderItem(),
|
honorWallBadges.isEmpty
|
||||||
|
? _wallPreviewItemCount
|
||||||
|
: honorWallBadges.length
|
||||||
|
.clamp(0, _wallPreviewItemCount)
|
||||||
|
.toInt(),
|
||||||
|
itemBuilder: (index) {
|
||||||
|
final badge =
|
||||||
|
index < honorWallBadges.length
|
||||||
|
? honorWallBadges[index]
|
||||||
|
: null;
|
||||||
|
return _buildHonorWallItem(badge);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 18.w),
|
SizedBox(height: 18.w),
|
||||||
_buildProfileSectionTitle(
|
_buildProfileSectionTitle(
|
||||||
@ -744,20 +777,34 @@ class _PersonDetailPageState extends State<PersonDetailPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHonorPlaceholderItem() {
|
Widget _buildHonorWallItem(WearBadge? badge) {
|
||||||
return _buildWallItemFrame(
|
return _buildWallItemFrame(
|
||||||
child: Opacity(
|
child:
|
||||||
opacity: 0.45,
|
badge == null
|
||||||
child: Image.asset(
|
? Opacity(
|
||||||
"sc_images/room/sc_icon_room_music_empty.png",
|
opacity: 0.45,
|
||||||
width: 38.w,
|
child: Image.asset(
|
||||||
height: 38.w,
|
"sc_images/room/sc_icon_room_music_empty.png",
|
||||||
fit: BoxFit.contain,
|
width: 38.w,
|
||||||
),
|
height: 38.w,
|
||||||
),
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: EdgeInsets.all(8.w),
|
||||||
|
child: netImage(
|
||||||
|
url: _badgeUrl(badge),
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
noDefaultImg: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _badgeUrl(WearBadge badge) => (badge.selectUrl ?? "").trim();
|
||||||
|
|
||||||
Widget _buildGiftWallItem(SocialChatGiftRes? gift) {
|
Widget _buildGiftWallItem(SocialChatGiftRes? gift) {
|
||||||
return _buildWallItemFrame(
|
return _buildWallItemFrame(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
|||||||
@ -20,21 +20,13 @@ class ProfileWallOfHonorsPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _ProfileWallOfHonorsPageState extends State<ProfileWallOfHonorsPage> {
|
class _ProfileWallOfHonorsPageState extends State<ProfileWallOfHonorsPage> {
|
||||||
static const Color _profileBg = Color(0xff072121);
|
static const Color _profileBg = Color(0xff072121);
|
||||||
static const Color _mutedText = Color(0xff8F9A98);
|
|
||||||
|
|
||||||
int _selectedTabIndex = 0;
|
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
SCUserBadgeRes _badges = SCUserBadgeRes.empty();
|
SCUserBadgeRes _badges = SCUserBadgeRes.empty();
|
||||||
|
|
||||||
List<WearBadge> get _honorBadges =>
|
List<WearBadge> get _wallBadges => _badges.honorWallBadges;
|
||||||
_badges.displayBadges.where(_isHonorBadge).toList();
|
|
||||||
|
|
||||||
List<WearBadge> get _eventBadges =>
|
int get _totalCount => _wallBadges.length;
|
||||||
_badges.displayBadges.where(_isEventBadge).toList();
|
|
||||||
|
|
||||||
int get _honorCount => _honorBadges.length;
|
|
||||||
int get _eventCount => _eventBadges.length;
|
|
||||||
int get _totalCount => _honorCount + _eventCount;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -110,54 +102,6 @@ class _ProfileWallOfHonorsPageState extends State<ProfileWallOfHonorsPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTabs() {
|
|
||||||
return SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: 82.w,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(child: _buildTab(index: 0, label: "Honors($_honorCount)")),
|
|
||||||
Expanded(child: _buildTab(index: 1, label: "Event($_eventCount)")),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildTab({required int index, required String label}) {
|
|
||||||
final selected = _selectedTabIndex == index;
|
|
||||||
return GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onTap: () {
|
|
||||||
if (_selectedTabIndex == index) return;
|
|
||||||
setState(() {
|
|
||||||
_selectedTabIndex = index;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
text(
|
|
||||||
label,
|
|
||||||
fontSize: 20,
|
|
||||||
textColor: selected ? Colors.white : _mutedText,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
SizedBox(height: 9.w),
|
|
||||||
AnimatedContainer(
|
|
||||||
duration: const Duration(milliseconds: 160),
|
|
||||||
width: selected ? 28.w : 0,
|
|
||||||
height: 4.w,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(4.w),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildEmptyState() {
|
Widget _buildEmptyState() {
|
||||||
return SliverFillRemaining(
|
return SliverFillRemaining(
|
||||||
hasScrollBody: false,
|
hasScrollBody: false,
|
||||||
@ -194,7 +138,7 @@ class _ProfileWallOfHonorsPageState extends State<ProfileWallOfHonorsPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBadgeGrid() {
|
Widget _buildBadgeGrid() {
|
||||||
final list = _selectedTabIndex == 0 ? _honorBadges : _eventBadges;
|
final list = _wallBadges;
|
||||||
if (list.isEmpty) {
|
if (list.isEmpty) {
|
||||||
return _buildEmptyState();
|
return _buildEmptyState();
|
||||||
}
|
}
|
||||||
@ -253,29 +197,6 @@ class _ProfileWallOfHonorsPageState extends State<ProfileWallOfHonorsPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isHonorBadge(WearBadge badge) {
|
|
||||||
final sourceType = badge.sourceType?.trim().toUpperCase() ?? "";
|
|
||||||
final type = badge.type?.trim().toUpperCase() ?? "";
|
|
||||||
return sourceType == "ACHIEVEMENT" ||
|
|
||||||
sourceType == "VIP" ||
|
|
||||||
(sourceType.isEmpty &&
|
|
||||||
(type == "LONG" || type == "ACHIEVEMENT" || type == "VIP"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _isEventBadge(WearBadge badge) {
|
|
||||||
final sourceType = badge.sourceType?.trim().toUpperCase() ?? "";
|
|
||||||
final type = badge.type?.trim().toUpperCase() ?? "";
|
|
||||||
if (sourceType == "ACTIVITY") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (sourceType.isNotEmpty) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return type == "ACTIVITY" ||
|
|
||||||
type == "SHORT" ||
|
|
||||||
(type != "LONG" && type != "VIP" && type != "ACHIEVEMENT");
|
|
||||||
}
|
|
||||||
|
|
||||||
String _badgeUrl(WearBadge badge) {
|
String _badgeUrl(WearBadge badge) {
|
||||||
return (badge.selectUrl ?? "").trim();
|
return (badge.selectUrl ?? "").trim();
|
||||||
}
|
}
|
||||||
@ -289,9 +210,7 @@ class _ProfileWallOfHonorsPageState extends State<ProfileWallOfHonorsPage> {
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(child: _buildTopBar()),
|
||||||
child: Column(children: [_buildTopBar(), _buildTabs()]),
|
|
||||||
),
|
|
||||||
_loading ? _buildLoadingState() : _buildBadgeGrid(),
|
_loading ? _buildLoadingState() : _buildBadgeGrid(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -851,6 +851,8 @@ class WearBadge {
|
|||||||
String? sourceType,
|
String? sourceType,
|
||||||
String? type,
|
String? type,
|
||||||
String? userId,
|
String? userId,
|
||||||
|
int? updateTime,
|
||||||
|
String? updatedAt,
|
||||||
bool? use,
|
bool? use,
|
||||||
}) {
|
}) {
|
||||||
_animationUrl = animationUrl;
|
_animationUrl = animationUrl;
|
||||||
@ -866,6 +868,8 @@ class WearBadge {
|
|||||||
_sourceType = sourceType;
|
_sourceType = sourceType;
|
||||||
_type = type;
|
_type = type;
|
||||||
_userId = userId;
|
_userId = userId;
|
||||||
|
_updateTime = updateTime;
|
||||||
|
_updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
WearBadge.fromJson(dynamic json) {
|
WearBadge.fromJson(dynamic json) {
|
||||||
@ -889,6 +893,10 @@ class WearBadge {
|
|||||||
_stringValue(json['sourceType']) ?? _sourceTypeFromType(rawType);
|
_stringValue(json['sourceType']) ?? _sourceTypeFromType(rawType);
|
||||||
_type = rawType;
|
_type = rawType;
|
||||||
_userId = _stringValue(json['userId']);
|
_userId = _stringValue(json['userId']);
|
||||||
|
_updateTime = _intValue(
|
||||||
|
json['updateTime'] ?? json['updatedAt'] ?? json['createTime'],
|
||||||
|
);
|
||||||
|
_updatedAt = _stringValue(json['updatedAt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
String? _animationUrl;
|
String? _animationUrl;
|
||||||
@ -904,6 +912,8 @@ class WearBadge {
|
|||||||
String? _sourceType;
|
String? _sourceType;
|
||||||
String? _type;
|
String? _type;
|
||||||
String? _userId;
|
String? _userId;
|
||||||
|
int? _updateTime;
|
||||||
|
String? _updatedAt;
|
||||||
|
|
||||||
WearBadge copyWith({
|
WearBadge copyWith({
|
||||||
String? animationUrl,
|
String? animationUrl,
|
||||||
@ -919,6 +929,8 @@ class WearBadge {
|
|||||||
String? sourceType,
|
String? sourceType,
|
||||||
String? type,
|
String? type,
|
||||||
String? userId,
|
String? userId,
|
||||||
|
int? updateTime,
|
||||||
|
String? updatedAt,
|
||||||
}) => WearBadge(
|
}) => WearBadge(
|
||||||
animationUrl: animationUrl ?? _animationUrl,
|
animationUrl: animationUrl ?? _animationUrl,
|
||||||
badgeKey: badgeKey ?? _badgeKey,
|
badgeKey: badgeKey ?? _badgeKey,
|
||||||
@ -933,6 +945,8 @@ class WearBadge {
|
|||||||
sourceType: sourceType ?? _sourceType,
|
sourceType: sourceType ?? _sourceType,
|
||||||
type: type ?? _type,
|
type: type ?? _type,
|
||||||
userId: userId ?? _userId,
|
userId: userId ?? _userId,
|
||||||
|
updateTime: updateTime ?? _updateTime,
|
||||||
|
updatedAt: updatedAt ?? _updatedAt,
|
||||||
);
|
);
|
||||||
|
|
||||||
String? get animationUrl => _animationUrl;
|
String? get animationUrl => _animationUrl;
|
||||||
@ -961,6 +975,10 @@ class WearBadge {
|
|||||||
|
|
||||||
String? get userId => _userId;
|
String? get userId => _userId;
|
||||||
|
|
||||||
|
int? get updateTime => _updateTime;
|
||||||
|
|
||||||
|
String? get updatedAt => _updatedAt;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final map = <String, dynamic>{};
|
final map = <String, dynamic>{};
|
||||||
map['animationUrl'] = _animationUrl;
|
map['animationUrl'] = _animationUrl;
|
||||||
@ -976,6 +994,8 @@ class WearBadge {
|
|||||||
map['sourceType'] = _sourceType;
|
map['sourceType'] = _sourceType;
|
||||||
map['type'] = _type;
|
map['type'] = _type;
|
||||||
map['userId'] = _userId;
|
map['userId'] = _userId;
|
||||||
|
map['updateTime'] = _updateTime;
|
||||||
|
map['updatedAt'] = _updatedAt;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,19 +12,20 @@ import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
|||||||
/// userLevel : {"charmLevel":0,"extValues":{"":{}},"wealthLevel":0}
|
/// userLevel : {"charmLevel":0,"extValues":{"":{}},"wealthLevel":0}
|
||||||
/// userProfile : {"account":"","accountStatus":"","age":0,"bornDay":0,"bornMonth":0,"bornYear":0,"countryCode":"","countryId":0,"countryName":"","createTime":0,"del":false,"freezingTime":0,"id":"0","originSys":"","ownSpecialId":{"account":"","expiredTime":0},"sameRegion":false,"sysOriginChild":"","useProps":[{"expireTime":0,"propsResources":{"amount":0.0,"code":"","cover":"","expand":"","id":0,"name":"","sourceUrl":"","type":""},"userId":0}],"userAvatar":"","userNickname":"","userSex":0,"wearBadge":[{"animationUrl":"","badgeKey":"","badgeLevel":0,"badgeName":"","expireTime":0,"id":0,"milestone":0,"notSelectUrl":"","selectUrl":"","type":"","userId":0}]}
|
/// userProfile : {"account":"","accountStatus":"","age":0,"bornDay":0,"bornMonth":0,"bornYear":0,"countryCode":"","countryId":0,"countryName":"","createTime":0,"del":false,"freezingTime":0,"id":"0","originSys":"","ownSpecialId":{"account":"","expiredTime":0},"sameRegion":false,"sysOriginChild":"","useProps":[{"expireTime":0,"propsResources":{"amount":0.0,"code":"","cover":"","expand":"","id":0,"name":"","sourceUrl":"","type":""},"userId":0}],"userAvatar":"","userNickname":"","userSex":0,"wearBadge":[{"animationUrl":"","badgeKey":"","badgeLevel":0,"badgeName":"","expireTime":0,"id":0,"milestone":0,"notSelectUrl":"","selectUrl":"","type":"","userId":0}]}
|
||||||
|
|
||||||
class RoomUserCardRes {
|
class RoomUserCardRes {
|
||||||
RoomUserCardRes({
|
RoomUserCardRes({
|
||||||
bool? agent,
|
bool? agent,
|
||||||
bool? anchor,
|
bool? anchor,
|
||||||
bool? follow,
|
bool? follow,
|
||||||
bool? friend,
|
bool? friend,
|
||||||
String? ktvIntegral,
|
String? ktvIntegral,
|
||||||
String? roomRole,
|
String? roomRole,
|
||||||
String? supperVip,
|
String? supperVip,
|
||||||
List<UseBadge>? useBadge,
|
List<UseBadge>? useBadge,
|
||||||
List<UseProps>? useProps,
|
List<UseProps>? useProps,
|
||||||
UserLevel? userLevel,
|
UserLevel? userLevel,
|
||||||
SocialChatUserProfile? userProfile,}){
|
SocialChatUserProfile? userProfile,
|
||||||
|
}) {
|
||||||
_agent = agent;
|
_agent = agent;
|
||||||
_anchor = anchor;
|
_anchor = anchor;
|
||||||
_follow = follow;
|
_follow = follow;
|
||||||
@ -35,12 +36,8 @@ class RoomUserCardRes {
|
|||||||
_useBadge = useBadge;
|
_useBadge = useBadge;
|
||||||
_useProps = useProps;
|
_useProps = useProps;
|
||||||
_userLevel = userLevel;
|
_userLevel = userLevel;
|
||||||
final normalizedVipLevel = supperVip?.trim();
|
_userProfile = _profileWithCardHints(userProfile, supperVip, userLevel);
|
||||||
_userProfile =
|
}
|
||||||
normalizedVipLevel == null || normalizedVipLevel.isEmpty
|
|
||||||
? userProfile
|
|
||||||
: userProfile?.copyWith(vipLevel: normalizedVipLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomUserCardRes.fromJson(dynamic json) {
|
RoomUserCardRes.fromJson(dynamic json) {
|
||||||
_agent = json['agent'];
|
_agent = json['agent'];
|
||||||
@ -62,15 +59,15 @@ class RoomUserCardRes {
|
|||||||
_useProps?.add(UseProps.fromJson(v));
|
_useProps?.add(UseProps.fromJson(v));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_userLevel = json['userLevel'] != null ? UserLevel.fromJson(json['userLevel']) : null;
|
_userLevel =
|
||||||
|
json['userLevel'] != null
|
||||||
|
? UserLevel.fromJson(json['userLevel'])
|
||||||
|
: null;
|
||||||
_userProfile =
|
_userProfile =
|
||||||
json['userProfile'] != null
|
json['userProfile'] != null
|
||||||
? socialChatUserProfileFromJsonWithVipHint(json)
|
? socialChatUserProfileFromJsonWithVipHint(json)
|
||||||
: null;
|
: null;
|
||||||
final normalizedVipLevel = _supperVip?.trim();
|
_userProfile = _profileWithCardHints(_userProfile, _supperVip, _userLevel);
|
||||||
if (normalizedVipLevel != null && normalizedVipLevel.isNotEmpty) {
|
|
||||||
_userProfile = _userProfile?.copyWith(vipLevel: normalizedVipLevel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bool? _agent;
|
bool? _agent;
|
||||||
bool? _anchor;
|
bool? _anchor;
|
||||||
@ -83,29 +80,31 @@ class RoomUserCardRes {
|
|||||||
List<UseProps>? _useProps;
|
List<UseProps>? _useProps;
|
||||||
UserLevel? _userLevel;
|
UserLevel? _userLevel;
|
||||||
SocialChatUserProfile? _userProfile;
|
SocialChatUserProfile? _userProfile;
|
||||||
RoomUserCardRes copyWith({ bool? agent,
|
RoomUserCardRes copyWith({
|
||||||
bool? anchor,
|
bool? agent,
|
||||||
bool? follow,
|
bool? anchor,
|
||||||
bool? friend,
|
bool? follow,
|
||||||
String? ktvIntegral,
|
bool? friend,
|
||||||
String? roomRole,
|
String? ktvIntegral,
|
||||||
String? supperVip,
|
String? roomRole,
|
||||||
List<UseBadge>? useBadge,
|
String? supperVip,
|
||||||
List<UseProps>? useProps,
|
List<UseBadge>? useBadge,
|
||||||
UserLevel? userLevel,
|
List<UseProps>? useProps,
|
||||||
SocialChatUserProfile? userProfile,
|
UserLevel? userLevel,
|
||||||
}) => RoomUserCardRes( agent: agent ?? _agent,
|
SocialChatUserProfile? userProfile,
|
||||||
anchor: anchor ?? _anchor,
|
}) => RoomUserCardRes(
|
||||||
follow: follow ?? _follow,
|
agent: agent ?? _agent,
|
||||||
friend: friend ?? _friend,
|
anchor: anchor ?? _anchor,
|
||||||
ktvIntegral: ktvIntegral ?? _ktvIntegral,
|
follow: follow ?? _follow,
|
||||||
roomRole: roomRole ?? _roomRole,
|
friend: friend ?? _friend,
|
||||||
supperVip: supperVip ?? _supperVip,
|
ktvIntegral: ktvIntegral ?? _ktvIntegral,
|
||||||
useBadge: useBadge ?? _useBadge,
|
roomRole: roomRole ?? _roomRole,
|
||||||
useProps: useProps ?? _useProps,
|
supperVip: supperVip ?? _supperVip,
|
||||||
userLevel: userLevel ?? _userLevel,
|
useBadge: useBadge ?? _useBadge,
|
||||||
userProfile: userProfile ?? _userProfile,
|
useProps: useProps ?? _useProps,
|
||||||
);
|
userLevel: userLevel ?? _userLevel,
|
||||||
|
userProfile: userProfile ?? _userProfile,
|
||||||
|
);
|
||||||
bool? get agent => _agent;
|
bool? get agent => _agent;
|
||||||
bool? get anchor => _anchor;
|
bool? get anchor => _anchor;
|
||||||
bool? get follow => _follow;
|
bool? get follow => _follow;
|
||||||
@ -141,7 +140,28 @@ RoomUserCardRes copyWith({ bool? agent,
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SocialChatUserProfile? _profileWithCardHints(
|
||||||
|
SocialChatUserProfile? profile,
|
||||||
|
String? supperVip,
|
||||||
|
UserLevel? userLevel,
|
||||||
|
) {
|
||||||
|
if (profile == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var result = profile;
|
||||||
|
final normalizedVipLevel = supperVip?.trim();
|
||||||
|
if (normalizedVipLevel != null && normalizedVipLevel.isNotEmpty) {
|
||||||
|
result = result.copyWith(vipLevel: normalizedVipLevel);
|
||||||
|
}
|
||||||
|
if (userLevel?.wealthLevel != null || userLevel?.charmLevel != null) {
|
||||||
|
result = result.copyWith(
|
||||||
|
wealthLevel: userLevel?.wealthLevel ?? result.wealthLevel,
|
||||||
|
charmLevel: userLevel?.charmLevel ?? result.charmLevel,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// account : ""
|
/// account : ""
|
||||||
@ -181,17 +201,18 @@ RoomUserCardRes copyWith({ bool? agent,
|
|||||||
|
|
||||||
class WearBadge {
|
class WearBadge {
|
||||||
WearBadge({
|
WearBadge({
|
||||||
String? animationUrl,
|
String? animationUrl,
|
||||||
String? badgeKey,
|
String? badgeKey,
|
||||||
num? badgeLevel,
|
num? badgeLevel,
|
||||||
String? badgeName,
|
String? badgeName,
|
||||||
num? expireTime,
|
num? expireTime,
|
||||||
num? id,
|
num? id,
|
||||||
num? milestone,
|
num? milestone,
|
||||||
String? notSelectUrl,
|
String? notSelectUrl,
|
||||||
String? selectUrl,
|
String? selectUrl,
|
||||||
String? type,
|
String? type,
|
||||||
num? userId,}){
|
num? userId,
|
||||||
|
}) {
|
||||||
_animationUrl = animationUrl;
|
_animationUrl = animationUrl;
|
||||||
_badgeKey = badgeKey;
|
_badgeKey = badgeKey;
|
||||||
_badgeLevel = badgeLevel;
|
_badgeLevel = badgeLevel;
|
||||||
@ -203,7 +224,7 @@ class WearBadge {
|
|||||||
_selectUrl = selectUrl;
|
_selectUrl = selectUrl;
|
||||||
_type = type;
|
_type = type;
|
||||||
_userId = userId;
|
_userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
WearBadge.fromJson(dynamic json) {
|
WearBadge.fromJson(dynamic json) {
|
||||||
_animationUrl = json['animationUrl'];
|
_animationUrl = json['animationUrl'];
|
||||||
@ -229,29 +250,31 @@ class WearBadge {
|
|||||||
String? _selectUrl;
|
String? _selectUrl;
|
||||||
String? _type;
|
String? _type;
|
||||||
num? _userId;
|
num? _userId;
|
||||||
WearBadge copyWith({ String? animationUrl,
|
WearBadge copyWith({
|
||||||
String? badgeKey,
|
String? animationUrl,
|
||||||
num? badgeLevel,
|
String? badgeKey,
|
||||||
String? badgeName,
|
num? badgeLevel,
|
||||||
num? expireTime,
|
String? badgeName,
|
||||||
num? id,
|
num? expireTime,
|
||||||
num? milestone,
|
num? id,
|
||||||
String? notSelectUrl,
|
num? milestone,
|
||||||
String? selectUrl,
|
String? notSelectUrl,
|
||||||
String? type,
|
String? selectUrl,
|
||||||
num? userId,
|
String? type,
|
||||||
}) => WearBadge( animationUrl: animationUrl ?? _animationUrl,
|
num? userId,
|
||||||
badgeKey: badgeKey ?? _badgeKey,
|
}) => WearBadge(
|
||||||
badgeLevel: badgeLevel ?? _badgeLevel,
|
animationUrl: animationUrl ?? _animationUrl,
|
||||||
badgeName: badgeName ?? _badgeName,
|
badgeKey: badgeKey ?? _badgeKey,
|
||||||
expireTime: expireTime ?? _expireTime,
|
badgeLevel: badgeLevel ?? _badgeLevel,
|
||||||
id: id ?? _id,
|
badgeName: badgeName ?? _badgeName,
|
||||||
milestone: milestone ?? _milestone,
|
expireTime: expireTime ?? _expireTime,
|
||||||
notSelectUrl: notSelectUrl ?? _notSelectUrl,
|
id: id ?? _id,
|
||||||
selectUrl: selectUrl ?? _selectUrl,
|
milestone: milestone ?? _milestone,
|
||||||
type: type ?? _type,
|
notSelectUrl: notSelectUrl ?? _notSelectUrl,
|
||||||
userId: userId ?? _userId,
|
selectUrl: selectUrl ?? _selectUrl,
|
||||||
);
|
type: type ?? _type,
|
||||||
|
userId: userId ?? _userId,
|
||||||
|
);
|
||||||
String? get animationUrl => _animationUrl;
|
String? get animationUrl => _animationUrl;
|
||||||
String? get badgeKey => _badgeKey;
|
String? get badgeKey => _badgeKey;
|
||||||
num? get badgeLevel => _badgeLevel;
|
num? get badgeLevel => _badgeLevel;
|
||||||
@ -279,16 +302,13 @@ WearBadge copyWith({ String? animationUrl,
|
|||||||
map['userId'] = _userId;
|
map['userId'] = _userId;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserLevel {
|
class UserLevel {
|
||||||
UserLevel({
|
UserLevel({num? charmLevel, num? wealthLevel}) {
|
||||||
num? charmLevel,
|
|
||||||
num? wealthLevel,}){
|
|
||||||
_charmLevel = charmLevel;
|
_charmLevel = charmLevel;
|
||||||
_wealthLevel = wealthLevel;
|
_wealthLevel = wealthLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserLevel.fromJson(dynamic json) {
|
UserLevel.fromJson(dynamic json) {
|
||||||
_charmLevel = json['charmLevel'];
|
_charmLevel = json['charmLevel'];
|
||||||
@ -296,11 +316,10 @@ class UserLevel {
|
|||||||
}
|
}
|
||||||
num? _charmLevel;
|
num? _charmLevel;
|
||||||
num? _wealthLevel;
|
num? _wealthLevel;
|
||||||
UserLevel copyWith({ num? charmLevel,
|
UserLevel copyWith({num? charmLevel, num? wealthLevel}) => UserLevel(
|
||||||
num? wealthLevel,
|
charmLevel: charmLevel ?? _charmLevel,
|
||||||
}) => UserLevel( charmLevel: charmLevel ?? _charmLevel,
|
wealthLevel: wealthLevel ?? _wealthLevel,
|
||||||
wealthLevel: wealthLevel ?? _wealthLevel,
|
);
|
||||||
);
|
|
||||||
num? get charmLevel => _charmLevel;
|
num? get charmLevel => _charmLevel;
|
||||||
num? get wealthLevel => _wealthLevel;
|
num? get wealthLevel => _wealthLevel;
|
||||||
|
|
||||||
@ -310,22 +329,22 @@ UserLevel copyWith({ num? charmLevel,
|
|||||||
map['wealthLevel'] = _wealthLevel;
|
map['wealthLevel'] = _wealthLevel;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UseBadge {
|
class UseBadge {
|
||||||
UseBadge({
|
UseBadge({
|
||||||
String? animationUrl,
|
String? animationUrl,
|
||||||
String? badgeKey,
|
String? badgeKey,
|
||||||
num? badgeLevel,
|
num? badgeLevel,
|
||||||
String? badgeName,
|
String? badgeName,
|
||||||
num? expireTime,
|
num? expireTime,
|
||||||
String? id,
|
String? id,
|
||||||
String? milestone,
|
String? milestone,
|
||||||
String? notSelectUrl,
|
String? notSelectUrl,
|
||||||
String? selectUrl,
|
String? selectUrl,
|
||||||
String? type,
|
String? type,
|
||||||
String? userId,}){
|
String? userId,
|
||||||
|
}) {
|
||||||
_animationUrl = animationUrl;
|
_animationUrl = animationUrl;
|
||||||
_badgeKey = badgeKey;
|
_badgeKey = badgeKey;
|
||||||
_badgeLevel = badgeLevel;
|
_badgeLevel = badgeLevel;
|
||||||
@ -337,7 +356,7 @@ class UseBadge {
|
|||||||
_selectUrl = selectUrl;
|
_selectUrl = selectUrl;
|
||||||
_type = type;
|
_type = type;
|
||||||
_userId = userId;
|
_userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
UseBadge.fromJson(dynamic json) {
|
UseBadge.fromJson(dynamic json) {
|
||||||
_animationUrl = json['animationUrl'];
|
_animationUrl = json['animationUrl'];
|
||||||
@ -363,29 +382,31 @@ class UseBadge {
|
|||||||
String? _selectUrl;
|
String? _selectUrl;
|
||||||
String? _type;
|
String? _type;
|
||||||
String? _userId;
|
String? _userId;
|
||||||
UseBadge copyWith({ String? animationUrl,
|
UseBadge copyWith({
|
||||||
String? badgeKey,
|
String? animationUrl,
|
||||||
num? badgeLevel,
|
String? badgeKey,
|
||||||
String? badgeName,
|
num? badgeLevel,
|
||||||
num? expireTime,
|
String? badgeName,
|
||||||
String? id,
|
num? expireTime,
|
||||||
String? milestone,
|
String? id,
|
||||||
String? notSelectUrl,
|
String? milestone,
|
||||||
String? selectUrl,
|
String? notSelectUrl,
|
||||||
String? type,
|
String? selectUrl,
|
||||||
String? userId,
|
String? type,
|
||||||
}) => UseBadge( animationUrl: animationUrl ?? _animationUrl,
|
String? userId,
|
||||||
badgeKey: badgeKey ?? _badgeKey,
|
}) => UseBadge(
|
||||||
badgeLevel: badgeLevel ?? _badgeLevel,
|
animationUrl: animationUrl ?? _animationUrl,
|
||||||
badgeName: badgeName ?? _badgeName,
|
badgeKey: badgeKey ?? _badgeKey,
|
||||||
expireTime: expireTime ?? _expireTime,
|
badgeLevel: badgeLevel ?? _badgeLevel,
|
||||||
id: id ?? _id,
|
badgeName: badgeName ?? _badgeName,
|
||||||
milestone: milestone ?? _milestone,
|
expireTime: expireTime ?? _expireTime,
|
||||||
notSelectUrl: notSelectUrl ?? _notSelectUrl,
|
id: id ?? _id,
|
||||||
selectUrl: selectUrl ?? _selectUrl,
|
milestone: milestone ?? _milestone,
|
||||||
type: type ?? _type,
|
notSelectUrl: notSelectUrl ?? _notSelectUrl,
|
||||||
userId: userId ?? _userId,
|
selectUrl: selectUrl ?? _selectUrl,
|
||||||
);
|
type: type ?? _type,
|
||||||
|
userId: userId ?? _userId,
|
||||||
|
);
|
||||||
String? get animationUrl => _animationUrl;
|
String? get animationUrl => _animationUrl;
|
||||||
String? get badgeKey => _badgeKey;
|
String? get badgeKey => _badgeKey;
|
||||||
num? get badgeLevel => _badgeLevel;
|
num? get badgeLevel => _badgeLevel;
|
||||||
@ -413,5 +434,4 @@ UseBadge copyWith({ String? animationUrl,
|
|||||||
map['userId'] = _userId;
|
map['userId'] = _userId;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,17 @@ class SCUserBadgeRes {
|
|||||||
return badges;
|
return badges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<WearBadge> get honorWallBadges {
|
||||||
|
final source =
|
||||||
|
shortBadges.isNotEmpty
|
||||||
|
? shortBadges
|
||||||
|
: displayBadges.where(_isHonorWallBadge).toList();
|
||||||
|
final result =
|
||||||
|
source.where((badge) => _badgeUrl(badge).isNotEmpty).toList();
|
||||||
|
result.sort((a, b) => _badgeSortValue(b).compareTo(_badgeSortValue(a)));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static dynamic _bodyFrom(dynamic json) {
|
static dynamic _bodyFrom(dynamic json) {
|
||||||
if (json is Map) {
|
if (json is Map) {
|
||||||
final body = json['body'];
|
final body = json['body'];
|
||||||
@ -92,6 +103,31 @@ class SCUserBadgeRes {
|
|||||||
type == "ACHIEVEMENT";
|
type == "ACHIEVEMENT";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _isHonorWallBadge(WearBadge badge) {
|
||||||
|
final sourceType = badge.sourceType?.trim().toUpperCase() ?? "";
|
||||||
|
final type = badge.type?.trim().toUpperCase() ?? "";
|
||||||
|
if (type == "LONG" || type == "VIP" || sourceType == "VIP") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (sourceType.isNotEmpty) {
|
||||||
|
return sourceType == "ACTIVITY" || sourceType == "ACHIEVEMENT";
|
||||||
|
}
|
||||||
|
return type == "SHORT" ||
|
||||||
|
type == "ACTIVITY" ||
|
||||||
|
type == "ACHIEVEMENT" ||
|
||||||
|
type == "HONOR_ACTIVITY" ||
|
||||||
|
type == "HONOR_ADMIN";
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _badgeSortValue(WearBadge badge) {
|
||||||
|
return badge.updateTime ??
|
||||||
|
badge.expireTime ??
|
||||||
|
DateTime.tryParse(
|
||||||
|
(badge.updatedAt ?? "").replaceFirst(" ", "T"),
|
||||||
|
)?.millisecondsSinceEpoch ??
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
|
||||||
static String? _stringValue(dynamic value) {
|
static String? _stringValue(dynamic value) {
|
||||||
final text = value?.toString().trim();
|
final text = value?.toString().trim();
|
||||||
return text == null || text.isEmpty ? null : text;
|
return text == null || text.isEmpty ? null : text;
|
||||||
|
|||||||
@ -471,7 +471,43 @@ _buildPhoneInput(
|
|||||||
|
|
||||||
///vip标识
|
///vip标识
|
||||||
getVIPBadge(String? type, {double? width, double? height}) {
|
getVIPBadge(String? type, {double? width, double? height}) {
|
||||||
return Container();
|
final level = _vipBadgeLevel(type);
|
||||||
|
if (level <= 0) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
final assetLevel = level.clamp(1, 5).toInt();
|
||||||
|
return Image.asset(
|
||||||
|
"sc_images/vip/sc_vip_badge_$assetLevel.png",
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _vipBadgeLevel(String? type) {
|
||||||
|
final text = type?.trim() ?? "";
|
||||||
|
if (text.isEmpty) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
final plain = int.tryParse(text);
|
||||||
|
if ((plain ?? 0) > 0) {
|
||||||
|
return plain!;
|
||||||
|
}
|
||||||
|
final vipMatch = RegExp(
|
||||||
|
r'(?:S?VIP|NOBLE[_\s-]*VIP)[^\d]*([1-9]\d*)',
|
||||||
|
caseSensitive: false,
|
||||||
|
).firstMatch(text);
|
||||||
|
if (vipMatch != null) {
|
||||||
|
return int.tryParse(vipMatch.group(1) ?? "") ?? 0;
|
||||||
|
}
|
||||||
|
final trailingMatch = RegExp(r'([1-9]\d*)$').firstMatch(text);
|
||||||
|
if (trailingMatch != null) {
|
||||||
|
return int.tryParse(trailingMatch.group(1) ?? "") ?? 0;
|
||||||
|
}
|
||||||
|
return RegExp(r'S?VIP|NOBLE[_\s-]*VIP', caseSensitive: false).hasMatch(text)
|
||||||
|
? 1
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///用户等级
|
///用户等级
|
||||||
|
|||||||
280
lib/ui_kit/widgets/props/sc_data_card_resource_view.dart
Normal file
280
lib/ui_kit/widgets/props/sc_data_card_resource_view.dart
Normal file
@ -0,0 +1,280 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:video_player/video_player.dart';
|
||||||
|
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||||
|
import 'package:yumi/ui_kit/components/sc_compontent.dart';
|
||||||
|
import 'package:yumi/ui_kit/widgets/room/rocket/room_rocket_pag_effect_overlay.dart';
|
||||||
|
import 'package:yumi/ui_kit/widgets/svga/sc_network_svga_widget.dart';
|
||||||
|
|
||||||
|
class SCDataCardResourceView extends StatelessWidget {
|
||||||
|
const SCDataCardResourceView({
|
||||||
|
super.key,
|
||||||
|
this.resource,
|
||||||
|
this.sourceUrl,
|
||||||
|
this.coverUrl,
|
||||||
|
this.width,
|
||||||
|
this.height,
|
||||||
|
this.fit = BoxFit.cover,
|
||||||
|
this.loop = true,
|
||||||
|
this.fallback,
|
||||||
|
});
|
||||||
|
|
||||||
|
final PropsResources? resource;
|
||||||
|
final String? sourceUrl;
|
||||||
|
final String? coverUrl;
|
||||||
|
final double? width;
|
||||||
|
final double? height;
|
||||||
|
final BoxFit fit;
|
||||||
|
final bool loop;
|
||||||
|
final Widget? fallback;
|
||||||
|
|
||||||
|
static bool isSupported(String? url) {
|
||||||
|
return _isSvga(url) || _isPag(url) || _isVideo(url) || _isImage(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final resolvedWidth = _resolvedSize(width, constraints.maxWidth);
|
||||||
|
final resolvedHeight = _resolvedSize(height, constraints.maxHeight);
|
||||||
|
final cover = _firstNonBlank([coverUrl, resource?.cover]);
|
||||||
|
final source = _firstNonBlank([sourceUrl, resource?.sourceUrl]);
|
||||||
|
final resourceUrl = source.isNotEmpty ? source : cover;
|
||||||
|
final fallbackView =
|
||||||
|
fallback ??
|
||||||
|
_buildImage(
|
||||||
|
cover,
|
||||||
|
width: resolvedWidth,
|
||||||
|
height: resolvedHeight,
|
||||||
|
fit: fit,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (resourceUrl.isEmpty) {
|
||||||
|
return fallbackView;
|
||||||
|
}
|
||||||
|
if (_isSvga(resourceUrl)) {
|
||||||
|
return SCNetworkSvgaWidget(
|
||||||
|
resource: resourceUrl,
|
||||||
|
width: resolvedWidth,
|
||||||
|
height: resolvedHeight,
|
||||||
|
loop: loop,
|
||||||
|
fit: fit,
|
||||||
|
fallback: fallbackView,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (_isPag(resourceUrl)) {
|
||||||
|
return RoomRocketPagPreview(
|
||||||
|
resource: resourceUrl,
|
||||||
|
width: resolvedWidth,
|
||||||
|
height: resolvedHeight,
|
||||||
|
loop: loop,
|
||||||
|
fit: fit,
|
||||||
|
underlayBuilder: (_) => fallbackView,
|
||||||
|
defaultBuilder: (_) => fallbackView,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (_isVideo(resourceUrl)) {
|
||||||
|
return _LoopingDataCardVideo(
|
||||||
|
url: resourceUrl,
|
||||||
|
width: resolvedWidth,
|
||||||
|
height: resolvedHeight,
|
||||||
|
fit: fit,
|
||||||
|
loop: loop,
|
||||||
|
fallback: fallbackView,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _buildImage(
|
||||||
|
resourceUrl,
|
||||||
|
width: resolvedWidth,
|
||||||
|
height: resolvedHeight,
|
||||||
|
fit: fit,
|
||||||
|
fallback: fallbackView,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double? _resolvedSize(double? fixed, double constrained) {
|
||||||
|
if (fixed != null && fixed.isFinite && fixed > 0) {
|
||||||
|
return fixed;
|
||||||
|
}
|
||||||
|
if (constrained.isFinite && constrained > 0) {
|
||||||
|
return constrained;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Widget _buildImage(
|
||||||
|
String url, {
|
||||||
|
double? width,
|
||||||
|
double? height,
|
||||||
|
required BoxFit fit,
|
||||||
|
Widget? fallback,
|
||||||
|
}) {
|
||||||
|
if (url.trim().isEmpty) {
|
||||||
|
return fallback ?? SizedBox(width: width, height: height);
|
||||||
|
}
|
||||||
|
return netImage(
|
||||||
|
url: url.trim(),
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
fit: fit,
|
||||||
|
noDefaultImg: fallback != null,
|
||||||
|
loadingWidget: fallback,
|
||||||
|
errorWidget: fallback,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String _firstNonBlank(Iterable<String?> values) {
|
||||||
|
for (final value in values) {
|
||||||
|
final text = value?.trim() ?? '';
|
||||||
|
if (text.isNotEmpty) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool _hasExtension(String? url, List<String> extensions) {
|
||||||
|
final lower = url?.trim().toLowerCase() ?? '';
|
||||||
|
if (lower.isEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return extensions.any(
|
||||||
|
(extension) =>
|
||||||
|
lower.endsWith(extension) ||
|
||||||
|
lower.contains('$extension?') ||
|
||||||
|
lower.contains('$extension&'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool _isSvga(String? url) => _hasExtension(url, const ['.svga']);
|
||||||
|
|
||||||
|
static bool _isPag(String? url) => _hasExtension(url, const ['.pag']);
|
||||||
|
|
||||||
|
static bool _isVideo(String? url) =>
|
||||||
|
_hasExtension(url, const ['.mp4', '.mov', '.m4v']);
|
||||||
|
|
||||||
|
static bool _isImage(String? url) => _hasExtension(url, const [
|
||||||
|
'.png',
|
||||||
|
'.jpg',
|
||||||
|
'.jpeg',
|
||||||
|
'.webp',
|
||||||
|
'.gif',
|
||||||
|
'.bmp',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoopingDataCardVideo extends StatefulWidget {
|
||||||
|
const _LoopingDataCardVideo({
|
||||||
|
required this.url,
|
||||||
|
this.width,
|
||||||
|
this.height,
|
||||||
|
required this.fit,
|
||||||
|
required this.loop,
|
||||||
|
required this.fallback,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String url;
|
||||||
|
final double? width;
|
||||||
|
final double? height;
|
||||||
|
final BoxFit fit;
|
||||||
|
final bool loop;
|
||||||
|
final Widget fallback;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_LoopingDataCardVideo> createState() => _LoopingDataCardVideoState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoopingDataCardVideoState extends State<_LoopingDataCardVideo> {
|
||||||
|
VideoPlayerController? _controller;
|
||||||
|
bool _ready = false;
|
||||||
|
bool _failed = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant _LoopingDataCardVideo oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.url != widget.url || oldWidget.loop != widget.loop) {
|
||||||
|
_disposeController();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _load() async {
|
||||||
|
final url = widget.url.trim();
|
||||||
|
if (url.isEmpty) {
|
||||||
|
setState(() => _failed = true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_ready = false;
|
||||||
|
_failed = false;
|
||||||
|
});
|
||||||
|
final controller = VideoPlayerController.networkUrl(Uri.parse(url));
|
||||||
|
_controller = controller;
|
||||||
|
try {
|
||||||
|
await controller.setLooping(widget.loop);
|
||||||
|
await controller.setVolume(0);
|
||||||
|
await controller.initialize();
|
||||||
|
if (!mounted || _controller != controller) {
|
||||||
|
await controller.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() => _ready = true);
|
||||||
|
await controller.play();
|
||||||
|
} catch (_) {
|
||||||
|
if (!mounted || _controller != controller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_ready = false;
|
||||||
|
_failed = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _disposeController() {
|
||||||
|
final controller = _controller;
|
||||||
|
_controller = null;
|
||||||
|
if (controller != null) {
|
||||||
|
controller.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_disposeController();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final controller = _controller;
|
||||||
|
if (_failed || !_ready || controller == null) {
|
||||||
|
return widget.fallback;
|
||||||
|
}
|
||||||
|
final videoSize = controller.value.size;
|
||||||
|
final child =
|
||||||
|
videoSize.width > 0 && videoSize.height > 0
|
||||||
|
? FittedBox(
|
||||||
|
fit: widget.fit,
|
||||||
|
child: SizedBox(
|
||||||
|
width: videoSize.width,
|
||||||
|
height: videoSize.height,
|
||||||
|
child: VideoPlayer(controller),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: VideoPlayer(controller);
|
||||||
|
return SizedBox(
|
||||||
|
width: widget.width,
|
||||||
|
height: widget.height,
|
||||||
|
child: ClipRect(child: child),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1296,10 +1296,10 @@ class _MsgItemState extends State<MsgItem> {
|
|||||||
child: SCUserBadgeStrip(
|
child: SCUserBadgeStrip(
|
||||||
userId: userId,
|
userId: userId,
|
||||||
fallbackBadges: fallbackBadges,
|
fallbackBadges: fallbackBadges,
|
||||||
height: 16.w,
|
height: 23.w,
|
||||||
badgeHeight: 14.w,
|
badgeHeight: 21.w,
|
||||||
longBadgeWidth: 34.w,
|
longBadgeWidth: 51.w,
|
||||||
spacing: 3.w,
|
spacing: 4.5.w,
|
||||||
maxBadges: 8,
|
maxBadges: 8,
|
||||||
reserveSpace: true,
|
reserveSpace: true,
|
||||||
),
|
),
|
||||||
@ -1841,10 +1841,10 @@ class _MsgItemState extends State<MsgItem> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 3.w),
|
SizedBox(width: 8.w),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 48.w,
|
height: 50.w,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -1887,10 +1887,10 @@ class _MsgItemState extends State<MsgItem> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 3.w),
|
SizedBox(width: 8.w),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 48.w,
|
height: 50.w,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import 'package:yumi/ui_kit/components/sc_compontent.dart';
|
|||||||
import 'package:yumi/app/routes/sc_fluro_navigator.dart';
|
import 'package:yumi/app/routes/sc_fluro_navigator.dart';
|
||||||
import 'package:yumi/shared/tools/sc_lk_dialog_util.dart';
|
import 'package:yumi/shared/tools/sc_lk_dialog_util.dart';
|
||||||
import 'package:yumi/shared/tools/sc_room_utils.dart';
|
import 'package:yumi/shared/tools/sc_room_utils.dart';
|
||||||
|
import 'package:yumi/shared/data_sources/models/enum/sc_props_type.dart';
|
||||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
||||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||||
import 'package:yumi/shared/business_logic/models/res/room_user_card_res.dart'
|
import 'package:yumi/shared/business_logic/models/res/room_user_card_res.dart'
|
||||||
@ -30,6 +31,7 @@ import 'package:yumi/services/audio/rtc_manager.dart';
|
|||||||
import 'package:yumi/services/auth/user_profile_manager.dart';
|
import 'package:yumi/services/auth/user_profile_manager.dart';
|
||||||
import 'package:yumi/modules/gift/gift_page.dart';
|
import 'package:yumi/modules/gift/gift_page.dart';
|
||||||
import 'package:yumi/ui_kit/widgets/id/sc_special_id_badge.dart';
|
import 'package:yumi/ui_kit/widgets/id/sc_special_id_badge.dart';
|
||||||
|
import 'package:yumi/ui_kit/widgets/props/sc_data_card_resource_view.dart';
|
||||||
|
|
||||||
import '../../../shared/data_sources/models/enum/sc_room_roles_type.dart';
|
import '../../../shared/data_sources/models/enum/sc_room_roles_type.dart';
|
||||||
import '../../../shared/business_logic/models/res/sc_user_identity_res.dart';
|
import '../../../shared/business_logic/models/res/sc_user_identity_res.dart';
|
||||||
@ -83,7 +85,7 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final sheetHeight = MediaQuery.of(context).size.height * 0.4;
|
final sheetHeight = MediaQuery.of(context).size.height * 0.6;
|
||||||
|
|
||||||
return Consumer<SocialChatUserProfileManager>(
|
return Consumer<SocialChatUserProfileManager>(
|
||||||
builder: (context, ref, child) {
|
builder: (context, ref, child) {
|
||||||
@ -151,6 +153,7 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
}) {
|
}) {
|
||||||
final bottomPadding = MediaQuery.of(context).padding.bottom;
|
final bottomPadding = MediaQuery.of(context).padding.bottom;
|
||||||
final profile = ref.userCardInfo?.userProfile;
|
final profile = ref.userCardInfo?.userProfile;
|
||||||
|
final dataCard = _activeDataCard(ref.userCardInfo);
|
||||||
final canShowReport = currentUserId != widget.userId;
|
final canShowReport = currentUserId != widget.userId;
|
||||||
final canShowSetting =
|
final canShowSetting =
|
||||||
canShowReport &&
|
canShowReport &&
|
||||||
@ -162,86 +165,84 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
height: sheetHeight,
|
height: sheetHeight,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(18.w)),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(18.w)),
|
||||||
child: DecoratedBox(
|
child: Stack(
|
||||||
decoration: _sheetDecoration(),
|
children: [
|
||||||
child: Stack(
|
Positioned.fill(child: _buildSheetBackground(dataCard)),
|
||||||
children: [
|
Positioned.fill(
|
||||||
Positioned.fill(
|
child: SingleChildScrollView(
|
||||||
child: SingleChildScrollView(
|
physics: const ClampingScrollPhysics(),
|
||||||
physics: const ClampingScrollPhysics(),
|
padding: EdgeInsets.fromLTRB(
|
||||||
padding: EdgeInsets.fromLTRB(
|
18.w,
|
||||||
18.w,
|
16.w,
|
||||||
16.w,
|
18.w,
|
||||||
18.w,
|
bottomPadding + 10.w,
|
||||||
bottomPadding + 10.w,
|
),
|
||||||
),
|
child: Column(
|
||||||
child: Column(
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
children: [
|
_buildProfileHeader(context, profile, ref),
|
||||||
_buildProfileHeader(context, profile, ref),
|
SizedBox(height: 6.w),
|
||||||
SizedBox(height: 6.w),
|
_buildInfoChips(context, profile),
|
||||||
_buildInfoChips(context, profile),
|
SizedBox(height: 9.w),
|
||||||
SizedBox(height: 9.w),
|
_buildBadgeStrip(
|
||||||
_buildBadgeStrip(
|
profile?.id ?? widget.userId,
|
||||||
profile?.id ?? widget.userId,
|
ref,
|
||||||
ref,
|
profile,
|
||||||
profile,
|
),
|
||||||
),
|
SizedBox(height: 10.w),
|
||||||
SizedBox(height: 10.w),
|
_buildActions(
|
||||||
_buildActions(
|
context: context,
|
||||||
context: context,
|
ref: ref,
|
||||||
ref: ref,
|
rtcProvider: rtcProvider,
|
||||||
rtcProvider: rtcProvider,
|
isSelf: isSelf,
|
||||||
isSelf: isSelf,
|
canLeaveMic: canLeaveMic,
|
||||||
canLeaveMic: canLeaveMic,
|
currentMicIndex: currentMicIndex,
|
||||||
currentMicIndex: currentMicIndex,
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (canShowReport)
|
),
|
||||||
Positioned(
|
if (canShowReport)
|
||||||
top: 14.w,
|
Positioned(
|
||||||
right: 16.w,
|
top: 14.w,
|
||||||
child: _buildHeaderIconButton(
|
right: 16.w,
|
||||||
iconAsset: "sc_images/room/sc_icon_user_card_report.png",
|
child: _buildHeaderIconButton(
|
||||||
onTap: () {
|
iconAsset: "sc_images/room/sc_icon_user_card_report.png",
|
||||||
final route =
|
onTap: () {
|
||||||
"${SCMainRoute.report}?type=user&tageId=${widget.userId}";
|
final route =
|
||||||
Navigator.of(context).pop();
|
"${SCMainRoute.report}?type=user&tageId=${widget.userId}";
|
||||||
SCNavigatorUtils.push(
|
Navigator.of(context).pop();
|
||||||
navigatorKey.currentState?.context ?? context,
|
SCNavigatorUtils.push(
|
||||||
route,
|
navigatorKey.currentState?.context ?? context,
|
||||||
replace: false,
|
route,
|
||||||
);
|
replace: false,
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
if (canShowSetting)
|
),
|
||||||
Positioned(
|
if (canShowSetting)
|
||||||
top: 14.w,
|
Positioned(
|
||||||
right: 52.w,
|
top: 14.w,
|
||||||
child: _buildHeaderIconButton(
|
right: 52.w,
|
||||||
iconAsset:
|
child: _buildHeaderIconButton(
|
||||||
"sc_images/room/sc_icon_room_user_card_setting.png",
|
iconAsset:
|
||||||
onTap: () {
|
"sc_images/room/sc_icon_room_user_card_setting.png",
|
||||||
if (userProvider?.userCardInfo == null) {
|
onTap: () {
|
||||||
return;
|
if (userProvider?.userCardInfo == null) {
|
||||||
}
|
return;
|
||||||
Navigator.of(context).pop();
|
}
|
||||||
showBottomInBottomDialog(
|
Navigator.of(context).pop();
|
||||||
navigatorKey.currentState?.context ?? context,
|
showBottomInBottomDialog(
|
||||||
RoomUserCardSetting(
|
navigatorKey.currentState?.context ?? context,
|
||||||
roomId: roomId,
|
RoomUserCardSetting(
|
||||||
userCardInfo: userProvider?.userCardInfo?.copyWith(),
|
roomId: roomId,
|
||||||
),
|
userCardInfo: userProvider?.userCardInfo?.copyWith(),
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -262,6 +263,57 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildSheetBackground(PropsResources? dataCard) {
|
||||||
|
if (dataCard == null) {
|
||||||
|
return DecoratedBox(decoration: _sheetDecoration());
|
||||||
|
}
|
||||||
|
return Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
SCDataCardResourceView(resource: dataCard, fit: BoxFit.cover),
|
||||||
|
DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [
|
||||||
|
Colors.white.withValues(alpha: 0.08),
|
||||||
|
Colors.white.withValues(alpha: 0.22),
|
||||||
|
Colors.white.withValues(alpha: 0.58),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropsResources? _activeDataCard(room_card.RoomUserCardRes? cardInfo) {
|
||||||
|
return _activeDataCardFromUseProps(cardInfo?.userProfile?.useProps) ??
|
||||||
|
_activeDataCardFromUseProps(cardInfo?.useProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropsResources? _activeDataCardFromUseProps(List<UseProps>? useProps) {
|
||||||
|
final now = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
for (final item in useProps ?? const <UseProps>[]) {
|
||||||
|
final resource = item.propsResources;
|
||||||
|
if (resource?.type != SCPropsType.DATA_CARD.name) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final expireText = item.expireTime?.trim() ?? "";
|
||||||
|
final expireTime = int.tryParse(expireText);
|
||||||
|
if (expireText.isNotEmpty && (expireTime ?? 0) <= now) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final source = resource?.sourceUrl?.trim() ?? "";
|
||||||
|
final cover = resource?.cover?.trim() ?? "";
|
||||||
|
if (source.isNotEmpty || cover.isNotEmpty) {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildProfileHeader(
|
Widget _buildProfileHeader(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
SocialChatUserProfile? profile,
|
SocialChatUserProfile? profile,
|
||||||
@ -290,7 +342,7 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 4.w),
|
SizedBox(width: 4.w),
|
||||||
socialchatNickNameText(
|
socialchatNickNameText(
|
||||||
maxWidth: 190.w,
|
maxWidth: 116.w,
|
||||||
profile?.userNickname ?? "",
|
profile?.userNickname ?? "",
|
||||||
fontSize: 18.sp,
|
fontSize: 18.sp,
|
||||||
textColor: Colors.black,
|
textColor: Colors.black,
|
||||||
@ -298,6 +350,30 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
type: "",
|
type: "",
|
||||||
needScroll: (profile?.userNickname?.characters.length ?? 0) > 12,
|
needScroll: (profile?.userNickname?.characters.length ?? 0) > 12,
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 3.w),
|
||||||
|
getVIPBadge(
|
||||||
|
profile?.vipLevel ?? profile?.getVIP()?.name,
|
||||||
|
width: 45.w,
|
||||||
|
height: 25.w,
|
||||||
|
),
|
||||||
|
SizedBox(width: 3.w),
|
||||||
|
getWealthLevel(
|
||||||
|
profile?.wealthLevel ??
|
||||||
|
ref.userCardInfo?.userLevel?.wealthLevel ??
|
||||||
|
0,
|
||||||
|
width: 42.w,
|
||||||
|
height: 20.w,
|
||||||
|
fontSize: 9.sp,
|
||||||
|
),
|
||||||
|
SizedBox(width: 2.w),
|
||||||
|
getUserLevel(
|
||||||
|
profile?.charmLevel ??
|
||||||
|
ref.userCardInfo?.userLevel?.charmLevel ??
|
||||||
|
0,
|
||||||
|
width: 42.w,
|
||||||
|
height: 20.w,
|
||||||
|
fontSize: 9.sp,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 2.w),
|
SizedBox(height: 2.w),
|
||||||
@ -422,10 +498,10 @@ class _RoomUserInfoCardState extends State<RoomUserInfoCard> {
|
|||||||
return SCUserBadgeStrip(
|
return SCUserBadgeStrip(
|
||||||
userId: userId,
|
userId: userId,
|
||||||
fallbackBadges: _roomCardFallbackBadges(ref, profile),
|
fallbackBadges: _roomCardFallbackBadges(ref, profile),
|
||||||
height: 55.w,
|
height: 82.w,
|
||||||
badgeHeight: 23.w,
|
badgeHeight: 34.5.w,
|
||||||
longBadgeWidth: 58.w,
|
longBadgeWidth: 87.w,
|
||||||
spacing: 8.w,
|
spacing: 10.w,
|
||||||
maxBadges: 12,
|
maxBadges: 12,
|
||||||
wrap: true,
|
wrap: true,
|
||||||
reserveSpace: true,
|
reserveSpace: true,
|
||||||
|
|||||||
82
test/sc_user_badge_res_test.dart
Normal file
82
test/sc_user_badge_res_test.dart
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:yumi/shared/business_logic/models/res/sc_user_badge_res.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('SCUserBadgeRes honor wall badges', () {
|
||||||
|
test('uses short badges only and sorts newest first', () {
|
||||||
|
final result = SCUserBadgeRes.fromJson({
|
||||||
|
'longBadges': [
|
||||||
|
{
|
||||||
|
'id': 'vip',
|
||||||
|
'type': 'LONG',
|
||||||
|
'sourceType': 'VIP',
|
||||||
|
'selectUrl': 'https://example.com/vip.png',
|
||||||
|
'updateTime': 3000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'shortBadges': [
|
||||||
|
{
|
||||||
|
'id': 'old',
|
||||||
|
'type': 'SHORT',
|
||||||
|
'sourceType': 'ACTIVITY',
|
||||||
|
'selectUrl': 'https://example.com/old.png',
|
||||||
|
'updateTime': 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'new',
|
||||||
|
'type': 'SHORT',
|
||||||
|
'sourceType': 'ACHIEVEMENT',
|
||||||
|
'selectUrl': 'https://example.com/new.png',
|
||||||
|
'updateTime': 2000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.displayBadges.map((badge) => badge.id), [
|
||||||
|
'vip',
|
||||||
|
'old',
|
||||||
|
'new',
|
||||||
|
]);
|
||||||
|
expect(result.honorWallBadges.map((badge) => badge.id), ['new', 'old']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('filters long and vip badges from legacy mixed badges', () {
|
||||||
|
final result = SCUserBadgeRes.fromJson({
|
||||||
|
'badges': [
|
||||||
|
{
|
||||||
|
'id': 'long',
|
||||||
|
'type': 'LONG',
|
||||||
|
'selectUrl': 'https://example.com/long.png',
|
||||||
|
'updateTime': 3000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'vip',
|
||||||
|
'type': 'VIP',
|
||||||
|
'sourceType': 'VIP',
|
||||||
|
'selectUrl': 'https://example.com/vip.png',
|
||||||
|
'updateTime': 2500,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'activity',
|
||||||
|
'type': 'ACTIVITY',
|
||||||
|
'sourceType': 'ACTIVITY',
|
||||||
|
'selectUrl': 'https://example.com/activity.png',
|
||||||
|
'updateTime': 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'achievement',
|
||||||
|
'type': 'ACHIEVEMENT',
|
||||||
|
'sourceType': 'ACHIEVEMENT',
|
||||||
|
'selectUrl': 'https://example.com/achievement.png',
|
||||||
|
'updateTime': 2000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.honorWallBadges.map((badge) => badge.id), [
|
||||||
|
'achievement',
|
||||||
|
'activity',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user