578 lines
21 KiB
Dart
578 lines
21 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:aslan/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_debounce_widget.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_page_list.dart';
|
|
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
|
|
import 'package:marquee/marquee.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../../../../chatvibe_core/config/business_logic_strategy.dart';
|
|
import '../../../../chatvibe_core/constants/at_global_config.dart';
|
|
import '../../../../chatvibe_data/models/enum/at_vip_type.dart';
|
|
import '../../../../chatvibe_data/sources/local/user_manager.dart';
|
|
import '../../../../chatvibe_data/sources/repositories/user_repository_impl.dart';
|
|
import '../../../../chatvibe_domain/models/res/follow_room_res.dart';
|
|
import '../../../../chatvibe_managers/room_manager.dart';
|
|
import '../../../../chatvibe_managers/rtc_manager.dart';
|
|
import '../../../../chatvibe_ui/components/at_compontent.dart';
|
|
import '../../../../chatvibe_ui/widgets/country/at_country_flag_image.dart';
|
|
import '../../../../chatvibe_ui/theme/chatvibe_theme.dart';
|
|
|
|
class HomeMinePage extends ATPageList {
|
|
@override
|
|
_HomeMinePageState createState() => _HomeMinePageState();
|
|
}
|
|
|
|
class _HomeMinePageState extends ATPageListState<FollowRoomRes, HomeMinePage> {
|
|
List<FollowRoomRes> historyRooms = [];
|
|
String? lastId;
|
|
|
|
BusinessLogicStrategy get _strategy => ATGlobalConfig.businessLogicStrategy;
|
|
|
|
bool isLoading = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
enablePullUp = true;
|
|
backgroundColor = Colors.transparent;
|
|
loadData(1);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 15.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.myRoom,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.black,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 5.w),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 12.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12.w),
|
|
color: Colors.white,
|
|
border: Border.all(color: ChatVibeTheme.primaryLight, width: 1.w),
|
|
),
|
|
width: ScreenUtil().screenWidth,
|
|
height: 85.w,
|
|
child: _buildMyRoom(),
|
|
),
|
|
SizedBox(height: 5.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 15.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.history,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.black,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 5.w),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 12.w),
|
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12.w),
|
|
color: Colors.white,
|
|
border: Border.all(color: ChatVibeTheme.primaryLight, width: 1.w),
|
|
),
|
|
width: ScreenUtil().screenWidth,
|
|
height: 85.w,
|
|
child:
|
|
historyRooms.isNotEmpty
|
|
? SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
spacing: 6.w,
|
|
crossAxisAlignment: CrossAxisAlignment.center, // 垂直居中
|
|
children: List.generate(historyRooms.length, (index) {
|
|
return Padding(
|
|
padding: EdgeInsets.only(
|
|
right: index == historyRooms.length - 1 ? 0 : 6.w,
|
|
),
|
|
child: _buildHistoryRoomItem(historyRooms[index]),
|
|
);
|
|
}),
|
|
),
|
|
)
|
|
: Row(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/general/at_icon_no_data_icon2.png",
|
|
width: 70.w,
|
|
height: 70.w,
|
|
),
|
|
SizedBox(width: 8.w),
|
|
text(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.noHistoricalRecordsAvailable,
|
|
fontSize: 14.sp,
|
|
textColor: Colors.black,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 5.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 15.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.following,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.black,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 5.w),
|
|
Expanded(child: buildList(context)),
|
|
],
|
|
);
|
|
}
|
|
|
|
_buildMyRoom() {
|
|
return Consumer<ChatVibeRoomManager>(
|
|
builder: (_, provider, __) {
|
|
return provider.myRoom != null
|
|
? GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
netImage(
|
|
url: provider.myRoom?.roomCover ?? "",
|
|
borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
width: 70.w,
|
|
),
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child: Stack(
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(height: 6.w),
|
|
Container(
|
|
constraints: BoxConstraints(
|
|
maxWidth: 200.w,
|
|
maxHeight: 24.w,
|
|
),
|
|
child:
|
|
(provider.myRoom?.roomName?.length ?? 0) > 18
|
|
? Marquee(
|
|
text: provider.myRoom?.roomName ?? "",
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
decoration: TextDecoration.none,
|
|
),
|
|
scrollAxis: Axis.horizontal,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
blankSpace: 40.0,
|
|
velocity: 40.0,
|
|
pauseAfterRound: Duration(seconds: 1),
|
|
accelerationDuration: Duration(
|
|
seconds: 1,
|
|
),
|
|
accelerationCurve: Curves.easeOut,
|
|
decelerationDuration: Duration(
|
|
milliseconds: 500,
|
|
),
|
|
decelerationCurve: Curves.easeOut,
|
|
)
|
|
: Text(
|
|
provider.myRoom?.roomName ?? "",
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
decoration: TextDecoration.none,
|
|
),
|
|
),
|
|
),
|
|
text(
|
|
provider.myRoom?.roomDesc ?? "",
|
|
fontSize: 14.sp,
|
|
textColor: Colors.black,
|
|
),
|
|
text(
|
|
"ID:${AccountStorage().getCurrentUser()?.userProfile?.getID()}",
|
|
fontSize: 12.sp,
|
|
textColor: Colors.black54,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Icon(
|
|
ATGlobalConfig.lang == "ar"
|
|
? Icons.keyboard_arrow_left
|
|
: Icons.keyboard_arrow_right,
|
|
size: 25.w,
|
|
color: Colors.white,
|
|
),
|
|
SizedBox(width: 12.w),
|
|
],
|
|
),
|
|
onTap: () {
|
|
String roomId =
|
|
Provider.of<ChatVibeRoomManager>(
|
|
context,
|
|
listen: false,
|
|
).myRoom?.id ??
|
|
"";
|
|
Provider.of<RealTimeCommunicationManager>(
|
|
context,
|
|
listen: false,
|
|
).joinRoom(context, roomId);
|
|
},
|
|
)
|
|
: GestureDetector(
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Image.asset(
|
|
"atu_images/general/at_icon_edit_user_info_add_pic.png",
|
|
height: 70.w,
|
|
width: 70.w,
|
|
),
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.crateMyRoom,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.black,
|
|
),
|
|
],
|
|
),
|
|
onTap: () {
|
|
provider.createRoom(context);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
void _loadOtherData() {
|
|
ATLoadingManager.exhibitOperation();
|
|
AccountRepository()
|
|
.trace()
|
|
.then((res) {
|
|
historyRooms = res;
|
|
ATLoadingManager.veilRoutine();
|
|
setState(() {});
|
|
})
|
|
.catchError((_) {
|
|
ATLoadingManager.veilRoutine();
|
|
});
|
|
}
|
|
|
|
_buildHistoryRoomItem(FollowRoomRes roomRes) {
|
|
return GestureDetector(
|
|
child: SizedBox(
|
|
width: 70.w,
|
|
height: 70.w,
|
|
child: Stack(
|
|
children: [
|
|
netImage(
|
|
url: roomRes.roomProfile?.roomCover ?? "",
|
|
width: 70.w,
|
|
height: 70.w,
|
|
fit: BoxFit.cover,
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
),
|
|
(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(
|
|
"atu_images/index/at_icon_room_suo.png",
|
|
width: 16.w,
|
|
height: 16.w,
|
|
)
|
|
: Container(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).joinRoom(context, roomRes.roomProfile?.id ?? "");
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget buildItem(FollowRoomRes res) {
|
|
return ATDebounceWidget(
|
|
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: 5.w,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Stack(
|
|
children: [
|
|
netImage(
|
|
url: res.roomProfile?.roomCover ?? "",
|
|
fit: BoxFit.cover,
|
|
borderRadius: BorderRadius.all(Radius.circular(12.w)),
|
|
width: 95.w,
|
|
height: 95.w,
|
|
),
|
|
PositionedDirectional(
|
|
top: 3.w,
|
|
end: 5.w,
|
|
child:
|
|
(res
|
|
.roomProfile
|
|
?.extValues
|
|
?.roomSetting
|
|
?.password
|
|
?.isNotEmpty ??
|
|
false)
|
|
? Image.asset(
|
|
"atu_images/index/at_icon_room_suo.png",
|
|
width: 16.w,
|
|
height: 16.w,
|
|
)
|
|
: Container(),
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(height: 15.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 8.w),
|
|
ATCountryFlagImage(
|
|
countryName: res.roomProfile?.countryName,
|
|
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?.userProfile?.getID()}",
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.black,
|
|
fontSize: 15.sp,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 3.w),
|
|
Container(
|
|
constraints: BoxConstraints(maxWidth: 180.w),
|
|
margin: EdgeInsetsDirectional.symmetric(
|
|
horizontal: 8.w,
|
|
),
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 2.w,
|
|
children: List.generate(
|
|
(res.onlineUsers?.length ?? 0),
|
|
(index) {
|
|
return netImage(
|
|
url: res.onlineUsers?[index].userAvatar ?? "",
|
|
width: 23.w,
|
|
height: 23.w,
|
|
shape: BoxShape.circle,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
PositionedDirectional(
|
|
end: 35.w,
|
|
bottom: 25.w,
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/index/at_icon_room_flot_ani.gif",
|
|
width: 14.w,
|
|
height: 14.w,
|
|
),
|
|
text(
|
|
res.roomProfile?.extValues?.memberQuantity ?? "0",
|
|
textColor: Colors.black38,
|
|
fontSize: 11.sp,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
Provider.of<RtcProvider>(
|
|
context,
|
|
listen: false,
|
|
).joinRoom(context, res.roomProfile?.id ?? "");
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
builderDivider() {
|
|
// return Divider(
|
|
// height: 1.w,
|
|
// color: Color(0xff3D3277).withOpacity(0.5),
|
|
// indent: 15.w,
|
|
// );
|
|
return Container(height: 4.w);
|
|
}
|
|
|
|
///加载数据
|
|
@override
|
|
loadPage({
|
|
required int page,
|
|
required Function(List<FollowRoomRes>) onSuccess,
|
|
Function? onErr,
|
|
}) async {
|
|
_loadOtherData();
|
|
if (page == 1) {
|
|
lastId = null;
|
|
}
|
|
try {
|
|
var roomList = await AccountRepository().followRoomList(lastId: lastId);
|
|
if (roomList.isNotEmpty) {
|
|
lastId = roomList.last.id;
|
|
}
|
|
onSuccess(roomList);
|
|
} catch (e) {
|
|
if (onErr != null) {
|
|
onErr();
|
|
}
|
|
}
|
|
}
|
|
|
|
String getRoomCoverHeaddress(FollowRoomRes roomRes) {
|
|
var vip = roomRes.roomProfile?.userProfile?.getVIP();
|
|
if (vip?.name == ATVIPType.DUKE.name) {
|
|
return "atu_images/vip/at_icon_vip4_room_cover_headdress.png";
|
|
} else if (vip?.name == ATVIPType.KING.name) {
|
|
return "atu_images/vip/at_icon_vip5_room_cover_headdress.png";
|
|
} else if (vip?.name == ATVIPType.EMPEROR.name) {
|
|
return "atu_images/vip/at_icon_vip6_room_cover_headdress.png";
|
|
}
|
|
return "";
|
|
}
|
|
}
|