import 'package:cached_network_image/cached_network_image.dart'; import 'package:dating_touchme_app/components/page_appbar.dart'; import 'package:dating_touchme_app/controller/mine/my_friend_controller.dart'; import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/model/mine/friend_data.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'; class MyFriendPage extends StatelessWidget { const MyFriendPage({super.key}); @override Widget build(BuildContext context) { return GetX( init: MyFriendController(), builder: (controller){ 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.page.value = 1; controller.friendList.clear(); await controller.getFriendList(); controller.listRefreshController.finishRefresh(IndicatorResult.success); controller.listRefreshController.finishLoad(IndicatorResult.none); }, // 上拉加载更多 onLoad: () async { print('推荐列表上拉加载被触发, hasMore: '); controller.page.value += 1; controller.getFriendList(); }, child: SingleChildScrollView( child: Container( padding: EdgeInsets.symmetric(horizontal: 12.w), child: Column( children: [ TDTabBar( tabs: [ TDTab( child: Padding( padding: EdgeInsets.only(right: 16, left: 16), child: Text('我的关注'), ), ), TDTab( child: Padding( padding: EdgeInsets.only(right: 16, left: 16), child: Text('好友'), ), ), TDTab( child: Padding( padding: EdgeInsets.only(right: 12, left: 12), child: Text('粉丝'), ), ), ], backgroundColor: Colors.transparent, labelPadding: const EdgeInsets.only(right: 4, top: 10, bottom: 10, left: 4), selectedBgColor: const Color.fromRGBO(108, 105, 244, 1), unSelectedBgColor: Colors.transparent, labelColor: Colors.white, dividerHeight: 0, tabAlignment: TabAlignment.start, outlineType: TDTabBarOutlineType.capsule, controller: controller.tabController, showIndicator: false, isScrollable: true, onTap: (index) { print('相亲页面 Tab: $index'); }, ), if(controller.friendList.isEmpty) ...[ Container( padding: EdgeInsets.only(top: 60.w,bottom: 13.w), child: Center( child: Image.asset( Assets.imagesEmptyIcon, width: 91.w, height: 91.w, ), ), ), Text( "你还没有关注任何人噢", style: TextStyle( fontSize: 12.w, fontWeight: FontWeight.w500, color: const Color.fromRGBO(144, 144, 144, 1) ), ), Container( width: 151.w, height: 32.w, margin: EdgeInsets.only(top: 11.w), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(32.w)), gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, stops: [0.0, 0.7753, 1.0], colors: [ Color.fromRGBO(131, 89, 255, 1), Color.fromRGBO(77, 127, 231, 1), Color.fromRGBO(61, 138, 224, 1), ], ), ), child: Center( child: Text( "去聊聊", style: TextStyle( fontSize: 12.w, color: Colors.white, fontWeight: FontWeight.w500 ), ), ), ), ], if(controller.friendList.isNotEmpty) ...[ ...controller.friendList.map((e){ return UserItem(item: e,); }) ] ], ), ), ), ), ); }, ); } } class UserItem extends StatefulWidget { final Records item; const UserItem({super.key, required this.item}); @override State createState() => _UserItemState(); } class _UserItemState extends State { @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.symmetric( vertical: 15.w ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ ClipRRect( borderRadius: BorderRadius.all(Radius.circular(45.w)), child: CachedNetworkImage( imageUrl: "${widget.item.profilePhoto ?? ""}?x-oss-process=image/format,webp/resize,w_170", width: 45.w, height: 45.w, fit: BoxFit.cover, ), ), SizedBox(width: 9.w,), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text( "${widget.item.nickName}", style: TextStyle( fontSize: 14.w, fontWeight: FontWeight.w500 ), ), Container( margin: EdgeInsets.only(left: 7.w), width: 12.w, height: 12.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(12.w)), color: widget.item.genderCode == 0 ? const Color.fromRGBO(237, 245, 255, 1) : const Color.fromRGBO(255, 237, 255, 1) ), child: Center( child: Image.asset( widget.item.genderCode == 0 ? Assets.imagesMale : Assets.imagesFemale, width: 7.w, ), ), ) ], ), Text( "30岁·广州", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(144, 144, 144, 1), fontWeight: FontWeight.w500 ), ) ], ) ], ), Container( width: 60.w, height: 22.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(22.w)), color: const Color.fromRGBO(224, 224, 224, .5) ), child: Center( child: Text( "已关注", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(144, 144, 144, 1), fontWeight: FontWeight.w500 ), ), ), ) ], ), ); } }