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.
 
 
 
 
 

104 lines
3.5 KiB

import 'package:dating_touchme_app/components/page_appbar.dart';
import 'package:dating_touchme_app/controller/home/home_controller.dart';
import 'package:dating_touchme_app/pages/home/matchmaker_card.dart';
import 'package:dating_touchme_app/pages/home/nearby_tab.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';
class MatchmakerPage extends StatefulWidget {
const MatchmakerPage({super.key});
@override
State<MatchmakerPage> createState() => _MatchmakerPageState();
}
class _MatchmakerPageState extends State<MatchmakerPage> with AutomaticKeepAliveClientMixin {
final HomeController controller = Get.find<HomeController>();
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
appBar: PageAppbar(title: "金牌红娘"),
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.marchPage.value = 1;
controller.matchmakerList.clear();
await controller.getMatchmakerList();
controller.listRefreshController.finishRefresh(IndicatorResult.success);
controller.listRefreshController.finishLoad(IndicatorResult.none);
setState(() {
});
},
// 上拉加载更多
onLoad: () async {
print('推荐列表上拉加载被触发, hasMore: ');
controller.marchPage.value += 1;
await controller.getMatchmakerList();
setState(() {
});
},
child: Container(
padding: EdgeInsets.symmetric(
vertical: 6.w,
horizontal: 15.w
),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top,
),
child: GridView.builder(
padding: EdgeInsets.only(top: 8.w, left: 10.w, right: 8.w, bottom: 0.w),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // 每行2个
crossAxisSpacing: 4.w, // 左右间距
mainAxisSpacing: 4.w, // 上下间距
childAspectRatio: 1, // 宽高比
),
itemCount: controller.matchmakerList.length,
itemBuilder: (context, index) {
final visitor = controller.matchmakerList[index];
return MatchmakerCard(visitor: visitor);
},
),
),
),
),
);
}
@override
bool get wantKeepAlive => true;
}