骨架屏以及一些已知bug

This commit is contained in:
NIGGER SLAYER 2026-04-15 11:44:49 +08:00
parent 37a04d5ad7
commit db3edcefb4
25 changed files with 4552 additions and 3419 deletions

View File

@ -15,6 +15,11 @@ import 'package:yumi/app/constants/sc_global_config.dart';
import '../../shared/data_sources/models/enum/sc_gift_type.dart'; import '../../shared/data_sources/models/enum/sc_gift_type.dart';
enum _GiftGridPageStatus { idle, loading, ready }
const Duration _kGiftPageSkeletonMinDuration = Duration(milliseconds: 420);
const Duration _kGiftPageSkeletonMaxDuration = Duration(milliseconds: 900);
class GiftTabPage extends StatefulWidget { class GiftTabPage extends StatefulWidget {
String type; String type;
bool isDark = true; bool isDark = true;
@ -26,13 +31,19 @@ class GiftTabPage extends StatefulWidget {
_GiftTabPageState createState() => _GiftTabPageState(); _GiftTabPageState createState() => _GiftTabPageState();
} }
class _GiftTabPageState extends State<GiftTabPage> { class _GiftTabPageState extends State<GiftTabPage>
PageController _giftPageController = PageController(); with AutomaticKeepAliveClientMixin {
final PageController _giftPageController = PageController();
final Map<int, _GiftGridPageStatus> _pageStatuses =
<int, _GiftGridPageStatus>{};
int _index = 0; int _index = 0;
int checkedIndex = 0; int checkedIndex = 0;
BusinessLogicStrategy get _strategy => SCGlobalConfig.businessLogicStrategy; BusinessLogicStrategy get _strategy => SCGlobalConfig.businessLogicStrategy;
@override
bool get wantKeepAlive => true;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -47,13 +58,20 @@ class _GiftTabPageState extends State<GiftTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return Consumer<SCAppGeneralManager>( return Consumer<SCAppGeneralManager>(
builder: (context, ref, child) { builder: (context, ref, child) {
return (ref.giftByTab[widget.type] ?? []).isEmpty final gifts = ref.giftByTab[widget.type] ?? <SocialChatGiftRes>[];
? mainEmpty( if (gifts.isNotEmpty) {
textColor: Colors.white54, _schedulePageWarmup(ref, gifts, _index);
msg: SCAppLocalizations.of(context)!.noData, }
) return gifts.isEmpty
? (ref.isGiftListLoading
? _buildGiftPageSkeleton()
: mainEmpty(
textColor: Colors.white54,
msg: SCAppLocalizations.of(context)!.noData,
))
: Column( : Column(
children: [ children: [
SizedBox(height: 23.w), SizedBox(height: 23.w),
@ -64,16 +82,21 @@ class _GiftTabPageState extends State<GiftTabPage> {
setState(() { setState(() {
_index = i; _index = i;
}); });
_schedulePageWarmup(ref, gifts, i);
}, },
itemBuilder: (c, i) { itemBuilder: (c, i) {
var current = _schedulePageWarmup(ref, gifts, i);
(ref.giftByTab[widget.type]!.length - (i * 8)); var current = (gifts.length - (i * 8));
int size = int size =
current > 8 current > 8
? 8 ? 8
: current % 8 == 0 : current % 8 == 0
? 8 ? 8
: current % 8; : current % 8;
if ((_pageStatuses[i] ?? _GiftGridPageStatus.idle) !=
_GiftGridPageStatus.ready) {
return _buildGiftPageSkeleton();
}
return GridView.builder( return GridView.builder(
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.symmetric(horizontal: 12.w), padding: EdgeInsets.symmetric(horizontal: 12.w),
@ -86,14 +109,11 @@ class _GiftTabPageState extends State<GiftTabPage> {
), ),
itemCount: size, itemCount: size,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return _bagItem( return _bagItem(gifts[(i * 8) + index], ref);
ref.giftByTab[widget.type]![(i * 8) + index],
ref,
);
}, },
); );
}, },
itemCount: (ref.giftByTab[widget.type]!.length / 8).ceil(), itemCount: (gifts.length / 8).ceil(),
), ),
), ),
_indicator(ref), _indicator(ref),
@ -104,6 +124,173 @@ class _GiftTabPageState extends State<GiftTabPage> {
); );
} }
void _schedulePageWarmup(
SCAppGeneralManager ref,
List<SocialChatGiftRes> gifts,
int pageIndex,
) {
final totalPages = (gifts.length / 8).ceil();
_ensurePageReady(ref, totalPages, pageIndex);
_ensurePageReady(ref, totalPages, pageIndex + 1);
}
void _ensurePageReady(
SCAppGeneralManager ref,
int totalPages,
int pageIndex,
) {
if (pageIndex < 0 || pageIndex >= totalPages) {
return;
}
final status = _pageStatuses[pageIndex] ?? _GiftGridPageStatus.idle;
if (status == _GiftGridPageStatus.loading ||
status == _GiftGridPageStatus.ready) {
return;
}
_pageStatuses[pageIndex] = _GiftGridPageStatus.loading;
WidgetsBinding.instance.addPostFrameCallback((_) async {
final warmupTask = ref.warmGiftPageCovers(
widget.type,
pageIndex: pageIndex,
);
await Future.any<void>([
Future.wait<void>([
warmupTask,
Future<void>.delayed(_kGiftPageSkeletonMinDuration),
]),
Future<void>.delayed(_kGiftPageSkeletonMaxDuration),
]);
if (!mounted) {
return;
}
setState(() {
_pageStatuses[pageIndex] = _GiftGridPageStatus.ready;
});
});
}
Widget _buildGiftPageSkeleton() {
return Stack(
children: [
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withValues(alpha: 0.1),
Colors.white.withValues(alpha: 0.04),
],
),
),
),
),
Positioned.fill(
child: Center(
child: Container(
width: 132.w,
height: 132.w,
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(20.w),
border: Border.all(
color: Colors.white.withValues(alpha: 0.12),
width: 1.w,
),
),
alignment: Alignment.center,
child: Opacity(
opacity: 0.75,
child: Image.asset(
"sc_images/general/sc_icon_loading.png",
width: 92.w,
fit: BoxFit.contain,
),
),
),
),
),
GridView.builder(
shrinkWrap: true,
padding: EdgeInsets.symmetric(horizontal: 12.w),
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 0.75,
mainAxisSpacing: 8.w,
crossAxisSpacing: 8.w,
),
itemCount: 8,
itemBuilder: (context, index) => _buildGiftSkeletonCard(),
),
],
);
}
Widget _buildGiftSkeletonCard() {
final baseColor = Colors.white.withValues(alpha: 0.12);
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: Colors.white.withValues(alpha: 0.08),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 48.w,
height: 48.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: baseColor,
image: const DecorationImage(
image: AssetImage("sc_images/general/sc_icon_loading.png"),
fit: BoxFit.cover,
opacity: 0.32,
),
),
),
SizedBox(height: 7.w),
Container(
width: 52.w,
height: 8.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(999.w),
color: baseColor,
),
),
SizedBox(height: 6.w),
Container(
width: 40.w,
height: 8.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(999.w),
color: baseColor,
),
),
],
),
);
}
Widget _buildGiftCoverLoading() {
return Container(
width: 48.w,
height: 48.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: Colors.white.withValues(alpha: 0.08),
),
clipBehavior: Clip.antiAlias,
child: Image.asset(
"sc_images/general/sc_icon_loading.png",
fit: BoxFit.cover,
),
);
}
Widget _bagItem(SocialChatGiftRes gift, SCAppGeneralManager ref) { Widget _bagItem(SocialChatGiftRes gift, SCAppGeneralManager ref) {
return gift.id == "-1000" return gift.id == "-1000"
? GestureDetector( ? GestureDetector(
@ -236,6 +423,8 @@ class _GiftTabPageState extends State<GiftTabPage> {
fit: BoxFit.cover, fit: BoxFit.cover,
width: 48.w, width: 48.w,
height: 48.w, height: 48.w,
loadingWidget: _buildGiftCoverLoading(),
errorWidget: _buildGiftCoverLoading(),
), ),
SizedBox(height: 5.w), SizedBox(height: 5.w),
Container( Container(

View File

@ -1,285 +1,298 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.dart'; import 'package:provider/provider.dart';
import 'package:provider/provider.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
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/sc_page_list.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/widgets/room/room_live_audio_indicator.dart';
import 'package:yumi/app/constants/sc_screen.dart'; import 'package:yumi/app/constants/sc_screen.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/follow_room_res.dart'; import 'package:yumi/shared/business_logic/models/res/follow_room_res.dart';
import 'package:yumi/services/general/sc_app_general_manager.dart'; import 'package:yumi/services/general/sc_app_general_manager.dart';
import 'package:yumi/services/audio/rtc_manager.dart'; import 'package:yumi/services/audio/rtc_manager.dart';
import '../mine/sc_home_mine_skeleton.dart';
///
class SCRoomFollowPage extends SCPageList { ///
@override class SCRoomFollowPage extends SCPageList {
_RoomFollowPageState createState() => _RoomFollowPageState(); const SCRoomFollowPage({super.key});
}
@override
class _RoomFollowPageState SCPageListState createState() => _RoomFollowPageState();
extends SCPageListState<FollowRoomRes, SCRoomFollowPage> { }
String? lastId;
bool _isLoading = true; // class _RoomFollowPageState
extends SCPageListState<FollowRoomRes, SCRoomFollowPage> {
@override String? lastId;
void initState() {
super.initState(); @override
enablePullUp = true; void initState() {
backgroundColor = Colors.transparent; super.initState();
isGridView = true; enablePullUp = true;
gridViewCount = 2; backgroundColor = Colors.transparent;
loadData(1); isGridView = true;
} gridViewCount = 2;
loadData(1);
@override }
Widget build(BuildContext context) {
return Scaffold( @override
resizeToAvoidBottomInset: false, Widget build(BuildContext context) {
backgroundColor: Colors.transparent, return Scaffold(
body: buildList(context), resizeToAvoidBottomInset: false,
); backgroundColor: Colors.transparent,
} body:
items.isEmpty && isLoading
@override ? const SCHomeSkeletonShimmer(
Widget buildItem(FollowRoomRes roomRes) { builder: _buildFollowSkeletonContent,
return GestureDetector( )
child: Container( : buildList(context),
margin: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w), );
decoration: BoxDecoration( }
borderRadius: BorderRadius.circular(12.w),
color: Colors.transparent, static Widget _buildFollowSkeletonContent(
), BuildContext context,
child: Stack( double progress,
alignment: Alignment.bottomCenter, ) {
children: [ return buildHomeRoomGridSkeleton(progress);
Container( }
padding: EdgeInsets.all(3.w),
decoration: BoxDecoration( @override
image: DecorationImage( Widget buildItem(FollowRoomRes roomRes) {
image: AssetImage("sc_images/index/sc_icon_room_bord.png"), return GestureDetector(
fit: BoxFit.fill, child: Container(
), margin: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w),
), decoration: BoxDecoration(
child: netImage( borderRadius: BorderRadius.circular(12.w),
url: resolveRoomCoverUrl( color: Colors.transparent,
roomRes.roomProfile?.id, ),
roomRes.roomProfile?.roomCover, child: Stack(
), alignment: Alignment.bottomCenter,
defaultImg: kRoomCoverDefaultImg, children: [
borderRadius: BorderRadius.circular(12.w), Container(
width: 200.w, padding: EdgeInsets.all(3.w),
height: 200.w, decoration: BoxDecoration(
), image: DecorationImage(
), image: AssetImage("sc_images/index/sc_icon_room_bord.png"),
Container( fit: BoxFit.fill,
padding: EdgeInsets.symmetric(vertical: 6.w), ),
margin: EdgeInsets.symmetric(horizontal: 1.w), ),
decoration: BoxDecoration( child: netImage(
image: DecorationImage( url: resolveRoomCoverUrl(
image: AssetImage( roomRes.roomProfile?.id,
"sc_images/index/sc_icon_index_room_brd.png", roomRes.roomProfile?.roomCover,
), ),
fit: BoxFit.fill, defaultImg: kRoomCoverDefaultImg,
), borderRadius: BorderRadius.circular(12.w),
), width: 200.w,
child: Row( height: 200.w,
children: [ ),
SizedBox(width: 10.w), ),
Consumer<SCAppGeneralManager>( Container(
builder: (_, provider, __) { padding: EdgeInsets.symmetric(vertical: 6.w),
return netImage( margin: EdgeInsets.symmetric(horizontal: 1.w),
url: decoration: BoxDecoration(
"${provider.findCountryByName(roomRes.roomProfile?.countryName ?? "")?.nationalFlag}", image: DecorationImage(
width: 20.w, image: AssetImage(
height: 13.w, "sc_images/index/sc_icon_index_room_brd.png",
borderRadius: BorderRadius.circular(2.w), ),
); fit: BoxFit.fill,
}, ),
), ),
SizedBox(width: 5.w), child: Row(
Expanded( children: [
child: SizedBox( SizedBox(width: 10.w),
height: 21.w, Consumer<SCAppGeneralManager>(
child: text( builder: (_, provider, __) {
roomRes.roomProfile?.roomName ?? "", return netImage(
fontSize: 15.sp, url:
textColor: Color(0xffffffff), "${provider.findCountryByName(roomRes.roomProfile?.countryName ?? "")?.nationalFlag}",
fontWeight: FontWeight.w400, width: 20.w,
), height: 13.w,
// (roomRes.roomProfile?.roomName?.length ?? 0) > 10 borderRadius: BorderRadius.circular(2.w),
// ? Marquee( );
// text: roomRes.roomProfile?.roomName ?? "", },
// style: TextStyle( ),
// fontSize: 15.sp, SizedBox(width: 5.w),
// color: Color(0xffffffff), Expanded(
// fontWeight: FontWeight.w400, child: SizedBox(
// decoration: TextDecoration.none, height: 17.w,
// ), child: Align(
// scrollAxis: Axis.horizontal, alignment: Alignment.centerLeft,
// crossAxisAlignment: CrossAxisAlignment.start, child: Transform.translate(
// blankSpace: 20.0, offset: Offset(0, -0.6.w),
// velocity: 40.0, child: text(
// pauseAfterRound: Duration(seconds: 1), roomRes.roomProfile?.roomName ?? "",
// accelerationDuration: Duration(seconds: 1), fontSize: 13.sp,
// accelerationCurve: Curves.easeOut, textColor: Color(0xffffffff),
// decelerationDuration: Duration( fontWeight: FontWeight.w400,
// milliseconds: 500, lineHeight: 1,
// ), ),
// decelerationCurve: Curves.easeOut, ),
// ) ),
// : Text( // (roomRes.roomProfile?.roomName?.length ?? 0) > 10
// roomRes.roomProfile?.roomName ?? "", // ? Marquee(
// maxLines: 1, // text: roomRes.roomProfile?.roomName ?? "",
// overflow: TextOverflow.ellipsis, // style: TextStyle(
// style: TextStyle( // fontSize: 15.sp,
// fontSize: 15.sp, // color: Color(0xffffffff),
// color: Color(0xffffffff), // fontWeight: FontWeight.w400,
// fontWeight: FontWeight.w400, // decoration: TextDecoration.none,
// decoration: TextDecoration.none, // ),
// ), // scrollAxis: Axis.horizontal,
// ), // crossAxisAlignment: CrossAxisAlignment.start,
), // blankSpace: 20.0,
), // velocity: 40.0,
SizedBox(width: 5.w), // pauseAfterRound: Duration(seconds: 1),
(roomRes // accelerationDuration: Duration(seconds: 1),
.roomProfile // accelerationCurve: Curves.easeOut,
?.extValues // decelerationDuration: Duration(
?.roomSetting // milliseconds: 500,
?.password // ),
?.isEmpty ?? // decelerationCurve: Curves.easeOut,
false) // )
? Image.asset( // : Text(
"sc_images/general/sc_icon_online_user.png", // roomRes.roomProfile?.roomName ?? "",
width: 14.w, // maxLines: 1,
height: 14.w, // overflow: TextOverflow.ellipsis,
) // style: TextStyle(
: Image.asset( // fontSize: 15.sp,
"sc_images/index/sc_icon_room_suo.png", // color: Color(0xffffffff),
width: 20.w, // fontWeight: FontWeight.w400,
height: 20.w, // decoration: TextDecoration.none,
), // ),
(roomRes // ),
.roomProfile ),
?.extValues ),
?.roomSetting SizedBox(width: 5.w),
?.password (roomRes
?.isEmpty ?? .roomProfile
false) ?.extValues
? SizedBox(width: 3.w) ?.roomSetting
: Container(height: 10.w), ?.password
(roomRes ?.isEmpty ??
.roomProfile false)
?.extValues ? SCRoomLiveAudioIndicator(width: 14.w, height: 14.w)
?.roomSetting : Image.asset(
?.password "sc_images/index/sc_icon_room_suo.png",
?.isEmpty ?? width: 20.w,
false) height: 20.w,
? text( ),
roomRes.roomProfile?.extValues?.memberQuantity ?? "0", (roomRes
fontSize: 12.sp, .roomProfile
) ?.extValues
: Container(height: 10.w), ?.roomSetting
SizedBox(width: 10.w), ?.password
], ?.isEmpty ??
), false)
), ? SizedBox(width: 3.w)
getRoomCoverHeaddress(roomRes).isNotEmpty : Container(height: 10.w),
? Transform.translate( (roomRes
offset: Offset(0, -5.w), .roomProfile
child: Transform.scale( ?.extValues
scaleX: 1.1, ?.roomSetting
scaleY: 1.12, ?.password
child: Image.asset(getRoomCoverHeaddress(roomRes)), ?.isEmpty ??
), false)
) ? text(
: Container(), roomRes.roomProfile?.extValues?.memberQuantity ?? "0",
fontSize: 10.sp,
(roomRes.roomProfile?.roomGameIcon?.isNotEmpty ?? false) lineHeight: 1,
? PositionedDirectional( )
top: 8.w, : Container(height: 10.w),
end: 8.w, SizedBox(width: 10.w),
child: netImage( ],
url: roomRes.roomProfile?.roomGameIcon ?? "", ),
width: 25.w, ),
height: 25.w, getRoomCoverHeaddress(roomRes).isNotEmpty
borderRadius: BorderRadius.circular(4.w), ? Transform.translate(
), offset: Offset(0, -5.w),
) child: Transform.scale(
: Container(), scaleX: 1.1,
], scaleY: 1.12,
), child: Image.asset(getRoomCoverHeaddress(roomRes)),
), ),
onTap: () { )
Provider.of<RtcProvider>( : Container(),
context,
listen: false, (roomRes.roomProfile?.roomGameIcon?.isNotEmpty ?? false)
).joinVoiceRoomSession(context, roomRes.roomProfile?.id ?? ""); ? PositionedDirectional(
}, top: 8.w,
); end: 8.w,
} child: netImage(
url: roomRes.roomProfile?.roomGameIcon ?? "",
String getRoomCoverHeaddress(FollowRoomRes roomRes) { width: 25.w,
return ""; height: 25.w,
} borderRadius: BorderRadius.circular(4.w),
),
@override )
empty() { : Container(),
List<Widget> list = []; ],
list.add(SizedBox(height: height(30))); ),
list.add( ),
Image.asset( onTap: () {
'sc_images/general/sc_icon_loading.png', Provider.of<RtcProvider>(
width: 120.w, context,
height: 120.w, listen: false,
), ).joinVoiceRoomSession(context, roomRes.roomProfile?.id ?? "");
); },
list.add(SizedBox(height: height(15))); );
list.add( }
Text(
SCAppLocalizations.of(context)!.youHaventFollowed, String getRoomCoverHeaddress(FollowRoomRes roomRes) {
style: TextStyle( return "";
fontSize: sp(14), }
color: Color(0xff999999),
fontWeight: FontWeight.w400, @override
decoration: TextDecoration.none, empty() {
height: 1, List<Widget> list = [];
), list.add(SizedBox(height: height(30)));
), list.add(
); Image.asset(
return Column( 'sc_images/general/sc_icon_loading.png',
mainAxisSize: MainAxisSize.max, width: 120.w,
crossAxisAlignment: CrossAxisAlignment.center, height: 120.w,
children: list, ),
); );
} list.add(SizedBox(height: height(15)));
list.add(
/// Text(
@override SCAppLocalizations.of(context)!.youHaventFollowed,
loadPage({ style: TextStyle(
required int page, fontSize: sp(14),
required Function(List<FollowRoomRes>) onSuccess, color: Color(0xff999999),
Function? onErr, fontWeight: FontWeight.w400,
}) async { decoration: TextDecoration.none,
if (page == 1) { height: 1,
lastId = null; ),
} ),
try { );
var roomList = await SCAccountRepository().followRoomList(lastId: lastId); return Column(
if (roomList.isNotEmpty) { mainAxisSize: MainAxisSize.max,
lastId = roomList.last.id; crossAxisAlignment: CrossAxisAlignment.center,
} children: list,
onSuccess(roomList); );
} catch (e) { }
if (onErr != null) {
onErr(); ///
} @override
} finally { loadPage({
// required int page,
setState(() { required Function(List<FollowRoomRes>) onSuccess,
_isLoading = false; Function? onErr,
}); }) async {
} if (page == 1) {
} lastId = null;
} }
try {
var roomList = await SCAccountRepository().followRoomList(lastId: lastId);
if (roomList.isNotEmpty) {
lastId = roomList.last.id;
}
onSuccess(roomList);
} catch (e) {
if (onErr != null) {
onErr();
}
}
}
}

View File

@ -1,285 +1,298 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.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:provider/provider.dart';
import 'package:provider/provider.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
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/sc_page_list.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/widgets/room/room_live_audio_indicator.dart';
import 'package:yumi/app/constants/sc_screen.dart'; import 'package:yumi/app/constants/sc_screen.dart';
import 'package:yumi/shared/business_logic/models/res/follow_room_res.dart'; import 'package:yumi/shared/business_logic/models/res/follow_room_res.dart';
import 'package:yumi/services/general/sc_app_general_manager.dart'; import 'package:yumi/services/general/sc_app_general_manager.dart';
import 'package:yumi/services/audio/rtc_manager.dart'; import 'package:yumi/services/audio/rtc_manager.dart';
import '../mine/sc_home_mine_skeleton.dart';
///
class SCRoomHistoryPage extends SCPageList { ///
@override class SCRoomHistoryPage extends SCPageList {
_SCRoomHistoryPageState createState() => _SCRoomHistoryPageState(); const SCRoomHistoryPage({super.key});
}
@override
class _SCRoomHistoryPageState SCPageListState createState() => _SCRoomHistoryPageState();
extends SCPageListState<FollowRoomRes, SCRoomHistoryPage> { }
String? lastId;
bool _isLoading = true; // class _SCRoomHistoryPageState
extends SCPageListState<FollowRoomRes, SCRoomHistoryPage> {
@override String? lastId;
void initState() {
super.initState(); @override
enablePullUp = true; void initState() {
backgroundColor = Colors.transparent; super.initState();
isGridView = true; enablePullUp = true;
gridViewCount = 2; backgroundColor = Colors.transparent;
loadData(1); isGridView = true;
} gridViewCount = 2;
loadData(1);
@override }
Widget build(BuildContext context) {
return Scaffold( @override
resizeToAvoidBottomInset: false, Widget build(BuildContext context) {
backgroundColor: Colors.transparent, return Scaffold(
body: buildList(context), resizeToAvoidBottomInset: false,
); backgroundColor: Colors.transparent,
} body:
items.isEmpty && isLoading
@override ? const SCHomeSkeletonShimmer(
Widget buildItem(FollowRoomRes roomRes) { builder: _buildHistorySkeletonContent,
return GestureDetector( )
child: Container( : buildList(context),
margin: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w), );
decoration: BoxDecoration( }
borderRadius: BorderRadius.circular(12.w),
color: Colors.transparent, static Widget _buildHistorySkeletonContent(
), BuildContext context,
child: Stack( double progress,
alignment: Alignment.bottomCenter, ) {
children: [ return buildHomeRoomGridSkeleton(progress);
Container( }
padding: EdgeInsets.all(3.w),
decoration: BoxDecoration( @override
image: DecorationImage( Widget buildItem(FollowRoomRes roomRes) {
image: AssetImage("sc_images/index/sc_icon_room_bord.png"), return GestureDetector(
fit: BoxFit.fill, child: Container(
), margin: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w),
), decoration: BoxDecoration(
child: netImage( borderRadius: BorderRadius.circular(12.w),
url: resolveRoomCoverUrl( color: Colors.transparent,
roomRes.roomProfile?.id, ),
roomRes.roomProfile?.roomCover, child: Stack(
), alignment: Alignment.bottomCenter,
defaultImg: kRoomCoverDefaultImg, children: [
borderRadius: BorderRadius.circular(12.w), Container(
width: 200.w, padding: EdgeInsets.all(3.w),
height: 200.w, decoration: BoxDecoration(
), image: DecorationImage(
), image: AssetImage("sc_images/index/sc_icon_room_bord.png"),
Container( fit: BoxFit.fill,
padding: EdgeInsets.symmetric(vertical: 6.w), ),
margin: EdgeInsets.symmetric(horizontal: 1.w), ),
decoration: BoxDecoration( child: netImage(
image: DecorationImage( url: resolveRoomCoverUrl(
image: AssetImage( roomRes.roomProfile?.id,
"sc_images/index/sc_icon_index_room_brd.png", roomRes.roomProfile?.roomCover,
), ),
fit: BoxFit.fill, defaultImg: kRoomCoverDefaultImg,
), borderRadius: BorderRadius.circular(12.w),
), width: 200.w,
child: Row( height: 200.w,
children: [ ),
SizedBox(width: 10.w), ),
Consumer<SCAppGeneralManager>( Container(
builder: (_, provider, __) { padding: EdgeInsets.symmetric(vertical: 6.w),
return netImage( margin: EdgeInsets.symmetric(horizontal: 1.w),
url: decoration: BoxDecoration(
"${provider.findCountryByName(roomRes.roomProfile?.countryName ?? "")?.nationalFlag}", image: DecorationImage(
width: 20.w, image: AssetImage(
height: 13.w, "sc_images/index/sc_icon_index_room_brd.png",
borderRadius: BorderRadius.circular(2.w), ),
); fit: BoxFit.fill,
}, ),
), ),
SizedBox(width: 5.w), child: Row(
Expanded( children: [
child: SizedBox( SizedBox(width: 10.w),
height: 21.w, Consumer<SCAppGeneralManager>(
child: text( builder: (_, provider, __) {
roomRes.roomProfile?.roomName ?? "", return netImage(
fontSize: 15.sp, url:
textColor: Color(0xffffffff), "${provider.findCountryByName(roomRes.roomProfile?.countryName ?? "")?.nationalFlag}",
fontWeight: FontWeight.w400, width: 20.w,
), height: 13.w,
borderRadius: BorderRadius.circular(2.w),
// (roomRes.roomProfile?.roomName?.length ?? 0) > 10 );
// ? Marquee( },
// text: roomRes.roomProfile?.roomName ?? "", ),
// style: TextStyle( SizedBox(width: 5.w),
// fontSize: 15.sp, Expanded(
// color: Color(0xffffffff), child: SizedBox(
// fontWeight: FontWeight.w400, height: 17.w,
// decoration: TextDecoration.none, child: Align(
// ), alignment: Alignment.centerLeft,
// scrollAxis: Axis.horizontal, child: Transform.translate(
// crossAxisAlignment: CrossAxisAlignment.start, offset: Offset(0, -0.6.w),
// blankSpace: 20.0, child: text(
// velocity: 40.0, roomRes.roomProfile?.roomName ?? "",
// pauseAfterRound: Duration(seconds: 1), fontSize: 13.sp,
// accelerationDuration: Duration(seconds: 1), textColor: Color(0xffffffff),
// accelerationCurve: Curves.easeOut, fontWeight: FontWeight.w400,
// decelerationDuration: Duration( lineHeight: 1,
// milliseconds: 500, ),
// ), ),
// decelerationCurve: Curves.easeOut, ),
// )
// : Text( // (roomRes.roomProfile?.roomName?.length ?? 0) > 10
// roomRes.roomProfile?.roomName ?? "", // ? Marquee(
// maxLines: 1, // text: roomRes.roomProfile?.roomName ?? "",
// overflow: TextOverflow.ellipsis, // style: TextStyle(
// style: TextStyle( // fontSize: 15.sp,
// fontSize: 15.sp, // color: Color(0xffffffff),
// color: Color(0xffffffff), // fontWeight: FontWeight.w400,
// fontWeight: FontWeight.w400, // decoration: TextDecoration.none,
// decoration: TextDecoration.none, // ),
// ), // scrollAxis: Axis.horizontal,
// ), // crossAxisAlignment: CrossAxisAlignment.start,
), // blankSpace: 20.0,
), // velocity: 40.0,
SizedBox(width: 5.w), // pauseAfterRound: Duration(seconds: 1),
(roomRes // accelerationDuration: Duration(seconds: 1),
.roomProfile // accelerationCurve: Curves.easeOut,
?.extValues // decelerationDuration: Duration(
?.roomSetting // milliseconds: 500,
?.password // ),
?.isEmpty ?? // decelerationCurve: Curves.easeOut,
false) // )
? Image.asset( // : Text(
"sc_images/general/sc_icon_online_user.png", // roomRes.roomProfile?.roomName ?? "",
width: 14.w, // maxLines: 1,
height: 14.w, // overflow: TextOverflow.ellipsis,
) // style: TextStyle(
: Image.asset( // fontSize: 15.sp,
"sc_images/index/sc_icon_room_suo.png", // color: Color(0xffffffff),
width: 20.w, // fontWeight: FontWeight.w400,
height: 20.w, // decoration: TextDecoration.none,
), // ),
(roomRes // ),
.roomProfile ),
?.extValues ),
?.roomSetting SizedBox(width: 5.w),
?.password (roomRes
?.isEmpty ?? .roomProfile
false) ?.extValues
? SizedBox(width: 3.w) ?.roomSetting
: Container(height: 10.w), ?.password
(roomRes ?.isEmpty ??
.roomProfile false)
?.extValues ? SCRoomLiveAudioIndicator(width: 14.w, height: 14.w)
?.roomSetting : Image.asset(
?.password "sc_images/index/sc_icon_room_suo.png",
?.isEmpty ?? width: 20.w,
false) height: 20.w,
? text( ),
roomRes.roomProfile?.extValues?.memberQuantity ?? "0", (roomRes
fontSize: 12.sp, .roomProfile
) ?.extValues
: Container(height: 10.w), ?.roomSetting
SizedBox(width: 10.w), ?.password
], ?.isEmpty ??
), false)
), ? SizedBox(width: 3.w)
getRoomCoverHeaddress(roomRes).isNotEmpty : Container(height: 10.w),
? Transform.translate( (roomRes
offset: Offset(0, -5.w), .roomProfile
child: Transform.scale( ?.extValues
scaleX: 1.1, ?.roomSetting
scaleY: 1.12, ?.password
child: Image.asset(getRoomCoverHeaddress(roomRes)), ?.isEmpty ??
), false)
) ? text(
: Container(), roomRes.roomProfile?.extValues?.memberQuantity ?? "0",
(roomRes.roomProfile?.roomGameIcon?.isNotEmpty ?? false) fontSize: 10.sp,
? PositionedDirectional( lineHeight: 1,
top: 8.w, )
end: 8.w, : Container(height: 10.w),
child: netImage( SizedBox(width: 10.w),
url: roomRes.roomProfile?.roomGameIcon ?? "", ],
width: 25.w, ),
height: 25.w, ),
borderRadius: BorderRadius.circular(4.w), getRoomCoverHeaddress(roomRes).isNotEmpty
), ? Transform.translate(
) offset: Offset(0, -5.w),
: Container(), child: Transform.scale(
], scaleX: 1.1,
), scaleY: 1.12,
), child: Image.asset(getRoomCoverHeaddress(roomRes)),
onTap: () { ),
Provider.of<RtcProvider>( )
context, : Container(),
listen: false, (roomRes.roomProfile?.roomGameIcon?.isNotEmpty ?? false)
).joinVoiceRoomSession(context, roomRes.roomProfile?.id ?? ""); ? PositionedDirectional(
}, top: 8.w,
); end: 8.w,
} child: netImage(
url: roomRes.roomProfile?.roomGameIcon ?? "",
@override width: 25.w,
empty() { height: 25.w,
List<Widget> list = []; borderRadius: BorderRadius.circular(4.w),
list.add(SizedBox(height: height(30))); ),
list.add( )
Image.asset( : Container(),
'sc_images/general/sc_icon_loading.png', ],
width: 120.w, ),
height: 120.w, ),
), onTap: () {
); Provider.of<RtcProvider>(
list.add(SizedBox(height: height(15))); context,
list.add( listen: false,
Text( ).joinVoiceRoomSession(context, roomRes.roomProfile?.id ?? "");
SCAppLocalizations.of(context)!.noData, },
style: TextStyle( );
fontSize: sp(14), }
color: Color(0xff999999),
fontWeight: FontWeight.w400, @override
decoration: TextDecoration.none, empty() {
height: 1, List<Widget> list = [];
), list.add(SizedBox(height: height(30)));
), list.add(
); Image.asset(
return Column( 'sc_images/general/sc_icon_loading.png',
mainAxisSize: MainAxisSize.max, width: 120.w,
crossAxisAlignment: CrossAxisAlignment.center, height: 120.w,
children: list, ),
); );
} list.add(SizedBox(height: height(15)));
list.add(
String getRoomCoverHeaddress(FollowRoomRes roomRes) { Text(
return ""; SCAppLocalizations.of(context)!.noData,
} style: TextStyle(
fontSize: sp(14),
/// color: Color(0xff999999),
@override fontWeight: FontWeight.w400,
loadPage({ decoration: TextDecoration.none,
required int page, height: 1,
required Function(List<FollowRoomRes>) onSuccess, ),
Function? onErr, ),
}) async { );
if (page == 1) { return Column(
lastId = null; mainAxisSize: MainAxisSize.max,
} crossAxisAlignment: CrossAxisAlignment.center,
try { children: list,
var roomList = await SCAccountRepository().trace(lastId: lastId); );
if (roomList.isNotEmpty) { }
lastId = roomList.last.id;
} String getRoomCoverHeaddress(FollowRoomRes roomRes) {
onSuccess(roomList); return "";
} catch (e) { }
if (onErr != null) {
onErr(); ///
} @override
} finally { loadPage({
// required int page,
setState(() { required Function(List<FollowRoomRes>) onSuccess,
_isLoading = false; Function? onErr,
}); }) async {
} if (page == 1) {
} lastId = null;
} }
try {
var roomList = await SCAccountRepository().trace(lastId: lastId);
if (roomList.isNotEmpty) {
lastId = roomList.last.id;
}
onSuccess(roomList);
} catch (e) {
if (onErr != null) {
onErr();
}
}
}
}

View File

@ -1,607 +1,296 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/shared/tools/sc_loading_manager.dart'; import 'package:marquee/marquee.dart';
import 'package:yumi/ui_kit/components/sc_debounce_widget.dart'; import 'package:provider/provider.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import '../../../../services/general/sc_app_general_manager.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import '../../../../services/audio/rtc_manager.dart';
import 'package:marquee/marquee.dart'; import '../../../../services/room/rc_room_manager.dart';
import 'package:provider/provider.dart'; import '../../../../ui_kit/components/sc_compontent.dart';
import '../../../../app/config/business_logic_strategy.dart'; import '../../../../ui_kit/theme/socialchat_theme.dart';
import '../../../../app/constants/sc_global_config.dart'; import '../follow/sc_room_follow_page.dart';
import '../../../../shared/data_sources/sources/repositories/sc_user_repository_impl.dart'; import '../history/sc_room_history_page.dart';
import '../../../../shared/business_logic/models/res/follow_room_res.dart'; import 'sc_home_mine_skeleton.dart';
import '../../../../services/general/sc_app_general_manager.dart';
import '../../../../services/room/rc_room_manager.dart'; class SCHomeMinePage extends StatefulWidget {
import '../../../../services/audio/rtc_manager.dart'; const SCHomeMinePage({super.key});
import '../../../../ui_kit/components/sc_compontent.dart';
import '../../../../ui_kit/theme/socialchat_theme.dart'; @override
import '../follow/sc_room_follow_page.dart'; State<SCHomeMinePage> createState() => _HomeMinePageState();
import '../history/sc_room_history_page.dart'; }
class SCHomeMinePage extends SCPageList { class _HomeMinePageState extends State<SCHomeMinePage>
@override with SingleTickerProviderStateMixin {
_HomeMinePageState createState() => _HomeMinePageState(); late TabController _tabController;
} final List<Widget> _pages = const [SCRoomHistoryPage(), SCRoomFollowPage()];
final List<Widget> _tabs = [];
class _HomeMinePageState extends SCPageListState<FollowRoomRes, SCHomeMinePage>
with SingleTickerProviderStateMixin { @override
List<FollowRoomRes> historyRooms = []; void initState() {
String? lastId; super.initState();
_tabController = TabController(length: 2, vsync: this);
BusinessLogicStrategy get _strategy => SCGlobalConfig.businessLogicStrategy; Provider.of<SocialChatRoomManager>(
late TabController _tabController; context,
final List<Widget> _pages = [SCRoomHistoryPage(), SCRoomFollowPage()]; listen: false,
bool isLoading = false; ).fetchMyRoomData();
final List<Widget> _tabs = []; }
@override @override
void initState() { void dispose() {
super.initState(); _tabController.dispose();
_tabController = TabController(length: 2, vsync: this); super.dispose();
enablePullUp = true; }
backgroundColor = Colors.transparent;
loadData(1); @override
} Widget build(BuildContext context) {
_tabs.clear();
@override _tabs.add(Tab(text: SCAppLocalizations.of(context)!.recent));
Widget build(BuildContext context) { _tabs.add(Tab(text: SCAppLocalizations.of(context)!.followed));
_tabs.clear(); return Column(
_tabs.add(Tab(text: SCAppLocalizations.of(context)!.recent)); crossAxisAlignment: CrossAxisAlignment.start,
_tabs.add(Tab(text: SCAppLocalizations.of(context)!.followed)); children: [
return Column( Consumer<SocialChatRoomManager>(
crossAxisAlignment: CrossAxisAlignment.start, builder: (_, provider, __) {
children: [ if (provider.isMyRoomLoading && provider.myRoom == null) {
Row( return const SCHomeSkeletonShimmer(
children: [ builder: _buildMineRoomSkeletonContent,
SizedBox(width: 15.w), );
text( }
SCAppLocalizations.of(context)!.myRoom, return Container(
fontSize: 16.sp, margin: EdgeInsets.symmetric(horizontal: 12.w),
fontWeight: FontWeight.bold, decoration: BoxDecoration(
textColor: Colors.white, image: DecorationImage(
), image: AssetImage(
], provider.myRoom == null
), ? "sc_images/index/sc_icon_my_room_no_bg.png"
SizedBox(height: 5.w), : "sc_images/index/sc_icon_my_room_has_bg.png",
Consumer<SocialChatRoomManager>( ),
builder: (_, provider, __) { fit: BoxFit.fill,
return Container( ),
margin: EdgeInsets.symmetric(horizontal: 12.w), ),
decoration: BoxDecoration( width: ScreenUtil().screenWidth,
image: DecorationImage( height: 85.w,
image: AssetImage( child: _buildMyRoom(provider),
provider.myRoom == null );
? "sc_images/index/sc_icon_my_room_no_bg.png" },
: "sc_images/index/sc_icon_my_room_has_bg.png", ),
), SizedBox(height: 5.w),
fit: BoxFit.fill, Row(
), children: [
), SizedBox(width: 5.w),
width: ScreenUtil().screenWidth, TabBar(
height: 85.w, tabAlignment: TabAlignment.start,
child: _buildMyRoom(provider), labelPadding: EdgeInsets.symmetric(horizontal: 12.w),
); labelColor: SocialChatTheme.primaryLight,
}, isScrollable: true,
), indicator: BoxDecoration(),
SizedBox(height: 5.w), unselectedLabelColor: Colors.white,
Row( labelStyle: TextStyle(
children: [ fontSize: 15.sp,
SizedBox(width: 5.w), fontFamily: 'MyCustomFont',
TabBar( fontWeight: FontWeight.w600,
tabAlignment: TabAlignment.start, ),
labelPadding: EdgeInsets.symmetric(horizontal: 12.w), unselectedLabelStyle: TextStyle(
labelColor: SocialChatTheme.primaryLight, fontSize: 13.sp,
isScrollable: true, fontFamily: 'MyCustomFont',
indicator: BoxDecoration(), fontWeight: FontWeight.w500,
unselectedLabelColor: Colors.white, ),
labelStyle: TextStyle( indicatorColor: Colors.transparent,
fontSize: 15.sp, dividerColor: Colors.transparent,
fontFamily: 'MyCustomFont', controller: _tabController,
fontWeight: FontWeight.w600, tabs: _tabs,
), ),
unselectedLabelStyle: TextStyle( ],
fontSize: 13.sp, ),
fontFamily: 'MyCustomFont', Expanded(
fontWeight: FontWeight.w500, child: TabBarView(
), controller: _tabController,
indicatorColor: Colors.transparent, physics: NeverScrollableScrollPhysics(),
dividerColor: Colors.transparent, children: _pages,
controller: _tabController, ),
tabs: _tabs, ),
), ],
], );
), }
Expanded(
child: TabBarView( static Widget _buildMineRoomSkeletonContent(
controller: _tabController, BuildContext context,
physics: NeverScrollableScrollPhysics(), double progress,
children: _pages, ) {
), return buildHomeMyRoomSkeleton(progress);
), }
],
); Widget _buildMyRoom(SocialChatRoomManager provider) {
} return provider.myRoom != null
? GestureDetector(
_buildMyRoom(SocialChatRoomManager provider) { behavior: HitTestBehavior.opaque,
return provider.myRoom != null child: Row(
? GestureDetector( children: [
behavior: HitTestBehavior.opaque, SizedBox(width: 10.w),
child: Row( netImage(
children: [ url: resolveRoomCoverUrl(
SizedBox(width: 10.w), provider.myRoom?.id,
netImage( provider.myRoom?.roomCover,
url: resolveRoomCoverUrl( ),
provider.myRoom?.id, defaultImg: kRoomCoverDefaultImg,
provider.myRoom?.roomCover, borderRadius: BorderRadius.all(Radius.circular(8.w)),
), width: 70.w,
defaultImg: kRoomCoverDefaultImg, ),
borderRadius: BorderRadius.all(Radius.circular(8.w)), SizedBox(width: 10.w),
width: 70.w, Expanded(
), child: Stack(
SizedBox(width: 10.w), children: [
Expanded( Column(
child: Stack( crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Column( SizedBox(height: 6.w),
crossAxisAlignment: CrossAxisAlignment.start, Row(
children: [ children: [
SizedBox(height: 6.w), netImage(
Row( url:
children: [ Provider.of<SCAppGeneralManager>(
netImage( context,
url: listen: false,
Provider.of<SCAppGeneralManager>( )
context, .findCountryByName(
listen: false, AccountStorage()
) .getCurrentUser()
.findCountryByName( ?.userProfile
AccountStorage() ?.countryName ??
.getCurrentUser() "",
?.userProfile )
?.countryName ?? ?.nationalFlag ??
"", "",
) borderRadius: BorderRadius.all(
?.nationalFlag ?? Radius.circular(3.w),
"", ),
borderRadius: BorderRadius.all( width: 19.w,
Radius.circular(3.w), height: 14.w,
), ),
width: 19.w, SizedBox(width: 3.w),
height: 14.w, Container(
), constraints: BoxConstraints(
SizedBox(width: 3.w), maxWidth: 200.w,
Container( maxHeight: 24.w,
constraints: BoxConstraints( ),
maxWidth: 200.w, child:
maxHeight: 24.w, (provider.myRoom?.roomName?.length ?? 0) > 18
), ? Marquee(
child: text: provider.myRoom?.roomName ?? "",
(provider.myRoom?.roomName?.length ?? 0) > 18 style: TextStyle(
? Marquee( fontSize: 16.sp,
text: provider.myRoom?.roomName ?? "", color: Colors.white,
style: TextStyle( fontWeight: FontWeight.bold,
fontSize: 16.sp, decoration: TextDecoration.none,
color: Colors.white, ),
fontWeight: FontWeight.bold, scrollAxis: Axis.horizontal,
decoration: TextDecoration.none, crossAxisAlignment:
), CrossAxisAlignment.start,
scrollAxis: Axis.horizontal, blankSpace: 40.0,
crossAxisAlignment: velocity: 40.0,
CrossAxisAlignment.start, pauseAfterRound: Duration(seconds: 1),
blankSpace: 40.0, accelerationDuration: Duration(
velocity: 40.0, seconds: 1,
pauseAfterRound: Duration(seconds: 1), ),
accelerationDuration: Duration( accelerationCurve: Curves.easeOut,
seconds: 1, decelerationDuration: Duration(
), milliseconds: 500,
accelerationCurve: Curves.easeOut, ),
decelerationDuration: Duration( decelerationCurve: Curves.easeOut,
milliseconds: 500, )
), : Text(
decelerationCurve: Curves.easeOut, provider.myRoom?.roomName ?? "",
) maxLines: 1,
: Text( overflow: TextOverflow.ellipsis,
provider.myRoom?.roomName ?? "", style: TextStyle(
maxLines: 1, fontSize: 16.sp,
overflow: TextOverflow.ellipsis, color: Colors.white,
style: TextStyle( fontWeight: FontWeight.bold,
fontSize: 16.sp, decoration: TextDecoration.none,
color: Colors.white, ),
fontWeight: FontWeight.bold, ),
decoration: TextDecoration.none, ),
), ],
), ),
), text(
], provider.myRoom?.roomDesc ?? "",
), fontSize: 14.sp,
text( textColor: Colors.white,
provider.myRoom?.roomDesc ?? "", ),
fontSize: 14.sp, text(
textColor: Colors.white, "ID:${provider.myRoom?.roomAccount}",
), fontSize: 12.sp,
text( textColor: Colors.white,
"ID:${provider.myRoom?.roomAccount}", ),
fontSize: 12.sp, ],
textColor: Colors.white, ),
), ],
], ),
), ),
], SizedBox(width: 12.w),
), ],
), ),
SizedBox(width: 12.w), onTap: () {
], String roomId =
), Provider.of<SocialChatRoomManager>(
onTap: () { context,
String roomId = listen: false,
Provider.of<SocialChatRoomManager>( ).myRoom?.id ??
context, "";
listen: false, Provider.of<RealTimeCommunicationManager>(
).myRoom?.id ?? context,
""; listen: false,
Provider.of<RealTimeCommunicationManager>( ).joinVoiceRoomSession(context, roomId);
context, },
listen: false, )
).joinVoiceRoomSession(context, roomId); : GestureDetector(
}, child: Row(
) children: [
: GestureDetector( SizedBox(width: 10.w),
child: Row( Image.asset(
children: [ "sc_images/index/sc_icon_index_creat_room_tag.png",
SizedBox(width: 10.w), height: 70.w,
Image.asset( width: 70.w,
"sc_images/index/sc_icon_index_creat_room_tag.png", ),
height: 70.w, SizedBox(width: 10.w),
width: 70.w, Expanded(
), child: Column(
SizedBox(width: 10.w), crossAxisAlignment: CrossAxisAlignment.start,
Expanded( mainAxisAlignment: MainAxisAlignment.center,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, text(
mainAxisAlignment: MainAxisAlignment.center, SCAppLocalizations.of(context)!.crateMyRoom,
children: [ fontSize: 14.sp,
text( fontWeight: FontWeight.bold,
SCAppLocalizations.of(context)!.crateMyRoom, textColor: Colors.white,
fontSize: 14.sp, ),
fontWeight: FontWeight.bold, text(
textColor: Colors.white, SCAppLocalizations.of(context)!.startYourBrandNewJourney,
), fontSize: 12.sp,
text( textColor: Colors.white,
SCAppLocalizations.of(context)!.startYourBrandNewJourney, ),
fontSize: 12.sp, ],
textColor: Colors.white, ),
), ),
], Image.asset(
), "sc_images/index/sc_icon_my_room_tag2.png",
), height: 25.w,
Image.asset( width: 25.w,
"sc_images/index/sc_icon_my_room_tag2.png", ),
height: 25.w, SizedBox(width: 10.w),
width: 25.w, Icon(
), Icons.chevron_right_outlined,
SizedBox(width: 10.w), color: Colors.white,
Icon( size: 20.w,
Icons.chevron_right_outlined, ),
color: Colors.white, SizedBox(width: 15.w),
size: 20.w, ],
), ),
SizedBox(width: 15.w), onTap: () {
], provider.createNewRoom(context);
), },
onTap: () { );
provider.createNewRoom(context); }
}, }
);
}
void _loadOtherData() {
SCLoadingManager.show();
Provider.of<SocialChatRoomManager>(
context,
listen: false,
).fetchMyRoomData();
SCAccountRepository()
.trace()
.then((res) {
historyRooms = res;
SCLoadingManager.hide();
setState(() {});
})
.catchError((_) {
SCLoadingManager.hide();
});
}
_buildHistoryRoomItem(FollowRoomRes roomRes) {
return GestureDetector(
child: SizedBox(
width: 70.w,
height: 70.w,
child: Stack(
children: [
netImage(
url: resolveRoomCoverUrl(
roomRes.roomProfile?.id,
roomRes.roomProfile?.roomCover,
),
defaultImg: kRoomCoverDefaultImg,
width: 70.w,
height: 70.w,
fit: BoxFit.cover,
borderRadius: BorderRadius.circular(8.w),
),
getRoomCoverHeaddress(roomRes).isNotEmpty
? Transform.translate(
offset: Offset(0, -2.w),
child: Transform.scale(
scaleX: 1.1,
scaleY: 1.12,
child: Image.asset(getRoomCoverHeaddress(roomRes)),
),
)
: Container(),
(roomRes.roomProfile?.roomGameIcon?.isNotEmpty ?? false)
? PositionedDirectional(
top: 8.w,
end: 8.w,
child: netImage(
url: roomRes.roomProfile?.roomGameIcon ?? "",
width: 15.w,
height: 15.w,
borderRadius: BorderRadius.circular(4.w),
),
)
: Container(),
PositionedDirectional(
top: 3.w,
end: 5.w,
child:
(roomRes
.roomProfile
?.extValues
?.roomSetting
?.password
?.isNotEmpty ??
false)
? Image.asset(
"sc_images/index/sc_icon_room_suo.png",
width: 16.w,
height: 16.w,
)
: Container(),
),
],
),
),
onTap: () {
Provider.of<RtcProvider>(
context,
listen: false,
).joinVoiceRoomSession(context, roomRes.roomProfile?.id ?? "");
},
);
}
@override
Widget buildItem(FollowRoomRes res) {
return SCDebounceWidget(
child: SizedBox(
height: 105.w,
child: Stack(
alignment: Alignment.center,
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(13.w),
border: Border.all(
color: _strategy.getExploreRoomBorderColor(),
width: _strategy.getExploreRoomBorderWidth().w,
),
),
margin: EdgeInsetsDirectional.symmetric(
horizontal: 10.w,
vertical: 3.w,
),
),
Row(
children: [
SizedBox(width: 20.w),
netImage(
url: resolveRoomCoverUrl(
res.roomProfile?.id,
res.roomProfile?.roomCover,
),
defaultImg: kRoomCoverDefaultImg,
fit: BoxFit.cover,
borderRadius: BorderRadius.all(Radius.circular(12.w)),
width: 85.w,
height: 85.w,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 15.w),
Row(
children: [
SizedBox(width: 8.w),
Consumer<SCAppGeneralManager>(
builder: (_, provider, __) {
return netImage(
url:
"${provider.findCountryByName(res.roomProfile?.countryName ?? "")?.nationalFlag}",
width: 25.w,
height: 15.w,
borderRadius: BorderRadius.all(
Radius.circular(3.w),
),
);
},
),
SizedBox(width: 5.w),
Container(
constraints: BoxConstraints(
maxHeight: 21.w,
maxWidth: 150.w,
),
child:
(res.roomProfile?.roomName?.length ?? 0) >
_strategy
.getExploreRoomNameMarqueeThreshold()
? Marquee(
text: res.roomProfile?.roomName ?? "",
style: TextStyle(
fontSize: 15.sp,
color: Colors.black,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
),
scrollAxis: Axis.horizontal,
crossAxisAlignment:
CrossAxisAlignment.start,
blankSpace: 20.0,
velocity: 40.0,
pauseAfterRound: Duration(seconds: 1),
accelerationDuration: Duration(seconds: 1),
accelerationCurve: Curves.easeOut,
decelerationDuration: Duration(
milliseconds: 500,
),
decelerationCurve: Curves.easeOut,
)
: Text(
res.roomProfile?.roomName ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 15.sp,
color: Colors.black,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
),
),
),
],
),
SizedBox(height: 3.w),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(width: 8.w),
text(
"ID:${res.roomProfile?.roomAccount}",
fontWeight: FontWeight.w600,
textColor: Colors.black,
fontSize: 15.sp,
),
],
),
SizedBox(height: 3.w),
Row(
children: [
SizedBox(width: 8.w),
Image.asset(
"sc_images/msg/sc_icon_message_activity.png",
height: 25.w,
width: 25.w,
),
SizedBox(width: 4.w),
Container(
constraints: BoxConstraints(
maxHeight: 21.w,
maxWidth: 170.w,
),
child:
(res.roomProfile?.roomDesc?.length ?? 0) >
_strategy
.getExploreRoomDescMarqueeThreshold()
? Marquee(
text: res.roomProfile?.roomDesc ?? "",
style: TextStyle(
fontSize: 15.sp,
color: Colors.black,
decoration: TextDecoration.none,
),
scrollAxis: Axis.horizontal,
crossAxisAlignment:
CrossAxisAlignment.start,
blankSpace: 20.0,
velocity: 40.0,
pauseAfterRound: Duration(seconds: 1),
accelerationDuration: Duration(seconds: 1),
accelerationCurve: Curves.easeOut,
decelerationDuration: Duration(
milliseconds: 500,
),
decelerationCurve: Curves.easeOut,
)
: Text(
res.roomProfile?.roomDesc ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 15.sp,
color: Colors.black,
decoration: TextDecoration.none,
),
),
),
],
),
],
),
],
),
],
),
),
onTap: () {
Provider.of<RtcProvider>(
context,
listen: false,
).joinVoiceRoomSession(context, res.roomProfile?.id ?? "");
},
);
}
@override
builderDivider() {
// return Divider(
// height: 1.w,
// color: Color(0xff3D3277).withOpacity(0.5),
// indent: 15.w,
// );
return Container(height: 8.w);
}
///
@override
loadPage({
required int page,
required Function(List<FollowRoomRes>) onSuccess,
Function? onErr,
}) async {
_loadOtherData();
if (page == 1) {
lastId = null;
}
try {
var roomList = await SCAccountRepository().followRoomList(lastId: lastId);
if (roomList.isNotEmpty) {
lastId = roomList.last.id;
}
onSuccess(roomList);
} catch (e) {
if (onErr != null) {
onErr();
}
}
}
String getRoomCoverHeaddress(FollowRoomRes roomRes) {
return "";
}
}

View File

@ -0,0 +1,293 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
const Duration _kHomeMineSkeletonAnimationDuration = Duration(
milliseconds: 1450,
);
const Color _kHomeMineSkeletonShell = Color(0xFF0F3730);
const Color _kHomeMineSkeletonShellStrong = Color(0xFF1A4A41);
const Color _kHomeMineSkeletonBoneBase = Color(0xFF2B5C53);
const Color _kHomeMineSkeletonBoneHighlight = Color(0xFF5F8177);
const Color _kHomeMineSkeletonBorder = Color(0x66D8B57B);
class SCHomeSkeletonShimmer extends StatefulWidget {
const SCHomeSkeletonShimmer({super.key, required this.builder});
final Widget Function(BuildContext context, double progress) builder;
@override
State<SCHomeSkeletonShimmer> createState() => _SCHomeSkeletonShimmerState();
}
class _SCHomeSkeletonShimmerState extends State<SCHomeSkeletonShimmer>
with SingleTickerProviderStateMixin {
late final AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: _kHomeMineSkeletonAnimationDuration,
)..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) => widget.builder(context, _controller.value),
);
}
}
BoxDecoration buildHomeSkeletonShellDecoration({
required double radius,
EdgeInsetsGeometry? padding,
}) {
return BoxDecoration(
borderRadius: BorderRadius.circular(radius),
border: Border.all(color: _kHomeMineSkeletonBorder, width: 1.w),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [_kHomeMineSkeletonShellStrong, _kHomeMineSkeletonShell],
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.16),
blurRadius: 16.w,
offset: Offset(0, 8.w),
),
],
);
}
Widget buildHomeSkeletonBlock(
double progress, {
double? width,
required double height,
BorderRadius? borderRadius,
BoxShape shape = BoxShape.rectangle,
}) {
final double slideOffset = (progress * 2) - 1;
return Container(
width: width,
height: height,
decoration: BoxDecoration(
shape: shape,
borderRadius:
shape == BoxShape.circle
? null
: (borderRadius ?? BorderRadius.circular(10.w)),
gradient: LinearGradient(
begin: Alignment(-1.4 + slideOffset, -0.2),
end: Alignment(1.4 + slideOffset, 0.2),
colors: const [
_kHomeMineSkeletonBoneBase,
_kHomeMineSkeletonBoneBase,
_kHomeMineSkeletonBoneHighlight,
_kHomeMineSkeletonBoneBase,
],
stops: const [0.0, 0.36, 0.54, 1.0],
),
),
);
}
Widget buildHomeMyRoomSkeleton(double progress) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 12.w),
width: double.infinity,
height: 85.w,
decoration: buildHomeSkeletonShellDecoration(radius: 16.w),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
child: Row(
children: [
buildHomeSkeletonBlock(
progress,
width: 70.w,
height: 70.w,
borderRadius: BorderRadius.circular(10.w),
),
SizedBox(width: 10.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
buildHomeSkeletonBlock(
progress,
width: 18.w,
height: 14.w,
borderRadius: BorderRadius.circular(3.w),
),
SizedBox(width: 5.w),
buildHomeSkeletonBlock(
progress,
width: 110.w,
height: 14.w,
borderRadius: BorderRadius.circular(999.w),
),
],
),
SizedBox(height: 9.w),
buildHomeSkeletonBlock(
progress,
width: 170.w,
height: 12.w,
borderRadius: BorderRadius.circular(999.w),
),
SizedBox(height: 8.w),
buildHomeSkeletonBlock(
progress,
width: 76.w,
height: 10.w,
borderRadius: BorderRadius.circular(999.w),
),
],
),
),
SizedBox(width: 10.w),
buildHomeSkeletonBlock(
progress,
width: 24.w,
height: 24.w,
shape: BoxShape.circle,
),
],
),
),
);
}
Widget buildHomeRoomGridSkeleton(
double progress, {
int itemCount = 6,
EdgeInsetsGeometry? padding,
}) {
return GridView.builder(
shrinkWrap: true,
padding: padding ?? EdgeInsets.symmetric(horizontal: 5.w),
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
itemCount: itemCount,
itemBuilder: (context, index) => buildHomeRoomCardSkeleton(progress),
);
}
Widget buildHomeRoomCardSkeleton(double progress) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14.w),
border: Border.all(color: _kHomeMineSkeletonBorder, width: 1.w),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.16),
blurRadius: 16.w,
offset: Offset(0, 8.w),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(14.w),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Positioned.fill(
child: DecoratedBox(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
_kHomeMineSkeletonShellStrong,
_kHomeMineSkeletonShell,
],
),
),
),
),
Positioned.fill(
child: Padding(
padding: EdgeInsets.only(bottom: 34.w),
child: buildHomeSkeletonBlock(
progress,
height: double.infinity,
borderRadius: BorderRadius.vertical(top: Radius.circular(14.w)),
),
),
),
Positioned(
top: 12.w,
right: 12.w,
child: buildHomeSkeletonBlock(
progress,
width: 30.w,
height: 12.w,
borderRadius: BorderRadius.circular(999.w),
),
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
height: 34.w,
padding: EdgeInsets.symmetric(horizontal: 10.w),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.24),
border: Border(
top: BorderSide(
color: Colors.white.withValues(alpha: 0.05),
width: 1.w,
),
),
),
child: Row(
children: [
buildHomeSkeletonBlock(
progress,
width: 20.w,
height: 13.w,
borderRadius: BorderRadius.circular(3.w),
),
SizedBox(width: 6.w),
Expanded(
child: buildHomeSkeletonBlock(
progress,
height: 10.w,
borderRadius: BorderRadius.circular(999.w),
),
),
SizedBox(width: 8.w),
buildHomeSkeletonBlock(
progress,
width: 18.w,
height: 10.w,
borderRadius: BorderRadius.circular(999.w),
),
],
),
),
),
],
),
),
);
}

View File

@ -1,9 +1,7 @@
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yumi/ui_kit/components/sc_debounce_widget.dart'; import 'package:yumi/ui_kit/components/sc_debounce_widget.dart';
import 'package:marquee/marquee.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../../../../app_localizations.dart'; import '../../../../app_localizations.dart';
@ -13,15 +11,25 @@ import '../../../../shared/tools/sc_banner_utils.dart';
import '../../../../shared/data_sources/sources/repositories/sc_room_repository_imp.dart'; import '../../../../shared/data_sources/sources/repositories/sc_room_repository_imp.dart';
import '../../../../shared/business_logic/models/res/follow_room_res.dart'; import '../../../../shared/business_logic/models/res/follow_room_res.dart';
import '../../../../shared/business_logic/models/res/room_res.dart'; import '../../../../shared/business_logic/models/res/room_res.dart';
import '../../../../services/general/sc_app_general_manager.dart';
import '../../../../services/audio/rtc_manager.dart'; import '../../../../services/audio/rtc_manager.dart';
import '../../../../services/general/sc_app_general_manager.dart';
import '../../../../ui_kit/components/sc_compontent.dart'; import '../../../../ui_kit/components/sc_compontent.dart';
import '../../../../ui_kit/components/text/sc_text.dart'; import '../../../../ui_kit/components/text/sc_text.dart';
import '../../../../ui_kit/widgets/room/room_live_audio_indicator.dart';
import '../../../index/main_route.dart'; import '../../../index/main_route.dart';
const Duration _kPartySkeletonAnimationDuration = Duration(milliseconds: 1450);
const Color _kPartySkeletonShell = Color(0xFF0F3730);
const Color _kPartySkeletonShellStrong = Color(0xFF1A4A41);
const Color _kPartySkeletonBoneBase = Color(0xFF2B5C53);
const Color _kPartySkeletonBoneHighlight = Color(0xFF5F8177);
const Color _kPartySkeletonBorder = Color(0x66D8B57B);
class SCHomePartyPage extends StatefulWidget { class SCHomePartyPage extends StatefulWidget {
const SCHomePartyPage({super.key});
@override @override
_HomePartyPageState createState() => _HomePartyPageState(); State<SCHomePartyPage> createState() => _HomePartyPageState();
} }
class _HomePartyPageState extends State<SCHomePartyPage> class _HomePartyPageState extends State<SCHomePartyPage>
@ -29,18 +37,31 @@ class _HomePartyPageState extends State<SCHomePartyPage>
List<FollowRoomRes> historyRooms = []; List<FollowRoomRes> historyRooms = [];
String? lastId; String? lastId;
bool isLoading = false; bool isLoading = false;
bool _isLeaderboardLoading = false;
final RefreshController _refreshController = RefreshController( final RefreshController _refreshController = RefreshController(
initialRefresh: false, initialRefresh: false,
); );
late final AnimationController _skeletonController;
List<SocialChatRoomRes> rooms = []; List<SocialChatRoomRes> rooms = [];
int _currentIndex = 0; int _currentIndex = 0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_skeletonController = AnimationController(
vsync: this,
duration: _kPartySkeletonAnimationDuration,
)..repeat();
loadData(); loadData();
} }
@override
void dispose() {
_skeletonController.dispose();
_refreshController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -73,41 +94,13 @@ class _HomePartyPageState extends State<SCHomePartyPage>
), ),
Consumer<SCAppGeneralManager>( Consumer<SCAppGeneralManager>(
builder: (context, ref, child) { builder: (context, ref, child) {
if (_shouldShowLeaderboardSkeleton(ref)) {
return _buildLeaderboardSkeleton();
}
return _banner2(ref); return _banner2(ref);
}, },
), ),
rooms.isEmpty _buildRoomsSection(),
? GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
loadData();
},
child:
isLoading
? Center(
child: CupertinoActivityIndicator(
color: Colors.white24,
),
)
: mainEmpty(
msg: SCAppLocalizations.of(context)!.noData,
),
)
: GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // 2
childAspectRatio: 1, //
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
padding: EdgeInsets.all(10),
itemCount: rooms!.length,
itemBuilder: (context, index) {
return _buildItem(rooms[index], index);
},
),
], ],
), ),
), ),
@ -153,7 +146,6 @@ class _HomePartyPageState extends State<SCHomePartyPage>
borderRadius: BorderRadius.circular(12.w), borderRadius: BorderRadius.circular(12.w),
), ),
onTap: () { onTap: () {
print('ads:${item.toJson()}');
SCBannerUtils.openBanner(item, context); SCBannerUtils.openBanner(item, context);
}, },
); );
@ -384,9 +376,303 @@ class _HomePartyPageState extends State<SCHomePartyPage>
); );
} }
Widget _buildRoomsSection() {
if (isLoading && rooms.isEmpty) {
return _buildRoomGridSkeleton();
}
if (rooms.isEmpty) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
loadData();
},
child: mainEmpty(msg: SCAppLocalizations.of(context)!.noData),
);
}
return GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
padding: EdgeInsets.all(10),
itemCount: rooms.length,
itemBuilder: (context, index) {
return _buildItem(rooms[index], index);
},
);
}
bool _shouldShowLeaderboardSkeleton(SCAppGeneralManager ref) {
return _isLeaderboardLoading && !_hasLeaderboardData(ref);
}
bool _hasLeaderboardData(SCAppGeneralManager ref) {
final appLeaderResult = ref.appLeaderResult;
return (appLeaderResult?.giftsSendLeaderboard?.weekly?.isNotEmpty ??
false) ||
(appLeaderResult?.roomGiftsLeaderboard?.weekly?.isNotEmpty ?? false) ||
(appLeaderResult?.giftsReceivedLeaderboard?.weekly?.isNotEmpty ??
false);
}
Widget _buildLeaderboardSkeleton() {
return SizedBox(
height: 130.w,
child: Row(
children: List.generate(3, (index) {
final bool isCenterCard = index == 1;
return Expanded(
child: Padding(
padding: EdgeInsets.fromLTRB(
4.w,
isCenterCard ? 0 : 6.w,
4.w,
isCenterCard ? 0 : 6.w,
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(18.w),
border: Border.all(color: _kPartySkeletonBorder, width: 1.w),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [_kPartySkeletonShellStrong, _kPartySkeletonShell],
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.18),
blurRadius: 14.w,
offset: Offset(0, 8.w),
),
],
),
child: Stack(
alignment: Alignment.center,
children: [
Positioned.fill(
child: Padding(
padding: EdgeInsets.all(1.w),
child: ClipRRect(
borderRadius: BorderRadius.circular(17.w),
child: Opacity(
opacity: 0.34,
child: _buildSkeletonPanel(),
),
),
),
),
Positioned(
top: 21.w,
child: _buildSkeletonBone(
width: isCenterCard ? 42.w : 38.w,
height: isCenterCard ? 42.w : 38.w,
shape: BoxShape.circle,
),
),
PositionedDirectional(
start: 16.w,
top: 56.w,
child: _buildSkeletonBone(
width: 28.w,
height: 28.w,
shape: BoxShape.circle,
),
),
PositionedDirectional(
end: 16.w,
top: 56.w,
child: _buildSkeletonBone(
width: 28.w,
height: 28.w,
shape: BoxShape.circle,
),
),
Positioned(
bottom: 16.w,
child: _buildSkeletonBone(
width: isCenterCard ? 56.w : 48.w,
height: 10.w,
borderRadius: BorderRadius.circular(999.w),
),
),
],
),
),
),
);
}),
),
);
}
Widget _buildRoomGridSkeleton() {
return GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
padding: EdgeInsets.all(10.w),
itemCount: 6,
itemBuilder: (context, index) => _buildRoomSkeletonCard(),
);
}
Widget _buildRoomSkeletonCard() {
return Container(
margin: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14.w),
border: Border.all(color: _kPartySkeletonBorder, width: 1.w),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.16),
blurRadius: 16.w,
offset: Offset(0, 8.w),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(14.w),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Positioned.fill(
child: DecoratedBox(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [_kPartySkeletonShellStrong, _kPartySkeletonShell],
),
),
),
),
Positioned.fill(
child: Padding(
padding: EdgeInsets.only(bottom: 34.w),
child: _buildSkeletonPanel(
borderRadius: BorderRadius.vertical(
top: Radius.circular(14.w),
),
),
),
),
Positioned(
top: 12.w,
right: 12.w,
child: _buildSkeletonBone(
width: 30.w,
height: 12.w,
borderRadius: BorderRadius.circular(999.w),
),
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
height: 34.w,
padding: EdgeInsets.symmetric(horizontal: 10.w),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.24),
border: Border(
top: BorderSide(
color: Colors.white.withValues(alpha: 0.05),
width: 1.w,
),
),
),
child: Row(
children: [
_buildSkeletonBone(
width: 20.w,
height: 13.w,
borderRadius: BorderRadius.circular(3.w),
),
SizedBox(width: 6.w),
Expanded(
child: _buildSkeletonBone(
height: 10.w,
borderRadius: BorderRadius.circular(999.w),
),
),
SizedBox(width: 8.w),
_buildSkeletonBone(
width: 18.w,
height: 10.w,
borderRadius: BorderRadius.circular(999.w),
),
],
),
),
),
],
),
),
);
}
Widget _buildSkeletonPanel({
BorderRadius? borderRadius,
BoxShape shape = BoxShape.rectangle,
}) {
return AnimatedBuilder(
animation: _skeletonController,
builder: (context, child) {
final double slideOffset = (_skeletonController.value * 2) - 1;
return DecoratedBox(
decoration: BoxDecoration(
shape: shape,
borderRadius:
shape == BoxShape.circle
? null
: (borderRadius ?? BorderRadius.circular(12.w)),
gradient: LinearGradient(
begin: Alignment(-1.4 + slideOffset, -0.2),
end: Alignment(1.4 + slideOffset, 0.2),
colors: const [
_kPartySkeletonBoneBase,
_kPartySkeletonBoneBase,
_kPartySkeletonBoneHighlight,
_kPartySkeletonBoneBase,
],
stops: const [0.0, 0.36, 0.54, 1.0],
),
),
);
},
);
}
Widget _buildSkeletonBone({
double? width,
double? height,
BorderRadius? borderRadius,
BoxShape shape = BoxShape.rectangle,
}) {
return SizedBox(
width: width,
height: height,
child: _buildSkeletonPanel(borderRadius: borderRadius, shape: shape),
);
}
loadData() { loadData() {
final generalManager = Provider.of<SCAppGeneralManager>(
context,
listen: false,
);
setState(() { setState(() {
isLoading = true; isLoading = true;
_isLeaderboardLoading = generalManager.appLeaderResult == null;
}); });
SCChatRoomRepository() SCChatRoomRepository()
.discovery(allRegion: true) .discovery(allRegion: true)
@ -403,8 +689,15 @@ class _HomePartyPageState extends State<SCHomePartyPage>
isLoading = false; isLoading = false;
if (mounted) setState(() {}); if (mounted) setState(() {});
}); });
Provider.of<SCAppGeneralManager>(context, listen: false).loadMainBanner(); generalManager.loadMainBanner();
Provider.of<SCAppGeneralManager>(context, listen: false).appLeaderboard(); generalManager.appLeaderboard().whenComplete(() {
if (!mounted) {
return;
}
setState(() {
_isLeaderboardLoading = false;
});
});
} }
_buildItem(SocialChatRoomRes res, int index) { _buildItem(SocialChatRoomRes res, int index) {
@ -462,12 +755,19 @@ class _HomePartyPageState extends State<SCHomePartyPage>
SizedBox(width: 5.w), SizedBox(width: 5.w),
Expanded( Expanded(
child: SizedBox( child: SizedBox(
height: 21.w, height: 17.w,
child: text( child: Align(
res.roomName ?? "", alignment: Alignment.centerLeft,
fontSize: 15.sp, child: Transform.translate(
textColor: Color(0xffffffff), offset: Offset(0, -0.6.w),
fontWeight: FontWeight.w400, child: text(
res.roomName ?? "",
fontSize: 13.sp,
textColor: Color(0xffffffff),
fontWeight: FontWeight.w400,
lineHeight: 1,
),
),
), ),
// (roomRes.roomProfile?.roomName?.length ?? 0) > 10 // (roomRes.roomProfile?.roomName?.length ?? 0) > 10
// ? Marquee( // ? Marquee(
@ -505,11 +805,7 @@ class _HomePartyPageState extends State<SCHomePartyPage>
), ),
SizedBox(width: 5.w), SizedBox(width: 5.w),
(res.extValues?.roomSetting?.password?.isEmpty ?? false) (res.extValues?.roomSetting?.password?.isEmpty ?? false)
? Image.asset( ? SCRoomLiveAudioIndicator(width: 14.w, height: 14.w)
"sc_images/general/sc_icon_online_user.png",
width: 14.w,
height: 14.w,
)
: Image.asset( : Image.asset(
"sc_images/index/sc_icon_room_suo.png", "sc_images/index/sc_icon_room_suo.png",
width: 20.w, width: 20.w,
@ -521,7 +817,8 @@ class _HomePartyPageState extends State<SCHomePartyPage>
(res.extValues?.roomSetting?.password?.isEmpty ?? false) (res.extValues?.roomSetting?.password?.isEmpty ?? false)
? text( ? text(
res.extValues?.memberQuantity ?? "0", res.extValues?.memberQuantity ?? "0",
fontSize: 12.sp, fontSize: 10.sp,
lineHeight: 1,
) )
: Container(height: 10.w), : Container(height: 10.w),
SizedBox(width: 10.w), SizedBox(width: 10.w),

View File

@ -96,25 +96,34 @@ class _SCIndexPageState extends State<SCIndexPage> {
fit: BoxFit.fill, fit: BoxFit.fill,
), ),
), ),
child: BottomNavigationBar( child: Theme(
elevation: 0, data: Theme.of(context).copyWith(
backgroundColor: Colors.transparent, splashFactory: NoSplash.splashFactory,
selectedLabelStyle: TextStyle( splashColor: Colors.transparent,
fontWeight: FontWeight.w600, highlightColor: Colors.transparent,
fontSize: 14.sp, hoverColor: Colors.transparent,
), ),
unselectedLabelStyle: TextStyle( child: BottomNavigationBar(
fontWeight: FontWeight.w500, elevation: 0,
fontSize: 13.sp, enableFeedback: false,
backgroundColor: Colors.transparent,
selectedLabelStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14.sp,
),
unselectedLabelStyle: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 13.sp,
),
type: BottomNavigationBarType.fixed,
selectedItemColor: Color(0xffBF854A),
unselectedItemColor: Color(0xffC4C4C4),
showUnselectedLabels: true,
showSelectedLabels: true,
items: _bottomItems,
currentIndex: _currentIndex,
onTap: (index) => setState(() => _currentIndex = index),
), ),
type: BottomNavigationBarType.fixed,
selectedItemColor: Color(0xffBF854A),
unselectedItemColor: Color(0xffC4C4C4),
showUnselectedLabels: true,
showSelectedLabels: true,
items: _bottomItems,
currentIndex: _currentIndex,
onTap: (index) => setState(() => _currentIndex = index),
), ),
), ),
), ),

View File

@ -29,6 +29,7 @@ import '../../ui_kit/components/sc_compontent.dart';
import '../../ui_kit/components/sc_debounce_widget.dart'; import '../../ui_kit/components/sc_debounce_widget.dart';
import '../../ui_kit/components/sc_page_list.dart'; import '../../ui_kit/components/sc_page_list.dart';
import '../../ui_kit/components/text/sc_text.dart'; import '../../ui_kit/components/text/sc_text.dart';
import '../../ui_kit/widgets/room/room_live_audio_indicator.dart';
/// ///
class SearchPage extends SCPageList { class SearchPage extends SCPageList {
@ -485,12 +486,19 @@ class _SearchRoomListState extends State<SearchRoomList> {
SizedBox(width: 5.w), SizedBox(width: 5.w),
Expanded( Expanded(
child: SizedBox( child: SizedBox(
height: 21.w, height: 17.w,
child: text( child: Align(
e.roomName ?? "", alignment: Alignment.centerLeft,
fontSize: 15.sp, child: Transform.translate(
textColor: Color(0xffffffff), offset: Offset(0, -0.6.w),
fontWeight: FontWeight.w400, child: text(
e.roomName ?? "",
fontSize: 13.sp,
textColor: Color(0xffffffff),
fontWeight: FontWeight.w400,
lineHeight: 1,
),
),
), ),
// (roomRes.roomProfile?.roomName?.length ?? 0) > 10 // (roomRes.roomProfile?.roomName?.length ?? 0) > 10
@ -529,11 +537,7 @@ class _SearchRoomListState extends State<SearchRoomList> {
), ),
SizedBox(width: 5.w), SizedBox(width: 5.w),
(e.extValues?.roomSetting?.password?.isEmpty ?? false) (e.extValues?.roomSetting?.password?.isEmpty ?? false)
? Image.asset( ? SCRoomLiveAudioIndicator(width: 14.w, height: 14.w)
"sc_images/general/sc_icon_online_user.png",
width: 14.w,
height: 14.w,
)
: Image.asset( : Image.asset(
"sc_images/index/sc_icon_room_suo.png", "sc_images/index/sc_icon_room_suo.png",
width: 20.w, width: 20.w,
@ -543,7 +547,11 @@ class _SearchRoomListState extends State<SearchRoomList> {
? SizedBox(width: 3.w) ? SizedBox(width: 3.w)
: Container(height: 10.w), : Container(height: 10.w),
(e.extValues?.roomSetting?.password?.isEmpty ?? false) (e.extValues?.roomSetting?.password?.isEmpty ?? false)
? text(e.extValues?.memberQuantity ?? "0", fontSize: 12.sp) ? text(
e.extValues?.memberQuantity ?? "0",
fontSize: 10.sp,
lineHeight: 1,
)
: Container(height: 10.w), : Container(height: 10.w),
SizedBox(width: 10.w), SizedBox(width: 10.w),
], ],

View File

@ -1,243 +1,240 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/ui_kit/components/sc_tts.dart'; import 'package:provider/provider.dart';
import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:provider/provider.dart'; import 'package:yumi/ui_kit/components/sc_page_list.dart';
import 'package:yumi/shared/tools/sc_loading_manager.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/shared/tools/sc_loading_manager.dart'; import 'package:yumi/shared/business_logic/models/res/store_list_res.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart'; import 'package:yumi/services/auth/user_profile_manager.dart';
import 'package:yumi/shared/business_logic/models/res/store_list_res.dart'; import 'package:yumi/ui_kit/widgets/store/props_store_chatbox_detail_dialog.dart';
import 'package:yumi/services/auth/user_profile_manager.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import 'package:yumi/ui_kit/widgets/store/props_store_chatbox_detail_dialog.dart';
import '../../../shared/data_sources/models/enum/sc_currency_type.dart';
import '../../../shared/data_sources/models/enum/sc_currency_type.dart'; import '../../../shared/data_sources/models/enum/sc_props_type.dart';
import '../../../shared/data_sources/models/enum/sc_props_type.dart';
///
/// class StoreChatboxPage extends SCPageList {
class StoreChatboxPage extends SCPageList { @override
@override _StoreChatboxPageState createState() => _StoreChatboxPageState();
_StoreChatboxPageState createState() => _StoreChatboxPageState(); }
}
class _StoreChatboxPageState
class _StoreChatboxPageState extends SCPageListState<StoreListResBean, StoreChatboxPage> {
extends SCPageListState<StoreListResBean, StoreChatboxPage> { //
// double disCount = 1;
double disCount = 1;
@override
@override void initState() {
void initState() { super.initState();
super.initState(); enablePullUp = false;
enablePullUp = false; isGridView = true;
isGridView = true; gridViewCount = 3;
gridViewCount = 3; padding = EdgeInsets.symmetric(horizontal: 6.w);
padding = EdgeInsets.symmetric(horizontal: 6.w); backgroundColor = Colors.transparent;
backgroundColor = Colors.transparent; gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: gridViewCount,
crossAxisCount: gridViewCount, mainAxisSpacing: 12.w,
mainAxisSpacing: 12.w, crossAxisSpacing: 12.w,
crossAxisSpacing: 12.w, childAspectRatio: 0.78,
childAspectRatio: 0.78, );
); loadData(1);
loadData(1); }
}
@override
@override Widget build(BuildContext context) {
Widget build(BuildContext context) { return Scaffold(
return Scaffold( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, body:
body: buildList(context), items.isEmpty && isLoading
); ? const SCStoreGridSkeleton()
} : buildList(context),
);
@override }
Widget buildItem(StoreListResBean res) {
return GestureDetector( @override
child: Container( Widget buildItem(StoreListResBean res) {
decoration: BoxDecoration( return GestureDetector(
color: child: Container(
res.isSelecte decoration: BoxDecoration(
? Color(0xff18F2B1).withOpacity(0.1) color:
: SCGlobalConfig.businessLogicStrategy res.isSelecte
.getStoreItemBackgroundColor(), ? const Color(0xff18F2B1).withValues(alpha: 0.1)
border: Border.all( : SCGlobalConfig.businessLogicStrategy
color: .getStoreItemBackgroundColor(),
res.isSelecte border: Border.all(
? SCGlobalConfig.businessLogicStrategy color:
.getStoreItemSelectedBorderColor() res.isSelecte
: SCGlobalConfig.businessLogicStrategy ? SCGlobalConfig.businessLogicStrategy
.getStoreItemUnselectedBorderColor(), .getStoreItemSelectedBorderColor()
width: 1.w, : SCGlobalConfig.businessLogicStrategy
), .getStoreItemUnselectedBorderColor(),
borderRadius: BorderRadius.all(Radius.circular(8.w)), width: 1.w,
), ),
child: Stack( borderRadius: BorderRadius.all(Radius.circular(8.w)),
children: [ ),
Column( child: Stack(
children: [ children: [
SizedBox(height: 10.w), Column(
netImage( children: [
url: res.res.propsResources?.cover ?? "", SizedBox(height: 10.w),
height: 45.w, netImage(
fit: BoxFit.contain, url: res.res.propsResources?.cover ?? "",
), height: 45.w,
SizedBox(height: 3.w), fit: BoxFit.contain,
Row( ),
mainAxisSize: MainAxisSize.min, SizedBox(height: 3.w),
children: [ buildStoreBagItemTitle(
text( res.res.propsResources?.name ?? "",
res.res.propsResources?.name ?? "", textColor: Colors.white,
textColor: Colors.white, fontSize: 11.sp,
fontSize: 11.sp, ),
), SizedBox(height: 3.w),
], Row(
), mainAxisSize: MainAxisSize.min,
SizedBox(height: 3.w), children: [
Row( SizedBox(width: 10.w),
mainAxisSize: MainAxisSize.min, Expanded(
children: [ child: Text.rich(
SizedBox(width: 10.w), textAlign: TextAlign.center,
Expanded( TextSpan(
child: Text.rich( children: [
textAlign: TextAlign.center, WidgetSpan(
TextSpan( alignment: PlaceholderAlignment.middle,
children: [ child: Image.asset(
WidgetSpan( SCGlobalConfig.businessLogicStrategy
alignment: PlaceholderAlignment.middle, .getStoreItemGoldIcon(),
child: Image.asset( width: 22.w,
SCGlobalConfig.businessLogicStrategy ),
.getStoreItemGoldIcon(), ),
width: 22.w, TextSpan(text: " "),
), disCount < 1
), ? TextSpan(
TextSpan(text: " "), text: "${res.res.propsPrices![0].amount}",
disCount < 1 style: TextStyle(
? TextSpan( fontSize: 12.sp,
text: "${res.res.propsPrices![0].amount}", color:
style: TextStyle( SCGlobalConfig.businessLogicStrategy
fontSize: 12.sp, .getStoreItemPriceTextColor(),
color: fontWeight: FontWeight.w600,
SCGlobalConfig.businessLogicStrategy decoration: TextDecoration.lineThrough,
.getStoreItemPriceTextColor(), ),
fontWeight: FontWeight.w600, )
decoration: TextDecoration.lineThrough, : TextSpan(),
), disCount < 1 ? TextSpan(text: " ") : TextSpan(),
) TextSpan(
: TextSpan(), text:
disCount < 1 ? TextSpan(text: " ") : TextSpan(), "${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}",
TextSpan( style: TextStyle(
text: fontSize: 12.sp,
"${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}", color:
style: TextStyle( SCGlobalConfig.businessLogicStrategy
fontSize: 12.sp, .getStoreItemPriceTextColor(),
color: fontWeight: FontWeight.w600,
SCGlobalConfig.businessLogicStrategy ),
.getStoreItemPriceTextColor(), ),
fontWeight: FontWeight.w600, ],
), ),
), strutStyle: StrutStyle(
], height: 1.3, //
), fontWeight: FontWeight.w500,
strutStyle: StrutStyle( forceStrutHeight: true, //
height: 1.3, // ),
fontWeight: FontWeight.w500, ),
forceStrutHeight: true, // ),
), SizedBox(width: 10.w),
), ],
), ),
SizedBox(width: 10.w), ],
], ),
), ],
], ),
), ),
], onTap: () {
), _selectItem(res);
), _showDetail(res.res);
onTap: () { },
_selectItem(res); );
_showDetail(res.res); }
},
); ///
} @override
loadPage({
/// required int page,
@override required Function(List<StoreListResBean>) onSuccess,
loadPage({ Function? onErr,
required int page, }) async {
required Function(List<StoreListResBean>) onSuccess, try {
Function? onErr, List<StoreListResBean> beans = [];
}) async { var storeList = await SCStoreRepositoryImp().storeList(
try { SCCurrencyType.GOLD.name,
List<StoreListResBean> beans = []; SCPropsType.CHAT_BUBBLE.name,
var storeList = await SCStoreRepositoryImp().storeList( );
SCCurrencyType.GOLD.name, for (var value in storeList) {
SCPropsType.CHAT_BUBBLE.name, beans.add(StoreListResBean(value, false));
); }
for (var value in storeList) { onSuccess(beans);
beans.add(StoreListResBean(value, false)); } catch (e) {
} if (onErr != null) {
onSuccess(beans); onErr();
} catch (e) { }
if (onErr != null) { }
onErr(); }
}
} void _showDetail(StoreListRes res) {
} SmartDialog.show(
tag: "showPropsDetail",
void _showDetail(StoreListRes res) { alignment: Alignment.bottomCenter,
SmartDialog.show( animationType: SmartAnimationType.fade,
tag: "showPropsDetail", builder: (_) {
alignment: Alignment.bottomCenter, return PropsStoreChatboxDetailDialog(res, disCount);
animationType: SmartAnimationType.fade, },
builder: (_) { );
return PropsStoreChatboxDetailDialog(res,disCount,); }
},
); void _selectItem(StoreListResBean res) {
} for (var value in items) {
value.isSelecte = false;
void _selectItem(StoreListResBean res) { }
for (var value in items) { res.isSelecte = true;
value.isSelecte = false; setState(() {});
} }
res.isSelecte = true;
setState(() {}); void _buy(StoreListResBean res) {
} if (res.res.propsPrices!.isEmpty) {
return;
void _buy(StoreListResBean res) { }
if (res.res.propsPrices!.isEmpty) { SCLoadingManager.show();
return; num days = res.res.propsPrices![0].days ?? 0;
} SCStoreRepositoryImp()
SCLoadingManager.show(); .storePurchasing(
num days = res.res.propsPrices![0].days ?? 0; res.res.id ?? "",
SCStoreRepositoryImp() SCPropsType.CHAT_BUBBLE.name,
.storePurchasing( SCCurrencyType.GOLD.name,
res.res.id ?? "", "$days",
SCPropsType.CHAT_BUBBLE.name, )
SCCurrencyType.GOLD.name, .then((value) {
"$days", SCTts.show(SCAppLocalizations.of(context)!.purchaseIsSuccessful);
) Provider.of<SocialChatUserProfileManager>(
.then((value) { context,
SCTts.show(SCAppLocalizations.of(context)!.purchaseIsSuccessful); listen: false,
Provider.of<SocialChatUserProfileManager>( ).updateBalance(value);
context, SCLoadingManager.hide();
listen: false, })
).updateBalance(value); .catchError((e) {
SCLoadingManager.hide(); SCLoadingManager.hide();
}) });
.catchError((e) { }
SCLoadingManager.hide(); }
});
} class StoreListResBean {
} StoreListRes res;
bool isSelecte = false;
class StoreListResBean {
StoreListRes res; StoreListResBean(this.res, this.isSelecte);
bool isSelecte = false; }
StoreListResBean(this.res, this.isSelecte);
}

View File

@ -1,244 +1,239 @@
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:yumi/app_localizations.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/shared/tools/sc_loading_manager.dart';
import 'package:yumi/ui_kit/components/sc_tts.dart'; import 'package:provider/provider.dart';
import 'package:yumi/app/constants/sc_global_config.dart'; import 'package:yumi/ui_kit/components/sc_page_list.dart';
import 'package:yumi/shared/tools/sc_loading_manager.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:provider/provider.dart'; import 'package:yumi/shared/business_logic/models/res/store_list_res.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import 'package:yumi/services/auth/user_profile_manager.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart'; import 'package:yumi/ui_kit/widgets/store/props_store_headdress_detail_dialog.dart';
import 'package:yumi/shared/business_logic/models/res/store_list_res.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import 'package:yumi/services/auth/user_profile_manager.dart';
import 'package:yumi/ui_kit/widgets/store/props_store_headdress_detail_dialog.dart'; import '../../../shared/data_sources/models/enum/sc_currency_type.dart';
import '../../../shared/data_sources/models/enum/sc_props_type.dart';
import '../../../shared/data_sources/models/enum/sc_currency_type.dart';
import '../../../shared/data_sources/models/enum/sc_props_type.dart'; ///
class StoreHeaddressPage extends SCPageList {
/// @override
class StoreHeaddressPage extends SCPageList { _StoreHeaddressPageState createState() => _StoreHeaddressPageState();
@override }
_StoreHeaddressPageState createState() => _StoreHeaddressPageState();
} class _StoreHeaddressPageState
extends SCPageListState<StoreListResBean, StoreHeaddressPage> {
class _StoreHeaddressPageState //
extends SCPageListState<StoreListResBean, StoreHeaddressPage> { double disCount = 1;
//
double disCount = 1; @override
void initState() {
@override super.initState();
void initState() { enablePullUp = false;
super.initState(); isGridView = true;
enablePullUp = false; gridViewCount = 3;
isGridView = true; padding = EdgeInsets.symmetric(horizontal: 6.w);
gridViewCount = 3; backgroundColor = Colors.transparent;
padding = EdgeInsets.symmetric(horizontal: 6.w); gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
backgroundColor = Colors.transparent; crossAxisCount: gridViewCount,
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( mainAxisSpacing: 12.w,
crossAxisCount: gridViewCount, crossAxisSpacing: 12.w,
mainAxisSpacing: 12.w, childAspectRatio: 0.78,
crossAxisSpacing: 12.w, );
childAspectRatio: 0.78, loadData(1);
); }
loadData(1);
} @override
Widget build(BuildContext context) {
@override return Scaffold(
Widget build(BuildContext context) { backgroundColor: Colors.transparent,
return Scaffold( body:
backgroundColor: Colors.transparent, items.isEmpty && isLoading
body: buildList(context), ? const SCStoreGridSkeleton()
); : buildList(context),
} );
}
@override
Widget buildItem(StoreListResBean res) { @override
return GestureDetector( Widget buildItem(StoreListResBean res) {
child: Container( return GestureDetector(
decoration: BoxDecoration( child: Container(
color: decoration: BoxDecoration(
res.isSelecte color:
? Color(0xff18F2B1).withOpacity(0.1) res.isSelecte
: SCGlobalConfig.businessLogicStrategy ? const Color(0xff18F2B1).withValues(alpha: 0.1)
.getStoreItemBackgroundColor(), : SCGlobalConfig.businessLogicStrategy
border: Border.all( .getStoreItemBackgroundColor(),
color: border: Border.all(
res.isSelecte color:
? SCGlobalConfig.businessLogicStrategy res.isSelecte
.getStoreItemSelectedBorderColor() ? SCGlobalConfig.businessLogicStrategy
: SCGlobalConfig.businessLogicStrategy .getStoreItemSelectedBorderColor()
.getStoreItemUnselectedBorderColor(), : SCGlobalConfig.businessLogicStrategy
width: 1.w, .getStoreItemUnselectedBorderColor(),
), width: 1.w,
borderRadius: BorderRadius.all(Radius.circular(8.w)), ),
), borderRadius: BorderRadius.all(Radius.circular(8.w)),
child: Stack( ),
children: [ child: Stack(
Column( children: [
children: [ Column(
SizedBox(height: 10.w), children: [
netImage( SizedBox(height: 10.w),
url: res.res.propsResources?.cover ?? "", netImage(
width: 55.w, url: res.res.propsResources?.cover ?? "",
height: 55.w, width: 55.w,
), height: 55.w,
SizedBox(height: 3.w), ),
Row( SizedBox(height: 3.w),
mainAxisSize: MainAxisSize.min, buildStoreBagItemTitle(
children: [ res.res.propsResources?.name ?? "",
text( textColor: Colors.white,
res.res.propsResources?.name ?? "", fontSize: 11.sp,
textColor: Colors.white, ),
fontSize: 11.sp, SizedBox(height: 3.w),
), Row(
], mainAxisSize: MainAxisSize.min,
), children: [
SizedBox(height: 3.w), SizedBox(width: 10.w),
Row( Expanded(
mainAxisSize: MainAxisSize.min, child: Text.rich(
children: [ textAlign: TextAlign.center,
SizedBox(width: 10.w), TextSpan(
Expanded( children: [
child: Text.rich( WidgetSpan(
textAlign: TextAlign.center, alignment: PlaceholderAlignment.middle,
TextSpan( child: Image.asset(
children: [ SCGlobalConfig.businessLogicStrategy
WidgetSpan( .getStoreItemGoldIcon(),
alignment: PlaceholderAlignment.middle, width: 22.w,
child: Image.asset( ),
SCGlobalConfig.businessLogicStrategy ),
.getStoreItemGoldIcon(), TextSpan(text: " "),
width: 22.w, disCount < 1
), ? TextSpan(
), text: "${res.res.propsPrices![0].amount}",
TextSpan(text: " "), style: TextStyle(
disCount < 1 fontSize: 12.sp,
? TextSpan( color:
text: "${res.res.propsPrices![0].amount}", SCGlobalConfig.businessLogicStrategy
style: TextStyle( .getStoreItemPriceTextColor(),
fontSize: 12.sp, fontWeight: FontWeight.w600,
color: decoration: TextDecoration.lineThrough,
SCGlobalConfig.businessLogicStrategy ),
.getStoreItemPriceTextColor(), )
fontWeight: FontWeight.w600, : TextSpan(),
decoration: TextDecoration.lineThrough, disCount < 1 ? TextSpan(text: " ") : TextSpan(),
), TextSpan(
) text:
: TextSpan(), "${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}",
disCount < 1 ? TextSpan(text: " ") : TextSpan(), style: TextStyle(
TextSpan( fontSize: 12.sp,
text: color:
"${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}", SCGlobalConfig.businessLogicStrategy
style: TextStyle( .getStoreItemPriceTextColor(),
fontSize: 12.sp, fontWeight: FontWeight.w600,
color: ),
SCGlobalConfig.businessLogicStrategy ),
.getStoreItemPriceTextColor(), ],
fontWeight: FontWeight.w600, ),
), strutStyle: StrutStyle(
), height: 1.3, //
], fontWeight: FontWeight.w500,
), forceStrutHeight: true, //
strutStyle: StrutStyle( ),
height: 1.3, // ),
fontWeight: FontWeight.w500, ),
forceStrutHeight: true, // SizedBox(width: 10.w),
), ],
), ),
), ],
SizedBox(width: 10.w), ),
], ],
), ),
], ),
), onTap: () {
], _selectItem(res);
), _showDetail(res.res);
), },
onTap: () { );
_selectItem(res); }
_showDetail(res.res);
///
}, @override
); loadPage({
} required int page,
required Function(List<StoreListResBean>) onSuccess,
/// Function? onErr,
@override }) async {
loadPage({ try {
required int page, List<StoreListResBean> beans = [];
required Function(List<StoreListResBean>) onSuccess, var storeList = await SCStoreRepositoryImp().storeList(
Function? onErr, SCCurrencyType.GOLD.name,
}) async { SCPropsType.AVATAR_FRAME.name,
try { );
List<StoreListResBean> beans = []; for (var value in storeList) {
var storeList = await SCStoreRepositoryImp().storeList( beans.add(StoreListResBean(value, false));
SCCurrencyType.GOLD.name, }
SCPropsType.AVATAR_FRAME.name, onSuccess(beans);
); } catch (e) {
for (var value in storeList) { if (onErr != null) {
beans.add(StoreListResBean(value, false)); onErr();
} }
onSuccess(beans); }
} catch (e) { }
if (onErr != null) {
onErr(); void _showDetail(StoreListRes res) {
} SmartDialog.show(
} tag: "showPropsDetail",
} alignment: Alignment.bottomCenter,
animationType: SmartAnimationType.fade,
void _showDetail(StoreListRes res) { builder: (_) {
SmartDialog.show( return PropsStoreHeaddressDetailDialog(res, disCount);
tag: "showPropsDetail", },
alignment: Alignment.bottomCenter, );
animationType: SmartAnimationType.fade, }
builder: (_) {
return PropsStoreHeaddressDetailDialog(res, disCount); void _selectItem(StoreListResBean res) {
}, for (var value in items) {
); value.isSelecte = false;
} }
res.isSelecte = true;
void _selectItem(StoreListResBean res) { setState(() {});
for (var value in items) { }
value.isSelecte = false;
} void _buy(StoreListResBean res) {
res.isSelecte = true; if (res.res.propsPrices!.isEmpty) {
setState(() {}); return;
} }
SCLoadingManager.show();
void _buy(StoreListResBean res) { num days = res.res.propsPrices![0].days ?? 0;
if (res.res.propsPrices!.isEmpty) { SCStoreRepositoryImp()
return; .storePurchasing(
} res.res.id ?? "",
SCLoadingManager.show(); SCPropsType.AVATAR_FRAME.name,
num days = res.res.propsPrices![0].days ?? 0; SCCurrencyType.GOLD.name,
SCStoreRepositoryImp() "$days",
.storePurchasing( )
res.res.id ?? "", .then((value) {
SCPropsType.AVATAR_FRAME.name, SCTts.show(SCAppLocalizations.of(context)!.purchaseIsSuccessful);
SCCurrencyType.GOLD.name, Provider.of<SocialChatUserProfileManager>(
"$days", context,
) listen: false,
.then((value) { ).updateBalance(value);
SCTts.show(SCAppLocalizations.of(context)!.purchaseIsSuccessful); SCLoadingManager.hide();
Provider.of<SocialChatUserProfileManager>( })
context, .catchError((e) {
listen: false, SCLoadingManager.hide();
).updateBalance(value); });
SCLoadingManager.hide(); }
}) }
.catchError((e) {
SCLoadingManager.hide(); class StoreListResBean {
}); StoreListRes res;
} bool isSelecte = false;
}
StoreListResBean(this.res, this.isSelecte);
class StoreListResBean { }
StoreListRes res;
bool isSelecte = false;
StoreListResBean(this.res, this.isSelecte);
}

View File

@ -1,210 +1,210 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/ui_kit/components/sc_debounce_widget.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_page_list.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/shared/business_logic/models/res/store_list_res.dart';
import 'package:yumi/app/constants/sc_global_config.dart'; import 'package:yumi/ui_kit/widgets/store/props_store_mountains_detail_dialog.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import 'package:yumi/shared/business_logic/models/res/store_list_res.dart'; import 'package:yumi/modules/store/headdress/store_headdress_page.dart';
import 'package:yumi/ui_kit/widgets/store/props_store_mountains_detail_dialog.dart';
import 'package:yumi/modules/store/headdress/store_headdress_page.dart'; import '../../../shared/data_sources/models/enum/sc_currency_type.dart';
import '../../../shared/data_sources/models/enum/sc_props_type.dart';
import '../../../shared/data_sources/models/enum/sc_currency_type.dart';
import '../../../shared/data_sources/models/enum/sc_props_type.dart'; ///
class StoreMountainsPage extends SCPageList {
/// StoreMountainsPage();
class StoreMountainsPage extends SCPageList {
StoreMountainsPage(); @override
_StoreMountainsPageState createState() => _StoreMountainsPageState();
@override }
_StoreMountainsPageState createState() => _StoreMountainsPageState();
} class _StoreMountainsPageState
extends SCPageListState<StoreListResBean, StoreMountainsPage> {
class _StoreMountainsPageState //
extends SCPageListState<StoreListResBean, StoreMountainsPage> { double disCount = 1;
//
double disCount = 1; @override
void initState() {
@override super.initState();
void initState() { enablePullUp = false;
super.initState(); isGridView = true;
enablePullUp = false; gridViewCount = 3;
isGridView = true; padding = EdgeInsets.symmetric(horizontal: 6.w);
gridViewCount = 3; backgroundColor = Colors.transparent;
padding = EdgeInsets.symmetric(horizontal: 6.w); gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
backgroundColor = Colors.transparent; crossAxisCount: gridViewCount,
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( mainAxisSpacing: 12.w,
crossAxisCount: gridViewCount, crossAxisSpacing: 12.w,
mainAxisSpacing: 12.w, childAspectRatio: 0.78,
crossAxisSpacing: 12.w, );
childAspectRatio: 0.78, loadData(1);
); }
loadData(1);
} @override
void dispose() {
@override super.dispose();
void dispose() { }
super.dispose();
} @override
Widget build(BuildContext context) {
@override return Scaffold(
Widget build(BuildContext context) { backgroundColor: Colors.transparent,
return Scaffold( body:
backgroundColor: Colors.transparent, items.isEmpty && isLoading
body: buildList(context), ? const SCStoreGridSkeleton()
); : buildList(context),
} );
}
@override
Widget buildItem(StoreListResBean res) { @override
return GestureDetector( Widget buildItem(StoreListResBean res) {
child: Container( return GestureDetector(
decoration: BoxDecoration( child: Container(
color: decoration: BoxDecoration(
res.isSelecte color:
? Color(0xff18F2B1).withOpacity(0.1) res.isSelecte
: SCGlobalConfig.businessLogicStrategy ? const Color(0xff18F2B1).withValues(alpha: 0.1)
.getStoreItemBackgroundColor(), : SCGlobalConfig.businessLogicStrategy
border: Border.all( .getStoreItemBackgroundColor(),
color: border: Border.all(
res.isSelecte color:
? SCGlobalConfig.businessLogicStrategy res.isSelecte
.getStoreItemSelectedBorderColor() ? SCGlobalConfig.businessLogicStrategy
: SCGlobalConfig.businessLogicStrategy .getStoreItemSelectedBorderColor()
.getStoreItemUnselectedBorderColor(), : SCGlobalConfig.businessLogicStrategy
width: 1.w, .getStoreItemUnselectedBorderColor(),
), width: 1.w,
borderRadius: BorderRadius.all(Radius.circular(8.w)), ),
), borderRadius: BorderRadius.all(Radius.circular(8.w)),
child: Stack( ),
children: [ child: Stack(
Column( children: [
children: [ Column(
SizedBox(height: 10.w), children: [
netImage( SizedBox(height: 10.w),
url: res.res.propsResources?.cover ?? "", netImage(
width: 55.w, url: res.res.propsResources?.cover ?? "",
height: 55.w, width: 55.w,
), height: 55.w,
SizedBox(height: 3.w), ),
Row( SizedBox(height: 3.w),
mainAxisSize: MainAxisSize.min, buildStoreBagItemTitle(
children: [ res.res.propsResources?.name ?? "",
text( textColor: Colors.white,
res.res.propsResources?.name ?? "", fontSize: 11.sp,
textColor: Colors.white, ),
fontSize: 11.sp, SizedBox(height: 3.w),
), Row(
], mainAxisSize: MainAxisSize.min,
), children: [
SizedBox(height: 3.w), SizedBox(width: 10.w),
Row( Expanded(
mainAxisSize: MainAxisSize.min, child: Text.rich(
children: [ textAlign: TextAlign.center,
SizedBox(width: 10.w), TextSpan(
Expanded( children: [
child: Text.rich( WidgetSpan(
textAlign: TextAlign.center, alignment: PlaceholderAlignment.middle,
TextSpan( child: Image.asset(
children: [ SCGlobalConfig.businessLogicStrategy
WidgetSpan( .getStoreItemGoldIcon(),
alignment: PlaceholderAlignment.middle, width: 22.w,
child: Image.asset( ),
SCGlobalConfig.businessLogicStrategy.getStoreItemGoldIcon(), ),
width: 22.w, TextSpan(text: " "),
), disCount < 1
), ? TextSpan(
TextSpan(text: " "), text: "${res.res.propsPrices![0].amount}",
disCount < 1 style: TextStyle(
? TextSpan( fontSize: 12.sp,
text: "${res.res.propsPrices![0].amount}", color:
style: TextStyle( SCGlobalConfig.businessLogicStrategy
fontSize: 12.sp, .getStoreItemPriceTextColor(),
color: SCGlobalConfig.businessLogicStrategy.getStoreItemPriceTextColor(), fontWeight: FontWeight.w600,
fontWeight: FontWeight.w600, decoration: TextDecoration.lineThrough,
decoration: TextDecoration.lineThrough, ),
), )
) : TextSpan(),
: TextSpan(), disCount < 1 ? TextSpan(text: " ") : TextSpan(),
disCount < 1 ? TextSpan(text: " ") : TextSpan(), TextSpan(
TextSpan( text:
text: "${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}",
"${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}", style: TextStyle(
style: TextStyle( fontSize: 12.sp,
fontSize: 12.sp, color:
color: SCGlobalConfig.businessLogicStrategy.getStoreItemPriceTextColor(), SCGlobalConfig.businessLogicStrategy
fontWeight: FontWeight.w600, .getStoreItemPriceTextColor(),
), fontWeight: FontWeight.w600,
), ),
], ),
), ],
strutStyle: StrutStyle( ),
height: 1.3, // strutStyle: StrutStyle(
fontWeight: FontWeight.w500, height: 1.3, //
forceStrutHeight: true, // fontWeight: FontWeight.w500,
), forceStrutHeight: true, //
), ),
), ),
SizedBox(width: 10.w), ),
], SizedBox(width: 10.w),
), ],
], ),
), ],
], ),
), ],
), ),
onTap: () { ),
_selectItem(res); onTap: () {
_showDetail(res.res); _selectItem(res);
}, _showDetail(res.res);
); },
} );
}
/// ///
@override @override
loadPage({ loadPage({
required int page, required int page,
required Function(List<StoreListResBean>) onSuccess, required Function(List<StoreListResBean>) onSuccess,
Function? onErr, Function? onErr,
}) async { }) async {
try { try {
List<StoreListResBean> beans = []; List<StoreListResBean> beans = [];
var storeList = await SCStoreRepositoryImp().storeList( var storeList = await SCStoreRepositoryImp().storeList(
SCCurrencyType.GOLD.name, SCCurrencyType.GOLD.name,
SCPropsType.RIDE.name, SCPropsType.RIDE.name,
); );
for (var value in storeList) { for (var value in storeList) {
beans.add(StoreListResBean(value, false)); beans.add(StoreListResBean(value, false));
} }
onSuccess(beans); onSuccess(beans);
} catch (e) { } catch (e) {
if (onErr != null) { if (onErr != null) {
onErr(); onErr();
} }
} }
} }
void _showDetail(StoreListRes res) { void _showDetail(StoreListRes res) {
SmartDialog.show( SmartDialog.show(
tag: "showPropsDetail", tag: "showPropsDetail",
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
animationType: SmartAnimationType.fade, animationType: SmartAnimationType.fade,
builder: (_) { builder: (_) {
return PropsStoreMountainsDetailDialog(res, disCount); return PropsStoreMountainsDetailDialog(res, disCount);
}, },
); );
} }
void _selectItem(StoreListResBean res) { void _selectItem(StoreListResBean res) {
for (var value in items) { for (var value in items) {
value.isSelecte = false; value.isSelecte = false;
} }
res.isSelecte = true; res.isSelecte = true;
setState(() {}); setState(() {});
} }
} }

View File

@ -1,239 +1,233 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:provider/provider.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:yumi/ui_kit/components/sc_debounce_widget.dart'; import 'package:yumi/app_localizations.dart';
import 'package:provider/provider.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/shared/business_logic/models/res/store_list_res.dart';
import 'package:yumi/ui_kit/components/sc_tts.dart'; import 'package:yumi/services/auth/user_profile_manager.dart';
import 'package:yumi/ui_kit/theme/socialchat_theme.dart'; import 'package:yumi/ui_kit/widgets/store/props_store_theme_detail_dialog.dart';
import 'package:yumi/app/constants/sc_global_config.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart'; import 'package:yumi/modules/store/headdress/store_headdress_page.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/shared/business_logic/models/res/store_list_res.dart'; import '../../../shared/data_sources/models/enum/sc_currency_type.dart';
import 'package:yumi/services/auth/user_profile_manager.dart'; import '../../../shared/data_sources/models/enum/sc_props_type.dart';
import 'package:yumi/ui_kit/widgets/store/props_store_theme_detail_dialog.dart';
import 'package:yumi/modules/store/headdress/store_headdress_page.dart'; ///
class StoreThemePage extends SCPageList {
import '../../../shared/data_sources/models/enum/sc_currency_type.dart'; StoreThemePage();
import '../../../shared/data_sources/models/enum/sc_props_type.dart';
@override
/// _StoreThemePagePageState createState() => _StoreThemePagePageState();
class StoreThemePage extends SCPageList { }
StoreThemePage(); class _StoreThemePagePageState
extends SCPageListState<StoreListResBean, StoreThemePage> {
@override //
_StoreThemePagePageState createState() => _StoreThemePagePageState(); double disCount = 1;
}
@override
class _StoreThemePagePageState void initState() {
extends SCPageListState<StoreListResBean, StoreThemePage> { super.initState();
enablePullUp = false;
isGridView = true;
// gridViewCount = 3;
double disCount = 1; padding = EdgeInsets.symmetric(horizontal: 6.w);
backgroundColor = Colors.transparent;
@override gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
void initState() { crossAxisCount: gridViewCount,
super.initState(); mainAxisSpacing: 12.w,
enablePullUp = false; crossAxisSpacing: 12.w,
isGridView = true; childAspectRatio: 0.78,
gridViewCount = 3; );
padding = EdgeInsets.symmetric(horizontal: 6.w); loadData(1);
backgroundColor = Colors.transparent; }
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: gridViewCount, @override
mainAxisSpacing: 12.w, Widget build(BuildContext context) {
crossAxisSpacing: 12.w, return Scaffold(
childAspectRatio: 0.78, backgroundColor: Colors.transparent,
); body:
loadData(1); items.isEmpty && isLoading
} ? const SCStoreGridSkeleton()
: buildList(context),
@override );
Widget build(BuildContext context) { }
return Scaffold(
backgroundColor: Colors.transparent, @override
body: buildList(context), Widget buildItem(StoreListResBean res) {
); return GestureDetector(
} child: Container(
decoration: BoxDecoration(
@override color:
Widget buildItem(StoreListResBean res) { res.isSelecte
return GestureDetector( ? const Color(0xff18F2B1).withValues(alpha: 0.1)
child: Container( : SCGlobalConfig.businessLogicStrategy
decoration: BoxDecoration( .getStoreItemBackgroundColor(),
color: border: Border.all(
res.isSelecte color:
? Color(0xff18F2B1).withOpacity(0.1) res.isSelecte
: SCGlobalConfig.businessLogicStrategy ? SCGlobalConfig.businessLogicStrategy
.getStoreItemBackgroundColor(), .getStoreItemSelectedBorderColor()
border: Border.all( : SCGlobalConfig.businessLogicStrategy
color: .getStoreItemUnselectedBorderColor(),
res.isSelecte width: 1.w,
? SCGlobalConfig.businessLogicStrategy ),
.getStoreItemSelectedBorderColor() borderRadius: BorderRadius.all(Radius.circular(8.w)),
: SCGlobalConfig.businessLogicStrategy ),
.getStoreItemUnselectedBorderColor(), child: Stack(
width: 1.w, children: [
), Column(
borderRadius: BorderRadius.all(Radius.circular(8.w)), children: [
), SizedBox(height: 10.w),
child: Stack( netImage(
children: [ url: res.res.propsResources?.cover ?? "",
Column( width: 55.w,
children: [ height: 55.w,
SizedBox(height: 10.w), borderRadius: BorderRadius.all(Radius.circular(8.w)),
netImage( ),
url: res.res.propsResources?.cover ?? "", SizedBox(height: 3.w),
width: 55.w, buildStoreBagItemTitle(
height: 55.w, res.res.propsResources?.name ?? "",
borderRadius: BorderRadius.all(Radius.circular(8.w)), textColor: Colors.white,
), fontSize: 11.sp,
SizedBox(height: 3.w), ),
Row( SizedBox(height: 3.w),
mainAxisSize: MainAxisSize.min, Row(
children: [ mainAxisSize: MainAxisSize.min,
text( children: [
res.res.propsResources?.name ?? "", SizedBox(width: 10.w),
textColor: Colors.white, Expanded(
fontSize: 11.sp, child: Text.rich(
), textAlign: TextAlign.center,
], TextSpan(
), children: [
SizedBox(height: 3.w), WidgetSpan(
Row( alignment: PlaceholderAlignment.middle,
mainAxisSize: MainAxisSize.min, child: Image.asset(
children: [ SCGlobalConfig.businessLogicStrategy
SizedBox(width: 10.w), .getStoreItemGoldIcon(),
Expanded( width: 22.w,
child: Text.rich( ),
textAlign: TextAlign.center, ),
TextSpan( TextSpan(text: " "),
children: [ disCount < 1
WidgetSpan( ? TextSpan(
alignment: PlaceholderAlignment.middle, text: "${res.res.propsPrices![0].amount}",
child: Image.asset( style: TextStyle(
SCGlobalConfig.businessLogicStrategy.getStoreItemGoldIcon(), fontSize: 12.sp,
width: 22.w, color:
), SCGlobalConfig.businessLogicStrategy
), .getStoreItemPriceTextColor(),
TextSpan(text: " "), fontWeight: FontWeight.w600,
disCount < 1 decoration: TextDecoration.lineThrough,
? TextSpan( ),
text: "${res.res.propsPrices![0].amount}", )
style: TextStyle( : TextSpan(),
fontSize: 12.sp, disCount < 1 ? TextSpan(text: " ") : TextSpan(),
color: SCGlobalConfig.businessLogicStrategy.getStoreItemPriceTextColor(), TextSpan(
fontWeight: FontWeight.w600, text:
decoration: TextDecoration.lineThrough, "${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}",
), style: TextStyle(
) fontSize: 12.sp,
: TextSpan(), color:
disCount < 1 ? TextSpan(text: " ") : TextSpan(), SCGlobalConfig.businessLogicStrategy
TextSpan( .getStoreItemPriceTextColor(),
text: fontWeight: FontWeight.w600,
"${((res.res.propsPrices![0].amount ?? 0) * disCount).toInt()}/${res.res.propsPrices![0].days} ${SCAppLocalizations.of(context)!.day}", ),
style: TextStyle( ),
fontSize: 12.sp, ],
color: SCGlobalConfig.businessLogicStrategy.getStoreItemPriceTextColor(), ),
fontWeight: FontWeight.w600, strutStyle: StrutStyle(
), height: 1.3, //
), fontWeight: FontWeight.w500,
], forceStrutHeight: true, //
), ),
strutStyle: StrutStyle( ),
height: 1.3, // ),
fontWeight: FontWeight.w500, SizedBox(width: 10.w),
forceStrutHeight: true, // ],
), ),
), ],
), ),
SizedBox(width: 10.w), ],
], ),
), ),
], onTap: () {
), _selectItem(res);
], _showDetail(res.res);
), },
), );
onTap: () { }
_selectItem(res);
_showDetail(res.res); void _showDetail(StoreListRes res) {
}, SmartDialog.show(
); tag: "showPropsDetail",
} alignment: Alignment.bottomCenter,
animationType: SmartAnimationType.fade,
void _showDetail(StoreListRes res) { builder: (_) {
SmartDialog.show( return PropsStoreThemeDetailDialog(res, disCount);
tag: "showPropsDetail", },
alignment: Alignment.bottomCenter, );
animationType: SmartAnimationType.fade, }
builder: (_) {
return PropsStoreThemeDetailDialog(res, disCount); ///
}, @override
); loadPage({
} required int page,
required Function(List<StoreListResBean>) onSuccess,
Function? onErr,
/// }) async {
@override try {
loadPage({ List<StoreListResBean> beans = [];
required int page, var storeList = await SCStoreRepositoryImp().storeList(
required Function(List<StoreListResBean>) onSuccess, SCCurrencyType.GOLD.name,
Function? onErr, SCPropsType.THEME.name,
}) async { );
try { for (var value in storeList) {
List<StoreListResBean> beans = []; beans.add(StoreListResBean(value, false));
var storeList = await SCStoreRepositoryImp().storeList( }
SCCurrencyType.GOLD.name, onSuccess(beans);
SCPropsType.THEME.name, } catch (e) {
); if (onErr != null) {
for (var value in storeList) { onErr();
beans.add(StoreListResBean(value, false)); }
} }
onSuccess(beans); }
} catch (e) {
if (onErr != null) { void _selectItem(StoreListResBean res) {
onErr(); for (var value in items) {
} value.isSelecte = false;
} }
} res.isSelecte = true;
setState(() {});
void _selectItem(StoreListResBean res) { }
for (var value in items) {
value.isSelecte = false; void _buy(StoreListResBean res) {
} num days = 0;
res.isSelecte = true; if (res.res.propsPrices!.length > 1) {
setState(() {}); days = res.res.propsPrices![1].days ?? 0;
} } else {
days = res.res.propsPrices![0].days ?? 0;
void _buy(StoreListResBean res) { }
num days = 0; SCStoreRepositoryImp()
if (res.res.propsPrices!.length > 1) { .storePurchasing(
days = res.res.propsPrices![1].days ?? 0; res.res.id ?? "",
} else { SCPropsType.THEME.name,
days = res.res.propsPrices![0].days ?? 0; SCCurrencyType.GOLD.name,
} "$days",
SCStoreRepositoryImp() )
.storePurchasing( .then((value) {
res.res.id ?? "", SCTts.show(SCAppLocalizations.of(context)!.purchaseIsSuccessful);
SCPropsType.THEME.name, Provider.of<SocialChatUserProfileManager>(
SCCurrencyType.GOLD.name, context,
"$days", listen: false,
) ).updateBalance(value);
.then((value) { });
SCTts.show(SCAppLocalizations.of(context)!.purchaseIsSuccessful); }
Provider.of<SocialChatUserProfileManager>( }
context,
listen: false,
).updateBalance(value);
});
}
}

View File

@ -1,383 +1,383 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart'; import 'package:provider/provider.dart';
import 'package:provider/provider.dart'; import 'package:yumi/ui_kit/components/dialog/dialog_base.dart';
import 'package:yumi/ui_kit/components/dialog/dialog_base.dart'; import 'package:yumi/ui_kit/components/sc_page_list.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/ui_kit/components/sc_tts.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_loading_manager.dart';
import 'package:yumi/shared/tools/sc_loading_manager.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart'; import 'package:yumi/shared/business_logic/models/res/bags_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/bags_list_res.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/services/auth/user_profile_manager.dart';
import 'package:yumi/services/auth/user_profile_manager.dart'; import 'package:yumi/ui_kit/widgets/bag/props_bag_chatbox_detail_dialog.dart';
import 'package:yumi/ui_kit/widgets/bag/props_bag_chatbox_detail_dialog.dart'; import 'package:yumi/ui_kit/widgets/countdown_timer.dart';
import 'package:yumi/ui_kit/widgets/countdown_timer.dart'; import 'package:yumi/modules/store/store_route.dart';
import 'package:yumi/modules/store/store_route.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import '../../../../shared/data_sources/models/enum/sc_props_type.dart'; import '../../../../shared/data_sources/models/enum/sc_props_type.dart';
import '../../../../ui_kit/components/sc_debounce_widget.dart'; import '../../../../ui_kit/components/sc_debounce_widget.dart';
import '../../../../ui_kit/theme/socialchat_theme.dart'; import '../../../../ui_kit/theme/socialchat_theme.dart';
///- ///-
class BagsChatboxPage extends SCPageList { class BagsChatboxPage extends SCPageList {
@override @override
_BagsChatboxPageState createState() => _BagsChatboxPageState(); _BagsChatboxPageState createState() => _BagsChatboxPageState();
} }
class _BagsChatboxPageState class _BagsChatboxPageState
extends SCPageListState<BagsListRes, BagsChatboxPage> { extends SCPageListState<BagsListRes, BagsChatboxPage> {
/// ///
PropsResources? myChatbox; PropsResources? myChatbox;
BagsListRes? selecteChatbox; BagsListRes? selecteChatbox;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
enablePullUp = false; enablePullUp = false;
isGridView = true; isGridView = true;
gridViewCount = 3; gridViewCount = 3;
padding = EdgeInsets.symmetric(horizontal: 6.w); padding = EdgeInsets.symmetric(horizontal: 6.w);
backgroundColor = Colors.transparent; backgroundColor = Colors.transparent;
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: gridViewCount, crossAxisCount: gridViewCount,
mainAxisSpacing: 12.w, mainAxisSpacing: 12.w,
crossAxisSpacing: 12.w, crossAxisSpacing: 12.w,
childAspectRatio: 0.88, childAspectRatio: 0.88,
); );
myChatbox = AccountStorage().getChatbox(); myChatbox = AccountStorage().getChatbox();
loadData(1); loadData(1);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Column( body: Column(
children: [ children: [
Expanded(child: buildList(context)), Expanded(
selecteChatbox != null ? SizedBox(height: 10.w) : Container(), child:
selecteChatbox != null items.isEmpty && isLoading
? Container( ? const SCBagGridSkeleton()
decoration: BoxDecoration( : buildList(context),
borderRadius: BorderRadius.only( ),
topLeft: Radius.circular(12.w), selecteChatbox != null ? SizedBox(height: 10.w) : Container(),
topRight: Radius.circular(12.w), selecteChatbox != null
), ? Container(
color: Color(0xff18F2B1).withOpacity(0.1), decoration: BoxDecoration(
), borderRadius: BorderRadius.only(
child: Column( topLeft: Radius.circular(12.w),
children: [ topRight: Radius.circular(12.w),
SizedBox(height: 5.w), ),
Row( color: const Color(0xff18F2B1).withValues(alpha: 0.1),
spacing: 5.w, ),
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ children: [
text( SizedBox(height: 5.w),
"${SCAppLocalizations.of(context)!.expirationTime}:", Row(
textColor: Colors.white, spacing: 5.w,
fontSize: 12.sp, mainAxisAlignment: MainAxisAlignment.center,
), children: [
CountdownTimer( text(
fontSize: 11.sp, "${SCAppLocalizations.of(context)!.expirationTime}:",
color: SocialChatTheme.primaryLight, textColor: Colors.white,
expiryDate: DateTime.fromMillisecondsSinceEpoch( fontSize: 12.sp,
selecteChatbox?.expireTime ?? 0, ),
), CountdownTimer(
), fontSize: 11.sp,
], color: SocialChatTheme.primaryLight,
), expiryDate: DateTime.fromMillisecondsSinceEpoch(
SizedBox(height: 10.w), selecteChatbox?.expireTime ?? 0,
Row( ),
mainAxisAlignment: MainAxisAlignment.center, ),
children: [ ],
SCDebounceWidget( ),
child: Container( SizedBox(height: 10.w),
alignment: Alignment.center, Row(
width: 120.w, mainAxisAlignment: MainAxisAlignment.center,
height: 35.w, children: [
decoration: BoxDecoration( SCDebounceWidget(
borderRadius: BorderRadius.circular(12.w), child: Container(
color: SocialChatTheme.primaryLight, alignment: Alignment.center,
), width: 120.w,
child: text( height: 35.w,
SCAppLocalizations.of(context)!.renewal, decoration: BoxDecoration(
fontWeight: FontWeight.w600, borderRadius: BorderRadius.circular(12.w),
fontSize: 14.sp, color: SocialChatTheme.primaryLight,
textColor: Colors.white, ),
), child: text(
), SCAppLocalizations.of(context)!.renewal,
onTap: () { fontWeight: FontWeight.w600,
/// fontSize: 14.sp,
SCNavigatorUtils.push( textColor: Colors.white,
context, ),
StoreRoute.list, ),
replace: false, onTap: () {
); ///
}, SCNavigatorUtils.push(
), context,
SizedBox(width: 10.w), StoreRoute.list,
SCDebounceWidget( replace: false,
child: Container( );
alignment: Alignment.center, },
width: 120.w, ),
height: 35.w, SizedBox(width: 10.w),
decoration: BoxDecoration( SCDebounceWidget(
borderRadius: BorderRadius.circular(12.w), child: Container(
color: alignment: Alignment.center,
myChatbox?.id == width: 120.w,
selecteChatbox?.propsResources?.id height: 35.w,
? Colors.white decoration: BoxDecoration(
: SocialChatTheme.primaryLight, borderRadius: BorderRadius.circular(12.w),
), color:
child: text( myChatbox?.id ==
myChatbox?.id == selecteChatbox?.propsResources?.id
selecteChatbox?.propsResources?.id ? Colors.white
? SCAppLocalizations.of(context)!.inUse : SocialChatTheme.primaryLight,
: SCAppLocalizations.of(context)!.use, ),
fontWeight: FontWeight.w600, child: text(
fontSize: 14.sp, myChatbox?.id ==
textColor: selecteChatbox?.propsResources?.id
myChatbox?.id != ? SCAppLocalizations.of(context)!.inUse
selecteChatbox?.propsResources?.id : SCAppLocalizations.of(context)!.use,
? Colors.white fontWeight: FontWeight.w600,
: Color(0xffB1B1B1), fontSize: 14.sp,
), textColor:
), myChatbox?.id !=
onTap: () { selecteChatbox?.propsResources?.id
if (myChatbox?.id != ? Colors.white
selecteChatbox?.propsResources?.id) { : Color(0xffB1B1B1),
/// ),
SmartDialog.show( ),
tag: "showConfirmDialog", onTap: () {
alignment: Alignment.center, if (myChatbox?.id !=
debounce: true, selecteChatbox?.propsResources?.id) {
animationType: SmartAnimationType.fade, ///
builder: (_) { SmartDialog.show(
return MsgDialog( tag: "showConfirmDialog",
title: SCAppLocalizations.of(context)!.tips, alignment: Alignment.center,
msg: debounce: true,
SCAppLocalizations.of( animationType: SmartAnimationType.fade,
context, builder: (_) {
)!.confirmUseTips, return MsgDialog(
btnText: title: SCAppLocalizations.of(context)!.tips,
SCAppLocalizations.of(context)!.confirm, msg:
onEnsure: () { SCAppLocalizations.of(
_use(selecteChatbox!, false); context,
}, )!.confirmUseTips,
); btnText:
}, SCAppLocalizations.of(context)!.confirm,
); onEnsure: () {
} else { _use(selecteChatbox!, false);
/// },
SmartDialog.show( );
tag: "showConfirmDialog", },
alignment: Alignment.center, );
debounce: true, } else {
animationType: SmartAnimationType.fade, ///
builder: (_) { SmartDialog.show(
return MsgDialog( tag: "showConfirmDialog",
title: SCAppLocalizations.of(context)!.tips, alignment: Alignment.center,
msg: debounce: true,
SCAppLocalizations.of( animationType: SmartAnimationType.fade,
context, builder: (_) {
)!.confirmUnUseTips, return MsgDialog(
btnText: title: SCAppLocalizations.of(context)!.tips,
SCAppLocalizations.of(context)!.confirm, msg:
onEnsure: () { SCAppLocalizations.of(
_use(selecteChatbox!, true); context,
}, )!.confirmUnUseTips,
); btnText:
}, SCAppLocalizations.of(context)!.confirm,
); onEnsure: () {
} _use(selecteChatbox!, true);
}, },
), );
], },
), );
SizedBox(height: 10.w), }
], },
), ),
) ],
: Container(), ),
], SizedBox(height: 10.w),
), ],
); ),
} )
: Container(),
@override ],
Widget buildItem(BagsListRes res) { ),
return GestureDetector( );
child: Container( }
decoration:BoxDecoration(
color:Color(0xff18F2B1).withOpacity(0.1), @override
border: Border.all( Widget buildItem(BagsListRes res) {
color: return GestureDetector(
selecteChatbox?.propsResources?.id == res.propsResources?.id child: Container(
? SocialChatTheme.primaryLight decoration: BoxDecoration(
: Colors.transparent, color: const Color(0xff18F2B1).withValues(alpha: 0.1),
width: 1.w, border: Border.all(
), color:
borderRadius: BorderRadius.all(Radius.circular(8.w)), selecteChatbox?.propsResources?.id == res.propsResources?.id
) , ? SocialChatTheme.primaryLight
child: Stack( : Colors.transparent,
alignment: Alignment.center, width: 1.w,
children: [ ),
Column( borderRadius: BorderRadius.all(Radius.circular(8.w)),
children: [ ),
SizedBox(height: 25.w), child: Stack(
netImage( alignment: Alignment.center,
url: res.propsResources?.cover ?? "", children: [
height: 35.w, Column(
fit: BoxFit.contain, children: [
), SizedBox(height: 25.w),
SizedBox(height: 8.w), netImage(
Row( url: res.propsResources?.cover ?? "",
mainAxisSize: MainAxisSize.min, height: 35.w,
children: [ fit: BoxFit.contain,
text( ),
res.propsResources?.name ?? "", SizedBox(height: 8.w),
textColor: Colors.black, buildStoreBagItemTitle(
fontSize: 12.sp, res.propsResources?.name ?? "",
), textColor: Colors.black,
], fontSize: 12.sp,
), ),
], ],
), ),
PositionedDirectional( PositionedDirectional(
top: 0, top: 0,
start: 0, start: 0,
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 5.w), padding: EdgeInsets.symmetric(horizontal: 5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: SocialChatTheme.primaryLight, color: SocialChatTheme.primaryLight,
borderRadius: BorderRadiusDirectional.only( borderRadius: BorderRadiusDirectional.only(
topStart: Radius.circular(6.w), topStart: Radius.circular(6.w),
topEnd: Radius.circular(12.w), topEnd: Radius.circular(12.w),
bottomEnd: Radius.circular(12.w), bottomEnd: Radius.circular(12.w),
), ),
), ),
child: Row( child: Row(
children: [ children: [
CountdownTimer( CountdownTimer(
fontSize: 9.sp, fontSize: 9.sp,
color: Colors.white, color: Colors.white,
expiryDate: DateTime.fromMillisecondsSinceEpoch( expiryDate: DateTime.fromMillisecondsSinceEpoch(
res.expireTime ?? 0, res.expireTime ?? 0,
), ),
), ),
SizedBox(width: 3.w), SizedBox(width: 3.w),
Image.asset( Image.asset(
"sc_images/store/sc_icon_bag_clock.png", "sc_images/store/sc_icon_bag_clock.png",
width: 22.w, width: 22.w,
height: 22.w, height: 22.w,
), ),
], ],
), ),
), ),
), ),
PositionedDirectional( PositionedDirectional(
bottom: 5.w, bottom: 5.w,
end: 5.w, end: 5.w,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
selecteChatbox = res; selecteChatbox = res;
setState(() {}); setState(() {});
_showDetail(res); _showDetail(res);
}, },
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Container( child: Container(
padding: EdgeInsets.all(5.w), padding: EdgeInsets.all(5.w),
child: Image.asset( child: Image.asset(
"sc_images/store/sc_icon_shop_item_search.png", "sc_images/store/sc_icon_shop_item_search.png",
width: 18.w, width: 18.w,
height: 18.w, height: 18.w,
color: Colors.white, color: Colors.white,
), ),
), ),
), ),
), ),
], ],
), ),
), ),
onTap: () { onTap: () {
selecteChatbox = res; selecteChatbox = res;
setState(() {}); setState(() {});
}, },
); );
} }
/// ///
@override @override
loadPage({ loadPage({
required int page, required int page,
required Function(List<BagsListRes>) onSuccess, required Function(List<BagsListRes>) onSuccess,
Function? onErr, Function? onErr,
}) async { }) async {
try { try {
var storeList = await SCStoreRepositoryImp().storeBackpack( var storeList = await SCStoreRepositoryImp().storeBackpack(
AccountStorage().getCurrentUser()?.userProfile?.id ?? "", AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
SCPropsType.CHAT_BUBBLE.name, SCPropsType.CHAT_BUBBLE.name,
); );
for (var v in storeList) { for (var v in storeList) {
if (v.propsResources?.id == myChatbox?.id) { if (v.propsResources?.id == myChatbox?.id) {
selecteChatbox = v; selecteChatbox = v;
continue; continue;
} }
} }
onSuccess(storeList); onSuccess(storeList);
} catch (e) { } catch (e) {
if (onErr != null) { if (onErr != null) {
onErr(); onErr();
} }
} }
} }
void _showDetail(BagsListRes res) { void _showDetail(BagsListRes res) {
SmartDialog.show( SmartDialog.show(
tag: "showPropsDetail", tag: "showPropsDetail",
alignment: Alignment.center, alignment: Alignment.center,
animationType: SmartAnimationType.fade, animationType: SmartAnimationType.fade,
builder: (_) { builder: (_) {
return PropsBagChatboxDetailDialog(res); return PropsBagChatboxDetailDialog(res);
}, },
onDismiss: () { onDismiss: () {
myChatbox = AccountStorage().getChatbox(); myChatbox = AccountStorage().getChatbox();
setState(() {}); setState(() {});
}, },
); );
} }
void _use(BagsListRes res, bool unload) { void _use(BagsListRes res, bool unload) {
SCLoadingManager.show(context: context); SCLoadingManager.show(context: context);
SCStoreRepositoryImp() SCStoreRepositoryImp()
.switchPropsUse( .switchPropsUse(
SCPropsType.CHAT_BUBBLE.name, SCPropsType.CHAT_BUBBLE.name,
res.propsResources?.id ?? "", res.propsResources?.id ?? "",
unload, unload,
) )
.then((value) async { .then((value) async {
setState(() {}); setState(() {});
if (!unload) { if (!unload) {
myChatbox = res.propsResources; myChatbox = res.propsResources;
SCTts.show(SCAppLocalizations.of(context)!.successfulWear); SCTts.show(SCAppLocalizations.of(context)!.successfulWear);
} else { } else {
myChatbox = null; myChatbox = null;
SCTts.show(SCAppLocalizations.of(context)!.successfullyUnloaded); SCTts.show(SCAppLocalizations.of(context)!.successfullyUnloaded);
} }
Provider.of<SocialChatUserProfileManager>( Provider.of<SocialChatUserProfileManager>(
context, context,
listen: false, listen: false,
).fetchUserProfileData(loadGuardCount: false); ).fetchUserProfileData(loadGuardCount: false);
SCLoadingManager.hide(); SCLoadingManager.hide();
}) })
.catchError((e) { .catchError((e) {
SCLoadingManager.hide(); SCLoadingManager.hide();
}); });
} }
} }

View File

@ -19,6 +19,7 @@ import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/ui_kit/theme/socialchat_theme.dart'; import 'package:yumi/ui_kit/theme/socialchat_theme.dart';
import 'package:yumi/ui_kit/widgets/bag/props_bag_headdress_detail_dialog.dart'; import 'package:yumi/ui_kit/widgets/bag/props_bag_headdress_detail_dialog.dart';
import 'package:yumi/ui_kit/widgets/countdown_timer.dart'; import 'package:yumi/ui_kit/widgets/countdown_timer.dart';
import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../../../shared/data_sources/models/enum/sc_props_type.dart'; import '../../../../shared/data_sources/models/enum/sc_props_type.dart';
@ -59,7 +60,12 @@ class _BagsHeaddressPageState
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Column( body: Column(
children: [ children: [
Expanded(child: buildList(context)), Expanded(
child:
items.isEmpty && isLoading
? const SCBagGridSkeleton()
: buildList(context),
),
selecteHeaddress != null ? SizedBox(height: 10.w) : Container(), selecteHeaddress != null ? SizedBox(height: 10.w) : Container(),
selecteHeaddress != null selecteHeaddress != null
? Container( ? Container(
@ -68,11 +74,11 @@ class _BagsHeaddressPageState
topLeft: Radius.circular(12.w), topLeft: Radius.circular(12.w),
topRight: Radius.circular(12.w), topRight: Radius.circular(12.w),
), ),
color: Color(0xff18F2B1).withOpacity(0.1), color: const Color(0xff18F2B1).withValues(alpha: 0.1),
), ),
child: Column( child: Column(
children: [ children: [
SizedBox(height: 5.w,), SizedBox(height: 5.w),
Row( Row(
spacing: 5.w, spacing: 5.w,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -128,9 +134,11 @@ class _BagsHeaddressPageState
height: 35.w, height: 35.w,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(55.w), borderRadius: BorderRadius.circular(55.w),
color: myHeaddress?.id == color:
selecteHeaddress?.propsResources?.id myHeaddress?.id ==
?Colors.white:SocialChatTheme.primaryLight, selecteHeaddress?.propsResources?.id
? Colors.white
: SocialChatTheme.primaryLight,
), ),
child: text( child: text(
myHeaddress?.id == myHeaddress?.id ==
@ -212,7 +220,7 @@ class _BagsHeaddressPageState
return GestureDetector( return GestureDetector(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color:Color(0xff18F2B1).withOpacity(0.1), color: const Color(0xff18F2B1).withValues(alpha: 0.1),
border: Border.all( border: Border.all(
color: color:
selecteHeaddress?.propsResources?.id == res.propsResources?.id selecteHeaddress?.propsResources?.id == res.propsResources?.id
@ -234,15 +242,10 @@ class _BagsHeaddressPageState
height: 55.w, height: 55.w,
), ),
SizedBox(height: 8.w), SizedBox(height: 8.w),
Row( buildStoreBagItemTitle(
mainAxisSize: MainAxisSize.min, res.propsResources?.name ?? "",
children: [ textColor: Colors.white,
text( fontSize: 12.sp,
res.propsResources?.name ?? "",
textColor: Colors.white,
fontSize: 12.sp,
),
],
), ),
], ],
), ),

View File

@ -1,368 +1,368 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:yumi/ui_kit/widgets/bag/props_bag_mountains_detail_dialog.dart';
import 'package:yumi/ui_kit/widgets/bag/props_bag_mountains_detail_dialog.dart'; import 'package:provider/provider.dart';
import 'package:provider/provider.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
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/sc_page_list.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/ui_kit/components/sc_tts.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_loading_manager.dart';
import 'package:yumi/shared/tools/sc_loading_manager.dart'; import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart'; import 'package:yumi/shared/business_logic/models/res/bags_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/bags_list_res.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/services/auth/user_profile_manager.dart';
import 'package:yumi/services/auth/user_profile_manager.dart'; import 'package:yumi/ui_kit/widgets/countdown_timer.dart';
import 'package:yumi/ui_kit/widgets/countdown_timer.dart'; import 'package:yumi/modules/store/store_route.dart';
import 'package:yumi/modules/store/store_route.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import '../../../../shared/data_sources/models/enum/sc_props_type.dart'; import '../../../../shared/data_sources/models/enum/sc_props_type.dart';
import '../../../../ui_kit/components/sc_debounce_widget.dart'; import '../../../../ui_kit/components/sc_debounce_widget.dart';
import '../../../../ui_kit/components/dialog/dialog_base.dart'; import '../../../../ui_kit/components/dialog/dialog_base.dart';
import '../../../../ui_kit/theme/socialchat_theme.dart'; import '../../../../ui_kit/theme/socialchat_theme.dart';
/// ///
class BagsMountainsPage extends SCPageList { class BagsMountainsPage extends SCPageList {
@override @override
_BagsMountainsPageState createState() => _BagsMountainsPageState(); _BagsMountainsPageState createState() => _BagsMountainsPageState();
} }
class _BagsMountainsPageState class _BagsMountainsPageState
extends SCPageListState<BagsListRes, BagsMountainsPage> { extends SCPageListState<BagsListRes, BagsMountainsPage> {
BagsListRes? selecteMountains; BagsListRes? selecteMountains;
/// ///
PropsResources? myMountains; PropsResources? myMountains;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
enablePullUp = false; enablePullUp = false;
isGridView = true; isGridView = true;
gridViewCount = 3; gridViewCount = 3;
padding = EdgeInsets.symmetric(horizontal: 6.w); padding = EdgeInsets.symmetric(horizontal: 6.w);
backgroundColor = Colors.transparent; backgroundColor = Colors.transparent;
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: gridViewCount, crossAxisCount: gridViewCount,
mainAxisSpacing: 12.w, mainAxisSpacing: 12.w,
crossAxisSpacing: 12.w, crossAxisSpacing: 12.w,
childAspectRatio: 0.88, childAspectRatio: 0.88,
); );
myMountains = AccountStorage().getMountains(); myMountains = AccountStorage().getMountains();
loadData(1); loadData(1);
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Column( body: Column(
children: [ children: [
Expanded(child: buildList(context)), Expanded(
selecteMountains != null ? SizedBox(height: 10.w) : Container(), child:
selecteMountains != null items.isEmpty && isLoading
? Container( ? const SCBagGridSkeleton()
decoration: BoxDecoration( : buildList(context),
borderRadius: BorderRadius.only( ),
topLeft: Radius.circular(12.w), selecteMountains != null ? SizedBox(height: 10.w) : Container(),
topRight: Radius.circular(12.w), selecteMountains != null
), ? Container(
color: Color(0xff18F2B1).withOpacity(0.1), decoration: BoxDecoration(
), borderRadius: BorderRadius.only(
child: Column( topLeft: Radius.circular(12.w),
children: [ topRight: Radius.circular(12.w),
SizedBox(height: 5.w), ),
Row( color: const Color(0xff18F2B1).withValues(alpha: 0.1),
spacing: 5.w, ),
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ children: [
text( SizedBox(height: 5.w),
"${SCAppLocalizations.of(context)!.expirationTime}:", Row(
textColor: Colors.white, spacing: 5.w,
fontSize: 12.sp, mainAxisAlignment: MainAxisAlignment.center,
), children: [
CountdownTimer( text(
fontSize: 11.sp, "${SCAppLocalizations.of(context)!.expirationTime}:",
color: SocialChatTheme.primaryLight, textColor: Colors.white,
expiryDate: DateTime.fromMillisecondsSinceEpoch( fontSize: 12.sp,
selecteMountains?.expireTime ?? 0, ),
), CountdownTimer(
), fontSize: 11.sp,
], color: SocialChatTheme.primaryLight,
), expiryDate: DateTime.fromMillisecondsSinceEpoch(
SizedBox(height: 10.w), selecteMountains?.expireTime ?? 0,
Row( ),
mainAxisAlignment: MainAxisAlignment.center, ),
children: [ ],
SCDebounceWidget( ),
child: Container( SizedBox(height: 10.w),
alignment: Alignment.center, Row(
width: 120.w, mainAxisAlignment: MainAxisAlignment.center,
height: 35.w, children: [
decoration: BoxDecoration( SCDebounceWidget(
borderRadius: BorderRadius.circular(12.w), child: Container(
color: SocialChatTheme.primaryLight, alignment: Alignment.center,
), width: 120.w,
child: text( height: 35.w,
SCAppLocalizations.of(context)!.renewal, decoration: BoxDecoration(
fontWeight: FontWeight.w600, borderRadius: BorderRadius.circular(12.w),
fontSize: 14.sp, color: SocialChatTheme.primaryLight,
textColor: Colors.white, ),
), child: text(
), SCAppLocalizations.of(context)!.renewal,
onTap: () { fontWeight: FontWeight.w600,
/// fontSize: 14.sp,
SCNavigatorUtils.push( textColor: Colors.white,
context, ),
StoreRoute.list, ),
replace: false, onTap: () {
); ///
}, SCNavigatorUtils.push(
), context,
SizedBox(width: 10.w), StoreRoute.list,
SCDebounceWidget( replace: false,
child: Container( );
alignment: Alignment.center, },
width: 120.w, ),
height: 35.w, SizedBox(width: 10.w),
decoration: BoxDecoration( SCDebounceWidget(
borderRadius: BorderRadius.circular(12.w), child: Container(
color: alignment: Alignment.center,
myMountains?.id == width: 120.w,
selecteMountains?.propsResources?.id height: 35.w,
? Colors.white decoration: BoxDecoration(
: SocialChatTheme.primaryLight, borderRadius: BorderRadius.circular(12.w),
), color:
child: text( myMountains?.id ==
myMountains?.id == selecteMountains?.propsResources?.id
selecteMountains?.propsResources?.id ? Colors.white
? SCAppLocalizations.of(context)!.inUse : SocialChatTheme.primaryLight,
: SCAppLocalizations.of(context)!.use, ),
fontSize: 14.sp, child: text(
fontWeight: FontWeight.w600, myMountains?.id ==
textColor: selecteMountains?.propsResources?.id
myMountains?.id != ? SCAppLocalizations.of(context)!.inUse
selecteMountains?.propsResources?.id : SCAppLocalizations.of(context)!.use,
? Colors.white fontSize: 14.sp,
: Color(0xffB1B1B1), fontWeight: FontWeight.w600,
), textColor:
), myMountains?.id !=
onTap: () { selecteMountains?.propsResources?.id
if (myMountains?.id != ? Colors.white
selecteMountains?.propsResources?.id) { : Color(0xffB1B1B1),
/// ),
SmartDialog.show( ),
tag: "showConfirmDialog", onTap: () {
alignment: Alignment.center, if (myMountains?.id !=
debounce: true, selecteMountains?.propsResources?.id) {
animationType: SmartAnimationType.fade, ///
builder: (_) { SmartDialog.show(
return MsgDialog( tag: "showConfirmDialog",
title: SCAppLocalizations.of(context)!.tips, alignment: Alignment.center,
msg: debounce: true,
SCAppLocalizations.of( animationType: SmartAnimationType.fade,
context, builder: (_) {
)!.confirmUseTips, return MsgDialog(
btnText: title: SCAppLocalizations.of(context)!.tips,
SCAppLocalizations.of(context)!.confirm, msg:
onEnsure: () { SCAppLocalizations.of(
_use(selecteMountains!, false); context,
}, )!.confirmUseTips,
); btnText:
}, SCAppLocalizations.of(context)!.confirm,
); onEnsure: () {
} else { _use(selecteMountains!, false);
/// },
SmartDialog.show( );
tag: "showConfirmDialog", },
alignment: Alignment.center, );
debounce: true, } else {
animationType: SmartAnimationType.fade, ///
builder: (_) { SmartDialog.show(
return MsgDialog( tag: "showConfirmDialog",
title: SCAppLocalizations.of(context)!.tips, alignment: Alignment.center,
msg: debounce: true,
SCAppLocalizations.of( animationType: SmartAnimationType.fade,
context, builder: (_) {
)!.confirmUnUseTips, return MsgDialog(
btnText: title: SCAppLocalizations.of(context)!.tips,
SCAppLocalizations.of(context)!.confirm, msg:
onEnsure: () { SCAppLocalizations.of(
_use(selecteMountains!, true); context,
}, )!.confirmUnUseTips,
); btnText:
}, SCAppLocalizations.of(context)!.confirm,
); onEnsure: () {
} _use(selecteMountains!, true);
}, },
), );
], },
), );
SizedBox(height: 10.w), }
], },
), ),
) ],
: Container(), ),
], SizedBox(height: 10.w),
), ],
); ),
} )
: Container(),
@override ],
Widget buildItem(BagsListRes res) { ),
return GestureDetector( );
child: Container( }
decoration: BoxDecoration(
color:Color(0xff18F2B1).withOpacity(0.1), @override
border: Border.all( Widget buildItem(BagsListRes res) {
color: return GestureDetector(
selecteMountains?.propsResources?.id == res.propsResources?.id child: Container(
? SocialChatTheme.primaryLight decoration: BoxDecoration(
: Colors.transparent, color: const Color(0xff18F2B1).withValues(alpha: 0.1),
width: 1.w, border: Border.all(
), color:
borderRadius: BorderRadius.all(Radius.circular(8.w)), selecteMountains?.propsResources?.id == res.propsResources?.id
), ? SocialChatTheme.primaryLight
child: Stack( : Colors.transparent,
alignment: Alignment.center, width: 1.w,
children: [ ),
Column( borderRadius: BorderRadius.all(Radius.circular(8.w)),
children: [ ),
SizedBox(height: 25.w), child: Stack(
netImage( alignment: Alignment.center,
url: res.propsResources?.cover ?? "", children: [
width: 55.w, Column(
height: 55.w, children: [
), SizedBox(height: 25.w),
SizedBox(height: 8.w), netImage(
Row( url: res.propsResources?.cover ?? "",
mainAxisSize: MainAxisSize.min, width: 55.w,
children: [ height: 55.w,
text( ),
res.propsResources?.name ?? "", SizedBox(height: 8.w),
textColor: Colors.white, buildStoreBagItemTitle(
fontSize: 12.sp, res.propsResources?.name ?? "",
), textColor: Colors.white,
], fontSize: 12.sp,
), ),
], ],
), ),
PositionedDirectional( PositionedDirectional(
top: 0, top: 0,
start: 0, start: 0,
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 5.w), padding: EdgeInsets.symmetric(horizontal: 5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: SocialChatTheme.primaryLight, color: SocialChatTheme.primaryLight,
borderRadius: BorderRadiusDirectional.only( borderRadius: BorderRadiusDirectional.only(
topStart: Radius.circular(6.w), topStart: Radius.circular(6.w),
topEnd: Radius.circular(12.w), topEnd: Radius.circular(12.w),
bottomEnd: Radius.circular(12.w), bottomEnd: Radius.circular(12.w),
), ),
), ),
child: Row( child: Row(
children: [ children: [
CountdownTimer( CountdownTimer(
fontSize: 9.sp, fontSize: 9.sp,
color: Colors.white, color: Colors.white,
expiryDate: DateTime.fromMillisecondsSinceEpoch( expiryDate: DateTime.fromMillisecondsSinceEpoch(
res.expireTime ?? 0, res.expireTime ?? 0,
), ),
), ),
SizedBox(width: 3.w), SizedBox(width: 3.w),
Image.asset( Image.asset(
"sc_images/store/sc_icon_bag_clock.png", "sc_images/store/sc_icon_bag_clock.png",
width: 22.w, width: 22.w,
height: 22.w, height: 22.w,
), ),
], ],
), ),
), ),
), ),
], ],
), ),
), ),
onTap: () { onTap: () {
selecteMountains = res; selecteMountains = res;
setState(() {}); setState(() {});
}, },
); );
} }
/// ///
@override @override
loadPage({ loadPage({
required int page, required int page,
required Function(List<BagsListRes>) onSuccess, required Function(List<BagsListRes>) onSuccess,
Function? onErr, Function? onErr,
}) async { }) async {
try { try {
var storeList = await SCStoreRepositoryImp().storeBackpack( var storeList = await SCStoreRepositoryImp().storeBackpack(
AccountStorage().getCurrentUser()?.userProfile?.id ?? "", AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
SCPropsType.RIDE.name, SCPropsType.RIDE.name,
); );
for (var v in storeList) { for (var v in storeList) {
if (v.propsResources?.id == myMountains?.id) { if (v.propsResources?.id == myMountains?.id) {
selecteMountains = v; selecteMountains = v;
continue; continue;
} }
} }
onSuccess(storeList); onSuccess(storeList);
} catch (e) { } catch (e) {
if (onErr != null) { if (onErr != null) {
onErr(); onErr();
} }
} }
} }
void _showDetail(BagsListRes res) { void _showDetail(BagsListRes res) {
SmartDialog.show( SmartDialog.show(
tag: "showPropsDetail", tag: "showPropsDetail",
alignment: Alignment.center, alignment: Alignment.center,
animationType: SmartAnimationType.fade, animationType: SmartAnimationType.fade,
builder: (_) { builder: (_) {
return PropsBagMountainsDetailDialog(res); return PropsBagMountainsDetailDialog(res);
}, },
onDismiss: () { onDismiss: () {
myMountains = AccountStorage().getMountains(); myMountains = AccountStorage().getMountains();
setState(() {}); setState(() {});
}, },
); );
} }
void _use(BagsListRes res, bool unload) { void _use(BagsListRes res, bool unload) {
SCLoadingManager.show(context: context); SCLoadingManager.show(context: context);
SCStoreRepositoryImp() SCStoreRepositoryImp()
.switchPropsUse( .switchPropsUse(
SCPropsType.RIDE.name, SCPropsType.RIDE.name,
res.propsResources?.id ?? "", res.propsResources?.id ?? "",
unload, unload,
) )
.then((value) async { .then((value) async {
setState(() {}); setState(() {});
if (!unload) { if (!unload) {
myMountains = res.propsResources; myMountains = res.propsResources;
SCTts.show(SCAppLocalizations.of(context)!.successfulWear); SCTts.show(SCAppLocalizations.of(context)!.successfulWear);
} else { } else {
myMountains = null; myMountains = null;
SCTts.show(SCAppLocalizations.of(context)!.successfullyUnloaded); SCTts.show(SCAppLocalizations.of(context)!.successfullyUnloaded);
} }
Provider.of<SocialChatUserProfileManager>( Provider.of<SocialChatUserProfileManager>(
context, context,
listen: false, listen: false,
).fetchUserProfileData(loadGuardCount: false); ).fetchUserProfileData(loadGuardCount: false);
SCLoadingManager.hide(); SCLoadingManager.hide();
}) })
.catchError((e) { .catchError((e) {
SCLoadingManager.hide(); SCLoadingManager.hide();
}); });
} }
} }

View File

@ -1,359 +1,364 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:yumi/app_localizations.dart';
import 'package:yumi/app_localizations.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/theme/socialchat_theme.dart';
import 'package:yumi/ui_kit/theme/socialchat_theme.dart'; import 'package:yumi/ui_kit/components/sc_page_list.dart';
import 'package:yumi/ui_kit/components/sc_page_list.dart'; import 'package:yumi/app/routes/sc_fluro_navigator.dart';
import 'package:yumi/app/routes/sc_fluro_navigator.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_store_repository_imp.dart'; import 'package:yumi/ui_kit/widgets/bag/props_bag_theme_detail_dialog.dart';
import 'package:yumi/ui_kit/widgets/bag/props_bag_theme_detail_dialog.dart'; import 'package:yumi/ui_kit/widgets/countdown_timer.dart';
import 'package:yumi/ui_kit/widgets/countdown_timer.dart'; import 'package:yumi/modules/store/store_route.dart';
import 'package:yumi/modules/store/store_route.dart'; import 'package:provider/provider.dart';
import 'package:provider/provider.dart'; import 'package:yumi/ui_kit/widgets/store/store_bag_page_helpers.dart';
import '../../../../app/constants/sc_room_msg_type.dart'; import '../../../../app/constants/sc_room_msg_type.dart';
import '../../../../shared/tools/sc_loading_manager.dart'; import '../../../../shared/tools/sc_loading_manager.dart';
import '../../../../shared/business_logic/models/res/sc_room_theme_list_res.dart'; import '../../../../shared/business_logic/models/res/sc_room_theme_list_res.dart';
import '../../../../services/audio/rtc_manager.dart'; import '../../../../services/audio/rtc_manager.dart';
import '../../../../services/audio/rtm_manager.dart'; import '../../../../services/audio/rtm_manager.dart';
import '../../../../ui_kit/components/sc_debounce_widget.dart'; import '../../../../ui_kit/components/sc_debounce_widget.dart';
import '../../../../ui_kit/components/dialog/dialog_base.dart'; import '../../../../ui_kit/components/dialog/dialog_base.dart';
import '../../../../ui_kit/components/sc_tts.dart'; import '../../../../ui_kit/components/sc_tts.dart';
import '../../../../ui_kit/widgets/room/room_msg_item.dart'; import '../../../../ui_kit/widgets/room/room_msg_item.dart';
///- ///-
class BagsThemePage extends SCPageList { class BagsThemePage extends SCPageList {
@override @override
_BagsThemePageState createState() => _BagsThemePageState(); _BagsThemePageState createState() => _BagsThemePageState();
} }
class _BagsThemePageState class _BagsThemePageState
extends SCPageListState<SCRoomThemeListRes, BagsThemePage> { extends SCPageListState<SCRoomThemeListRes, BagsThemePage> {
SCRoomThemeListRes? selecteTheme; SCRoomThemeListRes? selecteTheme;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
enablePullUp = false; enablePullUp = false;
isGridView = true; isGridView = true;
gridViewCount = 3; gridViewCount = 3;
padding = EdgeInsets.symmetric(horizontal: 6.w); padding = EdgeInsets.symmetric(horizontal: 6.w);
backgroundColor = Colors.transparent; backgroundColor = Colors.transparent;
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: gridViewCount, crossAxisCount: gridViewCount,
mainAxisSpacing: 12.w, mainAxisSpacing: 12.w,
crossAxisSpacing: 12.w, crossAxisSpacing: 12.w,
childAspectRatio: 0.88, childAspectRatio: 0.88,
); );
loadData(1); loadData(1);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Column( body: Column(
children: [ children: [
Expanded(child: buildList(context)), Expanded(
selecteTheme != null ? SizedBox(height: 10.w) : Container(), child:
selecteTheme != null items.isEmpty && isLoading
? Container( ? const SCBagGridSkeleton(showTitle: false)
decoration: BoxDecoration( : buildList(context),
borderRadius: BorderRadius.only( ),
topLeft: Radius.circular(12.w), selecteTheme != null ? SizedBox(height: 10.w) : Container(),
topRight: Radius.circular(12.w), selecteTheme != null
), ? Container(
color: Color(0xff18F2B1).withOpacity(0.1), decoration: BoxDecoration(
), borderRadius: BorderRadius.only(
child: Column( topLeft: Radius.circular(12.w),
children: [ topRight: Radius.circular(12.w),
SizedBox(height: 5.w), ),
Row( color: const Color(0xff18F2B1).withValues(alpha: 0.1),
spacing: 5.w, ),
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ children: [
text( SizedBox(height: 5.w),
"${SCAppLocalizations.of(context)!.expirationTime}:", Row(
textColor: Colors.white, spacing: 5.w,
fontSize: 12.sp, mainAxisAlignment: MainAxisAlignment.center,
), children: [
CountdownTimer( text(
fontSize: 11.sp, "${SCAppLocalizations.of(context)!.expirationTime}:",
color: SocialChatTheme.primaryLight, textColor: Colors.white,
expiryDate: DateTime.fromMillisecondsSinceEpoch( fontSize: 12.sp,
selecteTheme?.expireTime ?? 0, ),
), CountdownTimer(
), fontSize: 11.sp,
], color: SocialChatTheme.primaryLight,
), expiryDate: DateTime.fromMillisecondsSinceEpoch(
SizedBox(height: 10.w), selecteTheme?.expireTime ?? 0,
Row( ),
mainAxisAlignment: MainAxisAlignment.center, ),
children: [ ],
SCDebounceWidget( ),
child: Container( SizedBox(height: 10.w),
alignment: Alignment.center, Row(
width: 120.w, mainAxisAlignment: MainAxisAlignment.center,
height: 35.w, children: [
decoration: BoxDecoration( SCDebounceWidget(
borderRadius: BorderRadius.circular(12.w), child: Container(
color: SocialChatTheme.primaryLight, alignment: Alignment.center,
), width: 120.w,
child: text( height: 35.w,
SCAppLocalizations.of(context)!.renewal, decoration: BoxDecoration(
fontWeight: FontWeight.w600, borderRadius: BorderRadius.circular(12.w),
fontSize: 14.sp, color: SocialChatTheme.primaryLight,
textColor: Colors.white, ),
), child: text(
), SCAppLocalizations.of(context)!.renewal,
onTap: () { fontWeight: FontWeight.w600,
/// fontSize: 14.sp,
SCNavigatorUtils.push( textColor: Colors.white,
context, ),
StoreRoute.list, ),
replace: false, onTap: () {
); ///
}, SCNavigatorUtils.push(
), context,
SizedBox(width: 10.w), StoreRoute.list,
SCDebounceWidget( replace: false,
child: Container( );
alignment: Alignment.center, },
width: 120.w, ),
height: 35.w, SizedBox(width: 10.w),
decoration: BoxDecoration( SCDebounceWidget(
borderRadius: BorderRadius.circular(12.w), child: Container(
color: alignment: Alignment.center,
(selecteTheme?.useTheme ?? false) width: 120.w,
? Colors.white height: 35.w,
: SocialChatTheme.primaryLight, decoration: BoxDecoration(
), borderRadius: BorderRadius.circular(12.w),
child: text( color:
(selecteTheme?.useTheme ?? false) (selecteTheme?.useTheme ?? false)
? SCAppLocalizations.of(context)!.inUse ? Colors.white
: SCAppLocalizations.of(context)!.use, : SocialChatTheme.primaryLight,
fontWeight: FontWeight.w600, ),
fontSize: 14.sp, child: text(
textColor: (selecteTheme?.useTheme ?? false)
!(selecteTheme?.useTheme ?? false) ? SCAppLocalizations.of(context)!.inUse
? Colors.white : SCAppLocalizations.of(context)!.use,
: Color(0xffB1B1B1), fontWeight: FontWeight.w600,
), fontSize: 14.sp,
), textColor:
onTap: () { !(selecteTheme?.useTheme ?? false)
if (!(selecteTheme?.useTheme ?? false)) { ? Colors.white
/// : Color(0xffB1B1B1),
SmartDialog.show( ),
tag: "showConfirmDialog", ),
alignment: Alignment.center, onTap: () {
debounce: true, if (!(selecteTheme?.useTheme ?? false)) {
animationType: SmartAnimationType.fade, ///
builder: (_) { SmartDialog.show(
return MsgDialog( tag: "showConfirmDialog",
title: SCAppLocalizations.of(context)!.tips, alignment: Alignment.center,
msg: debounce: true,
SCAppLocalizations.of( animationType: SmartAnimationType.fade,
context, builder: (_) {
)!.confirmUseTips, return MsgDialog(
btnText: title: SCAppLocalizations.of(context)!.tips,
SCAppLocalizations.of(context)!.confirm, msg:
onEnsure: () { SCAppLocalizations.of(
_use(selecteTheme!, false); context,
}, )!.confirmUseTips,
); btnText:
}, SCAppLocalizations.of(context)!.confirm,
); onEnsure: () {
} else { _use(selecteTheme!, false);
/// },
SmartDialog.show( );
tag: "showConfirmDialog", },
alignment: Alignment.center, );
debounce: true, } else {
animationType: SmartAnimationType.fade, ///
builder: (_) { SmartDialog.show(
return MsgDialog( tag: "showConfirmDialog",
title: SCAppLocalizations.of(context)!.tips, alignment: Alignment.center,
msg: debounce: true,
SCAppLocalizations.of( animationType: SmartAnimationType.fade,
context, builder: (_) {
)!.confirmUnUseTips, return MsgDialog(
btnText: title: SCAppLocalizations.of(context)!.tips,
SCAppLocalizations.of(context)!.confirm, msg:
onEnsure: () { SCAppLocalizations.of(
_use(selecteTheme!, true); context,
}, )!.confirmUnUseTips,
); btnText:
}, SCAppLocalizations.of(context)!.confirm,
); onEnsure: () {
} _use(selecteTheme!, true);
}, },
), );
], },
), );
SizedBox(height: 10.w), }
], },
), ),
) ],
: Container(), ),
], SizedBox(height: 10.w),
), ],
); ),
} )
: Container(),
@override ],
Widget buildItem(SCRoomThemeListRes res) { ),
return GestureDetector( );
child: Container( }
decoration: BoxDecoration(
color: Color(0xff18F2B1).withOpacity(0.1), @override
border: Border.all( Widget buildItem(SCRoomThemeListRes res) {
color: return GestureDetector(
selecteTheme?.id == res.id child: Container(
? SocialChatTheme.primaryLight decoration: BoxDecoration(
: Colors.transparent, color: const Color(0xff18F2B1).withValues(alpha: 0.1),
width: 1.w, border: Border.all(
), color:
borderRadius: BorderRadius.all(Radius.circular(8.w)), selecteTheme?.id == res.id
), ? SocialChatTheme.primaryLight
child: Stack( : Colors.transparent,
alignment: Alignment.center, width: 1.w,
children: [ ),
Column( borderRadius: BorderRadius.all(Radius.circular(8.w)),
children: [ ),
SizedBox(height: 25.w), child: Stack(
netImage( alignment: Alignment.center,
url: res.themeBack ?? "", children: [
width: 55.w, Column(
height: 55.w, children: [
borderRadius: BorderRadius.all(Radius.circular(8.w)), SizedBox(height: 25.w),
), netImage(
SizedBox(height: 8.w), url: res.themeBack ?? "",
], width: 55.w,
), height: 55.w,
PositionedDirectional( borderRadius: BorderRadius.all(Radius.circular(8.w)),
top: 0, ),
start: 0, SizedBox(height: 8.w),
child: Container( ],
padding: EdgeInsets.symmetric(horizontal: 5.w), ),
decoration: BoxDecoration( PositionedDirectional(
color: SocialChatTheme.primaryLight, top: 0,
borderRadius: BorderRadiusDirectional.only( start: 0,
topStart: Radius.circular(6.w), child: Container(
topEnd: Radius.circular(12.w), padding: EdgeInsets.symmetric(horizontal: 5.w),
bottomEnd: Radius.circular(12.w), decoration: BoxDecoration(
), color: SocialChatTheme.primaryLight,
), borderRadius: BorderRadiusDirectional.only(
child: Row( topStart: Radius.circular(6.w),
children: [ topEnd: Radius.circular(12.w),
CountdownTimer( bottomEnd: Radius.circular(12.w),
fontSize: 9.sp, ),
color: Colors.white, ),
expiryDate: DateTime.fromMillisecondsSinceEpoch( child: Row(
res.expireTime ?? 0, children: [
), CountdownTimer(
), fontSize: 9.sp,
SizedBox(width: 3.w), color: Colors.white,
Image.asset( expiryDate: DateTime.fromMillisecondsSinceEpoch(
"sc_images/store/sc_icon_bag_clock.png", res.expireTime ?? 0,
width: 22.w, ),
height: 22.w, ),
), SizedBox(width: 3.w),
], Image.asset(
), "sc_images/store/sc_icon_bag_clock.png",
), width: 22.w,
), height: 22.w,
], ),
), ],
), ),
onTap: () { ),
selecteTheme = res; ),
setState(() {}); ],
}, ),
); ),
} onTap: () {
selecteTheme = res;
/// setState(() {});
@override },
loadPage({ );
required int page, }
required Function(List<SCRoomThemeListRes>) onSuccess,
Function? onErr, ///
}) async { @override
try { loadPage({
var storeList = await SCStoreRepositoryImp().roomThemeBackpack(); required int page,
for (var v in storeList) { required Function(List<SCRoomThemeListRes>) onSuccess,
if (v.useTheme ?? false) { Function? onErr,
selecteTheme = v; }) async {
continue; try {
} var storeList = await SCStoreRepositoryImp().roomThemeBackpack();
} for (var v in storeList) {
onSuccess(storeList); if (v.useTheme ?? false) {
} catch (e) { selecteTheme = v;
if (onErr != null) { continue;
onErr(); }
} }
} onSuccess(storeList);
} } catch (e) {
if (onErr != null) {
void _use(SCRoomThemeListRes res, bool unload) { onErr();
SCLoadingManager.show(); }
SCStoreRepositoryImp() }
.themeSwitchUse(res.id ?? "", unload) }
.then((value) async {
SCLoadingManager.hide(); void _use(SCRoomThemeListRes res, bool unload) {
SmartDialog.dismiss(tag: "showPropsDetail"); SCLoadingManager.show();
if (!unload) { SCStoreRepositoryImp()
SCTts.show(SCAppLocalizations.of(context)!.successfulWear); .themeSwitchUse(res.id ?? "", unload)
Provider.of<RealTimeCommunicationManager>( .then((value) async {
context!, SCLoadingManager.hide();
listen: false, SmartDialog.dismiss(tag: "showPropsDetail");
).updateRoomBG(res); if (!unload) {
} else { SCTts.show(SCAppLocalizations.of(context)!.successfulWear);
Provider.of<RealTimeCommunicationManager>( Provider.of<RealTimeCommunicationManager>(
context!, context!,
listen: false, listen: false,
).updateRoomBG(SCRoomThemeListRes()); ).updateRoomBG(res);
selecteTheme = null; } else {
SCTts.show(SCAppLocalizations.of(context)!.successfullyUnloaded); Provider.of<RealTimeCommunicationManager>(
} context!,
loadData(1); listen: false,
).updateRoomBG(SCRoomThemeListRes());
/// selecteTheme = null;
String? groupId = SCTts.show(SCAppLocalizations.of(context)!.successfullyUnloaded);
Provider.of<RealTimeCommunicationManager>( }
context, loadData(1);
listen: false,
).currenRoom?.roomProfile?.roomProfile?.roomAccount; ///
if (groupId != null) { String? groupId =
Msg msg = Msg( Provider.of<RealTimeCommunicationManager>(
groupId: groupId, context,
msg: unload ? "" : jsonEncode(res.toJson()), listen: false,
type: SCRoomMsgType.roomBGUpdate, ).currenRoom?.roomProfile?.roomProfile?.roomAccount;
); if (groupId != null) {
Provider.of<RtmProvider>( Msg msg = Msg(
context!, groupId: groupId,
listen: false, msg: unload ? "" : jsonEncode(res.toJson()),
).dispatchMessage(msg, addLocal: false); type: SCRoomMsgType.roomBGUpdate,
} );
}) Provider.of<RtmProvider>(
.catchError((e) { context!,
SCLoadingManager.hide(); listen: false,
}); ).dispatchMessage(msg, addLocal: false);
} }
})
void _showDetail(SCRoomThemeListRes res) { .catchError((e) {
SmartDialog.show( SCLoadingManager.hide();
tag: "showPropsDetail", });
alignment: Alignment.center, }
animationType: SmartAnimationType.fade,
builder: (_) { void _showDetail(SCRoomThemeListRes res) {
return PropsBagThemeDetailDialog(res, () { SmartDialog.show(
loadData(1); tag: "showPropsDetail",
}); alignment: Alignment.center,
}, animationType: SmartAnimationType.fade,
); builder: (_) {
} return PropsBagThemeDetailDialog(res, () {
} loadData(1);
});
},
);
}
}

View File

@ -1,7 +1,11 @@
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_config_repository_imp.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_config_repository_imp.dart';
import 'package:yumi/shared/data_sources/sources/repositories/sc_room_repository_imp.dart'; import 'package:yumi/shared/data_sources/sources/repositories/sc_room_repository_imp.dart';
import 'package:yumi/shared/tools/sc_gift_vap_svga_manager.dart'; import 'package:yumi/shared/tools/sc_gift_vap_svga_manager.dart';
import 'package:yumi/shared/tools/sc_network_image_utils.dart';
import 'package:yumi/shared/data_sources/models/country_mode.dart'; import 'package:yumi/shared/data_sources/models/country_mode.dart';
import 'package:yumi/shared/business_logic/models/res/sc_banner_leaderboard_res.dart'; import 'package:yumi/shared/business_logic/models/res/sc_banner_leaderboard_res.dart';
import 'package:yumi/shared/business_logic/models/res/country_res.dart'; import 'package:yumi/shared/business_logic/models/res/country_res.dart';
@ -14,13 +18,17 @@ import '../../shared/data_sources/models/enum/sc_gift_type.dart';
class SCAppGeneralManager extends ChangeNotifier { class SCAppGeneralManager extends ChangeNotifier {
List<CountryMode> countryModeList = []; List<CountryMode> countryModeList = [];
Map<String, List<Country>> _countryMap = {}; final Map<String, List<Country>> _countryMap = {};
Map<String, Country> _countryByNameMap = {}; final Map<String, Country> _countryByNameMap = {};
bool _isFetchingCountryList = false; bool _isFetchingCountryList = false;
/// ///
List<SocialChatGiftRes> giftResList = []; List<SocialChatGiftRes> giftResList = [];
Map<String, SocialChatGiftRes> _giftByIdMap = {}; final Map<String, SocialChatGiftRes> _giftByIdMap = {};
final Set<String> _warmedGiftCoverUrls = <String>{};
final Set<String> _warmingGiftCoverUrls = <String>{};
bool _isFetchingGiftList = false;
bool _hasGiftListLoaded = false;
Map<String, List<SocialChatGiftRes>> giftByTab = {}; Map<String, List<SocialChatGiftRes>> giftByTab = {};
Map<String, List<SocialChatGiftRes>> activityGiftByTab = {}; Map<String, List<SocialChatGiftRes>> activityGiftByTab = {};
@ -38,6 +46,8 @@ class SCAppGeneralManager extends ChangeNotifier {
// configLevel(); // configLevel();
} }
bool get isGiftListLoading => _isFetchingGiftList && !_hasGiftListLoaded;
/// ///
Future<void> fetchCountryList() async { Future<void> fetchCountryList() async {
if (_isFetchingCountryList) { if (_isFetchingCountryList) {
@ -116,44 +126,122 @@ class SCAppGeneralManager extends ChangeNotifier {
Scaffold.of(context).closeDrawer(); Scaffold.of(context).closeDrawer();
} }
void giftList({bool includeCustomized = true}) async { Future<void> giftList({
bool includeCustomized = true,
bool forceRefresh = false,
}) async {
if (_isFetchingGiftList) {
return;
}
if (_hasGiftListLoaded && giftResList.isNotEmpty && !forceRefresh) {
_rebuildGiftTabs(includeCustomized: includeCustomized);
notifyListeners();
unawaited(
warmGiftPageCovers("ALL", pageIndex: 0, pageCount: 2, pageSize: 8),
);
return;
}
_isFetchingGiftList = true;
if (!_hasGiftListLoaded) {
notifyListeners();
}
try { try {
giftResList = await SCChatRoomRepository().giftList(); giftResList = await SCChatRoomRepository().giftList();
giftByTab.clear(); _hasGiftListLoaded = true;
for (var gift in giftResList) { _rebuildGiftTabs(includeCustomized: includeCustomized);
giftByTab[gift.giftTab];
var gmap = giftByTab[gift.giftTab];
gmap ??= [];
gmap.add(gift);
giftByTab[gift.giftTab!] = gmap;
var gAllMap = giftByTab["ALL"];
gAllMap ??= [];
if (gift.giftTab != "NSCIONAL_FLAG" &&
gift.giftTab != "ACTIVITY" &&
gift.giftTab != "LUCKY_GIFT" &&
gift.giftTab != "CP" &&
gift.giftTab != "CUSTOMIZED" &&
gift.giftTab != "MAGIC") {
gAllMap.add(gift);
}
giftByTab["ALL"] = gAllMap;
_giftByIdMap[gift.id!] = gift;
}
if (includeCustomized) {
giftByTab["CUSTOMIZED"] ??= [];
///
giftByTab["CUSTOMIZED"]?.insert(0, SocialChatGiftRes(id: "-1000"));
} else {
giftByTab.remove("CUSTOMIZED");
}
notifyListeners(); notifyListeners();
/// ///
downLoad(giftResList); downLoad(giftResList);
} catch (e) {} unawaited(
warmGiftPageCovers("ALL", pageIndex: 0, pageCount: 2, pageSize: 8),
);
} catch (_) {
return;
} finally {
_isFetchingGiftList = false;
notifyListeners();
}
}
void _rebuildGiftTabs({required bool includeCustomized}) {
giftByTab.clear();
_giftByIdMap.clear();
for (var gift in giftResList) {
giftByTab[gift.giftTab];
var gmap = giftByTab[gift.giftTab];
gmap ??= [];
gmap.add(gift);
giftByTab[gift.giftTab!] = gmap;
var gAllMap = giftByTab["ALL"];
gAllMap ??= [];
if (gift.giftTab != "NSCIONAL_FLAG" &&
gift.giftTab != "ACTIVITY" &&
gift.giftTab != "LUCKY_GIFT" &&
gift.giftTab != "CP" &&
gift.giftTab != "CUSTOMIZED" &&
gift.giftTab != "MAGIC") {
gAllMap.add(gift);
}
giftByTab["ALL"] = gAllMap;
_giftByIdMap[gift.id!] = gift;
}
if (includeCustomized) {
giftByTab["CUSTOMIZED"] ??= [];
///
giftByTab["CUSTOMIZED"]?.insert(0, SocialChatGiftRes(id: "-1000"));
} else {
giftByTab.remove("CUSTOMIZED");
}
}
Future<void> warmGiftPageCovers(
String type, {
required int pageIndex,
int pageCount = 1,
int pageSize = 8,
}) async {
final gifts = giftByTab[type] ?? <SocialChatGiftRes>[];
if (gifts.isEmpty) {
return;
}
final start = pageIndex * pageSize;
if (start >= gifts.length) {
return;
}
final end = math.min(gifts.length, start + (pageSize * pageCount));
await warmGiftCoverImages(gifts.sublist(start, end));
}
Future<void> warmGiftCoverImages(
Iterable<SocialChatGiftRes> gifts, {
int maxConcurrency = 4,
}) async {
final pending = <Future<void>>[];
for (final gift in gifts) {
final coverUrl = gift.giftPhoto ?? "";
if (coverUrl.isEmpty ||
_warmedGiftCoverUrls.contains(coverUrl) ||
!_warmingGiftCoverUrls.add(coverUrl)) {
continue;
}
pending.add(() async {
final warmed = await warmNetworkImage(coverUrl);
_warmingGiftCoverUrls.remove(coverUrl);
if (warmed) {
_warmedGiftCoverUrls.add(coverUrl);
}
}());
if (pending.length >= maxConcurrency) {
await Future.wait(pending);
pending.clear();
}
}
if (pending.isNotEmpty) {
await Future.wait(pending);
}
} }
void giftActivityList() async { void giftActivityList() async {
@ -168,14 +256,18 @@ class SCAppGeneralManager extends ChangeNotifier {
activityGiftByTab["${gift.activityId}"] = gmap; activityGiftByTab["${gift.activityId}"] = gmap;
} }
notifyListeners(); notifyListeners();
} catch (e) {} } catch (_) {
return;
}
} }
/// ///
void giftBackpack() async { void giftBackpack() async {
try { try {
var result = await SCChatRoomRepository().giftBackpack(); await SCChatRoomRepository().giftBackpack();
} catch (e) {} } catch (_) {
return;
}
} }
///id获取礼物 ///id获取礼物
@ -202,7 +294,7 @@ class SCAppGeneralManager extends ChangeNotifier {
List<SCIndexBannerRes> gameBanners = []; List<SCIndexBannerRes> gameBanners = [];
///banner ///banner
void loadMainBanner() async { Future<void> loadMainBanner() async {
try { try {
var banners = await SCConfigRepositoryImp().getBanner(); var banners = await SCConfigRepositoryImp().getBanner();
homeBanners.clear(); homeBanners.clear();
@ -227,7 +319,9 @@ class SCAppGeneralManager extends ChangeNotifier {
} }
} }
notifyListeners(); notifyListeners();
} catch (e) {} } catch (_) {
return;
}
} }
Map<String, List<Emojis>> emojiByTab = {}; Map<String, List<Emojis>> emojiByTab = {};
@ -249,10 +343,12 @@ class SCAppGeneralManager extends ChangeNotifier {
SCBannerLeaderboardRes? appLeaderResult; SCBannerLeaderboardRes? appLeaderResult;
/// ///
void appLeaderboard() async { Future<void> appLeaderboard() async {
try { try {
appLeaderResult = await SCChatRoomRepository().appLeaderboard(); appLeaderResult = await SCChatRoomRepository().appLeaderboard();
notifyListeners(); notifyListeners();
} catch (e) {} } catch (_) {
return;
}
} }
} }

View File

@ -12,11 +12,29 @@ import 'package:yumi/shared/business_logic/models/res/sc_room_contribute_level_r
class SocialChatRoomManager extends ChangeNotifier { class SocialChatRoomManager extends ChangeNotifier {
MyRoomRes? myRoom; MyRoomRes? myRoom;
SCRoomContributeLevelRes? roomContributeLevelRes; SCRoomContributeLevelRes? roomContributeLevelRes;
bool isMyRoomLoading = false;
bool hasLoadedMyRoom = false;
void fetchMyRoomData() async { Future<void> fetchMyRoomData() async {
myRoom = null; if (isMyRoomLoading) {
myRoom = await SCAccountRepository().myProfile(); return;
}
isMyRoomLoading = true;
if (!hasLoadedMyRoom) {
myRoom = null;
}
notifyListeners(); notifyListeners();
try {
myRoom = await SCAccountRepository().myProfile();
} catch (_) {
if (!hasLoadedMyRoom) {
myRoom = null;
}
} finally {
isMyRoomLoading = false;
hasLoadedMyRoom = true;
notifyListeners();
}
} }
void updateMyRoomInfo(SCEditRoomInfoRes roomInfo) { void updateMyRoomInfo(SCEditRoomInfoRes roomInfo) {
@ -43,6 +61,8 @@ class SocialChatRoomManager extends ChangeNotifier {
} }
await SCAccountRepository().createRoom(); await SCAccountRepository().createRoom();
myRoom = await SCAccountRepository().myProfile(); myRoom = await SCAccountRepository().myProfile();
hasLoadedMyRoom = true;
isMyRoomLoading = false;
if (!context.mounted) { if (!context.mounted) {
notifyListeners(); notifyListeners();
SCLoadingManager.hide(); SCLoadingManager.hide();

View File

@ -0,0 +1,85 @@
import 'dart:async';
import 'dart:io';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/painting.dart';
import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
bool _requiresAuthenticatedImageHeaders(String url) {
return url.contains("/external/oss/local/");
}
Map<String, String>? buildNetworkImageHeaders(String url) {
if (!_requiresAuthenticatedImageHeaders(url)) {
return null;
}
final uri = Uri.tryParse(url);
final headers = <String, String>{
"req-lang": SCGlobalConfig.lang,
"X-Forwarded-Proto": "http",
"User-Agent": "Dart/3.7.2(dart:io)",
"req-imei": SCGlobalConfig.imei,
"req-app-intel":
"version=${SCGlobalConfig.version};build=${SCGlobalConfig.build};model=${SCGlobalConfig.model};sysVersion=${SCGlobalConfig.sysVersion};channel=${SCGlobalConfig.channel}",
"req-client": Platform.isAndroid ? "Android" : "iOS",
"req-sys-origin":
"origin=${SCGlobalConfig.origin};originChild=${SCGlobalConfig.originChild}",
};
if ((uri?.host ?? "").isNotEmpty) {
headers["Host"] = uri!.host;
}
final token = AccountStorage().getToken();
if (token.isNotEmpty) {
headers["Authorization"] = "Bearer $token";
}
headers.removeWhere((key, value) => value.trim().isEmpty);
return headers;
}
ImageProvider<Object> buildCachedImageProvider(String url) {
if (url.startsWith("http")) {
return ExtendedNetworkImageProvider(
url,
headers: buildNetworkImageHeaders(url),
cache: true,
cacheMaxAge: const Duration(days: 7),
);
}
return FileImage(File(url));
}
Future<bool> warmNetworkImage(
String url, {
Duration timeout = const Duration(seconds: 6),
}) async {
if (url.isEmpty) {
return false;
}
final provider = buildCachedImageProvider(url);
final stream = provider.resolve(ImageConfiguration.empty);
final completer = Completer<bool>();
late final ImageStreamListener listener;
listener = ImageStreamListener(
(image, synchronousCall) {
if (!completer.isCompleted) {
completer.complete(true);
}
stream.removeListener(listener);
},
onError: (Object error, StackTrace? stackTrace) {
if (!completer.isCompleted) {
completer.complete(false);
}
stream.removeListener(listener);
},
);
stream.addListener(listener);
return completer.future.timeout(
timeout,
onTimeout: () {
stream.removeListener(listener);
return false;
},
);
}

View File

@ -1,7 +1,4 @@
import 'dart:io';
import 'package:extended_image/extended_image.dart'; import 'package:extended_image/extended_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
@ -9,48 +6,17 @@ import 'package:yumi/ui_kit/theme/socialchat_theme.dart';
import 'package:tancent_vap/utils/constant.dart'; import 'package:tancent_vap/utils/constant.dart';
import 'package:tancent_vap/widgets/vap_view.dart'; import 'package:tancent_vap/widgets/vap_view.dart';
import 'package:yumi/shared/data_sources/sources/local/file_cache_manager.dart'; import 'package:yumi/shared/data_sources/sources/local/file_cache_manager.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
import 'package:yumi/ui_kit/widgets/headdress/headdress_widget.dart'; import 'package:yumi/ui_kit/widgets/headdress/headdress_widget.dart';
import 'package:yumi/app/constants/sc_global_config.dart'; import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/app/constants/sc_screen.dart'; import 'package:yumi/app/constants/sc_screen.dart';
import 'package:yumi/shared/tools/sc_path_utils.dart'; import 'package:yumi/shared/tools/sc_path_utils.dart';
import 'package:yumi/shared/tools/sc_room_profile_cache.dart'; import 'package:yumi/shared/tools/sc_room_profile_cache.dart';
import 'package:yumi/shared/tools/sc_network_image_utils.dart';
import '../../shared/data_sources/models/enum/sc_room_roles_type.dart'; import '../../shared/data_sources/models/enum/sc_room_roles_type.dart';
const String kRoomCoverDefaultImg = "sc_images/general/sc_no_data.png"; const String kRoomCoverDefaultImg = "sc_images/general/sc_no_data.png";
bool _requiresAuthenticatedImageHeaders(String url) {
return url.contains("/external/oss/local/");
}
Map<String, String>? _buildImageHeaders(String url) {
if (!_requiresAuthenticatedImageHeaders(url)) {
return null;
}
final uri = Uri.tryParse(url);
final headers = <String, String>{
"req-lang": SCGlobalConfig.lang,
"X-Forwarded-Proto": "http",
"User-Agent": "Dart/3.7.2(dart:io)",
"req-imei": SCGlobalConfig.imei,
"req-app-intel":
"version=${SCGlobalConfig.version};build=${SCGlobalConfig.build};model=${SCGlobalConfig.model};sysVersion=${SCGlobalConfig.sysVersion};channel=${SCGlobalConfig.channel}",
"req-client": Platform.isAndroid ? "Android" : "iOS",
"req-sys-origin":
"origin=${SCGlobalConfig.origin};originChild=${SCGlobalConfig.originChild}",
};
if ((uri?.host ?? "").isNotEmpty) {
headers["Host"] = uri!.host;
}
final token = AccountStorage().getToken();
if (token.isNotEmpty) {
headers["Authorization"] = "Bearer $token";
}
headers.removeWhere((key, value) => value.trim().isEmpty);
return headers;
}
String resolveRoomCoverUrl(String? roomId, String? roomCover) { String resolveRoomCoverUrl(String? roomId, String? roomCover) {
final cache = SCRoomProfileCache.getRoomProfile(roomId ?? ""); final cache = SCRoomProfileCache.getRoomProfile(roomId ?? "");
return SCRoomProfileCache.preferCachedValue(cache["roomCover"], roomCover) ?? return SCRoomProfileCache.preferCachedValue(cache["roomCover"], roomCover) ??
@ -212,13 +178,15 @@ Widget netImage({
BoxFit? fit, BoxFit? fit,
BoxShape? shape, BoxShape? shape,
Border? border, Border? border,
Widget? loadingWidget,
Widget? errorWidget,
}) { }) {
// print('${SCGlobalConfig.imgHost}$image?imageslim'); // print('${SCGlobalConfig.imgHost}$image?imageslim');
return ExtendedImage.network( return ExtendedImage.network(
url, url,
width: width, width: width,
height: height ?? width, height: height ?? width,
headers: _buildImageHeaders(url), headers: buildNetworkImageHeaders(url),
fit: fit ?? BoxFit.cover, fit: fit ?? BoxFit.cover,
cache: true, cache: true,
shape: shape ?? BoxShape.rectangle, shape: shape ?? BoxShape.rectangle,
@ -234,6 +202,9 @@ Widget netImage({
fit: fit ?? BoxFit.cover, fit: fit ?? BoxFit.cover,
); );
} else if (state.extendedImageLoadState == LoadState.failed) { } else if (state.extendedImageLoadState == LoadState.failed) {
if (errorWidget != null) {
return errorWidget;
}
return noDefaultImg return noDefaultImg
? Container() ? Container()
: Image.asset( : Image.asset(
@ -241,6 +212,9 @@ Widget netImage({
fit: BoxFit.cover, fit: BoxFit.cover,
); );
} else { } else {
if (loadingWidget != null) {
return loadingWidget;
}
return noDefaultImg return noDefaultImg
? Container() ? Container()
: Image.asset( : Image.asset(

View File

@ -12,6 +12,7 @@ import 'package:yumi/shared/business_logic/models/res/join_room_res.dart';
import 'package:yumi/services/audio/rtc_manager.dart'; import 'package:yumi/services/audio/rtc_manager.dart';
import 'package:yumi/app/constants/sc_screen.dart'; import 'package:yumi/app/constants/sc_screen.dart';
import 'package:yumi/ui_kit/theme/socialchat_theme.dart'; import 'package:yumi/ui_kit/theme/socialchat_theme.dart';
import 'package:yumi/ui_kit/widgets/room/room_live_audio_indicator.dart';
// //
Offset kDefaultFloatOffset = Offset( Offset kDefaultFloatOffset = Offset(
@ -191,11 +192,7 @@ class _FloatRoomWindowState extends State<FloatRoomWindow> {
height: 40.w, height: 40.w,
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
), ),
Image.asset( SCRoomLiveAudioIndicator(width: 15.w, height: 15.w),
"sc_images/general/sc_icon_online_user.png",
width: 15.w,
height: 15.w,
),
], ],
), ),
SizedBox(width: width(5)), SizedBox(width: width(5)),

View File

@ -0,0 +1,137 @@
import 'dart:math' as math;
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class SCRoomLiveAudioIndicator extends StatefulWidget {
const SCRoomLiveAudioIndicator({
super.key,
this.width,
this.height,
this.color = const Color(0xFF1BF2AE),
this.duration = const Duration(milliseconds: 1260),
});
final double? width;
final double? height;
final Color color;
final Duration duration;
@override
State<SCRoomLiveAudioIndicator> createState() =>
_SCRoomLiveAudioIndicatorState();
}
class _SCRoomLiveAudioIndicatorState extends State<SCRoomLiveAudioIndicator>
with SingleTickerProviderStateMixin {
static const List<double> _phaseOffsets = <double>[0.0, 0.18, 0.36];
static const List<double> _minFactors = <double>[0.28, 0.2, 0.34];
static const List<double> _maxFactors = <double>[0.9, 0.76, 0.96];
late final AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: widget.duration)
..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final double indicatorWidth = widget.width ?? 14.w;
final double indicatorHeight = widget.height ?? 14.w;
return RepaintBoundary(
child: SizedBox(
width: indicatorWidth,
height: indicatorHeight,
child: AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return CustomPaint(
painter: _RoomLiveAudioPainter(
progress: _controller.value,
color: widget.color,
phaseOffsets: _phaseOffsets,
minFactors: _minFactors,
maxFactors: _maxFactors,
),
);
},
),
),
);
}
}
class _RoomLiveAudioPainter extends CustomPainter {
const _RoomLiveAudioPainter({
required this.progress,
required this.color,
required this.phaseOffsets,
required this.minFactors,
required this.maxFactors,
});
final double progress;
final Color color;
final List<double> phaseOffsets;
final List<double> minFactors;
final List<double> maxFactors;
@override
void paint(Canvas canvas, Size size) {
final Paint paint = Paint()..style = PaintingStyle.fill;
final double spacing = size.width * 0.16;
final double barWidth = (size.width - (spacing * 2)) / 3;
final double radius = math.min(barWidth / 2, size.height / 2);
final double baseline = size.height;
for (int index = 0; index < 3; index++) {
final double cycleProgress = (progress + phaseOffsets[index]) % 1.0;
final double wave = _buildWaveValue(cycleProgress);
final double factor =
lerpDouble(minFactors[index], maxFactors[index], wave) ??
minFactors[index];
final double barHeight = math.max(
size.height * factor,
size.height * 0.2,
);
final double left = index * (barWidth + spacing);
final double top = baseline - barHeight;
paint.color = color.withValues(alpha: 0.68 + (0.32 * wave));
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(left, top, barWidth, barHeight),
Radius.circular(radius),
),
paint,
);
}
}
@override
bool shouldRepaint(covariant _RoomLiveAudioPainter oldDelegate) {
return oldDelegate.progress != progress || oldDelegate.color != color;
}
double _buildWaveValue(double t) {
final double primary = 0.5 - (0.5 * math.cos(2 * math.pi * t));
final double smoothPrimary = primary * primary * (3 - (2 * primary));
final double detail = 0.5 - (0.5 * math.cos(4 * math.pi * t));
final double detailWeight = (1 - ((smoothPrimary - 0.5).abs() * 2)).clamp(
0.0,
1.0,
);
return (smoothPrimary + ((detail - 0.5) * 0.16 * detailWeight)).clamp(
0.0,
1.0,
);
}
}

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart';
@ -72,6 +73,10 @@ class _RoomOnlineUserWidgetState extends State<RoomOnlineUserWidget> {
"", "",
width: 23.w, width: 23.w,
height: 23.w, height: 23.w,
defaultImg:
SCGlobalConfig
.businessLogicStrategy
.getMePageDefaultAvatarImage(),
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all( border: Border.all(
color: Colors.white, color: Colors.white,

View File

@ -0,0 +1,288 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart';
const Duration _kStoreBagSkeletonAnimationDuration = Duration(
milliseconds: 1450,
);
const Color _kStoreBagSkeletonShell = Color(0xFF0F3730);
const Color _kStoreBagSkeletonShellStrong = Color(0xFF1A4A41);
const Color _kStoreBagSkeletonBoneBase = Color(0xFF2B5C53);
const Color _kStoreBagSkeletonBoneHighlight = Color(0xFF5F8177);
const Color _kStoreBagSkeletonBorder = Color(0x66D8B57B);
Widget buildStoreBagItemTitle(
String content, {
required double fontSize,
Color textColor = Colors.white,
EdgeInsetsGeometry? padding,
}) {
return Padding(
padding: padding ?? EdgeInsets.symmetric(horizontal: 8.w),
child: SizedBox(
width: double.infinity,
child: text(
content,
fontSize: fontSize,
textColor: textColor,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
),
);
}
class _SCStoreBagSkeletonShimmer extends StatefulWidget {
const _SCStoreBagSkeletonShimmer({required this.builder});
final Widget Function(BuildContext context, double progress) builder;
@override
State<_SCStoreBagSkeletonShimmer> createState() =>
_SCStoreBagSkeletonShimmerState();
}
class _SCStoreBagSkeletonShimmerState extends State<_SCStoreBagSkeletonShimmer>
with SingleTickerProviderStateMixin {
late final AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: _kStoreBagSkeletonAnimationDuration,
)..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) => widget.builder(context, _controller.value),
);
}
}
class SCStoreGridSkeleton extends StatelessWidget {
const SCStoreGridSkeleton({super.key, this.itemCount = 9});
final int itemCount;
@override
Widget build(BuildContext context) {
return _SCStoreBagSkeletonShimmer(
builder:
(context, progress) => GridView.builder(
padding: EdgeInsets.symmetric(horizontal: 6.w),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 12.w,
crossAxisSpacing: 12.w,
childAspectRatio: 0.78,
),
itemCount: itemCount,
itemBuilder: (context, index) => _buildStoreCardSkeleton(progress),
),
);
}
}
class SCBagGridSkeleton extends StatelessWidget {
const SCBagGridSkeleton({
super.key,
this.itemCount = 9,
this.showTitle = true,
});
final int itemCount;
final bool showTitle;
@override
Widget build(BuildContext context) {
return _SCStoreBagSkeletonShimmer(
builder:
(context, progress) => GridView.builder(
padding: EdgeInsets.symmetric(horizontal: 6.w),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 12.w,
crossAxisSpacing: 12.w,
childAspectRatio: 0.88,
),
itemCount: itemCount,
itemBuilder:
(context, index) =>
_buildBagCardSkeleton(progress, showTitle: showTitle),
),
);
}
}
Widget _buildStoreCardSkeleton(double progress) {
return DecoratedBox(
decoration: _buildStoreBagShellDecoration(radius: 8.w),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.w),
child: Column(
children: [
SizedBox(height: 2.w),
_buildStoreBagSkeletonBone(
progress,
width: 55.w,
height: 55.w,
borderRadius: BorderRadius.circular(12.w),
),
SizedBox(height: 10.w),
_buildStoreBagSkeletonBone(
progress,
width: double.infinity,
height: 12.w,
borderRadius: BorderRadius.circular(999.w),
),
SizedBox(height: 10.w),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildStoreBagSkeletonBone(
progress,
width: 16.w,
height: 16.w,
shape: BoxShape.circle,
),
SizedBox(width: 6.w),
_buildStoreBagSkeletonBone(
progress,
width: 56.w,
height: 11.w,
borderRadius: BorderRadius.circular(999.w),
),
],
),
SizedBox(height: 6.w),
_buildStoreBagSkeletonBone(
progress,
width: 48.w,
height: 11.w,
borderRadius: BorderRadius.circular(999.w),
),
],
),
),
);
}
Widget _buildBagCardSkeleton(double progress, {required bool showTitle}) {
return DecoratedBox(
decoration: _buildStoreBagShellDecoration(radius: 8.w),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 12.w),
child: Stack(
children: [
PositionedDirectional(
top: 0,
start: 0,
child: _buildStoreBagSkeletonBone(
progress,
width: 60.w,
height: 18.w,
borderRadius: BorderRadiusDirectional.only(
topStart: Radius.circular(6.w),
topEnd: Radius.circular(12.w),
bottomEnd: Radius.circular(12.w),
),
),
),
PositionedDirectional(
bottom: 0,
end: 0,
child: _buildStoreBagSkeletonBone(
progress,
width: 18.w,
height: 18.w,
shape: BoxShape.circle,
),
),
Column(
children: [
SizedBox(height: 24.w),
_buildStoreBagSkeletonBone(
progress,
width: 55.w,
height: 55.w,
borderRadius: BorderRadius.circular(12.w),
),
if (showTitle) ...[
SizedBox(height: 10.w),
_buildStoreBagSkeletonBone(
progress,
width: double.infinity,
height: 12.w,
borderRadius: BorderRadius.circular(999.w),
),
],
],
),
],
),
),
);
}
BoxDecoration _buildStoreBagShellDecoration({required double radius}) {
return BoxDecoration(
borderRadius: BorderRadius.circular(radius),
border: Border.all(color: _kStoreBagSkeletonBorder, width: 1.w),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [_kStoreBagSkeletonShellStrong, _kStoreBagSkeletonShell],
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.16),
blurRadius: 16.w,
offset: Offset(0, 8.w),
),
],
);
}
Widget _buildStoreBagSkeletonBone(
double progress, {
double? width,
required double height,
BorderRadiusGeometry? borderRadius,
BoxShape shape = BoxShape.rectangle,
}) {
final double slideOffset = (progress * 2) - 1;
return Container(
width: width,
height: height,
decoration: BoxDecoration(
shape: shape,
borderRadius:
shape == BoxShape.circle
? null
: (borderRadius ?? BorderRadius.circular(10.w)),
gradient: LinearGradient(
begin: Alignment(-1.4 + slideOffset, -0.2),
end: Alignment(1.4 + slideOffset, 0.2),
colors: const [
_kStoreBagSkeletonBoneBase,
_kStoreBagSkeletonBoneBase,
_kStoreBagSkeletonBoneHighlight,
_kStoreBagSkeletonBoneBase,
],
stops: const [0.0, 0.36, 0.54, 1.0],
),
),
);
}

View File

@ -9,6 +9,7 @@
- 已定位并修复语言房礼物飘屏资源引用错误:代码里误写 `sc_icon_gift_flosc_bg` / `sc_icon_luck_gift_flosc_*`,实际资源文件名为 `float`,导致点击送礼后飘屏背景图加载失败,相关动画无法正常显示。 - 已定位并修复语言房礼物飘屏资源引用错误:代码里误写 `sc_icon_gift_flosc_bg` / `sc_icon_luck_gift_flosc_*`,实际资源文件名为 `float`,导致点击送礼后飘屏背景图加载失败,相关动画无法正常显示。
- 已继续定位语言房礼物特效不播放的根因:后端礼物配置返回的特效标记为 `ANIMATION`,而前端历史代码只识别拼写错误的 `ANIMSCION`,导致送礼后直接跳过全屏/半屏特效播放;现已改为同时兼容两种标记。 - 已继续定位语言房礼物特效不播放的根因:后端礼物配置返回的特效标记为 `ANIMATION`,而前端历史代码只识别拼写错误的 `ANIMSCION`,导致送礼后直接跳过全屏/半屏特效播放;现已改为同时兼容两种标记。
- 已继续优化语言房礼物特效播放性能:将礼物资源预热改为“后台串行预加载 + 选中礼物高优先级预加载 + 播放阶段复用同一解码/下载任务”,避免送礼时重复下载或重复解码同一个 `.svga/.mp4`;同时为全屏播放器增加 `RepaintBoundary`,并改为按原始比例渲染、关闭越界绘制,减少整页重绘和过度放大带来的卡顿。 - 已继续优化语言房礼物特效播放性能:将礼物资源预热改为“后台串行预加载 + 选中礼物高优先级预加载 + 播放阶段复用同一解码/下载任务”,避免送礼时重复下载或重复解码同一个 `.svga/.mp4`;同时为全屏播放器增加 `RepaintBoundary`,并改为按原始比例渲染、关闭越界绘制,减少整页重绘和过度放大带来的卡顿。
- 已继续优化礼物二级页首屏与翻页加载体验:礼物配置改为会话内复用,避免每次打开礼物面板都重新拉列表;首屏与翻页页卡增加整页骨架态,页面图片预热改为“当前页并发预热 + 下一页提前预热”,并增加“最短可感知骨架时长 + 最长骨架保护窗口”,避免整页骨架一闪而过;超过上限后再切换到真实卡片,并让单个礼物继续使用小 `loading` 占位补齐,整体交互对齐常见直播 app 的礼物面板体验。
- 已修复首页房间封面显示链路:兼容接口 `roomCover/cover` 双字段,并补齐编辑房间成功后的封面内存回写。 - 已修复首页房间封面显示链路:兼容接口 `roomCover/cover` 双字段,并补齐编辑房间成功后的封面内存回写。
- 已继续修复房间设置保存封面后丢失的问题:房间保存接口改为兼容提交 `id/roomId``roomCover/cover`,并在保存成功后优先保留刚提交的封面、名称、公告,避免被空响应覆盖。 - 已继续修复房间设置保存封面后丢失的问题:房间保存接口改为兼容提交 `id/roomId``roomCover/cover`,并在保存成功后优先保留刚提交的封面、名称、公告,避免被空响应覆盖。
- 已新增按房间 ID 的本地房间资料缓存兜底:首页、我的房间、历史/关注、搜索和再次进入房间都会优先回填最近一次本地保存的封面;同时已将房间封面空态图替换为新的 `sc_no_data.png` - 已新增按房间 ID 的本地房间资料缓存兜底:首页、我的房间、历史/关注、搜索和再次进入房间都会优先回填最近一次本地保存的封面;同时已将房间封面空态图替换为新的 `sc_no_data.png`
@ -18,6 +19,12 @@
- 已修复静态头像框透明区域误变黑的问题:调整头像框白底透明化公式后,进入房间时不再出现只有头像附近有颜色、其余房间背景被黑块覆盖的现象。 - 已修复静态头像框透明区域误变黑的问题:调整头像框白底透明化公式后,进入房间时不再出现只有头像附近有颜色、其余房间背景被黑块覆盖的现象。
- 已修复个人主页首屏黑屏与内容区多余圆角问题:为个人页补充稳定的底图/底色占位,避免进入页面时先出现黑屏;同时移除资料内容区顶部多余圆角。 - 已修复个人主页首屏黑屏与内容区多余圆角问题:为个人页补充稳定的底图/底色占位,避免进入页面时先出现黑屏;同时移除资料内容区顶部多余圆角。
- 已将个人主页首屏占位升级为骨架屏进入个人页时会先按真实版式展示头像、昵称、计数区、Tab 和资料内容的骨架块,不再先露默认背景等待约 1 秒。 - 已将个人主页首屏占位升级为骨架屏进入个人页时会先按真实版式展示头像、昵称、计数区、Tab 和资料内容的骨架块,不再先露默认背景等待约 1 秒。
- 已为首页 Party 页补齐首屏骨架屏:顶部 H5 榜单现按三列奖杯卡位展示头像/标题骨架,下方房间区改为双列房卡骨架,并采用深绿底 + 金色描边的项目内风格;同时拆分榜单与房间列表加载态,仅在“首屏无内容加载”时展示骨架,避免下拉刷新时整页闪烁。
- 已为首页 My 板块补齐首屏骨架屏:`My room` 顶部房间卡片改为独立加载态,避免首屏把“正在加载我的房间”误显示成“去创建房间”;`Recent/Followed` 两个子页也已改成同风格双列房卡骨架,进入 tab 时会先展示完整结构占位,再按真实数据切换。
- 已为 `Me` 入口下的 `Store / Bag` 页面补齐首屏骨架屏:四类 `store` 商品页和四类 `bag` 物品页在“首屏空数据加载”阶段都会先展示同风格的三列卡片骨架,不再只显示小菊花;同时已为商品/物品名称补齐宽度约束与省略号处理,避免超长文案顶出卡片。
- 已继续细化首页房卡体验:`My` 板块房卡骨架数量已从 `4` 个补齐到 `6` 个,与首页 Party 首屏保持一致;同时将房卡右下角原本的静态绿色“直播中”图片替换为代码驱动的三段式动态音频条,首页、我的、搜索结果和房间浮窗现都会展示跳动效果,不再依赖静态资源图;最新已把动效调整为“单周期完整峰谷 + A/B/C 错峰起伏”的连续波形,观感更接近直播音频电平。
- 已继续微调首页房卡信息密度:房卡底部房名与在线人数字号已统一调小,和动态音频条更协调;同时已移除 `My` 板块顶部 `my room` 标题及其占位,让房间卡片整体上移,对齐更紧凑。
- 已继续微调首页视觉细节房卡底栏房名再次缩小并轻微上移和国旗、动态音频条、人数的中线更一致首页顶部排行骨架也已简化为“3 个圆形头像 + 1 根文本条”,更贴近真实卡片结构。
- 已优化语言房顶部成员入口的点击范围:右上角在线成员区域现已将左侧头像堆叠区与右侧成员图标统一为同一点击热区,用户点击头像区也可直接打开成员列表页。 - 已优化语言房顶部成员入口的点击范围:右上角在线成员区域现已将左侧头像堆叠区与右侧成员图标统一为同一点击热区,用户点击头像区也可直接打开成员列表页。
- 已继续修复房间封面跨用户不同步问题:当列表或进房返回空封面时,客户端会自动补拉 `room/profile/specific` 详情并缓存真实封面;同时房主保存房间资料后会向房间内其他用户派发资料刷新消息,避免只有自己能看到新封面、其他用户仍显示 `no data` - 已继续修复房间封面跨用户不同步问题:当列表或进房返回空封面时,客户端会自动补拉 `room/profile/specific` 详情并缓存真实封面;同时房主保存房间资料后会向房间内其他用户派发资料刷新消息,避免只有自己能看到新封面、其他用户仍显示 `no data`
- 已修复个人主页编辑页头像上传后无变化的问题:上传成功后会先本地回写新头像地址并立即提交;资料更新接口现同时兼容 `userAvatar/avatar` 字段,且不再被紧接着的旧资料回拉覆盖,返回个人主页后头像会即时更新。 - 已修复个人主页编辑页头像上传后无变化的问题:上传成功后会先本地回写新头像地址并立即提交;资料更新接口现同时兼容 `userAvatar/avatar` 字段,且不再被紧接着的旧资料回拉覆盖,返回个人主页后头像会即时更新。
@ -71,6 +78,7 @@
## 已改动文件 ## 已改动文件
- `需求进度.md` - `需求进度.md`
- `lib/shared/data_sources/models/enum/sc_gift_type.dart` - `lib/shared/data_sources/models/enum/sc_gift_type.dart`
- `lib/shared/tools/sc_network_image_utils.dart`
- `lib/shared/tools/sc_gift_vap_svga_manager.dart` - `lib/shared/tools/sc_gift_vap_svga_manager.dart`
- `lib/services/general/sc_app_general_manager.dart` - `lib/services/general/sc_app_general_manager.dart`
- `lib/ui_kit/widgets/room/floating/floating_gift_screen_widget.dart` - `lib/ui_kit/widgets/room/floating/floating_gift_screen_widget.dart`
@ -91,10 +99,21 @@
- `lib/ui_kit/widgets/room/room_head_widget.dart` - `lib/ui_kit/widgets/room/room_head_widget.dart`
- `lib/modules/room/detail/room_detail_page.dart` - `lib/modules/room/detail/room_detail_page.dart`
- `lib/modules/home/popular/party/sc_home_party_page.dart` - `lib/modules/home/popular/party/sc_home_party_page.dart`
- `lib/modules/home/popular/mine/sc_home_mine_skeleton.dart`
- `lib/modules/home/popular/follow/sc_room_follow_page.dart` - `lib/modules/home/popular/follow/sc_room_follow_page.dart`
- `lib/modules/home/popular/history/sc_room_history_page.dart` - `lib/modules/home/popular/history/sc_room_history_page.dart`
- `lib/modules/home/popular/mine/sc_home_mine_page.dart` - `lib/modules/home/popular/mine/sc_home_mine_page.dart`
- `lib/ui_kit/widgets/room/room_live_audio_indicator.dart`
- `lib/modules/search/sc_search_page.dart` - `lib/modules/search/sc_search_page.dart`
- `lib/modules/store/headdress/store_headdress_page.dart`
- `lib/modules/store/mountains/store_mountains_page.dart`
- `lib/modules/store/theme/store_theme_page.dart`
- `lib/modules/store/chatbox/store_chatbox_page.dart`
- `lib/modules/user/my_items/headdress/bags_headdress_page.dart`
- `lib/modules/user/my_items/mountains/bags_mountains_page.dart`
- `lib/modules/user/my_items/chatbox/bags_chatbox_page.dart`
- `lib/modules/user/my_items/theme/bags_theme_page.dart`
- `lib/ui_kit/widgets/store/store_bag_page_helpers.dart`
- `sc_images/general/sc_no_data.png` - `sc_images/general/sc_no_data.png`
- `.gitignore` - `.gitignore`
- `android/key.properties` - `android/key.properties`
@ -125,6 +144,7 @@
- 已确认当前“点击赠送没有动画”至少包含一类前端资源问题:大额礼物/幸运礼物飘屏 widget 已进入渲染,但因为背景图 asset 路径写错而无法显示;全屏 `SVGA/VAP` 特效是否播放仍取决于具体礼物是否带有 `giftSourceUrl`,且 `special` 包含 `ANIMSCION/ANIMATION/GLOBAL_GIFT` 之一。 - 已确认当前“点击赠送没有动画”至少包含一类前端资源问题:大额礼物/幸运礼物飘屏 widget 已进入渲染,但因为背景图 asset 路径写错而无法显示;全屏 `SVGA/VAP` 特效是否播放仍取决于具体礼物是否带有 `giftSourceUrl`,且 `special` 包含 `ANIMSCION/ANIMATION/GLOBAL_GIFT` 之一。
- 已完成一轮针对卡顿的代码级优化:礼物列表现在只会对真正需要全屏特效的礼物做受控预热;用户选中礼物时会立即高优先级预热该礼物;播放器播放时优先复用内存里的 `MovieEntity` 或同一路径的在途任务,不再重复发起网络下载/重复解码;渲染层也已改为独立重绘边界以减少房间整页跟随重绘。 - 已完成一轮针对卡顿的代码级优化:礼物列表现在只会对真正需要全屏特效的礼物做受控预热;用户选中礼物时会立即高优先级预热该礼物;播放器播放时优先复用内存里的 `MovieEntity` 或同一路径的在途任务,不再重复发起网络下载/重复解码;渲染层也已改为独立重绘边界以减少房间整页跟随重绘。
- 已通过 GiftFX 调试日志确认:示例礼物 `阿拉伯舞蹈` 实际返回 `giftSourceUrl=.svga``special=ANIMATION`,此前前端因为不识别该标记而输出 `skip local play because special does not include ANIMSCION/GLOBAL_GIFT`;本轮已补齐 `ANIMATION` 兼容判断。 - 已通过 GiftFX 调试日志确认:示例礼物 `阿拉伯舞蹈` 实际返回 `giftSourceUrl=.svga``special=ANIMATION`,此前前端因为不识别该标记而输出 `skip local play because special does not include ANIMSCION/GLOBAL_GIFT`;本轮已补齐 `ANIMATION` 兼容判断。
- 礼物二级页当前已按“整页骨架 + 当前页并发预热 + 下一页提前预热 + 单卡小 loading 占位”的方式重构首屏加载策略:首次进入和翻页时不会再直接暴露 `noData` 图,且整页骨架会保留一个可感知时长,不再一闪而过;当前页礼物封面会并发预热而不是等每个格子各自串行体感加载。
- 当前工作区存在用户已有未提交改动,后续处理均避开覆盖。 - 当前工作区存在用户已有未提交改动,后续处理均避开覆盖。
- 首页 `party/follow/history/mine` 以及房间详情使用的房间封面模型已兼容 `roomCover``cover` 两种返回字段,上传封面后不会再因为字段名不一致掉回空占位。 - 首页 `party/follow/history/mine` 以及房间详情使用的房间封面模型已兼容 `roomCover``cover` 两种返回字段,上传封面后不会再因为字段名不一致掉回空占位。
- 房间设置保存封面时,前端现在会同时兼容提交和读取两套字段,并在 `PUT /room/profile` 响应或紧接着的房间详情刷新返回空封面时保留刚上传的封面,不再被空值冲掉。 - 房间设置保存封面时,前端现在会同时兼容提交和读取两套字段,并在 `PUT /room/profile` 响应或紧接着的房间详情刷新返回空封面时保留刚上传的封面,不再被空值冲掉。
@ -136,6 +156,12 @@
- 静态头像框的透明区域现已保持透明,不会再被错误算成黑色;房间麦位头像、个人主页主头像和其它复用 `head()` 的头像组件进入房间后不会再出现大块黑底遮罩。 - 静态头像框的透明区域现已保持透明,不会再被错误算成黑色;房间麦位头像、个人主页主头像和其它复用 `head()` 的头像组件进入房间后不会再出现大块黑底遮罩。
- 个人主页现在在数据加载前也会先展示默认背景和底色不会再闪黑“About me / Giftwall” 内容区顶部边缘已改为直角,不再额外出现一个圆角缺口。 - 个人主页现在在数据加载前也会先展示默认背景和底色不会再闪黑“About me / Giftwall” 内容区顶部边缘已改为直角,不再额外出现一个圆角缺口。
- 个人主页当前已接入贴合页面结构的骨架屏,占位期间不会先看到背景图单独显示;资料接口返回后再无缝切到真实内容,首屏观感更平滑。 - 个人主页当前已接入贴合页面结构的骨架屏,占位期间不会先看到背景图单独显示;资料接口返回后再无缝切到真实内容,首屏观感更平滑。
- 首页 Party 页当前已接入贴合真实版式的骨架屏:进入首页首屏时会先看到三张排行卡位与双列房卡占位,骨架配色已跟随页面深绿+鎏金主视觉,不再只显示居中的白色 `loading`;且排行榜与房间区会按各自请求结果独立切换,先返回的区域会先显示真实内容。
- 首页 My 板块当前已接入贴合真实版式的骨架屏:顶部 `My room` 现区分“首次加载中”和“确实未创建房间”,不会再先闪出创建房间卡;`Recent/Followed` 在首屏空数据加载时也会先展示双列房卡骨架,不再只显示小菊花或局部空白。
- `Me` 入口下的 `Store / Bag` 页面当前也已接入深绿主题的三列卡片骨架:首次进入并且列表尚未返回时,会先显示与正式卡片比例一致的占位;接口返回后再切到真实商品/物品卡片。`store``bag` 卡片标题现都带宽度约束和单行省略,类似截图里的长名称不会再横向撑破布局。
- 首页与搜索等房卡右下角的在线状态图标当前已改为代码绘制的动态音频条:三根绿条会按不同相位走完整的波峰波谷周期,错峰连续起伏,视觉上更接近直播/语聊房的实时状态;`My` 板块骨架数量也已与 Party 页对齐为 `6` 个。
- 首页房卡底部信息当前已进一步收紧:房名和人数文字比上一版更小,底栏与动态音频条的视觉重心更一致;`My` 页顶部 `my room` 标题也已移除,下方卡片和 tab 会自然上移填充。
- 首页顶部排行骨架当前已进一步收窄为单条标题占位,不再保留两条文本骨架;房卡底栏房名也已再次缩一号并做轻微上移,对齐更贴近设计稿观感。
- 目录体积排查显示:`build/``4.7G``.dart_tool/``347M``ios/``250M``sc_images/``48M``local_packages/``6.1M` - 目录体积排查显示:`build/``4.7G``.dart_tool/``347M``ios/``250M``sc_images/``48M``local_packages/``6.1M`
- 当前包体过大的主要原因已经确认: - 当前包体过大的主要原因已经确认:
- universal APK 带入了 `arm64-v8a``armeabi-v7a``x86_64` 三套 ABI。 - universal APK 带入了 `arm64-v8a``armeabi-v7a``x86_64` 三套 ABI。