You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
8.6 KiB
234 lines
8.6 KiB
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:dating_touchme_app/components/page_appbar.dart';
|
|
import 'package:dating_touchme_app/controller/home/event_list_controller.dart';
|
|
import 'package:dating_touchme_app/extension/ex_widget.dart';
|
|
import 'package:dating_touchme_app/generated/assets.dart';
|
|
import 'package:dating_touchme_app/model/home/event_list_data.dart';
|
|
import 'package:dating_touchme_app/pages/home/event_info.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';
|
|
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
|
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
|
|
|
|
class EventList extends StatelessWidget {
|
|
const EventList({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetX<EventListController>(
|
|
init: EventListController(),
|
|
builder: (controller){
|
|
return Scaffold(
|
|
appBar: PageAppbar(title: "活动"),
|
|
backgroundColor: const Color.fromRGBO(242, 242, 242, 1),
|
|
body: EasyRefresh(
|
|
|
|
controller: controller.listRefreshController,
|
|
header: const ClassicHeader(
|
|
dragText: '下拉刷新',
|
|
armedText: '释放刷新',
|
|
readyText: '刷新中...',
|
|
processingText: '刷新中...',
|
|
processedText: '刷新完成',
|
|
failedText: '刷新失败',
|
|
noMoreText: '没有更多数据',
|
|
showMessage: false
|
|
),
|
|
footer: ClassicFooter(
|
|
dragText: '上拉加载',
|
|
armedText: '释放加载',
|
|
readyText: '加载中...',
|
|
processingText: '加载中...',
|
|
processedText: '加载完成',
|
|
failedText: '加载失败',
|
|
noMoreText: '没有更多数据',
|
|
showMessage: false
|
|
),
|
|
// 下拉刷新
|
|
onRefresh: () async {
|
|
print('推荐列表下拉刷新被触发');
|
|
controller.page.value = 1;
|
|
controller.eventList.clear();
|
|
await controller.getEventList();
|
|
controller.listRefreshController.finishRefresh(IndicatorResult.success);
|
|
controller.listRefreshController.finishLoad(IndicatorResult.none);
|
|
},
|
|
// 上拉加载更多
|
|
onLoad: () async {
|
|
print('推荐列表上拉加载被触发, hasMore: ');
|
|
controller.page.value += 1;
|
|
await controller.getEventList();
|
|
},
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.all(15.w),
|
|
height: 165.w,
|
|
child: Swiper(
|
|
autoplay: false,
|
|
itemCount: 1,
|
|
loop: true,
|
|
onTap: (int index){
|
|
TDImageViewer.showImageViewer(context: context, images: ["https://dating-agency-test.oss-accelerate.aliyuncs.com/35BA357937A1.jpg"]);
|
|
},
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return CachedNetworkImage(
|
|
imageUrl: controller.imgList[index],
|
|
width: 345.w,
|
|
height: 165.w,
|
|
fit: BoxFit.cover,
|
|
|
|
imageBuilder: (context, imageProvider) => Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8),
|
|
image: DecorationImage(
|
|
image: imageProvider,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
errorWidget: (context, url, error) => Image.asset(
|
|
Assets.imagesUserAvatar,
|
|
width: 165.w,
|
|
height: 165.w,
|
|
fit: BoxFit.cover,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
TDTabBar(
|
|
tabs: [
|
|
TDTab(text: '近期活动'),
|
|
TDTab(text: '我的活动'),
|
|
TDTab(text: '全部活动'),
|
|
],
|
|
controller: controller.tabController,
|
|
showIndicator: true,
|
|
onTap: (int i) async {
|
|
if(controller.tab.value == i) return;
|
|
controller.tab.value = i;
|
|
controller.page.value = 1;
|
|
controller.eventList.clear();
|
|
await controller.getEventList();
|
|
},
|
|
),
|
|
ListView.builder(
|
|
padding: EdgeInsets.all(15.w),
|
|
shrinkWrap: true, // ⭐ 关键 1:高度由内容决定
|
|
physics: const NeverScrollableScrollPhysics(), // ⭐ 关键 2:禁用自身滚动
|
|
itemCount: controller.eventList.isEmpty ? 1 : controller.eventList.length,
|
|
itemBuilder: (_, index) {
|
|
if(controller.eventList.isEmpty){
|
|
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text('暂无数据'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return EventItem(item: controller.eventList[index],);
|
|
},
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class EventItem extends StatefulWidget {
|
|
final Records item;
|
|
const EventItem({super.key, required this.item});
|
|
|
|
@override
|
|
State<EventItem> createState() => _EventItemState();
|
|
}
|
|
|
|
class _EventItemState extends State<EventItem> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
margin: EdgeInsets.only(bottom: 10.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
color: Colors.white
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(8.w)),
|
|
child: Image.network(
|
|
widget.item.imgList?[0].url ?? "",
|
|
width: 345.w,
|
|
height: 150.w,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (context, error, stackTrace) {
|
|
return Image.asset(
|
|
Assets.imagesBanner,
|
|
width: 345.w,
|
|
height: 150.w,
|
|
fit: BoxFit.cover,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.all(10.w),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"${widget.item.name}",
|
|
style: TextStyle(
|
|
fontSize: 15.w,
|
|
fontWeight: FontWeight.w700
|
|
),
|
|
),
|
|
SizedBox(height: 5.w,),
|
|
Text(
|
|
"${widget.item.depict}",
|
|
style: TextStyle(
|
|
fontSize: 12.w
|
|
),
|
|
),
|
|
SizedBox(height: 5.w,),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"${widget.item.registrationPopulation}人已报名",
|
|
style: TextStyle(
|
|
fontSize: 12.w
|
|
),
|
|
),
|
|
Text(
|
|
"查看详情",
|
|
style: TextStyle(
|
|
fontSize: 12.w
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
).onTap((){
|
|
Get.to(() => EventInfo(id: widget.item.id ?? ""));
|
|
});
|
|
}
|
|
}
|
|
|