|
|
|
@ -1,6 +1,7 @@ |
|
|
|
import 'package:dating_touchme_app/controller/discover/discover_controller.dart'; |
|
|
|
import 'package:dating_touchme_app/extension/ex_widget.dart'; |
|
|
|
import 'package:dating_touchme_app/pages/discover/live_item_widget.dart'; |
|
|
|
import 'package:easy_refresh/easy_refresh.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
@ -21,6 +22,8 @@ class _DatingPageState extends State<DatingPage> |
|
|
|
late final DiscoverController discoverController; |
|
|
|
late final TabController _tabController; |
|
|
|
late final RoomController roomController; |
|
|
|
late final EasyRefreshController _refreshController; |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
@ -35,12 +38,17 @@ class _DatingPageState extends State<DatingPage> |
|
|
|
roomController = Get.put(RoomController()); |
|
|
|
} |
|
|
|
_tabController = TabController(length: 4, vsync: this); |
|
|
|
_refreshController = EasyRefreshController( |
|
|
|
controlFinishRefresh: true, |
|
|
|
controlFinishLoad: true, |
|
|
|
); |
|
|
|
discoverController.loadRtcChannelPage(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
_tabController.dispose(); |
|
|
|
_refreshController.dispose(); |
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -114,20 +122,48 @@ class _DatingPageState extends State<DatingPage> |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
return SingleChildScrollView( |
|
|
|
padding: EdgeInsets.symmetric(vertical: 5.w), |
|
|
|
child: Wrap( |
|
|
|
spacing: 7.w, |
|
|
|
runSpacing: 7.w, |
|
|
|
children: discoverController.rtcChannelList.map((channel) { |
|
|
|
return EasyRefresh( |
|
|
|
controller: _refreshController, |
|
|
|
header: const ClassicHeader( |
|
|
|
dragText: '下拉刷新', |
|
|
|
armedText: '释放刷新', |
|
|
|
readyText: '刷新中...', |
|
|
|
processingText: '刷新中...', |
|
|
|
processedText: '刷新完成', |
|
|
|
failedText: '刷新失败', |
|
|
|
noMoreText: '没有更多数据', |
|
|
|
showMessage: false, |
|
|
|
), |
|
|
|
onRefresh: () async { |
|
|
|
print('相亲页面下拉刷新被触发'); |
|
|
|
try { |
|
|
|
await discoverController.refreshRtcChannelPage(); |
|
|
|
_refreshController.finishRefresh(IndicatorResult.success); |
|
|
|
print('相亲页面刷新完成'); |
|
|
|
} catch (e) { |
|
|
|
print('相亲页面刷新失败: $e'); |
|
|
|
_refreshController.finishRefresh(IndicatorResult.fail); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: GridView.builder( |
|
|
|
padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 0), |
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
crossAxisCount: 2, // 每行2个 |
|
|
|
crossAxisSpacing: 7.w, // 左右间距 |
|
|
|
mainAxisSpacing: 7.w, // 上下间距 |
|
|
|
childAspectRatio: 1, // 宽高比 |
|
|
|
), |
|
|
|
itemCount: discoverController.rtcChannelList.length, |
|
|
|
itemBuilder: (context, index) { |
|
|
|
final channel = discoverController.rtcChannelList[index]; |
|
|
|
print('渲染频道: ${channel.channelId}, ${channel.channelName}'); |
|
|
|
return LiveItemWidget( |
|
|
|
channel: channel, |
|
|
|
channelId: channel.channelId, |
|
|
|
).onTap(() async{ |
|
|
|
).onTap(() async { |
|
|
|
await roomController.joinChannel(channel.channelId); |
|
|
|
}); |
|
|
|
}).toList(), |
|
|
|
}, |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
|