|
|
|
@ -1,6 +1,7 @@ |
|
|
|
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/extension/ex_widget.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'; |
|
|
|
@ -45,21 +46,37 @@ class MyFriendPage extends StatelessWidget { |
|
|
|
// 下拉刷新 |
|
|
|
onRefresh: () async { |
|
|
|
print('推荐列表下拉刷新被触发'); |
|
|
|
controller.page.value = 1; |
|
|
|
controller.friendList.clear(); |
|
|
|
await controller.getFriendList(); |
|
|
|
controller.listRefreshController.finishRefresh(IndicatorResult.success); |
|
|
|
controller.listRefreshController.finishLoad(IndicatorResult.none); |
|
|
|
if(controller.tab.value == 0){ |
|
|
|
controller.page.value = 1; |
|
|
|
controller.friendList.clear(); |
|
|
|
await controller.getFriendList(); |
|
|
|
controller.listRefreshController.finishRefresh(IndicatorResult.success); |
|
|
|
controller.listRefreshController.finishLoad(IndicatorResult.none); |
|
|
|
} else { |
|
|
|
controller.applyPage.value = 1; |
|
|
|
controller.friendApplyList.clear(); |
|
|
|
await controller.getFriendApplyList(); |
|
|
|
controller.listRefreshController.finishRefresh(IndicatorResult.success); |
|
|
|
controller.listRefreshController.finishLoad(IndicatorResult.none); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 上拉加载更多 |
|
|
|
onLoad: () async { |
|
|
|
print('推荐列表上拉加载被触发, hasMore: '); |
|
|
|
controller.page.value += 1; |
|
|
|
controller.getFriendList(); |
|
|
|
if(controller.tab.value == 0){ |
|
|
|
controller.page.value += 1; |
|
|
|
controller.getFriendList(); |
|
|
|
} else { |
|
|
|
controller.applyPage.value += 1; |
|
|
|
controller.getFriendApplyList(); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
constraints: BoxConstraints( |
|
|
|
minHeight: MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top, |
|
|
|
), |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
TDTabBar( |
|
|
|
@ -88,11 +105,25 @@ class MyFriendPage extends StatelessWidget { |
|
|
|
controller: controller.tabController, |
|
|
|
showIndicator: false, |
|
|
|
isScrollable: true, |
|
|
|
onTap: (index) { |
|
|
|
onTap: (index) async { |
|
|
|
print('相亲页面 Tab: $index'); |
|
|
|
controller.tab.value = index; |
|
|
|
if(index == 0){ |
|
|
|
controller.friendList.clear(); |
|
|
|
controller.page.value = 1; |
|
|
|
await controller.getFriendList(); |
|
|
|
controller.listRefreshController.finishRefresh(IndicatorResult.success); |
|
|
|
controller.listRefreshController.finishLoad(IndicatorResult.none); |
|
|
|
} else { |
|
|
|
controller.friendApplyList.clear(); |
|
|
|
controller.applyPage.value = 1; |
|
|
|
await controller.getFriendApplyList(); |
|
|
|
controller.listRefreshController.finishRefresh(IndicatorResult.success); |
|
|
|
controller.listRefreshController.finishLoad(IndicatorResult.none); |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
if(controller.friendList.isEmpty) ...[ |
|
|
|
if((controller.tab.value == 0 && controller.friendList.isEmpty) || (controller.tab.value == 1 && controller.friendApplyList.isEmpty)) ...[ |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.only(top: 60.w,bottom: 13.w), |
|
|
|
child: Center( |
|
|
|
@ -140,14 +171,16 @@ class MyFriendPage extends StatelessWidget { |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
if(controller.friendList.isNotEmpty) ...[ |
|
|
|
if(controller.tab.value == 0 && controller.friendList.isNotEmpty) ...[ |
|
|
|
...controller.friendList.map((e){ |
|
|
|
return UserItem(item: e,); |
|
|
|
}), |
|
|
|
], |
|
|
|
AddUserItem(item: fa.Records(),), |
|
|
|
AddUserItem(item: fa.Records(),), |
|
|
|
AddUserItem(item: fa.Records(),), |
|
|
|
if(controller.tab.value == 1 && controller.friendApplyList.isNotEmpty) ...[ |
|
|
|
...controller.friendApplyList.map((e){ |
|
|
|
return AddUserItem(item: e, controller: controller,); |
|
|
|
}), |
|
|
|
] |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
@ -256,7 +289,8 @@ class _UserItemState extends State<UserItem> { |
|
|
|
|
|
|
|
class AddUserItem extends StatefulWidget { |
|
|
|
final fa.Records item; |
|
|
|
const AddUserItem({super.key, required this.item}); |
|
|
|
final MyFriendController controller; |
|
|
|
const AddUserItem({super.key, required this.item, required this.controller}); |
|
|
|
|
|
|
|
@override |
|
|
|
State<AddUserItem> createState() => _AddUserItemState(); |
|
|
|
@ -378,7 +412,35 @@ class _AddUserItemState extends State<AddUserItem> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
).onTap((){ |
|
|
|
showDialog( |
|
|
|
context: context, |
|
|
|
builder: (BuildContext context) { |
|
|
|
// 返回一个 AlertDialog 组件 |
|
|
|
return AlertDialog( |
|
|
|
title: Text("提示"), |
|
|
|
content: Text("请确认是否同意添加对方为好友"), |
|
|
|
actions: <Widget>[ |
|
|
|
// 通常是按钮 |
|
|
|
TextButton( |
|
|
|
child: Text("同意"), |
|
|
|
onPressed: () async { |
|
|
|
await widget.controller.applyFriend(widget.item.id ?? "", 2, widget.item); |
|
|
|
Navigator.of(context).pop(); |
|
|
|
}, |
|
|
|
), |
|
|
|
// 通常是按钮 |
|
|
|
TextButton( |
|
|
|
child: Text("拒绝"), |
|
|
|
onPressed: () async { |
|
|
|
await widget.controller.applyFriend(widget.item.id ?? "", 3, widget.item); |
|
|
|
Navigator.of(context).pop(); |
|
|
|
}, |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
}); |
|
|
|
}) |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
|