12 changed files with 712 additions and 173 deletions
Unified View
Diff Options
-
BINassets/images/nearby_user.png
-
6lib/controller/home/friend_footprint_controller.dart
-
115lib/controller/home/home_controller.dart
-
1lib/generated/assets.dart
-
4lib/network/api_urls.dart
-
10lib/network/home_api.dart
-
77lib/network/home_api.g.dart
-
40lib/pages/home/friend_footprint.dart
-
301lib/pages/home/recommend_tab.dart
-
66lib/pages/home/report_page.dart
-
33lib/pages/message/conversation_tab.dart
-
232lib/pages/message/nearby_user.dart
@ -0,0 +1,6 @@ |
|||||
|
|
||||
|
import 'package:get/get.dart'; |
||||
|
|
||||
|
class FriendFootprintController extends GetxController { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
import 'package:dating_touchme_app/components/page_appbar.dart'; |
||||
|
import 'package:dating_touchme_app/controller/home/friend_footprint_controller.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 FriendFootprint extends StatelessWidget { |
||||
|
const FriendFootprint({super.key}); |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return GetX<FriendFootprintController>( |
||||
|
init: FriendFootprintController(), |
||||
|
builder: (controller){ |
||||
|
return Scaffold( |
||||
|
appBar: PageAppbar(title: "好友脚印"), |
||||
|
body: Container( |
||||
|
padding: EdgeInsets.all(12.w), |
||||
|
child: EasyRefresh( |
||||
|
child: ListView.separated( |
||||
|
itemBuilder: (context, index){ |
||||
|
return Container(); |
||||
|
}, |
||||
|
separatorBuilder: (context, index) { |
||||
|
// 空状态或加载状态时不显示分隔符 |
||||
|
if (true) { |
||||
|
return const SizedBox.shrink(); |
||||
|
} |
||||
|
return const SizedBox(height: 12); |
||||
|
}, |
||||
|
itemCount: 10, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
); |
||||
|
}, |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,232 @@ |
|||||
|
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/home_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/marriage_data.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/user_information_page.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 NearbyUser extends StatefulWidget { |
||||
|
const NearbyUser({super.key}); |
||||
|
|
||||
|
@override |
||||
|
State<NearbyUser> createState() => _NearbyUserState(); |
||||
|
} |
||||
|
|
||||
|
class _NearbyUserState extends State<NearbyUser> { |
||||
|
|
||||
|
|
||||
|
|
||||
|
final HomeController controller = Get.put(HomeController()); |
||||
|
late final EasyRefreshController _refreshController; |
||||
|
|
||||
|
@override |
||||
|
void initState() { |
||||
|
super.initState(); |
||||
|
_refreshController = EasyRefreshController(controlFinishRefresh: true, controlFinishLoad: true); |
||||
|
|
||||
|
controller.loadNearbyDisInitialData(); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return Scaffold( |
||||
|
appBar: PageAppbar(title: "附近的异性"), |
||||
|
body: Obx(() { |
||||
|
if (controller.nearbyIsLoading.value && controller.nearbyDisFeed.isEmpty) { |
||||
|
return Center( |
||||
|
child: Column( |
||||
|
mainAxisAlignment: MainAxisAlignment.center, |
||||
|
children: [ |
||||
|
CircularProgressIndicator(), |
||||
|
SizedBox(height: 16), |
||||
|
Text('加载附近的人数据中...'), |
||||
|
], |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
if (controller.nearbyDisFeed.isEmpty) { |
||||
|
return Center( |
||||
|
child: Column( |
||||
|
mainAxisAlignment: MainAxisAlignment.center, |
||||
|
children: [ |
||||
|
Icon(Icons.people_outline, size: 80, color: Colors.grey[300]), |
||||
|
SizedBox(height: 16), |
||||
|
Text( |
||||
|
'暂无附近的人,点击刷新', |
||||
|
style: TextStyle(fontSize: 14, color: Colors.grey), |
||||
|
), |
||||
|
SizedBox(height: 8), |
||||
|
], |
||||
|
), |
||||
|
).onTap((){ |
||||
|
controller.loadNearbyDisInitialData(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return EasyRefresh( |
||||
|
controller: _refreshController, |
||||
|
header: ClassicHeader( |
||||
|
dragText: '下拉刷新', |
||||
|
armedText: '释放刷新', |
||||
|
readyText: '刷新中...', |
||||
|
processingText: '刷新中...', |
||||
|
processedText: '刷新完成', |
||||
|
failedText: '刷新失败', |
||||
|
noMoreText: '没有更多数据', |
||||
|
messageText: '更新时间 %T', |
||||
|
showMessage: false |
||||
|
), |
||||
|
footer: ClassicFooter( |
||||
|
dragText: '上拉加载', |
||||
|
armedText: '释放加载', |
||||
|
readyText: '加载中...', |
||||
|
processingText: '加载中...', |
||||
|
processedText: '加载完成', |
||||
|
failedText: '加载失败', |
||||
|
noMoreText: '没有更多数据', |
||||
|
showMessage: false, |
||||
|
), |
||||
|
|
||||
|
// 下拉刷新 |
||||
|
onRefresh: () async { |
||||
|
print('推荐列表下拉刷新被触发'); |
||||
|
try { |
||||
|
await controller.refreshNearbyDisData(); |
||||
|
print( '推荐列表刷新完成, hasMore: $controller.recommendHasMore.value'); |
||||
|
_refreshController.finishRefresh(); |
||||
|
_refreshController.resetFooter(); |
||||
|
} catch (e) { |
||||
|
print('推荐列表刷新失败: $e'); |
||||
|
_refreshController.finishRefresh(IndicatorResult.fail); |
||||
|
} |
||||
|
}, |
||||
|
// 上拉加载更多 |
||||
|
onLoad: () async { |
||||
|
print('推荐列表上拉加载被触发, hasMore: $controller.recommendHasMore.value'); |
||||
|
try { |
||||
|
await controller.loadNearbyDisMoreData(); |
||||
|
// 完成加载,根据是否有更多数据决定 |
||||
|
if (controller.recommendHasMore.value) { |
||||
|
_refreshController.finishLoad(IndicatorResult.success); |
||||
|
print('推荐列表加载更多成功'); |
||||
|
} else { |
||||
|
_refreshController.finishLoad(IndicatorResult.noMore); |
||||
|
print('推荐列表没有更多数据了'); |
||||
|
} |
||||
|
} catch (e) { |
||||
|
print('推荐列表加载更多失败: $e'); |
||||
|
_refreshController.finishLoad(IndicatorResult.fail); |
||||
|
} |
||||
|
}, |
||||
|
child: GridView.builder( |
||||
|
padding: EdgeInsets.only(top: 8.w, left: 10.w, right: 8.w, bottom: 0.w), |
||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
||||
|
crossAxisCount: 3, // 每行2个 |
||||
|
crossAxisSpacing: 4.w, // 左右间距 |
||||
|
mainAxisSpacing: 4.w, // 上下间距 |
||||
|
childAspectRatio: 1, // 宽高比 |
||||
|
), |
||||
|
itemCount: controller.nearbyDisFeed.isEmpty ? 1 : controller.nearbyDisFeed.length, |
||||
|
itemBuilder: (context, index) { |
||||
|
final visitor = controller.nearbyDisFeed[index]; |
||||
|
return VisitorItem(visitor: visitor); |
||||
|
}, |
||||
|
), |
||||
|
); |
||||
|
}), |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
class VisitorItem extends StatelessWidget { |
||||
|
final MarriageData visitor; |
||||
|
|
||||
|
const VisitorItem({Key? key, required this.visitor}) : super(key: key); |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return Stack( |
||||
|
children: [ |
||||
|
ClipRRect( |
||||
|
borderRadius: BorderRadius.all(Radius.circular(10.w)), |
||||
|
child: CachedNetworkImage( |
||||
|
imageUrl: "${visitor.profilePhoto}?x-oss-process=image/format,webp/resize,w_240", |
||||
|
width: 113.w, |
||||
|
height: 113.w, |
||||
|
fit: BoxFit.cover, |
||||
|
placeholder: (context, url) => Container( |
||||
|
color: Colors.white38, |
||||
|
child: Center( |
||||
|
child: CircularProgressIndicator( |
||||
|
strokeWidth: 1.w, |
||||
|
color: Colors.grey, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
errorWidget: (context, url, error) => |
||||
|
Image.asset( |
||||
|
Assets.imagesUserAvatar, |
||||
|
width: 113.w, |
||||
|
height: 113.w, |
||||
|
fit: BoxFit.cover, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
Positioned( |
||||
|
left: 8.w, |
||||
|
bottom: 12.w, |
||||
|
child: Column( |
||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||
|
children: [ |
||||
|
SizedBox( |
||||
|
width: 113.w, |
||||
|
child: Row( |
||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
|
children: [ |
||||
|
Text( |
||||
|
"${visitor.age}岁 | ${visitor.districtName}", |
||||
|
style: TextStyle( |
||||
|
fontSize: 8.w, |
||||
|
color: Colors.white, |
||||
|
fontWeight: FontWeight.w500, |
||||
|
), |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
) |
||||
|
], |
||||
|
), |
||||
|
) |
||||
|
], |
||||
|
).onTap((){ |
||||
|
Get.to(() => UserInformationPage(miId: visitor.miId)); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// String _formatTime(String timestamp) { |
||||
|
// var time = DateTime.parse(timestamp); |
||||
|
// final now = DateTime.now(); |
||||
|
// final difference = now.difference(time); |
||||
|
// |
||||
|
// if (difference.inMinutes < 1) { |
||||
|
// return '刚刚'; |
||||
|
// } else if (difference.inHours < 1) { |
||||
|
// return '${difference.inMinutes}分钟前'; |
||||
|
// } else if (difference.inDays < 1) { |
||||
|
// return '${difference.inHours}小时前'; |
||||
|
// } else if (difference.inDays < 7) { |
||||
|
// return '${difference.inDays}天前'; |
||||
|
// } else { |
||||
|
// return '${time.month}/${time.day}'; |
||||
|
// } |
||||
|
// } |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save