199 lines
5.4 KiB
Dart
199 lines
5.4 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
import '../../components/my_app_bar.dart';
|
|
import '../../router/app_routers.dart';
|
|
import '../../util/util.dart';
|
|
import 'logic.dart';
|
|
|
|
class FriendslistPage extends StatelessWidget {
|
|
FriendslistPage({Key? key}) : super(key: key);
|
|
|
|
final logic = Get.find<FriendslistLogic>();
|
|
final state = Get.find<FriendslistLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<FriendslistLogic>(builder: (logic) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(getBaseImage("home_back")),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
child: Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
appBar: MyAppBar(
|
|
centerTitle: _getTitleName(logic.type),
|
|
),
|
|
body: SafeArea(
|
|
child: SmartRefresher(
|
|
controller: logic.refreshController,
|
|
onRefresh: _onRefresh,
|
|
onLoading: _onLoading,
|
|
child: ListView.builder(
|
|
// padding: EdgeInsets.all(16.sp),
|
|
itemCount: logic.lists.length,
|
|
itemBuilder: (context, index) {
|
|
return ListItem(logic.lists[index]);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
Widget ListItem(UserInfo item) {
|
|
return GestureDetector(
|
|
onTap: (){
|
|
Get.toNamed(AppRoutes.UserInfoActivity, arguments: item.id.toString());
|
|
},
|
|
child: Container(
|
|
margin: EdgeInsets.only(bottom: 21),
|
|
child: Row(
|
|
children: [
|
|
Stack(children: [
|
|
ClipOval(
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
var imgList = <String>[];
|
|
imgList.add(item.avatar);
|
|
Get.toNamed(AppRoutes.Swiper, arguments: {
|
|
'imaglist': imgList,
|
|
'index': 0
|
|
});
|
|
},
|
|
child: CachedNetworkImage(
|
|
imageUrl: item.avatar,
|
|
width: 53.sp,
|
|
height: 53.sp,
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
left: 0,
|
|
bottom: 0,
|
|
|
|
child: item.vip>0 ?
|
|
Image(
|
|
image: AssetImage(getBaseImage("vip")),
|
|
width: 44.sp,
|
|
height: 18.sp,
|
|
):Container(),)
|
|
],),
|
|
SizedBox(width: 10.sp),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Text(
|
|
item.nickname,
|
|
style: const TextStyle(color :Colors.white70,fontSize: 14, fontWeight: FontWeight.bold),
|
|
),
|
|
SizedBox(width: 4.sp),
|
|
// SizedBox(height: 8.sp),
|
|
_buildInfoRow(item),
|
|
// Placeholder image
|
|
],
|
|
),
|
|
|
|
SizedBox(height: 8.sp),
|
|
Container(
|
|
width: 150.sp,
|
|
child: Text(
|
|
item.signature,
|
|
style: TextStyle(fontSize: 12.sp, color: Color(0xFFB7BECC)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
// Pla
|
|
Spacer(),
|
|
GestureDetector(onTap: (){
|
|
showToast("私聊");
|
|
},
|
|
child: Container(
|
|
width: 60,
|
|
height: 28,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFFFF4D7C),
|
|
borderRadius: BorderRadius.circular(14),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"私聊",
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
),
|
|
),
|
|
),),
|
|
],
|
|
),
|
|
),);
|
|
}
|
|
|
|
|
|
|
|
Widget _buildInfoRow(UserInfo userInfoBean) {
|
|
String ageMsg = getAgeCOntent(userInfoBean!.gender, userInfoBean!.age,
|
|
userInfoBean!.role, userInfoBean!.orientation);
|
|
return Row(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(17),
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color.fromRGBO(141, 255, 248, 1.0),
|
|
Color.fromRGBO(181, 211, 255, 1.0),
|
|
],
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
),
|
|
),
|
|
padding: EdgeInsets.only(
|
|
top: 2.sp, bottom: 2.sp, left: 10.sp, right: 10.sp),
|
|
child: Text(
|
|
ageMsg ,
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 10,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 6.sp),
|
|
|
|
],
|
|
);
|
|
}
|
|
String _getTitleName(String type) {
|
|
switch (type) {
|
|
case "0":
|
|
return "我喜欢的";
|
|
case "1":
|
|
return "喜欢我的";
|
|
case "2":
|
|
return "最近访客";
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
void _onRefresh() async {
|
|
logic.page = 1;
|
|
logic.initList();
|
|
}
|
|
|
|
void _onLoading() async {
|
|
logic.page = logic.page + 1;
|
|
logic.initList();
|
|
}
|
|
}
|