circle_app/circle_app/lib/app/circle/widgets/like_view.dart
2023-12-21 16:13:15 +08:00

1508 lines
57 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:async';
import 'dart:convert';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:circle_app/app/circle/logic.dart';
import 'package:circle_app/app/circle/state.dart';
import 'package:circle_app/app/circle/widgets/video_item.dart';
import 'package:circle_app/app/home/logic.dart';
import 'package:circle_app/common/Widgets/circle_share.dart';
import 'package:circle_app/common/Widgets/text_more.dart';
import 'package:circle_app/main.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/eventBus.dart';
import 'package:circle_app/util/util.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 'package:shared_preferences/shared_preferences.dart';
import '../../../common/Widgets/base_tip_widget.dart';
class LikeView extends StatefulWidget {
@override
_LikeViewState createState() => _LikeViewState();
}
class _LikeViewState extends State<LikeView>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
final ScrollController scrollController = ScrollController();
final RefreshController refreshController = RefreshController();
// ListLogic? listsLg;
int callOutPage = 1;
int recomandPage = 1;
bool isLoad = true;
bool likeMore = true;
bool recomandMore = true;
var circleId = '';
List<Lists> lists = [];
List<Lists> recomanddlists = [];
@override
void dispose() {
// TODO: implement dispose
if (null != scroToTop) {
EventBusManager.cancelSubscription(scroToTop!);
}
EventBusManager.cancelSubscription(likeRefreshSub!);
scrollController.dispose();
super.dispose();
}
StreamSubscription? callRefreshCicle = null;
StreamSubscription? scroToTop = null;
StreamSubscription? likeRefreshSub = null;
@override
void initState() {
// TODO: implement initState
super.initState();
loadLikeListData();
scroToTop = EventBusManager.on<ScrollToTop>().listen((event) {
// if (widget.logic.state.index == widget.index) {
var str =
'{\"content\":{\"calloutId\":10453,\"interestId\":5},\"event\":3}';
var params = jsonDecode(str);
scrollController.animateTo(
0.0,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
});
likeRefreshSub = EventBusManager.on<LikeRefresh>().listen((event) {
// if (widget.logic.state.index == widget.index) {
refreshData();
// }
});
// widget.back(widget.createState());
}
loadLikeListData() async {
if (likeMore) {
var data = await DioManager.instance.get(
url: "/up-service/follow/callouts",
params: {"page": callOutPage, "page_size": "20"});
if (data["code"] == 200) {
List dataList = data["data"]["lists"] ?? [];
if (callOutPage == 1) {
lists.clear();
}
if (dataList.isNotEmpty) {
likeMore = true;
for (var element in dataList) {
lists.add(Lists.fromJson(element));
}
callOutPage++;
}
likeMore = dataList.length == 20;
if (!likeMore) {
loadRecomdistData();
} else {
if (callOutPage == 2 || callOutPage == 1) {
refreshController.refreshCompleted();
refreshController.loadComplete();
} else {
refreshController.loadComplete();
}
}
if (mounted) {
setState(() {});
}
} else {
showOKToast(data["msg"]);
}
} else {
loadRecomdistData();
}
}
loadRecomdistData() async {
var data = await DioManager.instance.get(
url: "/up-service/recommend/callouts",
params: {"page": recomandPage, "page_size": "20"});
if (data["code"] == 200) {
List dataList = data["data"]["lists"] ?? [];
if (recomandPage == 1) {
if (recomanddlists.isNotEmpty) {
recomanddlists.clear();
}
}
if (dataList.isNotEmpty) {
recomandMore = true;
List<Lists> info = [];
for (var element in dataList) {
Lists infos = Lists.fromJson(element);
bool isContain = false;
recomanddlists.forEach((listInfo) {
if (listInfo.id == infos.id) {
isContain = true;
}
});
if (!isContain) {
info.add(infos);
}
}
if (info.isNotEmpty) {
recomanddlists.addAll(info);
}
recomandPage++;
}
recomandMore = dataList.length == 20;
if (recomandPage == 2 || recomandPage == 1) {
refreshController.refreshCompleted();
refreshController.loadComplete();
} else {
if (recomandMore) {
refreshController.loadComplete();
} else {
refreshController.loadNoData();
}
}
if (mounted) {
setState(() {});
}
} else {
showOKToast(data["msg"]);
}
}
setCircleId(String id) {
circleId = id;
loadLikeListData();
}
void refreshData() {
callOutPage = 1;
recomandPage = 1;
likeMore = true;
recomandMore = true;
refreshController.resetNoData();
loadLikeListData();
}
void loadMore() {
if (recomandMore == false) return;
loadLikeListData();
}
void pushOtherPeopleHomePage(String userId) {
Get.toNamed(AppRoutes.UserInfoActivity, arguments: userId);
// if (bean.isQueen) {
// showJoinCiclePiker(cicleId);
// } else {
//跳转消息页面
// Get.bottomSheet(Open_vip_tipPage(),
// isScrollControlled: true,
// enableDrag: false,
// );
// }
}
void pushHomePage(var bean, String cicleId) async {
// SharedPreferencesHelper.getInstance().then((sharedPreferences) {
// int userId = sharedPreferences.getInt(SharedPreferencesHelper.USERID);
// if (bean.user!.id == userId) {
// Get.toNamed(AppRoutes.UserInfoActivity);
// } else {
Get.toNamed(AppRoutes.UserInfoActivity,
arguments: bean.user!.id!.toString());
// }
// });
// if (bean.isQueen) {
// showJoinCiclePiker(cicleId);
// } else {
//跳转消息页面
// Get.bottomSheet(Open_vip_tipPage(),
// isScrollControlled: true,
// enableDrag: false,
// );
// }
}
void pushMsgPage(var bean, String cicleId) async {
// if (bean.is_limit&&bean.amount>0) {
// showJoinCiclePiker(cicleId,bean.amount.toString(),bean.oldAmount.toString(),2,(payResult){
// bean.is_limit = false;
// if (Get.isRegistered<CircleLogic>()) {
// var logic = Get.find<CircleLogic>();
// for (var element in logic.circle.lists) {
// if (element.id == bean.id) {
// element.is_limit = false;
// element.isJoin = true;
// }
// }
// logic.update();
// }
// Get.back();
// },bean.ios_item);
// return;
// }
var sp = await SharedPreferencesHelper.getInstance();
String myUserId = sp.getMyUserId();
if (bean.user!.id.toString() == myUserId) {
showOKToast('无法与自己私聊');
return;
}
// if ()
var data = await DioManager.instance.get(
url: "/up-service/callout/${bean.id}/chat",
);
if (data["code"] == 200) {
pushChatPage(data['data']['account_id'].toString().split("_").last,
data['data']['account_id'], bean.user!.nickname!);
await Future.delayed(Duration(seconds: 1));
SharedPreferences sharedPreferences =
await SharedPreferences.getInstance();
// SharedPreferencesHelper.getInstance().then((sharedPreferences) {
int userId =
sharedPreferences.getInt(SharedPreferencesHelper.USERID) ?? 0;
String avatar =
sharedPreferences.getString(SharedPreferencesHelper.AVATAR) ?? "";
String name =
sharedPreferences.getString(SharedPreferencesHelper.NAME) ?? "";
bool isContain = false;
for (var info in bean.chat!.users!) {
if (info.id == userId) {
isContain = true;
}
}
if (!isContain) {
bean.chat!.users!
.add(Users(avatar: avatar, id: userId, nickname: name));
bean.chat!.count = bean.chat!.count + 1;
setState(() {});
}
}
}
@override
Widget build(BuildContext context) {
List urlList = [];
List<Widget> widgets = [];
int i = 0;
// print(urlList);
if (null != urlList) {
urlList.forEach((element) {
if (widgets.length > 2) {
return;
}
widgets.add(Positioned(
left: 15.sp * i,
child: circleWidget(
element.avatar! ??
"https://qiniuyun.leyuan666.com/quanzi/avatar/default.png",
element.id.toString()),
));
i++;
});
}
return ClipRRect(
borderRadius: BorderRadius.circular(10.sp),
child: Container(
width: Get.width,
padding: EdgeInsets.only(left: 10.sp, right: 10.sp),
// margin:
// EdgeInsets.only(left: widget.index > 0 ? 4.sp : 0, right: 4.sp),
child: SmartRefresher(
controller: refreshController,
onRefresh: refreshData,
onLoading: loadMore,
enablePullUp: recomandMore,
child: ListView.builder(
physics: const AlwaysScrollableScrollPhysics(),
addAutomaticKeepAlives: false,
addRepaintBoundaries: false,
scrollDirection: Axis.vertical,
controller: scrollController,
itemCount: likeMore
? lists.length
: lists.length + recomanddlists.length + 1,
itemBuilder: (context, index) {
if (lists.length - 1 >= index) {
var list = lists[index];
if (list.isQueen!) {
return vipDynamicItem(list);
} else {
return normalDynamicItem(list);
}
} else if (!likeMore &&
lists.length == index &&
recomanddlists.isNotEmpty) {
return tipItem();
} else if (index - lists.length < recomanddlists.length &&
!likeMore) {
var list = recomanddlists[index - lists.length];
if (list.isQueen!) {
return vipDynamicItem(list);
} else {
return normalDynamicItem(list);
}
} else {
if (recomandMore) return Container();
return Container(
margin: EdgeInsets.only(top: likeMore ? 0 : 10.sp),
child: likeMore
? loaddingWidget(likeMore)
: GestureDetector(
onTap: () {
var homeLogic = Get.find<HomeLogic>();
homeLogic.tabController.animateTo(1,
duration: Duration(milliseconds: 0),
curve: Curves.ease);
homeLogic.updateIndex(1);
},
child: Container(
margin: EdgeInsets.only(bottom: 10.sp),
child: Stack(
alignment: Alignment.center,
children: [
Image.asset(
getLoginImage('start_bg'),
width: 180.sp,
),
Text(
'查看更多圈子',
style: TextStyle(
color: Colors.white,
fontSize: 18.sp),
)
],
),
),
));
}
}),
),
));
}
void _showTextContentDialog(BuildContext context, String msg, String title) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
child: Container(
height: 300.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,
),
),
),
Positioned(
top: 15,
left: 0,
right: 0,
child: Center(
child: Text(title,
style: TextStyle(
color: const Color(0xFFF7FAFA), fontSize: 16.sp)),
)),
Container(
margin: EdgeInsets.only(top: 24.sp, bottom: 24.sp),
child: Container(
margin:
EdgeInsets.only(top: 12.sp, left: 14.sp, right: 14.sp),
alignment: Alignment.center,
child: SingleChildScrollView(
child: Text(
msg,
textAlign: TextAlign.center,
style: TextStyle(
color: const Color(0xCCF7FAFA), fontSize: 16.sp),
),
),
),
),
Positioned(
top: 8.sp,
right: 10.sp,
child: GestureDetector(
onTap: () {
Get.back();
},
child: Icon(
Icons.close,
color: Colors.white,
size: 20.sp,
),
)),
],
),
),
);
},
);
}
///至尊喊话
vipDynamicItem(Lists lists) {
Text descText = Text(
lists.content!,
style: TextStyle(color: Colors.white, fontSize: 17.sp),
maxLines: 2,
);
// List<JoinUser> urlList = bean.lastJoinUsers;
List<Widget> widgets = [];
int index = 0;
for (var element in lists.chat!.users!) {
widgets.add(Positioned(
left: 12.sp * index,
child: GestureDetector(
onTap: () {
// pushOtherPeopleHomePage(element.id.toString());
},
child:
circleWidget(element.avatar!, element.id.toString(), width: 24),
),
));
index++;
}
if (widgets.isNotEmpty) {
widgets.add(Positioned(
left: 12.sp * lists.chat!.users!.length,
child: Image.asset(
getCircleImage('more'),
width: 24.sp,
)));
}
double picHeight = 0.0;
if (lists.album != null) {
if (lists.album!.isNotEmpty) {
Album info = lists.album!.first;
if (info.type == 1) {
double picWidth = (Get.width - 20.sp) / 3;
if (lists.album!.length > 3) {
picHeight = picWidth * 2;
} else {
picHeight = picWidth;
}
} else {
picHeight = 140.sp;
}
}
}
double widgetHeight =
130.sp + contentHeight(lists.content!) + picHeight + 76.sp;
return GestureDetector(
onTap: () async {
var sp = await SharedPreferencesHelper.getInstance();
String myUserId = sp.getMyUserId();
if (lists.user?.id!.toString() == myUserId) {
Get.toNamed(AppRoutes.UserInfoActivity);
return;
}
pushHomePage(lists, lists.id.toString());
},
child: Container(
margin: EdgeInsets.only(top: 10.sp),
width: Get.width,
height: widgetHeight,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
getCircleImage('pic_bg'),
))),
child: Stack(children: [
Positioned(
left: 0,
top: 2.sp,
height: 18.sp,
child: Image.asset(getCircleImage('vip_say')),
),
Positioned(
right: 2.sp,
top: 2.sp,
child: Stack(
alignment: Alignment.center,
children: [
Image.asset(
getCircleImage('location'),
height: 30.sp,
),
Text(
(lists.user!.city ?? '外星').length > 4 ? (lists.user!.city ?? '外星').substring(0,4) + '...' :(lists.user!.city ?? '外星'),
style: TextStyle(color: Colors.white, fontSize: 15.sp),
)
],
),
),
Container(
height: widgetHeight,
width: Get.width,
padding: EdgeInsets.only(top: 12.sp, left: 12.sp, right: 12.sp),
child: Column(
children: [
SizedBox(
height: 72.sp,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Stack(
alignment: Alignment.center,
children: [
Image.asset(
getCircleImage('avatar_bg'),
width: 42.sp,
),
ClipOval(
child: CachedNetworkImage(
imageUrl: lists.user!.avatar_thumb!,
width: 40.sp,
height: 40.sp,
fit: BoxFit.cover,
),
)
],
),
Expanded(
child: Container(
padding: EdgeInsets.only(left: 8.sp, top: 12.sp),
alignment: Alignment.centerLeft,
height: 72.sp,
child: Column(
children: [
Row(
children: [
Text(
lists.user!.nickname!,
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
width: 8.sp,
),
lists.user?.vip != null &&
lists.user!.vip == 0
? Container()
: Image.asset(
getCircleImage(lists.user!.vip == 1
? 'vip'
: 'year_vip'),
width: 36.sp,
)
],
),
SizedBox(
height: 4.sp,
),
Row(
children: [
Container(
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(
lists.user!.gender ?? 0,
lists.user!.age ?? 0,
lists.user!.role ?? 0,
lists.user!.orientation ?? 0),
// '${genderList[lists.user!.gender!]}.${lists.user!.age}.${roleList[lists.user!.role!]}.${orientationList[lists.user!.orientation!]}',
style: TextStyle(
color: Colors.black,
fontSize: 12.sp,
),
),
)
],
),
],
),
)),
],
),
),
Container(
alignment: Alignment.topLeft,
// margin: EdgeInsets.only(top: 4.sp),
child: descText,
),
Container(
height: picHeight,
margin: EdgeInsets.only(top: 5.sp),
child: picHeight == 140.sp
? ClipRRect(
borderRadius: BorderRadius.circular(6.sp),
child: VideoItemWidget(lists.album![0].url!))
: GridView.builder(
itemCount: lists.album!.length,
physics: const NeverScrollableScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, //横轴三个子widget
crossAxisSpacing: 8.sp,
mainAxisSpacing: 8.sp,
childAspectRatio: 1.0 //宽高比为1时子widget
),
itemBuilder: (contentxt, currentIndex) {
Album album = lists.album![currentIndex];
return GestureDetector(
onTap: () {
var imgList = <String>[];
for (var element in lists.album!) {
imgList.add(element.url!);
}
Get.toNamed(AppRoutes.Swiper, arguments: {
'imaglist': imgList,
'index': currentIndex
});
},
child: ClipRRect(
borderRadius: BorderRadius.circular(6.sp),
child: CachedNetworkImage(
imageUrl: album.url!,
// placeholder: (context, url) =>
// SizedBox(
// width: 30.sp,
// height: 30.sp,
// child: CircularProgressIndicator(
// color: Color(0xFF07FAFB),
// strokeWidth: 2.sp,
// ),
// ),
errorWidget: (context, url, error) =>
const Icon(Icons.error),
fit: BoxFit.cover,
),
),
);
}),
),
Container(
height: 30.sp,
padding: EdgeInsets.only(left: 5.sp, right: 10.sp),
margin: EdgeInsets.only(top: picHeight == 0 ? 15.sp : 5.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.sp),
color: Color(0x33000000)),
child: Row(
children: [
widgets.isNotEmpty
? SizedBox(
width: 24 + 12.sp * widgets.length - 8.sp,
height: 24.sp,
child: Stack(children: widgets),
)
: Container(),
SizedBox(
width: 4.sp,
),
widgets.isNotEmpty
? Expanded(
child: Text(
'${lists.chat!.count!}位圈友已私聊',
style: TextStyle(
color: Colors.white, fontSize: 14.sp),
))
: Expanded(
child: Text(
'赶紧成为第一位私聊ta的圈友吧',
style: TextStyle(
color: Colors.white, fontSize: 14.sp),
)),
GestureDetector(
onTap: () {
pushMsgPage(
lists,
lists.interest!['id'].toString(),
);
// pushHomePage(
// lists, widget.bean.id.toString());
},
child: Image.asset(
getCircleImage('chat'),
width: 60.sp,
),
)
],
),
)
],
),
),
Positioned(
bottom: 2.sp,
left: 2.sp,
child: Container(
width: Get.width - 4.sp - 20.sp,
child: circleInfoItem(lists.interest, lists, index),
))
])),
);
}
///普通图文喊话
normalDynamicItem(Lists lists) {
Text descText = Text(
lists.content!,
style: TextStyle(color: Colors.white, fontSize: 17.sp),
// maxLines: 2,
);
double picHeight = 0.0;
if (lists.album != null) {
if (lists.album!.isNotEmpty) {
Album info = lists.album!.first;
if (info.type == 1) {
double picWidth = (Get.width - 20.sp) / 3;
if (lists.album!.length > 3) {
picHeight = picWidth * 2;
} else {
picHeight = picWidth;
}
} else {
picHeight = 140.sp;
}
}
}
List<Widget> widgets = [];
int index = 0;
lists.chat!.users!.forEach((element) {
widgets.add(Positioned(
left: 12.sp * index,
child: GestureDetector(
onTap: () {},
child:
circleWidget(element.avatar!, element.id.toString(), width: 24),
),
));
index++;
});
if (widgets.isNotEmpty) {
widgets.add(Positioned(
left: 12.sp * lists.chat!.users!.length,
child: Image.asset(
getCircleImage('more'),
width: 24.sp,
)));
}
return GestureDetector(
onTap: () async {
var sp = await SharedPreferencesHelper.getInstance();
String myUserId = sp.getMyUserId();
if (lists.user?.id!.toString() == myUserId) {
Get.toNamed(AppRoutes.UserInfoActivity);
return;
}
pushHomePage(lists, lists.id.toString());
},
child: Container(
margin: EdgeInsets.only(top: 10.sp),
width: Get.width,
height: 120.sp + contentHeight(lists.content!) + picHeight + 76.sp,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
getCircleImage('normal_bg'),
))),
child: Stack(
children: [
Positioned(
right: 2.sp,
top: 2.sp,
child: Stack(
alignment: Alignment.center,
children: [
Image.asset(
getCircleImage('location'),
height: 30.sp,
),
Text(
(lists.user!.city ?? '外星').length > 4 ? (lists.user!.city ?? '外星').substring(0,4) + '...' :(lists.user!.city ?? '外星'),
style: TextStyle(color: Colors.white, fontSize: 15.sp),
)
],
),
// height: 18.sp,
),
Container(
width: Get.width,
padding: EdgeInsets.only(left: 12.sp, right: 12.sp),
child: Column(
children: [
SizedBox(
height: 72.sp,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Stack(
alignment: Alignment.center,
children: [
Image.asset(
getCircleImage('avatar_bg'),
width: 42.sp,
),
ClipOval(
child: CachedNetworkImage(
imageUrl: lists.user!.avatar_thumb!,
width: 40.sp,
height: 40.sp,
fit: BoxFit.cover,
memCacheHeight: 40,
memCacheWidth: 40,
),
)
],
),
Expanded(
child: Container(
padding: EdgeInsets.only(left: 8.sp, top: 12.sp),
alignment: Alignment.centerLeft,
height: 72.sp,
child: Column(
children: [
Row(
children: [
Text(
lists.user!.nickname!,
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
width: 8.sp,
),
lists.user?.vip != null &&
lists.user!.vip == 0
? Container()
: Image.asset(
getCircleImage(lists.user!.vip == 1
? 'vip'
: 'year_vip'),
width: 36.sp,
)
],
),
SizedBox(
height: 4.sp,
),
Row(
children: [
Container(
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(
lists.user!.gender ?? 0,
lists.user!.age ?? 0,
lists.user!.role ?? 0,
lists.user!.orientation ?? 0),
style: TextStyle(
color: Colors.black,
fontSize: 12.sp,
),
),
)
],
),
],
),
)),
],
),
),
Container(
alignment: Alignment.topLeft,
// margin: EdgeInsets.only(top: 4.sp),
child: descText,
),
picHeight > 0
? Container(
height: picHeight,
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(top: 5.sp),
child: picHeight == 140.sp
? ClipRRect(
borderRadius: BorderRadius.circular(6.sp),
child:
VideoItemWidget(lists.album![0].url!))
: GridView.builder(
itemCount: lists.album!.length,
physics:
const NeverScrollableScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, //横轴三个子widget
crossAxisSpacing: 8.sp,
mainAxisSpacing: 8.sp,
childAspectRatio:
1.0 //宽高比为1时子widget
),
itemBuilder: (contentxt, currentIndex) {
Album album = lists.album![currentIndex];
if (album.type == 2) {
return ClipRRect(
borderRadius:
BorderRadius.circular(6.sp),
child: VideoItemWidget(album.url!));
}
return GestureDetector(
onTap: () {
var imgList = <String>[];
for (var element in lists.album!) {
imgList.add(element.url!);
}
Get.toNamed(AppRoutes.Swiper,
arguments: {
'imaglist': imgList,
'index': currentIndex
});
},
child: ClipRRect(
borderRadius:
BorderRadius.circular(6.sp),
child: CachedNetworkImage(
imageUrl: album.url!,
// placeholder: (context, url) =>
// SizedBox(
// width: 30.sp,
// height: 30.sp,
// child: CircularProgressIndicator(
// color: Color(0xFF07FAFB),
// strokeWidth: 2.sp,
// ),
// ),
errorWidget:
(context, url, error) =>
const Icon(Icons.error),
fit: BoxFit.cover,
),
),
);
}))
: Container(),
Container(
height: 30.sp,
padding: EdgeInsets.only(
left: 5.sp,
right: 10.sp,
),
margin:
EdgeInsets.only(top: picHeight == 0 ? 15.sp : 5.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.sp),
color: Color(0x33000000)),
child: Row(
children: [
widgets.isNotEmpty
? SizedBox(
width: 24 + 12.sp * widgets.length - 8.sp,
height: 24.sp,
child: Stack(children: widgets),
)
: Container(),
SizedBox(
width: 4.sp,
),
widgets.isNotEmpty
? Expanded(
child: Text(
'${lists.chat!.count!}位圈友已私聊',
style: TextStyle(
color: Colors.white, fontSize: 14.sp),
))
: Expanded(
child: Text(
'赶紧成为第一位私聊ta的圈友吧',
style: TextStyle(
color: Colors.white, fontSize: 14.sp),
)),
GestureDetector(
onTap: () async {
pushMsgPage(
lists, lists.interest!['id'].toString());
// });
},
child: Image.asset(
getCircleImage('chat'),
width: 60.sp,
))
],
),
),
],
),
),
Positioned(
left: 2.sp,
bottom: 2.sp,
child: Container(
width: Get.width - 4.sp - 20.sp,
child: circleInfoItem(lists.interest, lists, index),
))
],
)),
);
}
tipItem() {
bool showTitle = lists.isEmpty;
return Container(
margin: EdgeInsets.only(top: showTitle ? 20.sp : 0, bottom: 0.sp),
// height: 30.sp,
child: Column(
children: [
if (showTitle)
Container(
margin: EdgeInsets.only(bottom: 8.sp),
child: Image.asset(
getBaseImage('no_result'),
width: 200.sp,
),
),
if (showTitle)
Text(
'还没有您喜欢的圈友发布喊话哦~',
style: TextStyle(color: Colors.white, fontSize: 16.sp),
),
Container(
margin: EdgeInsets.only(top: 20.sp),
padding: EdgeInsets.only(left: 30.sp, right: 30.sp),
child: Row(
children: [
Expanded(
child: Container(
height: 2.sp,
color: Colors.white.withOpacity(0.5),
)),
Container(
margin: EdgeInsets.only(left: 8.sp, right: 8.sp),
height: 2.sp,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.5),
borderRadius: BorderRadius.circular(1.sp)),
),
Text(
'喊话推荐',
style: TextStyle(color: Colors.white, fontSize: 17.sp),
),
Container(
margin: EdgeInsets.only(left: 8.sp, right: 8.sp),
height: 2.sp,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.5),
borderRadius: BorderRadius.circular(1.sp)),
),
Expanded(
child: Container(
height: 2.sp,
color: Colors.white.withOpacity(0.5),
)),
],
),
)
],
),
);
}
circleInfoItem(var bean, Lists list, int index) {
return GestureDetector(
onTap: () {
Get.toNamed(AppRoutes.Signal_circle_list,
arguments: bean['id'].toString());
},
child: ClipRRect(
borderRadius: BorderRadius.circular(12.sp),
child: Container(
padding: EdgeInsets.only(left: 12.sp, right: 12.sp),
height: 72.sp,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(getCircleImage('top_circle_bg')))),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: 42.sp,
height: 42.sp,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF71F3F2),
Color(0xFFF558FF),
],
stops: [0.0365, 0.9427],
),
),
padding: EdgeInsets.all(1.sp),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: CachedNetworkImage(
imageUrl: bean['image'],
width: 40.sp,
height: 40.sp,
memCacheHeight: 40,
memCacheWidth: 40,
fit: BoxFit.cover),
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(left: 8.sp, top: 12.sp),
// alignment: Alignment.,
height: 72.sp,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
bean['title'],
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 4.sp,
),
Text(
// "view_total" -> 21
'${convertToTenThousand(bean['view_total'])}人看过',
textAlign: TextAlign.left,
style: TextStyle(
color: const Color(0xff03FEFB),
fontSize: 12.sp,
),
),
],
),
)),
GestureDetector(
//加入圈子
onTap: () async {
CircleLogic cLogic = Get.find<CircleLogic>();
if (bean['is_join']) {
var data = await DioManager.instance.get(
url: "/up-service/interest/${bean['id']}",
);
if (data["code"] == 200) {
Circle info = Circle.fromJson(data['data']);
Get.bottomSheet(CircleShare('', '', info),
isScrollControlled: true, enableDrag: false);
}
} else {
await cLogic.outCircle(
bean['id'].toString(), bean['is_join']);
bean['is_join'] = !bean['is_join'];
if (recomanddlists.isNotEmpty) {
recomanddlists.forEach((element) {
if (element.interest!['id'].toString() ==
bean['id'].toString()) {
element.interest!['is_join'] = true;
element.interest = element.interest!;
}
});
}
if (lists.isNotEmpty) {
lists.forEach((element) {
if (element.interest!['id'].toString() ==
bean['id'].toString()) {
element.interest!['is_join'] = true;
element.interest = element.interest!;
}
});
}
setState(() {});
}
},
child: Stack(
alignment: Alignment.center,
children: [
Image.asset(
getCircleImage('add'),
width: 77.sp,
),
Text(
!bean['is_join'] ? '申请加入' : '分享有奖',
style:
TextStyle(color: Colors.white, fontSize: 12.sp),
)
],
))
],
),
)),
);
}
circleWidget(String url, String userId, {double width = 24}) {
return GestureDetector(
onTap: () {
Get.toNamed(AppRoutes.UserInfoActivity, arguments: userId);
},
child: Stack(
alignment: Alignment.center,
children: [
Image.asset(
getCircleImage('avatar_bg'),
width: width.sp,
),
ClipOval(
child: CachedNetworkImage(
imageUrl: url ??
"https://qiniuyun.leyuan666.com/quanzi/avatar/default.png",
width: (width - 1).sp,
height: (width - 1).sp,
fit: BoxFit.cover,
memCacheHeight: width.toInt() - 1,
memCacheWidth: width.toInt() - 1,
),
)
],
));
}
void _showOutCircleDialog(BuildContext context, var controller, var bean) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
child: Container(
height: 160.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: 12.sp, left: 14.sp, right: 14.sp),
alignment: Alignment.center,
child: Text(
"是否确认退出该圈子。",
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: 30.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: 52.sp,
right: 52.sp),
child: Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
),
),
),
),
SizedBox(width: 24.sp),
GestureDetector(
onTap: () async {
Navigator.pop(context);
await controller.outCircle(
bean['id'].toString(), bean['is_join']);
},
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: Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
double contentHeight(String content) {
return calculateTextHeight(
content, 17.sp, FontWeight.w300, Get.width - 64.sp, 100);
}
void refreshCircleData() async {
var routePath = Get.currentRoute;
if (routePath == AppRoutes.Signal_circle_list) return;
// var data = await DioManager.instance
// .get(url: 'up-service/interest/${widget.bean.id}');
// if (data['code'] == 200) {
// widget.bean = Circle.fromJson(data['data']);
// widget.logic.updateCircleInfo(widget.bean);
// setState(() {
//
// });
// // final logic = Get.put(CircleLogic());
// // logic.update();
//
// }else if(data['code'] == 404){
// var logic = Get.put(CircleLogic());
// logic.circle.lists.removeAt(logic.state.index);
// logic.update();
// }
}
}