circle_app/circle_app/lib/app/circle/widgets/discover.dart
2024-05-16 18:20:37 +08:00

1579 lines
54 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:circle_app/app/circle/view.dart';
import 'package:circle_app/common/Widgets/base_tip_widget.dart';
import 'package:circle_app/common/Widgets/genderview.dart';
import 'package:circle_app/common/Widgets/tag_widget.dart';
import 'package:circle_app/common/colors/app_color.dart';
import 'package:circle_app/common/const.dart';
import 'package:circle_app/main.dart';
import 'package:circle_app/network/api.dart';
import 'package:circle_app/network/dio_manager.dart';
import 'package:circle_app/router/app_routers.dart';
import 'package:circle_app/util/SharedPreferencesHelper.dart';
import 'package:circle_app/util/util.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:get/utils.dart';
import 'package:gradient_borders/gradient_borders.dart';
import 'package:intl/intl.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../../../../util/eventBus.dart';
import '../../chat/widget/chat_gift_pannel.dart';
import '../../home/logic.dart';
import 'dart:ui' as ui show PlaceholderAlignment;
const String todayAddWxStatus = 'todayAddWxStatus';
class Discover extends StatefulWidget {
int unlockWxNum;
Discover(this.unlockWxNum, {super.key});
@override
_DiscoverState createState() => _DiscoverState();
}
class _DiscoverState extends State<Discover>
with AutomaticKeepAliveClientMixin {
// TODO: add state variables and methods
@override
bool get wantKeepAlive => true;
// TODO: add state variables and methods
ScrollController _scrollController = ScrollController();
RefreshController refreshController = RefreshController();
HomeLogic logic = Get.find<HomeLogic>();
var refreshSignSub;
var sub;
var sub1;
var subscripition;
List list = [];
List giftList = [];
bool isMore = true;
bool loadFail = false;
int index = 1;
List tagList = [];
List<String> genderList = [];
List<String> orientationList = [];
List<String> roleList = [];
bool isPop = false;
//获取屏幕宽度
Offset pointerStart = Offset.zero;
Offset pointerEnd = Offset.zero;
double touchRangeY = 0;
double nextOffset = 0;
int lastPage = 0;
double screenHeight = 0;
void animateToOffset(ScrollController controller, double offset,
void Function() onScrollCompleted) {
controller
.animateTo(offset,
duration: const Duration(milliseconds: 200), curve: Curves.easeIn)
.then((value) {
if (onScrollCompleted != null) {
onScrollCompleted();
}
}).catchError((e) {
print(e);
});
}
// 按下时保存当前的点
// 按下时保存当前的点
PointerDownEventListener getPointDownListenerInHorizontal() {
return (event) {
pointerStart = event.position;
};
}
// 抬起时触发
PointerUpEventListener getPointUpListenerInHorizontal() {
return (event) {
pointerEnd = event.position;
touchRangeY = pointerStart.dy - pointerEnd.dy;
if (touchRangeY.abs() < screenHeight / 8) {
// 滑动距离大于屏幕宽度的1/8就可以继续翻页了
nextOffset = (screenHeight + 5.sp) * lastPage;
animateToOffset(_scrollController, nextOffset, () {});
return;
}
if (touchRangeY < 0 && lastPage > 0) {
// 手指从下向上滑动
lastPage--;
animateToOffset(
_scrollController, lastPage * (screenHeight + 5.sp), () {});
} else if (touchRangeY > 0 && lastPage < list.length - 1) {
// 从上向下
lastPage++;
animateToOffset(
_scrollController, lastPage * (screenHeight + 5.sp), () {});
if (lastPage == 3 && isPop == false && widget.unlockWxNum == 0) {
isPop = true;
//弹窗提示
checkIsPopWxTip();
}
if (lastPage == list.length - 2) {
loadData();
}
}
};
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
if (widget.unlockWxNum == 0) {
subscripition.cancel();
}
sub.cancel();
sub1.cancel();
}
@override
void initState() {
// TODO: implement initState
super.initState();
loadData();
if (widget.unlockWxNum == 0) {
subscripition = EventBusManager.on<DiscoverDataRefresh>().listen((event) {
refreshData();
});
}
sub = EventBusManager.on<DiscovrScrollTap>().listen((event) {
pointerStart = Offset.zero;
pointerEnd = Offset.zero;
lastPage = 0;
_scrollController.animateTo(0,
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
refreshData();
});
sub1 = EventBusManager.on<OptionFindclass>().listen((event) {
genderList = event.genderList!;
orientationList = event.orientationList!;
roleList = event.roleList!;
index = 1;
loadData();
});
refreshSignSub = EventBusManager.on<DiscoverDataRefresh>().listen((event) {
loadSignDiscoverData(event.userId);
});
}
setLike(String userId, bool isLike, Function callBack) async {
// if (isBlack || isDestroy) {
// showOKToast("喜欢失败,存在拉黑关系或者该账户已注销");
// return;
// }
var data = await DioManager.instance.post(
url: "${Api.setLike + userId}/follow",
params: {'status': isLike ? "0" : "1"});
var bean = BaseResponse<dynamic>.fromJson(
data,
(jsonData) => jsonData,
);
if (bean.isSuccess()) {
callBack();
}
showOKToast(bean.msg);
}
loadSignDiscoverData(String userId) async {
try {
var result = await DioManager.instance
.get(url: Api.getFindPageUserByUserId, params: {
'userId': userId,
'lat': '0',
'lng': '0',
});
int initIndex = 0;
list.forEach((element) {
if (element['id'].toString() == userId) {
initIndex = list.indexOf(element);
}
});
list[initIndex] = result['data'];
setState(() {});
} catch (e) {}
}
loadData() async {
var data = await DioManager.instance.post(url: Api.findPage, params: {
'page': index,
'pageSize': 8,
'unlockWxNum': widget.unlockWxNum,
"genders": genderList,
"roles": roleList,
"orientations": orientationList,
'lat': '0',
'lng': '0',
});
//
if (data['code'] == 200) {
List dataList = data['data'];
if (dataList.isNotEmpty) {
if (index == 1) {
list = dataList;
refreshController.refreshCompleted();
} else {
List info = [];
dataList.forEach((element) {
var user = Users.fromJson(element);
bool isContain = false;
list.forEach((listInfo) {
var user1 = Users.fromJson(listInfo);
if (user1.userId == user.userId) {
isContain = true;
}
});
if (!isContain) {
info.add(element);
}
});
if (info.isNotEmpty) {
list.addAll(info);
}
// list.addAll(dataList);
}
index = index + 1;
isMore = true;
refreshController.loadComplete();
} else {
isMore = false;
refreshController.loadNoData();
}
if (mounted) {
setState(() {});
}
} else {
loadFail = true;
isMore = false;
showOKToast(data['msg']);
setState(() {
});
}
}
void refreshData() {
index = 1;
loadFail = false;
loadData();
}
_onLoading() {
loadData();
}
@override
Widget build(BuildContext context) {
// TODO: add widget build method
/// 延时一下,需要等state layout结束之后才能获取size
Future.delayed(Duration(milliseconds: 100), () {
if (!mounted) return;
if (screenHeight == 0 && list.isNotEmpty) {
var size = context?.findRenderObject()?.paintBounds?.size;
screenHeight = size!.height - 20.sp;
setState(() {});
print(size.toString());
}
});
return list.isEmpty
? loadFail ? noResultWidget(tip: '',callBack: () {
isMore = true;
loadFail = false;
setState(() {
});
refreshData();
}) : isMore
? loaddingWidget(true)
: noResultWidget(tip: '已解锁联系方式的圈友会展示在这里哦~')
: Stack(
fit: StackFit.expand,
children: [
Container(color: Colors.transparent),
Listener(
onPointerDown: getPointDownListenerInHorizontal(),
onPointerUp: getPointUpListenerInHorizontal(),
child: SmartRefresher(
footer: DiyLoadFooter(
noDataText: '只展示一些精选过的圈友哦~',
),
onRefresh: refreshData,
controller: refreshController,
onLoading: _onLoading,
enablePullUp: true,
child: ListView.builder(
itemBuilder: (context, index) {
var user = Users.fromJson(list[index]);
String onLineStr = '';
if (user.online_flag?.isNotEmpty ?? false) {
onLineStr = user.online_flag!;
if (user.distance != null) {
if (user.distance! < 100) {
onLineStr =
'${user.online_flag!}· ${user.distance!.toInt()}km';
}
}
} else {
if (user.distance != null) {
if ((user.distance! ?? 10) < 100) {
onLineStr = '${user.distance!.toInt()}km';
}
}
}
return FeaturedItem(info: list[index], index: index, screenHeight: screenHeight, sendNoLookData: () {
sendNoLookData(user.userId!.toString(),index);
},setLike: () {
setLike(user.userId!.toString(),
user.is_follow!, () {
list[index]['is_follow'] =
!user.is_follow!;
setState(() {});
});
}, loadSignDiscoverData: loadSignDiscoverData, showGiftPannel: showGiftPannel);
},
itemCount: list.length,
physics: BouncingScrollPhysics(),
controller: _scrollController,
),
),
),
],
);
}
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,
),
),
),
),
),
),
);
}
addWxPicker() {
return Get.bottomSheet(
Container(),
isScrollControlled: false,
enableDrag: false,
);
}
void checkIsPopWxTip() async {
SharedPreferencesHelper sp = await SharedPreferencesHelper.getInstance();
var date = DateTime.now();
final dateFormat = DateFormat("yyyy-MM-dd");
final date2 = dateFormat.format(date);
if (sp.preferences!.containsKey(todayAddWxStatus)) {
var lastDate = sp.preferences!.getString(todayAddWxStatus);
if (lastDate != date2) {
loadWxNumData();
sp.preferences!.setString(todayAddWxStatus, date2);
}
} else {
sp.preferences!.setString(todayAddWxStatus, date2);
loadWxNumData();
}
}
loadWxNumData() async {
loadWXEditStatus() async {
var data = await DioManager.instance.get(
url: Api.checkWxNumState,
);
if (data['code'] == 200) {
var data = await DioManager.instance.get(url: Api.getUserInfo);
if (data['code'] != 4000) {
if (data['data']['user']['wxNum'] == null) {
showAddWxPicker(false);
} else if (data['data']['user']['wxNum'].toString().isEmpty) {
showAddWxPicker(false);
}
}
} else {
// wxStatusInfo['${data['code']}'] = data['msg'];
}
}
}
void sendNoLookData(String userId, int index) async {
var data = await DioManager.instance.post(url: Api.uninterested + userId);
if (data['code'] == 200) {
showOKToast('操作成功');
list.removeAt(index);
setState(() {});
}
}
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,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
showGiftPannel(String accId) {
Get.bottomSheet(
ChatGiftPannel(
accid: accId,
isShowVip: false,
),
isScrollControlled: false,
enableDrag: false,
);
}
}
class FeaturedItem extends StatefulWidget {
var info;
int index;
double screenHeight;
Function sendNoLookData;
Function setLike;
Function loadSignDiscoverData;
Function showGiftPannel;
FeaturedItem(
{super.key,
required this.info,
required this.index,
required this.screenHeight,required this.sendNoLookData,required this.setLike,required this.loadSignDiscoverData,required this.showGiftPannel});
@override
State<FeaturedItem> createState() => _FeaturedItemState();
}
class _FeaturedItemState extends State<FeaturedItem> {
int currentIndex = 0;
PageController pageController = PageController();
@override
Widget build(BuildContext context) {
var info = widget.info;
int index = widget.index;
var user = Users.fromJson(info);
double screenHeight = widget.screenHeight;
String onLineStr = '';
if (user.online_flag?.isNotEmpty ?? false) {
onLineStr = user.online_flag!;
if (user.distance != null) {
if (user.distance! < 100) {
onLineStr = '${user.online_flag!}· ${user.distance!.toInt()}km';
}
}
} else {
if (user.distance != null) {
if ((user.distance! ?? 10) < 100) {
onLineStr = '${user.distance!.toInt()}km';
}
}
}
List<Widget> pointWidget = [];
int count = 0;
for (var item in user.images!) {
pointWidget.add( Expanded(
child: Container(
margin: EdgeInsets.only(
right: user.images!.indexOf(item) ==
user.images!.last
? 0
: 4.sp),
decoration: BoxDecoration(
color: currentIndex == count
? Colors.white
: Colors.white.withOpacity(0.25),
borderRadius: BorderRadius.circular(2.sp),
),
)));
count = count + 1;
}
return Container(
height: 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: screenHeight,
width: Get.width,
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
// clipBehavior: Clip.hardEdge,
child: Container(
// padding: EdgeInsets.all(2.sp),
child: PageView.builder(
controller: pageController,
//当页面选中后回调此方法
//参数[index]是当前滑动到的页面角标索引 从0开始
onPageChanged: (int index) {
print("当前的页面是 $index");
currentIndex = index;
setState(() {
});
},
//值为flase时 显示第一个页面 然后从左向右开始滑动
//值为true时 显示最后一个页面 然后从右向左开始滑动
reverse: false,
//滑动到页面底部无回弹效果
physics: BouncingScrollPhysics(),
//纵向滑动切换
scrollDirection: Axis.horizontal,
//页面控制器
// controller: pageController,
//所有的子Widget
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTapDown: (TapDownDetails details) {
if (details.localPosition.dx <
(Get.width - 10.sp) * 0.5) {
pageController.animateToPage(currentIndex - 1 >= 0 ? currentIndex -1 : user.images!.length - 1,duration: Duration(milliseconds: currentIndex - 1 >= 0 ? 200 : 10),curve: Curves.ease);
} else {
pageController.animateToPage(currentIndex+1 >= user.images!.length ? 0 : currentIndex+1,duration: Duration(milliseconds: currentIndex+1 >= user.images!.length ? 10 : 200),curve: Curves.ease);
}
},
child: CachedNetworkImage(
imageUrl: user.images![index],
fit: BoxFit.cover,
// width: Get.width,
height: screenHeight,
));
},
itemCount: user.images!.length,
)
// Swiper(
// autoplay: false,
// loop: user.images!.length == 1
// ? false
// : true,
// itemBuilder:
// (BuildContext context, int index) {
// // print(index);
// },
// itemCount: user.images!.length,
// ),
)),
),
if (user.images!.length > 1)
Positioned(
top: 4.sp,
child: Container(
height: 4.sp,
margin: EdgeInsets.only(left: 10.sp, right: 10.sp),
width: Get.width - 30.sp,
child: Row(
children: pointWidget,
),
)),
Positioned(
left: 5.sp,
top: 15.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: AppColor.mainColor,
),
),
// if (logic.online)
Text(
onLineStr,
style: TextStyle(
color: Colors.white, fontSize: 16.sp),
),
],
),
),
if (onLineStr!.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: AppColor.mainColor,
),
),
// 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: AppColor.mainColor,
),
),
// if (logic.online)
Text(
"你们有共同的圈子:${user.both_interests!.first['title']}",
style: TextStyle(
color: Colors.white, fontSize: 16.sp),
),
],
)),
],
),
)),
Positioned(
right: 16.sp,
top: 15.sp,
child: GestureDetector(
onTap: () {
Get.toNamed(AppRoutes.UserInfoActivity,
arguments: user.userId!.toString());
},
child: Container(
width: 73.sp,
height: 24.sp,
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.35),
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.contact!.isNotEmpty)
wxStatusWidget(
!user.contact!.contains('*'),
user.contact!,
user.userId.toString(),
user.contactType!,
user.avatarUrl!, () {
widget.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,
),
),
),
Container(
margin: EdgeInsets.only(
left: 4.sp,
),
child: UserTagWidget(user.mark!),
),
],
),
Container(
width: Get.width - 120.sp,
margin: EdgeInsets.only(top: 15.sp, bottom: 15.sp),
child: RichText(
overflow: TextOverflow.ellipsis,
maxLines: 2,
text: TextSpan(
children: [
WidgetSpan(
alignment: ui.PlaceholderAlignment.middle,
// alignment: Rect.fromCenter(center: center, width: width, height: height),
child: Container(
margin: EdgeInsets.only(right: 2.sp,),
padding: EdgeInsets.only(left: 4.sp,right: 4.sp),
height: 20.sp,
width: user.city!.length > 4 ? 70.sp : user.city!.contains('km') ? user.city!.length * 13.sp : user.city!.length * 20.sp,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22),
color: AppColor.cityBgColor,
),
child: Text(
user.city!,
style: TextStyle(
color: Colors.white,
fontSize: 11.sp,
fontWeight: FontWeight.w600),
),
),
),
TextSpan(
text: user.signature!,
// overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,)),
],
),
)
),
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 {
widget.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.setLike();
},
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(), index);
},
child: Image.asset(
getCircleImage(
'no_look_icon',
),
width: 50.sp,
),
)
],
),
))
],
));
}
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),
border: GradientBoxBorder(
gradient:
AppColor.mainVerLinearGradient,
width: 0.5.sp,
),
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,
),
),
),
),
),
);
}
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();
widget.sendNoLookData();
},
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,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
}
class DiscoverDataRefresh {
String userId;
DiscoverDataRefresh(this.userId);
}
class Users {
int? age;
bool? auth;
String? avatarUrl;
String? bgPicUrl;
String? birthday;
bool? blacklist;
String? city;
double? distance;
bool? dust;
String? email;
bool? followBag;
int? followStatus;
int? gender;
String? genderName;
String? heartbeatValue;
int? height;
int? hugCount;
String? imAccid;
List? images;
List? interests;
String? inviteCode;
int? kyNum;
String? lastLoginLog;
String? lastLoginTime;
int? level;
List? litGifts;
int? lvType;
MapUserJumpAo? mapUserJumpAo;
String? nickname;
String? nicknameNote;
bool? online;
String? openId;
String? online_flag;
bool? partner;
bool? is_follow;
String? phoneNum;
int? popularityValue;
bool? realPersonAuth;
int? relationshipStatus;
String? signature;
bool? specialConcern;
int? storyCount;
List? tags;
int? touchTime;
int? unLockWxNum;
int? userId;
int? weight;
int? orientation;
int? role;
int? vip;
String? wxNum;
int? mark;
int? contactType;
String? contact;
List? both_cities;
List? both_interests;
Users(
{this.age,
this.auth,
this.avatarUrl,
this.bgPicUrl,
this.birthday,
this.blacklist,
this.mark,
this.contact,
this.contactType,
this.online_flag,
this.city,
this.both_interests,
this.distance,
this.dust,
this.email,
this.is_follow,
this.vip,
this.followBag,
this.followStatus,
this.gender,
this.genderName,
this.heartbeatValue,
this.height,
this.hugCount,
this.imAccid,
this.role,
this.images,
this.interests,
this.inviteCode,
this.kyNum,
this.lastLoginLog,
this.lastLoginTime,
this.level,
this.litGifts,
this.lvType,
this.mapUserJumpAo,
this.nickname,
this.nicknameNote,
this.online,
this.openId,
this.partner,
this.phoneNum,
this.popularityValue,
this.realPersonAuth,
this.relationshipStatus,
this.signature,
this.specialConcern,
this.storyCount,
this.tags,
this.touchTime,
this.unLockWxNum,
this.both_cities,
this.userId,
this.orientation,
this.weight,
this.wxNum});
Users.fromJson(Map<String, dynamic> json) {
age = json['age'];
mark = json['mark'];
vip = json['vip'];
role = json['role'];
auth = json['auth'];
contactType = json['contactType'] ?? 0;
contact = json['contact'] ?? '';
online_flag = json['online_flag'];
both_interests = json['both_interests'] ?? [];
both_cities = json['both_cities'] ?? [];
is_follow = json['is_follow'];
interests = json['interests'];
avatarUrl = json['avatar'];
bgPicUrl = json['bgPicUrl'];
birthday = json['birthday'];
blacklist = json['blacklist'];
city = json['city'];
orientation = json['orientation'];
distance = json['distance'];
dust = json['dust'];
email = json['email'];
followBag = json['followBag'];
followStatus = json['followStatus'];
gender = json['gender'];
genderName = json['genderName'];
heartbeatValue = json['heartbeatValue'].toString();
height = json['height'];
hugCount = json['hugCount'];
imAccid = json['account_id'];
images = json['images'];
inviteCode = json['inviteCode'];
kyNum = json['kyNum'];
lastLoginLog = json['lastLoginLog'];
lastLoginTime = json['lastLoginTime'];
level = json['level'];
litGifts = json['litGifts'];
lvType = json['lvType'];
mapUserJumpAo = json['mapUserJumpAo'] != null
? new MapUserJumpAo.fromJson(json['mapUserJumpAo'])
: null;
nickname = json['nickname'];
nicknameNote = json['nicknameNote'];
online = json['isOnline'];
openId = json['openId'];
partner = json['partner'];
phoneNum = json['phoneNum'];
popularityValue = json['popularityValue'];
realPersonAuth = json['realPersonAuth'];
relationshipStatus = json['relationshipStatus'];
signature = json['signature'];
specialConcern = json['specialConcern'];
storyCount = json['storyCount'];
tags = json['tags'];
touchTime = json['touchTime'];
unLockWxNum = json['unLockWxNum'];
userId = json['id'];
weight = json['weight'];
wxNum = json['wx_num'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['age'] = this.age;
data['auth'] = this.auth;
data['avatarUrl'] = this.avatarUrl;
data['bgPicUrl'] = this.bgPicUrl;
data['birthday'] = this.birthday;
data['blacklist'] = this.blacklist;
data['city'] = this.city;
data['distance'] = this.distance;
data['dust'] = this.dust;
data['email'] = this.email;
data['followBag'] = this.followBag;
data['followStatus'] = this.followStatus;
data['gender'] = this.gender;
data['genderName'] = this.genderName;
data['heartbeatValue'] = this.heartbeatValue;
data['height'] = this.height;
data['hugCount'] = this.hugCount;
data['imAccid'] = this.imAccid;
if (this.images != null) {
data['images'] = this.images!.map((v) => v.toJson()).toList();
}
data['inviteCode'] = this.inviteCode;
data['kyNum'] = this.kyNum;
data['lastLoginLog'] = this.lastLoginLog;
data['lastLoginTime'] = this.lastLoginTime;
data['level'] = this.level;
if (this.litGifts != null) {
data['litGifts'] = this.litGifts!.map((v) => v.toJson()).toList();
}
data['lvType'] = this.lvType;
if (this.mapUserJumpAo != null) {
data['mapUserJumpAo'] = this.mapUserJumpAo!.toJson();
}
data['nickname'] = this.nickname;
data['nicknameNote'] = this.nicknameNote;
data['online'] = this.online;
data['openId'] = this.openId;
data['partner'] = this.partner;
data['phoneNum'] = this.phoneNum;
data['popularityValue'] = this.popularityValue;
data['realPersonAuth'] = this.realPersonAuth;
data['relationshipStatus'] = this.relationshipStatus;
data['signature'] = this.signature;
data['specialConcern'] = this.specialConcern;
data['storyCount'] = this.storyCount;
if (this.tags != null) {
data['tags'] = this.tags!.map((v) => v.toJson()).toList();
}
data['touchTime'] = this.touchTime;
data['unLockWxNum'] = this.unLockWxNum;
data['userId'] = this.userId;
data['weight'] = this.weight;
data['wxNum'] = this.wxNum;
return data;
}
}
class MapUserJumpAo {
int? id;
String? roomId;
String? title;
int? type;
MapUserJumpAo({this.id, this.roomId, this.title, this.type});
MapUserJumpAo.fromJson(Map<String, dynamic> json) {
id = json['id'];
roomId = json['roomId'];
title = json['title'];
type = json['type'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['roomId'] = this.roomId;
data['title'] = this.title;
data['type'] = this.type;
return data;
}
}
class msgPageRefresh {}