From 6a7dc210ea6a72e0c1d0fa9c65219e7943b65d26 Mon Sep 17 00:00:00 2001 From: CYH <13923927013@163.com> Date: Tue, 4 Jul 2023 18:15:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=88=E5=AD=90=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- circle_app/lib/app/circle/state.dart | 2 +- circle_app/lib/app/circle/view.dart | 4 +- .../app/circle/widgets/info_list_view.dart | 1095 +++++++++-------- .../lib/app/circle/widgets/list_logic.dart | 29 +- circle_app/lib/app/my_circle/view.dart | 6 +- 5 files changed, 626 insertions(+), 510 deletions(-) diff --git a/circle_app/lib/app/circle/state.dart b/circle_app/lib/app/circle/state.dart index ed2aadf..52a9fce 100644 --- a/circle_app/lib/app/circle/state.dart +++ b/circle_app/lib/app/circle/state.dart @@ -1,6 +1,6 @@ class CircleState { String msg = ''; - int index = 1; + int index = 0; CircleState() { ///Initialize variables } diff --git a/circle_app/lib/app/circle/view.dart b/circle_app/lib/app/circle/view.dart index 7d2a55b..18e7ed0 100644 --- a/circle_app/lib/app/circle/view.dart +++ b/circle_app/lib/app/circle/view.dart @@ -62,15 +62,17 @@ class _CirclePageState extends State controller.state.index = index; if (index == logic.circle.lists.length - 1) { logic.loadMore(); + } print(index.toString()); - controller.update(); + }, index: controller.state.index, itemCount: logic.circle.lists.length, viewportFraction: 0.93, // scale: 0.9, loop: false, + key: UniqueKey(), // pagination: new SwiperPagination(),//如果不填则不显示指示点 // control: new SwiperControl(),//如果不填则不显示左右按钮 )) diff --git a/circle_app/lib/app/circle/widgets/info_list_view.dart b/circle_app/lib/app/circle/widgets/info_list_view.dart index 221463f..1ad64a3 100644 --- a/circle_app/lib/app/circle/widgets/info_list_view.dart +++ b/circle_app/lib/app/circle/widgets/info_list_view.dart @@ -5,6 +5,7 @@ import 'package:circle_app/app/circle/logic.dart'; import 'package:circle_app/app/circle/state.dart'; import 'package:circle_app/app/circle/widgets/list_logic.dart'; import 'package:circle_app/app/circle/widgets/video_item.dart'; +import 'package:circle_app/network/dio_manager.dart'; import 'package:circle_app/router/app_routers.dart'; import 'package:circle_app/util/util.dart'; import 'package:flutter/material.dart'; @@ -12,6 +13,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:get/get_core/src/get_main.dart'; import 'package:get/get.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class InfoListView extends StatefulWidget { // Get.lazyPut(() => ListLogic()); @@ -26,7 +28,10 @@ class InfoListView extends StatefulWidget { State createState() => _InfoListViewState(); } -class _InfoListViewState extends State { +class _InfoListViewState extends State with AutomaticKeepAliveClientMixin { + @override + bool get wantKeepAlive => true; + List genderList = ['男', '女,' 'MTF', 'FTM', 'CD', '酷儿']; List orientationList = [ @@ -43,15 +48,121 @@ class _InfoListViewState extends State { ListLogic? listsLg; + int callOutPage = 1; + + bool isLoad = true; + bool callOutMore = true; + var circleId = ''; + List lists = []; + final ScrollController scrollController = ScrollController(); + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + scrollController.dispose(); + } + + @override void initState() { // TODO: implement initState super.initState(); - Get.lazyPut(() => ListLogic()); - listsLg = Get.find(); - listsLg!.loadCallOutListData(widget.bean.id.toString()); + scrollController.addListener(() { + try { + if (scrollController.position.pixels == + scrollController.position.maxScrollExtent) { + loadMore(); + } + } catch (e) {} + }); + circleId = widget.bean.id + .toString(); + loadCallOutListData(); } + + + loadCallOutListData() async { + var data = await DioManager.instance.get( + url: "/up-service/interest/$circleId/callouts", + params: {"page": callOutPage, "page_size": "20"}); + if (data["code"] == 200) { + List dataList = data["data"]["lists"] ?? []; + if (callOutPage == 1) { + if (lists.isNotEmpty) { + lists.clear(); + } + } + if (dataList.isNotEmpty) { + callOutMore = true; + for (var element in dataList) { + lists.add(Lists.fromJson(element)); + } + callOutPage++; + } + callOutMore = dataList.length == 20; + if (mounted) { + setState(() {}); + } + } else { + showToast(data["msg"]); + } + } + + setCircleId(String id) { + circleId = id; + loadCallOutListData(); + } + + void refreshData() { + callOutPage = 1; + callOutMore = true; + loadCallOutListData(); + } + + void loadMore() { + if (callOutMore == false) return; + loadCallOutListData(); + } + + 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(Lists bean, String cicleId) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + int userId = prefs.getInt("userId") ?? 0; + 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(Lists bean, String cicleId) async {} + @override Widget build(BuildContext context) { TextSpan descSpan; @@ -88,242 +199,235 @@ class _InfoListViewState extends State { i++; }); - return GetBuilder( - assignId: true, - builder: (listLogic) { - return ClipRRect( - borderRadius: BorderRadius.circular(10.sp), - child: Container( - width: Get.width, - margin: EdgeInsets.only( - left: widget.index > 0 ? 4.sp : 0, right: 4.sp), - child: Stack( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(10.sp), - child: SizedBox( - width: Get.width, - child: Image.asset( - getCircleImage('circle_bg'), - fit: BoxFit.fill, - ), - )), - Container( - height: Get.height, + return ClipRRect( + borderRadius: BorderRadius.circular(10.sp), + child: Container( + width: Get.width, + margin: + EdgeInsets.only(left: widget.index > 0 ? 4.sp : 0, right: 4.sp), + child: Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(10.sp), + child: SizedBox( width: Get.width, - margin: EdgeInsets.only(top: 72.sp), - child: RefreshIndicator( - onRefresh: () async { - listLogic.refreshData(); - }, - child: listLogic.lists.isEmpty - ? !listLogic.callOutMore ? noResultWidget() : loaddingWidget(true) - : ListView.builder( - physics: const AlwaysScrollableScrollPhysics(), - scrollDirection: Axis.vertical, - controller: listLogic.scrollController, - itemCount: listLogic.lists.length + 2, - itemBuilder: (context, index) { - if (index == 0) { - return Container( - padding: EdgeInsets.only( - left: 12.sp, right: 12.sp), - height: 88.sp, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage(getCircleImage( - 'circle_desc')))), - child: Container( - margin: EdgeInsets.only(top: 14.sp), - child: Column( - children: [ - Container( - width: Get.width, - height: 30.sp, - child: GestureDetector( - onTap: () { - _showTextContentDialog( - context, - widget.bean.intro); - }, - child: RichText( - overflow: TextOverflow.fade, - maxLines: 2, - text: TextSpan( - children: [ - descSpan, - span - ])), - ), - ), - Container( - child: Row( + child: Image.asset( + getCircleImage('circle_bg'), + fit: BoxFit.fill, + ), + )), + Container( + height: Get.height, + width: Get.width, + margin: EdgeInsets.only(top: 72.sp), + child: RefreshIndicator( + onRefresh: () async { + refreshData(); + }, + child: lists.isEmpty + ? !callOutMore + ? noResultWidget() + : loaddingWidget(true) + : ListView.builder( + physics: const AlwaysScrollableScrollPhysics(), + scrollDirection: Axis.vertical, + controller: scrollController, + itemCount: lists.length + 2, + itemBuilder: (context, index) { + if (index == 0) { + return Container( + padding: EdgeInsets.only( + left: 12.sp, right: 12.sp), + height: 88.sp, + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage( + getCircleImage('circle_desc')))), + child: Container( + margin: EdgeInsets.only(top: 14.sp), + child: Column( + children: [ + Container( + width: Get.width, + height: 30.sp, + child: GestureDetector( + onTap: () { + _showTextContentDialog( + context, widget.bean.intro); + }, + child: RichText( + overflow: TextOverflow.fade, + maxLines: 2, + text: TextSpan( + children: [ + descSpan, + span + ])), + ), + ), + Container( + child: Row( + children: [ + Row( children: [ - Row( - children: [ - Container( - height: 30.sp, - width: 30.0.sp + - 15.sp * - (widgets.length - - 1.sp), - child: Stack( - children: widgets, - ), - ), - SizedBox( - width: 8.sp, - ), - Text( - '${convertToTenThousand(widget.bean.viewTotal)}圈友', - style: TextStyle( - color: Colors.white, - fontSize: 12.sp), - ), - SizedBox( - width: 8.sp, - ), - Image.asset( - getCircleImage('play'), - width: 20.sp, - ) - ], + Container( + height: 30.sp, + width: 30.0.sp + + 15.sp * + (widgets.length - + 1.sp), + child: Stack( + children: widgets, + ), + ), + SizedBox( + width: 8.sp, + ), + Text( + '${convertToTenThousand(widget.bean.viewTotal)}圈友', + style: TextStyle( + color: Colors.white, + fontSize: 12.sp), + ), + SizedBox( + width: 8.sp, + ), + Image.asset( + getCircleImage('play'), + width: 20.sp, ) ], - ), - ), - ], + ) + ], + ), ), - ), - ); - } else if (listLogic.lists.length + 1 > - index) { - Lists lists = listLogic.lists[index - 1]; - if (lists.isQueen!) { - return vipDynamicItem(lists); - } else { - return normalDynamicItem(lists); - } - } else { - return Container( - margin: EdgeInsets.only(top: listLogic.callOutMore ? 0 : 10.sp), - child: loaddingWidget( - listLogic.callOutMore)); - } - }), - ), - ), - ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10.sp), - topRight: Radius.circular(10.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: Image.network( - widget.bean.image, - width: 40.sp, - height: 40.sp, - ), - ), + ); + } else if (lists.length + 1 > index) { + Lists list = lists[index - 1]; + if (list.isQueen!) { + return vipDynamicItem(list); + } else { + return normalDynamicItem(list); + } + } else { + return Container( + margin: EdgeInsets.only( + top: callOutMore ? 0 : 10.sp), + child: loaddingWidget(callOutMore)); + } + }), + ), + ), + ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10.sp), + topRight: Radius.circular(10.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], ), - Expanded( - child: Container( - padding: - EdgeInsets.only(left: 8.sp, top: 12.sp), - // alignment: Alignment., - height: 72.sp, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.bean.title, - style: TextStyle( - color: Colors.white, - fontSize: 18.sp, - fontWeight: FontWeight.w600), - ), - SizedBox( - height: 4.sp, - ), - Text( - '${convertToTenThousand(widget.bean.joinTotal)}人看过', - textAlign: TextAlign.left, - style: TextStyle( - color: Color(0xff03FEFB), - fontSize: 12.sp, - ), - ), - ], - ), - )), - GestureDetector( - onTap: () async { - if (widget.bean.isJoin) { - _showOutCircleDialog( - context, widget.logic, widget.bean); - } else { - await widget.logic.outCircle( - widget.bean.id.toString(), - widget.bean.isJoin); - widget.logic.update(); - } - }, - child: Stack( - alignment: Alignment.center, - children: [ - Image.asset( - getCircleImage('add'), - width: 77.sp, - ), - Text( - !widget.bean.isJoin ? '申请加入' : '已加入', - style: TextStyle( - color: Colors.white, - fontSize: 12.sp), - ) - ], - )) - ], + ), + padding: EdgeInsets.all(1.sp), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Image.network( + widget.bean.image, + width: 40.sp, + height: 40.sp, + ), + ), ), - )), - Positioned( - top: 70.sp, - child: Image.asset( - getCircleImage('circle_line'), - width: Get.width, - )), - ], - ))); - }, - ); + Expanded( + child: Container( + padding: EdgeInsets.only(left: 8.sp, top: 12.sp), + // alignment: Alignment., + height: 72.sp, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.bean.title, + style: TextStyle( + color: Colors.white, + fontSize: 18.sp, + fontWeight: FontWeight.w600), + ), + SizedBox( + height: 4.sp, + ), + Text( + '${convertToTenThousand(widget.bean.joinTotal)}人看过', + textAlign: TextAlign.left, + style: TextStyle( + color: Color(0xff03FEFB), + fontSize: 12.sp, + ), + ), + ], + ), + )), + GestureDetector( + onTap: () async { + if (widget.bean.isJoin) { + _showOutCircleDialog( + context, widget.logic, widget.bean); + } else { + await widget.logic.outCircle( + widget.bean.id.toString(), + widget.bean.isJoin); + widget.logic.update(); + } + }, + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('add'), + width: 77.sp, + ), + Text( + !widget.bean.isJoin ? '申请加入' : '已加入', + style: TextStyle( + color: Colors.white, fontSize: 12.sp), + ) + ], + )) + ], + ), + )), + Positioned( + top: 70.sp, + child: Image.asset( + getCircleImage('circle_line'), + width: Get.width, + )), + ], + ))); } void _showTextContentDialog(BuildContext context, String msg) { @@ -441,17 +545,16 @@ class _InfoListViewState extends State { double widgetHeight = 140.sp + contentHeight(lists.content!) + picHeight; return 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: [ + 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, @@ -461,7 +564,7 @@ class _InfoListViewState extends State { Positioned( right: 2.sp, top: 2.sp, - child:Stack( + child: Stack( alignment: Alignment.center, children: [ Image.asset( @@ -496,19 +599,18 @@ class _InfoListViewState extends State { width: 42.sp, ), GestureDetector( - onTap: () { - listsLg?.pushHomePage( - lists, lists.id.toString()); - }, - child: ClipOval( - child: Image.network( - lists.user!.avatar!, - width: 40.sp, - height: 40.sp, - fit: BoxFit.fill, - ), - ), - ) + onTap: () { + listsLg?.pushHomePage(lists, lists.id.toString()); + }, + child: ClipOval( + child: Image.network( + lists.user!.avatar!, + width: 40.sp, + height: 40.sp, + fit: BoxFit.fill, + ), + ), + ) ], )), Expanded( @@ -679,7 +781,8 @@ class _InfoListViewState extends State { ) ], ), - )])); + ) + ])); } ///普通图文喊话 @@ -733,248 +836,250 @@ class _InfoListViewState extends State { ))); } return Container( - margin: EdgeInsets.only(top: 10.sp), - width: Get.width, - height: 130.sp + contentHeight(lists.content!) + picHeight, - 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: 20.sp, - ), - Text( - lists.user!.city ?? '外星', - style: TextStyle(color: Colors.white, fontSize: 12.sp), - ) - ], - ), - // height: 18.sp, - ), - Container( - height: 130.sp + contentHeight(lists.content!) + picHeight, - width: Get.width, - padding: EdgeInsets.only(left: 12.sp, right: 12.sp), - child: Column( - children: [ - Container( - height: 72.sp, - child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - GestureDetector( - child: Stack( - alignment: Alignment.center, - children: [ - Image.asset( - getCircleImage('avatar_bg'), - width: 42.sp, - ), - GestureDetector( - onTap: () { - listsLg?.pushHomePage( - lists, widget.bean.id.toString()); - }, - child: ClipOval( - child: Image.network( - lists.user!.avatar!, - width: 40.sp, - height: 40.sp, - fit: BoxFit.fill, - ), - )) - ], - )), - 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! == 0 - ? Container() - : Image.asset( - getCircleImage('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( - '${genderList[lists.user!.gender!]}.${lists.user!.age}.${roleList[lists.user!.role!]}.${orientationList[lists.user!.orientation!]}', - style: TextStyle( - color: Colors.black, - fontSize: 12.sp, - ), - ), - ) - ], - ), - ], - ), - )), - ], + margin: EdgeInsets.only(top: 10.sp), + width: Get.width, + height: 130.sp + contentHeight(lists.content!) + picHeight, + 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: 20.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( + Text( + lists.user!.city ?? '外星', + style: TextStyle(color: Colors.white, fontSize: 12.sp), + ) + ], + ), + // height: 18.sp, + ), + Container( + height: 130.sp + contentHeight(lists.content!) + picHeight, + width: Get.width, + padding: EdgeInsets.only(left: 12.sp, right: 12.sp), + child: Column( + children: [ + Container( + height: 72.sp, + child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('avatar_bg'), + width: 42.sp, + ), + GestureDetector( + onTap: () { + listsLg?.pushHomePage( + lists, widget.bean.id.toString()); + }, + child: ClipOval( + child: Image.network( + lists.user!.avatar!, + width: 40.sp, + height: 40.sp, + fit: BoxFit.fill, + ), + )) + ], + )), + 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! == 0 + ? Container() + : Image.asset( + getCircleImage('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(6.sp), - child: VideoItemWidget(album.url!)); - } - return GestureDetector( - onTap: () { - var imgList = []; - 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) => - Icon(Icons.error), - fit: BoxFit.cover, + 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( + '${genderList[lists.user!.gender!]}.${lists.user!.age}.${roleList[lists.user!.role!]}.${orientationList[lists.user!.orientation!]}', + style: TextStyle( + color: Colors.black, + fontSize: 12.sp, ), ), - ); - })) - : Container(), - Container( - height: 34.sp, - padding: EdgeInsets.only(left: 5.sp, right: 10.sp), - margin: EdgeInsets.only(top: 5.sp), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(17.sp), - gradient: const LinearGradient( - begin: Alignment(0.25, 0.5), - end: Alignment(0.75, 0.5), - colors: [Color(0xff261240), Color(0xff122D40)])), - child: Row( - children: [ - widgets.isNotEmpty - ? Container( - width: 24 + 12.sp * widgets.length - 12.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: 12.sp), - )) - : Expanded( - child: Text( - '赶紧成为第一位私聊ta的圈友吧', - style: TextStyle( - color: Colors.white, fontSize: 12.sp), - )), - GestureDetector( - onTap: () { - listsLg?.pushHomePage( - lists, widget.bean.id.toString()); - }, - child: Image.asset( - getCircleImage('chat'), - width: 60.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 = []; + 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) => + Icon(Icons.error), + fit: BoxFit.cover, + ), + ), + ); + })) + : Container(), + Container( + height: 34.sp, + padding: EdgeInsets.only(left: 5.sp, right: 10.sp), + margin: EdgeInsets.only(top: 5.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17.sp), + gradient: const LinearGradient( + begin: Alignment(0.25, 0.5), + end: Alignment(0.75, 0.5), + colors: [Color(0xff261240), Color(0xff122D40)])), + child: Row( + children: [ + widgets.isNotEmpty + ? Container( + width: 24 + 12.sp * widgets.length - 12.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: 12.sp), + )) + : Expanded( + child: Text( + '赶紧成为第一位私聊ta的圈友吧', + style: TextStyle( + color: Colors.white, fontSize: 12.sp), + )), + GestureDetector( + onTap: () { + listsLg?.pushHomePage( + lists, widget.bean.id.toString()); + }, + child: Image.asset( + getCircleImage('chat'), + width: 60.sp, + )) + ], + ), + ) + ], + ), + ) + ], + )); } circleWidget(String url, {double width = 30}) { diff --git a/circle_app/lib/app/circle/widgets/list_logic.dart b/circle_app/lib/app/circle/widgets/list_logic.dart index dd0c87a..8a90ecd 100644 --- a/circle_app/lib/app/circle/widgets/list_logic.dart +++ b/circle_app/lib/app/circle/widgets/list_logic.dart @@ -13,12 +13,11 @@ class ListLogic extends GetxController { bool isLoad = true; bool callOutMore = true; - var _circleId = ''; + var circleId = ''; List lists = []; final ScrollController scrollController = ScrollController(); - loadCallOutListData(String circleId) async { - _circleId = circleId; + loadCallOutListData() async { var data = await DioManager.instance.get( url: "/up-service/interest/$circleId/callouts", params: {"page": callOutPage, "page_size": "20"}); @@ -43,17 +42,22 @@ class ListLogic extends GetxController { } } + setCircleId(String id) { + circleId = id; + loadCallOutListData(); + } + void refreshData() { callOutPage = 1; callOutMore = true; - loadCallOutListData(_circleId); + loadCallOutListData(); } void loadMore() { if (callOutMore == false) return; - loadCallOutListData(_circleId); + loadCallOutListData(); } @@ -100,18 +104,23 @@ class ListLogic extends GetxController { void onInit() { // TODO: implement onInit super.onInit(); + scrollController.addListener(() { + try { + if (scrollController.position.pixels == scrollController.position.maxScrollExtent) { + loadMore(); + } + } catch (e) { + } + + }); } @override void onReady() { // TODO: implement onReady super.onReady(); - scrollController.addListener(() { - if (scrollController.position.pixels == scrollController.position.maxScrollExtent && callOutMore) { - loadMore(); - } - }); + } @override void onClose() { diff --git a/circle_app/lib/app/my_circle/view.dart b/circle_app/lib/app/my_circle/view.dart index e94e759..dcc682d 100644 --- a/circle_app/lib/app/my_circle/view.dart +++ b/circle_app/lib/app/my_circle/view.dart @@ -54,12 +54,12 @@ class _My_circlePageState extends State // Text(controller.state.msg), //组件使用 Expanded( - child: Swiper( + child: logic.circle.lists.isEmpty ? loaddingWidget(true) : Swiper( itemBuilder: (BuildContext context, int index) { var bean = logic.circle.lists[index]; return InfoListView(index, bean, controller); }, - index: logic.circle.lists.isNotEmpty ? 0 : controller.state.index, + index: controller.state.index, itemCount: logic.circle.lists.length, viewportFraction: 0.93, // scale: 0.9, @@ -69,8 +69,8 @@ class _My_circlePageState extends State if (index == logic.circle.lists.length - 1 && controller.isMore) { logic.loadMore(); - controller.update(); } + }, // pagination: new SwiperPagination(),//如果不填则不显示指示点 // control: new SwiperControl(),//如果不填则不显示左右按钮