697 lines
26 KiB
Dart
697 lines
26 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:flutter_swiper/flutter_swiper.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:gradient_borders/box_borders/gradient_box_border.dart';
|
||
|
||
import '../../../common/colors/app_color.dart';
|
||
import '../../../common/const.dart';
|
||
import '../../../network/api.dart';
|
||
import '../../../network/dio_manager.dart';
|
||
import '../../../router/app_routers.dart';
|
||
import '../../../util/util.dart';
|
||
import '../../chat/TIMUIKitChat/TIMUIKitMessageItem/TIMUIKitMessageReaction/tim_uikit_chat_gift_elem.dart';
|
||
import '../../home/logic.dart';
|
||
import 'discover.dart';
|
||
|
||
|
||
class DiscoverItem extends StatefulWidget {
|
||
double screenHeight;
|
||
Function deleteCallBack;
|
||
Function likeCallBack;
|
||
List list;
|
||
int index;
|
||
String onLineStr;
|
||
|
||
DiscoverItem(this.screenHeight,this.list,this.index,this.onLineStr,this.deleteCallBack,this.likeCallBack, {super.key});
|
||
|
||
|
||
// screenHeight
|
||
@override
|
||
_DiscoverItemState createState() => new _DiscoverItemState();
|
||
|
||
}
|
||
|
||
class _DiscoverItemState extends State<DiscoverItem> {
|
||
// TODO: add state variables and methods
|
||
var user;
|
||
String onLineStr = '';
|
||
HomeLogic logic = Get.find<HomeLogic>();
|
||
|
||
@override
|
||
void initState() {
|
||
// TODO: implement initState
|
||
super.initState();
|
||
user = Users.fromJson(widget.list[widget.index]);
|
||
onLineStr= widget.onLineStr;
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
// TODO: add widget build method
|
||
return Container(
|
||
height: widget.screenHeight,
|
||
width: Get.width,
|
||
margin: EdgeInsets.only(
|
||
top: 5.sp, left: 16.sp, right: 16.sp),
|
||
child: Stack(
|
||
children: [
|
||
Container(
|
||
clipBehavior: Clip.hardEdge,
|
||
decoration: BoxDecoration(
|
||
color: Colors.black.withOpacity(0.25),
|
||
borderRadius: BorderRadius.circular(10.sp),
|
||
border: GradientBoxBorder(
|
||
gradient:
|
||
AppColor.mainVerLinearGradient,
|
||
width: 1.sp,
|
||
),
|
||
// image: DecorationImage(
|
||
// fit: BoxFit.fill,
|
||
// image: AssetImage(
|
||
// getCircleImage('open_vip_bg'),
|
||
// ))
|
||
),
|
||
height: widget.screenHeight,
|
||
width: Get.width,
|
||
child: ClipRRect(
|
||
borderRadius: BorderRadius.circular(10),
|
||
// clipBehavior: Clip.hardEdge,
|
||
child: Container(
|
||
// padding: EdgeInsets.all(2.sp),
|
||
child: Swiper(
|
||
autoplay: false,
|
||
loop: user.images!.length == 1
|
||
? false
|
||
: true,
|
||
itemBuilder:
|
||
(BuildContext context, int index) {
|
||
// print(index);
|
||
return GestureDetector(
|
||
onTap: () {
|
||
List<String> imgList = [];
|
||
user.images!.forEach((element) {
|
||
imgList.add(element);
|
||
});
|
||
|
||
Get.toNamed(AppRoutes.Swiper,
|
||
arguments: {
|
||
'imaglist': imgList,
|
||
'index': index
|
||
});
|
||
},
|
||
child: CachedNetworkImage(
|
||
imageUrl: user.images![index],
|
||
fit: BoxFit.cover,
|
||
width: Get.width,
|
||
height:widget.screenHeight,
|
||
));
|
||
},
|
||
itemCount: user.images!.length,
|
||
),
|
||
)),
|
||
),
|
||
Positioned(
|
||
left: 5.sp,
|
||
top: 10.sp,
|
||
child: Container(
|
||
child: Column(
|
||
crossAxisAlignment:
|
||
CrossAxisAlignment.start,
|
||
children: [
|
||
if (onLineStr.isNotEmpty)
|
||
Container(
|
||
height: 24.sp,
|
||
padding: EdgeInsets.only(
|
||
left: 6.sp, right: 6.sp),
|
||
decoration: BoxDecoration(
|
||
color: Colors.black
|
||
.withOpacity(0.35),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
12.sp)),
|
||
child: Row(
|
||
children: [
|
||
Container(
|
||
width: 6.sp,
|
||
height: 6.sp,
|
||
margin: EdgeInsets.only(
|
||
right: 4.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
3.sp),
|
||
color:
|
||
const Color(0xFFCE51FF),
|
||
),
|
||
),
|
||
// if (logic.online)
|
||
Text(
|
||
onLineStr,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
if (user.both_cities!.isNotEmpty)
|
||
SizedBox(
|
||
height: 8.sp,
|
||
),
|
||
if (user.both_cities!.isNotEmpty)
|
||
Container(
|
||
height: 24.sp,
|
||
padding: EdgeInsets.only(
|
||
left: 6.sp, right: 6.sp),
|
||
decoration: BoxDecoration(
|
||
color: Colors.black
|
||
.withOpacity(0.35),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
12.sp)),
|
||
child: Row(
|
||
children: [
|
||
Container(
|
||
width: 6.sp,
|
||
height: 6.sp,
|
||
margin: EdgeInsets.only(
|
||
right: 4.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
3.sp),
|
||
color: const Color(
|
||
0xFFCE51FF),
|
||
),
|
||
),
|
||
// if (logic.online)
|
||
Text(
|
||
"你们都来过${user.both_cities!.first}",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp),
|
||
),
|
||
],
|
||
)),
|
||
if (user.both_cities!.isNotEmpty)
|
||
SizedBox(
|
||
height: 8.sp,
|
||
),
|
||
if (user.both_interests!.isNotEmpty)
|
||
Container(
|
||
height: 24.sp,
|
||
padding: EdgeInsets.only(
|
||
left: 6.sp, right: 6.sp),
|
||
decoration: BoxDecoration(
|
||
color: Colors.black
|
||
.withOpacity(0.35),
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
12.sp)),
|
||
child: Row(
|
||
children: [
|
||
Container(
|
||
width: 6.sp,
|
||
height: 6.sp,
|
||
margin: EdgeInsets.only(
|
||
right: 4.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
3.sp),
|
||
color: const Color(
|
||
0xFFCE51FF),
|
||
),
|
||
),
|
||
// if (logic.online)
|
||
Text(
|
||
"你们有共同的圈子:${user.both_interests!.first['title']}",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp),
|
||
),
|
||
],
|
||
)),
|
||
],
|
||
),
|
||
)),
|
||
Positioned(
|
||
right: 16.sp,
|
||
top: 16.sp,
|
||
child: GestureDetector(
|
||
onTap: () {
|
||
Get.toNamed(AppRoutes.UserInfoActivity,
|
||
arguments: user.userId!.toString());
|
||
},
|
||
child: Container(
|
||
width: 73.sp,
|
||
height: 25.sp,
|
||
decoration: BoxDecoration(
|
||
gradient:
|
||
AppColor.mainVerLinearGradient,
|
||
borderRadius:
|
||
BorderRadius.circular(12.5.sp)),
|
||
child: Row(
|
||
mainAxisAlignment:
|
||
MainAxisAlignment.center,
|
||
children: [
|
||
Container(
|
||
margin: EdgeInsets.only(left: 5.sp),
|
||
child: Text(
|
||
'查看主页',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 10.sp,
|
||
),
|
||
),
|
||
),
|
||
Image(
|
||
width: 15.sp,
|
||
image: AssetImage(
|
||
getDisCoverImage("right_icon")),
|
||
// width: 44.sp,
|
||
),
|
||
],
|
||
),
|
||
),
|
||
)),
|
||
|
||
Positioned(
|
||
left: 6.sp,
|
||
bottom: 6.sp,
|
||
child: Container(
|
||
width: Get.width - 32.sp,
|
||
padding: EdgeInsets.only(right: 0.sp),
|
||
child: Column(
|
||
crossAxisAlignment:
|
||
CrossAxisAlignment.start,
|
||
children: [
|
||
if (user.wxNum != null && logic.isProd)
|
||
wxStatusWidget(
|
||
user.unLockWxNum == 1,
|
||
user.wxNum!,
|
||
user.userId.toString(),
|
||
0,
|
||
user.avatarUrl!, () {
|
||
loadSignDiscoverData(
|
||
user.userId.toString());
|
||
}),
|
||
SizedBox(
|
||
height: 15.sp,
|
||
),
|
||
Row(
|
||
children: [
|
||
Text(
|
||
user.nickname ?? '',
|
||
style: TextStyle(
|
||
fontSize: 18.sp,
|
||
color: Color(0XFFF7FAFA),
|
||
fontWeight: FontWeight.bold),
|
||
),
|
||
Container(
|
||
margin:
|
||
EdgeInsets.only(left: 5.sp),
|
||
alignment: Alignment.center,
|
||
height: 18.sp,
|
||
padding: EdgeInsets.only(
|
||
left: 6.sp, right: 6.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius:
|
||
BorderRadius.circular(
|
||
9.sp),
|
||
gradient:
|
||
const LinearGradient(
|
||
begin: Alignment(
|
||
0.25, 0.5),
|
||
end: Alignment(
|
||
0.75, 0.5),
|
||
colors: [
|
||
Color(0xff8DFFF8),
|
||
Color(0xffB5D3FF)
|
||
])),
|
||
child: Text(
|
||
getAgeCOntent(
|
||
user!.gender ?? 0,
|
||
user!.age ?? 0,
|
||
user!.role ?? 0,
|
||
user!.orientation ?? 0),
|
||
style: TextStyle(
|
||
color: Colors.black,
|
||
fontSize: 12.sp,
|
||
),
|
||
),
|
||
),
|
||
if (user.vip! > 0)
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
left: 4.sp,
|
||
),
|
||
child: Image.asset(
|
||
getCircleImage(user!.vip == 1
|
||
? 'vip'
|
||
: 'year_vip'),
|
||
width: 36.sp,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
Container(
|
||
width: Get.width - 120.sp,
|
||
margin: EdgeInsets.only(
|
||
top: 15.sp, bottom: 15.sp),
|
||
child: Text(
|
||
user.signature! ?? '',
|
||
overflow: TextOverflow.ellipsis,
|
||
maxLines:
|
||
(user.signature! ?? '').length >
|
||
15
|
||
? 2
|
||
: 1,
|
||
style: TextStyle(
|
||
fontSize: 16.sp,
|
||
color: const Color(0XFFF7FAFA)),
|
||
),
|
||
),
|
||
Container(
|
||
width: Get.width - 110.sp,
|
||
height: 35.sp,
|
||
child: tagItem(user.interests!),
|
||
),
|
||
],
|
||
),
|
||
)),
|
||
Positioned(
|
||
bottom: 5.sp,
|
||
right: 15.sp,
|
||
child: Container(
|
||
child: Column(
|
||
children: [
|
||
GestureDetector(
|
||
onTap: () async {
|
||
showGiftPannel(user.imAccid!.toString());
|
||
},
|
||
child: Image.asset(
|
||
getMsgImage('gift'),
|
||
width: 50.sp,
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 25.sp,
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
pushChatPage(
|
||
user.userId.toString(),
|
||
user.imAccid!.toString(),
|
||
user.nickname!);
|
||
},
|
||
child: Image.asset(
|
||
getCircleImage(
|
||
'chat_icon',
|
||
),
|
||
width: 50.sp,
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 25.sp,
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
widget.likeCallBack();
|
||
},
|
||
child: Image.asset(
|
||
getCircleImage(
|
||
user.is_follow!
|
||
? 'like_icon'
|
||
: 'nor_like_icon',
|
||
),
|
||
width: 50.sp,
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 20.sp,
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
_showReportDialog(context,
|
||
user.userId!.toString(), widget.index);
|
||
},
|
||
child: Image.asset(
|
||
getCircleImage(
|
||
'no_look_icon',
|
||
),
|
||
width: 50.sp,
|
||
),
|
||
)
|
||
],
|
||
),
|
||
))
|
||
],
|
||
));
|
||
}
|
||
|
||
|
||
void _showReportDialog(
|
||
BuildContext context, String userId, int currentIndex) {
|
||
showDialog(
|
||
context: context,
|
||
builder: (BuildContext context) {
|
||
return Dialog(
|
||
backgroundColor: Colors.transparent,
|
||
child: Container(
|
||
height: 277.sp,
|
||
padding: const EdgeInsets.all(1.0),
|
||
child: Stack(
|
||
children: [
|
||
Container(
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.rectangle,
|
||
borderRadius: BorderRadius.circular(10.0),
|
||
gradient: const LinearGradient(
|
||
colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)],
|
||
begin: Alignment.topCenter,
|
||
end: Alignment.bottomCenter,
|
||
),
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.all(1.sp),
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.rectangle,
|
||
borderRadius: BorderRadius.circular(10.0),
|
||
gradient: const LinearGradient(
|
||
colors: [Color(0xFF4C3E5F), Color(0xFF324140)],
|
||
begin: Alignment.topCenter,
|
||
end: Alignment.bottomCenter,
|
||
),
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(top: 24.sp),
|
||
child: Column(
|
||
children: [
|
||
Center(
|
||
child: Text(
|
||
"温馨提示",
|
||
style:
|
||
TextStyle(color: Colors.white, fontSize: 16.sp),
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(top: 14.sp),
|
||
alignment: Alignment.center,
|
||
child: Image(
|
||
image: AssetImage(getCircleImage("no_look_icon_h")),
|
||
width: 70.sp,
|
||
height: 70.sp,
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
top: 12.sp, left: 14.sp, right: 14.sp),
|
||
alignment: Alignment.center,
|
||
child: Text(
|
||
"您确认对TA不感兴趣吗?确认之后在这个板块就看不见TA了。",
|
||
textAlign: TextAlign.center,
|
||
style: TextStyle(
|
||
color: const Color(0xCCF7FAFA), fontSize: 16.sp),
|
||
),
|
||
),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
GestureDetector(
|
||
onTap: () {
|
||
Navigator.pop(context);
|
||
},
|
||
child: Container(
|
||
margin: EdgeInsets.only(top: 24.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(17),
|
||
gradient: const LinearGradient(
|
||
colors: [
|
||
Color(0x26FFFFFF),
|
||
Color(0x26FFFFFF),
|
||
],
|
||
begin: Alignment.centerLeft,
|
||
end: Alignment.centerRight,
|
||
),
|
||
),
|
||
padding: EdgeInsets.only(
|
||
top: 10.sp,
|
||
bottom: 10.sp,
|
||
left: 27.sp,
|
||
right: 27.sp),
|
||
child: const Text(
|
||
"再考虑考虑",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 12,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
SizedBox(width: 24.sp),
|
||
GestureDetector(
|
||
onTap: () {
|
||
Get.back();
|
||
sendNoLookData(userId, currentIndex);
|
||
},
|
||
child: Container(
|
||
margin: EdgeInsets.only(top: 24.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(17),
|
||
gradient: const LinearGradient(
|
||
colors: [
|
||
Color(0xFF06F9FA),
|
||
Color(0xFFDC5BFD),
|
||
],
|
||
begin: Alignment.centerLeft,
|
||
end: Alignment.centerRight,
|
||
),
|
||
),
|
||
padding: EdgeInsets.only(
|
||
top: 10.sp,
|
||
bottom: 10.sp,
|
||
left: 52.sp,
|
||
right: 52.sp),
|
||
child: const Text(
|
||
"确定",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 12,
|
||
),
|
||
),
|
||
),
|
||
)
|
||
],
|
||
)
|
||
],
|
||
),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
);
|
||
},
|
||
);
|
||
}
|
||
|
||
void sendNoLookData(String userId, int index) async {
|
||
var data = await DioManager.instance.post(url: Api.uninterested + userId);
|
||
if (data['code'] == 200) {
|
||
showOKToast('操作成功');
|
||
// widget.list.removeAt(index);
|
||
widget.deleteCallBack();
|
||
// setState(() {});
|
||
}
|
||
}
|
||
|
||
|
||
loadSignDiscoverData(String userId) async {
|
||
try {
|
||
var result = await DioManager.instance
|
||
.get(url: Api.getFindPageUserByUserId, params: {
|
||
'userId': userId,
|
||
'lat': '0',
|
||
'lng': '0',
|
||
});
|
||
|
||
int initIndex = 0;
|
||
widget.list.forEach((element) {
|
||
if (element['id'].toString() == userId) {
|
||
initIndex = widget.list.indexOf(element);
|
||
}
|
||
});
|
||
|
||
widget.list[initIndex] = result['data'];
|
||
setState(() {});
|
||
} catch (e) {}
|
||
}
|
||
|
||
|
||
tagItem(List item) {
|
||
return Container(
|
||
width: Get.width,
|
||
margin: EdgeInsets.only(top: 5.sp, bottom: 5.sp),
|
||
// color: Colors.red,
|
||
// height: 45.sp,
|
||
child: ListView.builder(
|
||
scrollDirection: Axis.horizontal,
|
||
itemCount: item.length,
|
||
itemBuilder: (context, index) {
|
||
return tagWidget(item[index]['title'], item[index]['id']);
|
||
}),
|
||
);
|
||
}
|
||
|
||
tagWidget(String tagName, int id) {
|
||
return GestureDetector(
|
||
onTap: () {
|
||
Get.toNamed(AppRoutes.Signal_circle_list, arguments: id);
|
||
},
|
||
child: Container(
|
||
margin: EdgeInsets.only(right: 6.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(17.0),
|
||
gradient: const LinearGradient(
|
||
colors: [
|
||
Color(0xFF06F9FA),
|
||
Color(0xFFDC5BFD),
|
||
],
|
||
),
|
||
color: const Color(0xFF392D53),
|
||
),
|
||
child: Container(
|
||
margin: EdgeInsets.all(0.2.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(17.0),
|
||
color: const Color(0xFF392D53),
|
||
),
|
||
child: Padding(
|
||
padding: EdgeInsets.only(
|
||
top: 2.sp,
|
||
bottom: 2.sp,
|
||
left: 10.sp,
|
||
right: 10.sp,
|
||
),
|
||
child: Center(
|
||
child: Text(
|
||
tagName,
|
||
style: const TextStyle(
|
||
fontSize: 11.0,
|
||
color: Colors.white,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
}
|