From 25bdfeb3f6c33aceda2f6180e2204f556d22d791 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 22 Oct 2021 09:38:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=A4=BE=E7=BE=A4=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/article/hot_article_item.dart | 7 +- lib/community/community_child_page.dart | 8 +- lib/community/community_details.dart | 145 +++++---- lib/community/community_page.dart | 3 +- .../community_view/community_comment.dart | 33 +- .../community_view/community_dynamic.dart | 93 ++++-- lib/mine/fans_page.dart | 58 +++- lib/mine/follow_page.dart | 64 +++- lib/mine/mine_view/community_follow.dart | 17 +- lib/mine/release_page.dart | 295 ++++-------------- lib/retrofit/data/article.dart | 1 + lib/retrofit/data/comunity_comment.dart | 3 +- lib/retrofit/data/follow_list.dart | 159 ++++++++++ lib/retrofit/data/page.dart | 2 +- lib/retrofit/min_api.dart | 2 +- lib/retrofit/retrofit_api.dart | 9 + lib/retrofit/retrofit_api.g.dart | 49 +++ lib/view_widget/coupon_widget.dart | 1 - lib/view_widget/hot_item.dart | 51 ++- lib/web/web_view/input_comment.dart | 8 +- 20 files changed, 631 insertions(+), 377 deletions(-) create mode 100644 lib/retrofit/data/follow_list.dart diff --git a/lib/article/hot_article_item.dart b/lib/article/hot_article_item.dart index bf9a17e8..da2e7b54 100644 --- a/lib/article/hot_article_item.dart +++ b/lib/article/hot_article_item.dart @@ -108,11 +108,12 @@ class _HotArticlePage extends State { scrollDirection: Axis.vertical, itemBuilder: (context, position) { return AspectRatio( - aspectRatio: position == 0 ? 1.38 : 3.56, + aspectRatio: position == 0 ? 1.38 : 2.56, child: Container( height: position == 0 ? 247.h : 96.h, - margin: EdgeInsets.symmetric(vertical: 6.h, horizontal: 16.w), - child: HotArticleItem(article: articles[position], isHot: position == 0), + margin: EdgeInsets.symmetric(vertical:6.h, horizontal: 16.w), + child: + HotArticleItem(article: articles[position], isHot: position == 0), ), ); }, diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 0f0660a5..db8e8666 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -11,6 +11,10 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CommunityChildPage extends StatefulWidget { + final String typeStr; + + CommunityChildPage(this.typeStr); + @override State createState() { return _CommunityChildPage(); @@ -47,7 +51,7 @@ class _CommunityChildPage extends State { } BaseData> baseData = await apiService.trendList({ - "onlyFollow": false, + "onlyFollow": widget.typeStr == "关注" ? true:false, "onlyMe": false, "pageNum": pageNum, "pageSize": 10, @@ -95,7 +99,7 @@ class _CommunityChildPage extends State { physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return InkWell( - child: CommunityDynamic(comments[position]), + child: CommunityDynamic(comments[position],0), onTap: () { Navigator.of(context).pushNamed( '/router/community_details', diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index ade0e947..705705d0 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -8,6 +8,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/member_comment_list.dart'; +import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/comment_menu.dart'; @@ -17,22 +18,24 @@ import 'package:huixiang/web/web_view/input_comment.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CommunityDetails extends StatefulWidget { - - // final ComunityComment arguments; final Map arguments; CommunityDetails({this.arguments}); - @override State createState() { return _CommunityDetails(); } } -class _CommunityDetails extends State { +class _CommunityDetails extends State + with WidgetsBindingObserver { double height = 0; double commentHeight = 60.h; + ComunityComment comunity; + String parenId = "0"; + final GlobalKey commentKey = GlobalKey(); + final ScrollController scrollController = ScrollController(); List memberList = []; ApiService apiService; @@ -41,9 +44,12 @@ class _CommunityDetails extends State { String hintText = S.current.liuxianinjingcaidepinglunba; bool isKeyBoardShow = false; + int commentTotal = 0; + @override void didChangeMetrics() { WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; if (MediaQuery.of(context).viewInsets.bottom == 0) { if (isKeyBoardShow) { FocusScope.of(context).requestFocus(FocusNode()); @@ -63,7 +69,10 @@ class _CommunityDetails extends State { @override void initState() { super.initState(); + comunity = widget.arguments["comment"]; + WidgetsBinding.instance.addObserver(this); + _queryMemberCommentList(); SharedPreferences.getInstance().then((value) { apiService = ApiService( Dio(), @@ -75,14 +84,17 @@ class _CommunityDetails extends State { @override Widget build(BuildContext context) { - return Column( + return Scaffold( + body: Container( + child: Column( children: [ Expanded( child: NestedScrollView( headerSliverBuilder: (context, position) { return [ SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + handle: + NestedScrollView.sliverOverlapAbsorberHandleFor(context), sliver: SliverAppBar( expandedHeight: (height == 0) ? 614 : height, pinned: true, @@ -120,7 +132,7 @@ class _CommunityDetails extends State { ), color: Colors.white, child: CommunityDynamic( - widget.arguments["comment"], + comunity,0, itemCount: 3, isDetails: true, heightFun: (height) { @@ -146,7 +158,7 @@ class _CommunityDetails extends State { child: Row( children: [ Text( - S.of(context).pinglun_("1"), + S.of(context).pinglun_(commentTotal.toString()), style: TextStyle( fontSize: 14, fontWeight: FontWeight.bold, @@ -157,7 +169,8 @@ class _CommunityDetails extends State { width: 16.w, ), Text( - S.of(context).xihuan_("0"), + S.of(context).xihuan_( + "${comunity?.likes ?? comunity?.likes ?? "0"}"), style: TextStyle( fontSize: 14, fontWeight: FontWeight.bold, @@ -177,11 +190,11 @@ class _CommunityDetails extends State { MediaQuery.of(context).padding.top + kToolbarHeight - 68, - margin: EdgeInsets.only(top: 68 + 50 + kToolbarHeight), + margin: EdgeInsets.only(top: 50 + kToolbarHeight), child: Column( children: [ if (memberList != null && memberList.length > 0) - ListView.builder( + Expanded(child: ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: memberList != null ? memberList.length : 0, @@ -197,35 +210,12 @@ class _CommunityDetails extends State { child: CommunityComment( memberList[position], _queryCommentLike, + (memberList.length-1 == position)?1:0 ), ), ); }, - ), - if (memberList != null && memberList.length > 0) - Container( - height: commentHeight, - decoration: BoxDecoration( - color: Color(0xFFF2F2F2), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 2), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - alignment: Alignment.topCenter, - padding: EdgeInsets.only(top: 22.h), - child: Text( - S.of(context).yixiansquanbupinglun, - style: TextStyle( - fontSize: 12, - color: Color(0xff353535), - ), - ), - ), + )), if (memberList == null || memberList.length == 0) Container( width: double.infinity, @@ -257,46 +247,54 @@ class _CommunityDetails extends State { _toComment, _queryMemberComment, _queryInformationLikes, + isLike: comunity.selfLike, ), ], - ); + ))); } - //给文章/活动点赞 + ///给文章/活动点赞 _queryInformationLikes() async { - BaseData baseData = await apiService.informationLikes(""); + BaseData baseData = await apiService.informationLikes(comunity.id); if (baseData != null && baseData.isSuccess) { // commentKey.currentState.setState(() {}); + setState(() { + if(comunity.selfLike??false) + comunity.likes -= 1; + else comunity.likes += 1; + comunity.selfLike = !comunity.selfLike??false; + }); } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } - //发布评论 + ///发布评论 _queryMemberComment(String content) async { - // BaseData baseData = await apiService.memberComment({ - // "content": content, - // "parentId": parenId, - // "relationalId": - // widget.arguments["activityId"] ?? widget.arguments["articleId"], - // "relationalType": 1 - // }).catchError((error) {}); - // if (baseData != null && baseData.isSuccess) { - // commentKey.currentState.initState(); - // commentTextController.text = ""; - // _toComment(); - // } + BaseData baseData = await apiService.memberComment({ + "content": content, + "parentId": parenId, + "relationalId": comunity.id, + "relationalType": 1 + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + // commentKey.currentState.initState(); + commentTextController.text = ""; + _toComment(); + } } ///滑动到评论列表 _toComment() { - // if (commentKey.currentContext == null) return; - // RenderBox firstRenderBox = commentKey.currentContext.findRenderObject(); - // Offset first = firstRenderBox.localToGlobal(Offset.zero); - // scrollController.animateTo(first.dy + scrollController.offset - - // (kToolbarHeight + MediaQuery.of(context).padding.top), - // duration: Duration(milliseconds: 300), - // curve: Curves.easeIn); + if (commentKey.currentContext == null) return; + RenderBox firstRenderBox = commentKey.currentContext.findRenderObject(); + Offset first = firstRenderBox.localToGlobal(Offset.zero); + scrollController.animateTo( + first.dy + + scrollController.offset - + (kToolbarHeight + MediaQuery.of(context).padding.top), + duration: Duration(milliseconds: 300), + curve: Curves.easeIn); } final GlobalKey inputKey = GlobalKey(); @@ -355,11 +353,11 @@ class _CommunityDetails extends State { ///评论 回复 _reply(memberComment) { FocusScope.of(context).requestFocus(commentFocus); - // parenId = memberComment.id; + parenId = memberComment.id; hintText = S.of(context).huifu_("${memberComment.username}"); } - //评论点赞 + ///评论点赞 _queryCommentLike(String id) async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); String token = sharedPreferences.getString("token"); @@ -382,4 +380,29 @@ class _CommunityDetails extends State { }); } } + + ///评论列表 + _queryMemberCommentList() async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + if (apiService == null) + apiService = ApiService( + Dio(), + context: context, + token: sharedPreferences.getString("token"), + showLoading: false, + ); + BaseData> baseData = + await apiService.memberCommentList({ + "pageNum": 1, + "pageSize": 100, + "relationalId": comunity.id, + "relationalType": 1, + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + commentTotal = baseData.data.size; + memberList = baseData.data.list; + contentHeight(); + setState(() {}); + } + } } diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index 0afd229b..b6c679e0 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:huixiang/article/hot_article_item.dart'; import 'package:huixiang/community/community_child_page.dart'; -import 'package:huixiang/home/home_view/hot_article.dart'; import 'package:huixiang/home/huixiang_brand_page.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -94,7 +93,7 @@ class _CommunityPage extends State }else if(e == "头条"){ return HotArticlePage(); } else { - return CommunityChildPage(); + return CommunityChildPage(e); } }).toList(), controller: tabcontroller, diff --git a/lib/community/community_view/community_comment.dart b/lib/community/community_view/community_comment.dart index 1110a120..123a9c3c 100644 --- a/lib/community/community_view/community_comment.dart +++ b/lib/community/community_view/community_comment.dart @@ -1,19 +1,17 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/member_comment_list.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/custom_image.dart'; -import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:like_button/like_button.dart'; -import 'package:shared_preferences/shared_preferences.dart'; class CommunityComment extends StatefulWidget { - MemberCommentList memberList; - Function(String id) queryCommentLike; - CommunityComment(this.memberList, this.queryCommentLike); + final MemberCommentList memberList; + final Function(String id) queryCommentLike; + final int footType; + CommunityComment(this.memberList, this.queryCommentLike,this.footType); @override State createState() { @@ -194,6 +192,29 @@ class _CommunityComment extends State { ), ), ), + if (widget.footType == 1) + Container( + decoration: BoxDecoration( + color: Color(0xFFF2F2F2), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 2), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + alignment: Alignment.topCenter, + padding: EdgeInsets.only(top: 22.h), + child: Text( + S.of(context).yixiansquanbupinglun, + style: TextStyle( + fontSize: 12, + color: Color(0xff353535), + ), + ), + ), ], ), ); diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index d922f0d7..4aa3aa15 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -1,21 +1,27 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/comunity_comment.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class CommunityDynamic extends StatefulWidget { final int itemCount; final Function(double height) heightFun; final bool isDetails; + final int commentType; final ComunityComment comment; CommunityDynamic( - this.comment, { + this.comment, + this.commentType,{ Key key, this.itemCount = 9, this.heightFun, @@ -27,10 +33,27 @@ class CommunityDynamic extends StatefulWidget { return _CommunityDynamic(); } } - class _CommunityDynamic extends State { GlobalKey globalKey = GlobalKey(); double height = 0; + ApiService apiService; + + @override + void initState() { + super.initState(); + SharedPreferences.getInstance().then((value) => { + apiService = ApiService(Dio(), + context: context, token: value.getString('token')), + }); + } + + ///关注/取关会员 + _vipFollow(followId) async { + BaseData baseData = await apiService.follow(followId); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("关注成功"); + } + } @override Widget build(BuildContext context) { @@ -64,13 +87,14 @@ class _CommunityDynamic extends State { height: 44, child: Row( children: [ - ClipRRect( - child: Image.asset( - "assets/image/default_user.png", - width: 44, - height: 44, - ), - borderRadius: BorderRadius.circular(22), + MImage( + widget.comment != null ? widget.comment.memberInfo.avatar : "", + width: 44, + height: 44, + isCircle: true, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", ), SizedBox( width: 8, @@ -80,7 +104,7 @@ class _CommunityDynamic extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "百花谷", + widget.comment != null ? widget.comment.memberInfo.nickname : "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, @@ -88,7 +112,7 @@ class _CommunityDynamic extends State { ), ), Text( - "2021.04.12", + widget.comment != null ? widget.comment.createTime : "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -100,21 +124,35 @@ class _CommunityDynamic extends State { ], ), ), - RoundButton( - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 3, - ), - backgroup: Color(0xFF32A060), - textColor: Colors.white, - text: "关注", - radius: 20, - icons: SvgPicture.asset( - "assets/svg/shequ_fabu.svg", - fit: BoxFit.contain, - color: Colors.white, - width: 14, - height: 14, + GestureDetector( + onTap: (){ + setState(() { + if(widget.commentType == 0){ + widget.comment.selfFollow = !(widget.comment.selfFollow??false); + _vipFollow(widget.comment.memberInfo.mid); + }else{ + SmartDialog.showToast("删除成功", alignment: Alignment.center); + } + }); + }, + child: (widget.commentType == 0)?RoundButton( + padding: EdgeInsets.symmetric( + horizontal: 8, + vertical: 3, + ), + backgroup: (widget.comment.selfFollow??false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), + textColor: (widget.comment.selfFollow??false) ? Color(0xFF808080):Colors.white , + text:(widget.comment.selfFollow??false) ? "已关注":"关注", + radius: 20, + icons: Icon( + (widget.comment.selfFollow??false) ? Icons.check: Icons.add, + color:(widget.comment.selfFollow??false) ? Color(0xFF808080):Colors.white , + size: 14, + ), + ):Icon( + Icons.close, + color:Colors.black, + size: 16, ), ), ], @@ -173,6 +211,7 @@ class _CommunityDynamic extends State { ); } + ///动态内容 Widget buildMedia(SubjectInfo subjectInfo) { if (subjectInfo == null) { return Container(); diff --git a/lib/mine/fans_page.dart b/lib/mine/fans_page.dart index 72362b2a..7c3ee5d8 100644 --- a/lib/mine/fans_page.dart +++ b/lib/mine/fans_page.dart @@ -1,15 +1,14 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/vip_card.dart'; +import 'package:huixiang/retrofit/data/follow_list.dart'; +import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_footer.dart'; -import 'package:huixiang/view_widget/no_data_view.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -23,7 +22,8 @@ class FansPage extends StatefulWidget { class _FansPage extends State { RefreshController _refreshController; - + int pageNum = 1; + List list = []; ApiService apiService; @override @@ -34,16 +34,50 @@ class _FansPage extends State { SharedPreferences.getInstance().then((value) { apiService = ApiService(Dio(), context: context, token: value.getString("token")); - + _queryFollowList(); }); } + ///我的关注列表 + _queryFollowList() async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + if (apiService == null) + apiService = ApiService( + Dio(), + context: context, + token: sharedPreferences.getString("token"), + showLoading: false, + ); + BaseData> baseData = await apiService.followList({ + "isMyFans": true, + "pageNum": 1, + "pageSize": 100, + }).catchError((error) { + _refreshController.refreshFailed(); + _refreshController.loadFailed(); + }); + _refreshController.refreshCompleted(); + _refreshController.loadComplete(); + if (baseData != null && baseData.isSuccess) { + if (pageNum == 1) { + list.clear(); + } + list.addAll(baseData.data.list); + print("list: ${list.length}"); + if (int.tryParse(baseData.data.total) < (pageNum * 10)) { + _refreshController.loadNoData(); + } + setState(() {}); + } + } @override Widget build(BuildContext context) { return Scaffold( body: Container( + margin: EdgeInsets.only(top: 2), + color:Colors.white, child: SmartRefresher( enablePullDown: true, enablePullUp: false, @@ -57,16 +91,18 @@ class _FansPage extends State { // onRefresh: , physics: BouncingScrollPhysics(), child: ListView.builder( + itemCount: list == null ? 0 : list.length, padding: EdgeInsets.symmetric(vertical: 8.h), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + scrollDirection: Axis.vertical, itemBuilder: (context, position) { return GestureDetector( onTap: () { - }, - child: fansItem(), + child: fansItem(list[position]), ); }, - itemCount:5, ) // NoDataView( // isShowBtn: false, @@ -80,7 +116,7 @@ class _FansPage extends State { } - Widget fansItem() { + Widget fansItem(ListData list) { return Container( margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), child:Row( @@ -88,7 +124,7 @@ class _FansPage extends State { crossAxisAlignment:CrossAxisAlignment.center, children: [ MImage( - "assets/image/default_1.png", + list != null ? (list.avatar ?? "") : "", width: 44, height: 44, isCircle: true, @@ -100,7 +136,7 @@ class _FansPage extends State { width:8, ), Expanded(child:Text( - "百花谷", + list != null ? (list.nickname ?? "") : "", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, diff --git a/lib/mine/follow_page.dart b/lib/mine/follow_page.dart index 633d8309..cf0f71f0 100644 --- a/lib/mine/follow_page.dart +++ b/lib/mine/follow_page.dart @@ -3,6 +3,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/follow_list.dart'; +import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/vip_card.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -23,8 +25,9 @@ class FollowPage extends StatefulWidget { class _FollowPage extends State { RefreshController _refreshController; - ApiService apiService; + int pageNum = 1; + List list = []; @override void initState() { @@ -34,16 +37,50 @@ class _FollowPage extends State { SharedPreferences.getInstance().then((value) { apiService = ApiService(Dio(), context: context, token: value.getString("token")); - + _queryFollowList(); }); } + ///我的关注列表 + _queryFollowList() async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + if (apiService == null) + apiService = ApiService( + Dio(), + context: context, + token: sharedPreferences.getString("token"), + showLoading: false, + ); + BaseData> baseData = await apiService.followList({ + "isMyFans": false, + "pageNum": 1, + "pageSize": 100, + }).catchError((error) { + _refreshController.refreshFailed(); + _refreshController.loadFailed(); + }); + _refreshController.refreshCompleted(); + _refreshController.loadComplete(); + if (baseData != null && baseData.isSuccess) { + if (pageNum == 1) { + list.clear(); + } + list.addAll(baseData.data.list); + print("list: ${list.length}"); + if (int.tryParse(baseData.data.total) < (pageNum * 10)) { + _refreshController.loadNoData(); + } + setState(() {}); + } + } @override Widget build(BuildContext context) { return Scaffold( body: Container( + margin: EdgeInsets.only(top: 2), + color:Colors.white, child: SmartRefresher( enablePullDown: true, enablePullUp: false, @@ -56,18 +93,18 @@ class _FollowPage extends State { controller: _refreshController, // onRefresh: , physics: BouncingScrollPhysics(), - child: ListView.builder( + child: ListView.builder( + itemCount: list == null ? 0 : list.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + scrollDirection: Axis.vertical, padding: EdgeInsets.symmetric(vertical: 8.h), itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - - }, - child: followItem(), + return Container( + child: followItem(list[position]), ); }, - itemCount:5, - ) + ), // NoDataView( // isShowBtn: false, // text: "共关注0人", @@ -75,12 +112,13 @@ class _FollowPage extends State { // margin: EdgeInsets.only(top: 120.h), // ), ), + ), ); } - Widget followItem() { + Widget followItem(ListData list) { return Container( margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), child:Row( @@ -88,7 +126,7 @@ class _FollowPage extends State { crossAxisAlignment:CrossAxisAlignment.center, children: [ MImage( - "assets/image/default_1.png", + list != null ? (list.avatar ?? "") : "", width: 44, height: 44, isCircle: true, @@ -100,7 +138,7 @@ class _FollowPage extends State { width:8, ), Expanded(child:Text( - "百花谷", + list != null ? (list.nickname ?? "") : "", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, diff --git a/lib/mine/mine_view/community_follow.dart b/lib/mine/mine_view/community_follow.dart index 3ea67a39..81844dd5 100644 --- a/lib/mine/mine_view/community_follow.dart +++ b/lib/mine/mine_view/community_follow.dart @@ -1,9 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/mine/follow_page.dart'; import 'package:huixiang/mine/release_page.dart'; -import 'package:huixiang/mine/vip_card_page.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -21,6 +19,15 @@ class CommunityFollow extends StatefulWidget { class _CommunityFollow extends State with SingleTickerProviderStateMixin { + + + @override + void initState() { + super.initState(); + + } + + @override Widget build(BuildContext context) { return DefaultTabController( @@ -50,9 +57,9 @@ class _CommunityFollow extends State indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: [ - MyTab(text:"关注(23)"), - MyTab(text: "粉丝(55)"), - MyTab(text: "发布(26)"), + MyTab(text:"关注(0)",), + MyTab(text: "粉丝(0)"), + MyTab(text: "发布(0)"), ], ), ), diff --git a/lib/mine/release_page.dart b/lib/mine/release_page.dart index e621ce45..3a1ec9b1 100644 --- a/lib/mine/release_page.dart +++ b/lib/mine/release_page.dart @@ -1,18 +1,15 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/community/community_view/community_dynamic.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/vip_card.dart'; +import 'package:huixiang/retrofit/data/comunity_comment.dart'; +import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; -import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_footer.dart'; -import 'package:huixiang/view_widget/no_data_view.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; class ReleasePage extends StatefulWidget { @override @@ -22,251 +19,97 @@ class ReleasePage extends StatefulWidget { } class _ReleasePage extends State { - RefreshController _refreshController; - var isShowShrink = false; + RefreshController refreshController = RefreshController(); ApiService apiService; + int pageNum = 1; + + List comments = []; @override void initState() { super.initState(); - _refreshController = RefreshController(); - SharedPreferences.getInstance().then((value) { - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); + _onRefresh(); + } - }); + _onRefresh() async { + pageNum = 1; + setState(() {}); } + queryCommunity() async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = await apiService.trendList({ + "onlyFollow": false, + "onlyMe": true, + "pageNum": pageNum, + "pageSize": 10, + "searchKey": "" + }).catchError((error) { + refreshController.refreshFailed(); + refreshController.loadFailed(); + }); + + refreshController.refreshCompleted(); + refreshController.loadComplete(); + if (baseData.isSuccess) { + if (pageNum == 1) { + comments.clear(); + } + comments.addAll(baseData.data.list); + print("comments: ${comments.length}"); + if (int.tryParse(baseData.data.total) < (pageNum * 10)) { + refreshController.loadNoData(); + } + } + } @override Widget build(BuildContext context) { - return Scaffold( - body: Container( - child: SmartRefresher( + return FutureBuilder( + future: queryCommunity(), + builder: (context, position) { + return SmartRefresher( + controller: refreshController, enablePullDown: true, - enablePullUp: false, + enablePullUp: true, + physics: BouncingScrollPhysics(), header: MyHeader(), footer: CustomFooter( builder: (context, mode) { return MyFooter(mode); }, ), - controller: _refreshController, - // onRefresh: , - physics: BouncingScrollPhysics(), - child: ListView.builder( - padding: EdgeInsets.symmetric(vertical: 8.h), + onRefresh: _onRefresh, + onLoading: () { + setState(() {}); + }, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { - return GestureDetector( + return InkWell( + child: CommunityDynamic(comments[position],1), onTap: () { - + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "comment": comments[position], + }, + ); }, - child: releaseItem(), ); }, - itemCount:5, - ) - // NoDataView( - // isShowBtn: false, - // text: "共关注0人", - // fontSize: 16.sp, - // margin: EdgeInsets.only(top: 120.h), - // ), - ), - ), - ); - } - - - Widget releaseItem() { - return Container( - color: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 16.w), - margin: EdgeInsets.symmetric(vertical: 16.w), - child:Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment:CrossAxisAlignment.start, - children: [ - Row( - children: [ - ClipOval( - child: Image.network( - "https://t7.baidu.com/it/u=2841334870,333581502&fm=193&f=GIF", - fit: BoxFit.cover, - width: 44.w, - height: 44.h, - ), - clipBehavior: Clip.hardEdge, - ), - SizedBox( - width: 8.w, - ), - Expanded( - child: Container( - height: 60.h, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded(child: Text( - "百花谷", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xff808080), - ), - ), ), - InkWell( - onTap: () { - }, - child: Icon( - Icons.close, - color: Colors.black, - size: 16, - ), - ), - ], - ), - Text( - "2021.04.12 12:12", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 12.sp, - color: Color(0xff808080), - ), - ), - ], - ), - ), - flex: 1, - ), - ], - ), - SizedBox(height: 12), - Text( - "文本,是指书面语言的表现形式,从文学角度说,通常是具有完整、系统含义(Message)的一个句子或多个句子的组合。" - "一个文本可以是一个句子(Sentence)、一个段落(Paragraph)或者一个篇章(Discourse)。广义“文本”:" - "任何由书写所固定下来的任何话语。(利科尔) 狭义“文本”:由语言文字组成的文学实体,代指“作品”,相对于作者、世界构成一个独立、自足的系统。", - overflow: isShowShrink - ? TextOverflow.visible - : TextOverflow.ellipsis, - maxLines: isShowShrink ? 10 :5, - style: TextStyle( - fontSize: 14.sp, - color:Color(0xFF1A1A1A), - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox(height: 4.h), - GestureDetector( - onTap: () { - setState(() { - isShowShrink = !isShowShrink; - }); - }, - child: Row( - // mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Text( - (isShowShrink != null && !isShowShrink) - ?"查看全文":"收起", - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.medium, - ), - ), - ], - ), - ), - SizedBox(height:16.h), - Image.asset( - "assets/image/laoban.png", - height: 310.h, - ), - SizedBox(height: 17.h), - Padding(padding: EdgeInsets.only(bottom: 16), - child:Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - InkWell( - onTap: () { - }, - child: Image.asset( - "assets/image/browse.png", - height: 16.h, - width: 16.w, - ), - ), - SizedBox(width:4), - Text( - "15", - style: TextStyle( - fontSize: 12.sp, - color:Color(0xFF1A1A1A), - fontWeight: MyFontWeight.regular, - ), - ), - ], - ), - Row( - children: [ - InkWell( - onTap: () { - }, - child: Image.asset( - "assets/image/leaving_message.png", - height: 16.h, - width: 16.w, - ), - ), - SizedBox(width:4), - Text( - "52", - style: TextStyle( - fontSize: 12.sp, - color:Color(0xFF1A1A1A), - fontWeight: MyFontWeight.regular, - ), - ), - ], - ), - Row( - children: [ - InkWell( - onTap: () { - }, - child: Image.asset( - "assets/image/follow.png", - height: 16.h, - width: 16.w, - ), - ), - SizedBox(width:4), - Text( - "25", - style: TextStyle( - fontSize: 12.sp, - color:Color(0xFF1A1A1A), - fontWeight: MyFontWeight.regular, - ), - ), - ], - ), - ], - ),), - ], - ), + itemCount: comments.length, + )); + }, ); } } diff --git a/lib/retrofit/data/article.dart b/lib/retrofit/data/article.dart index 0085a6ed..620b84a6 100644 --- a/lib/retrofit/data/article.dart +++ b/lib/retrofit/data/article.dart @@ -24,6 +24,7 @@ class Article { bool _isHot; bool _liked; int _viewers; + bool isFollow; dynamic _storeName; String get id => _id; diff --git a/lib/retrofit/data/comunity_comment.dart b/lib/retrofit/data/comunity_comment.dart index 45ef149b..a9fe7bc2 100644 --- a/lib/retrofit/data/comunity_comment.dart +++ b/lib/retrofit/data/comunity_comment.dart @@ -10,7 +10,6 @@ /// createTime : "2021-10-19 09:55:16" class ComunityComment { - ComunityComment({ String id, String subject, @@ -20,7 +19,7 @@ class ComunityComment { int viewers, int comments, bool selfLike, - bool selfFollow, + bool selfFollow, String createTime,}){ this.id = id; this.subject = subject; diff --git a/lib/retrofit/data/follow_list.dart b/lib/retrofit/data/follow_list.dart new file mode 100644 index 00000000..27691608 --- /dev/null +++ b/lib/retrofit/data/follow_list.dart @@ -0,0 +1,159 @@ +/// pageNum : 1 +/// pageSize : 100 +/// size : 1 +/// pages : 1 +/// hasPreviousPage : false +/// hasNextPage : false +/// total : "1" +/// list : [{"mid":"1406879717390286848","nickname":"flutter无敌","avatar":"https://pos.upload.gznl.top/admin/2021/10/fb4dadec-a836-49bd-a4c9-c35fc9fd5008.jpeg"}] + +class FollowList { + FollowList({ + int pageNum, + int pageSize, + int size, + int pages, + bool hasPreviousPage, + bool hasNextPage, + String total, + List list,}){ + _pageNum = pageNum; + _pageSize = pageSize; + _size = size; + _pages = pages; + _hasPreviousPage = hasPreviousPage; + _hasNextPage = hasNextPage; + _total = total; + _list = list; +} + + FollowList.fromJson(dynamic json) { + _pageNum = json['pageNum']; + _pageSize = json['pageSize']; + _size = json['size']; + _pages = json['pages']; + _hasPreviousPage = json['hasPreviousPage']; + _hasNextPage = json['hasNextPage']; + _total = json['total']; + if (json['list'] != null) { + _list = []; + json['list'].forEach((v) { + _list.add(ListData.fromJson(v)); + }); + } + } + int _pageNum; + int _pageSize; + int _size; + int _pages; + bool _hasPreviousPage; + bool _hasNextPage; + String _total; + List _list; + + int get pageNum => _pageNum; + int get pageSize => _pageSize; + int get size => _size; + int get pages => _pages; + bool get hasPreviousPage => _hasPreviousPage; + bool get hasNextPage => _hasNextPage; + String get total => _total; + List get list => _list; + + + set pageNum(int value) { + _pageNum = value; + } + + Map toJson() { + final map = {}; + map['pageNum'] = _pageNum; + map['pageSize'] = _pageSize; + map['size'] = _size; + map['pages'] = _pages; + map['hasPreviousPage'] = _hasPreviousPage; + map['hasNextPage'] = _hasNextPage; + map['total'] = _total; + if (_list != null) { + map['list'] = _list.map((v) => v.toJson()).toList(); + } + return map; + } + + set pageSize(int value) { + _pageSize = value; + } + + set size(int value) { + _size = value; + } + + set pages(int value) { + _pages = value; + } + + set hasPreviousPage(bool value) { + _hasPreviousPage = value; + } + + set hasNextPage(bool value) { + _hasNextPage = value; + } + + set total(String value) { + _total = value; + } + + set list(List value) { + _list = value; + } +} + +/// mid : "1406879717390286848" +/// nickname : "flutter无敌" +/// avatar : "https://pos.upload.gznl.top/admin/2021/10/fb4dadec-a836-49bd-a4c9-c35fc9fd5008.jpeg" + +class ListData { + ListData({ + String mid, + String nickname, + String avatar,}){ + _mid = mid; + _nickname = nickname; + _avatar = avatar; +} + + ListData.fromJson(dynamic json) { + _mid = json['mid']; + _nickname = json['nickname']; + _avatar = json['avatar']; + } + String _mid; + String _nickname; + String _avatar; + + String get mid => _mid; + String get nickname => _nickname; + String get avatar => _avatar; + + + set mid(String value) { + _mid = value; + } + + Map toJson() { + final map = {}; + map['mid'] = _mid; + map['nickname'] = _nickname; + map['avatar'] = _avatar; + return map; + } + + set nickname(String value) { + _nickname = value; + } + + set avatar(String value) { + _avatar = value; + } +} \ No newline at end of file diff --git a/lib/retrofit/data/page.dart b/lib/retrofit/data/page.dart index 257ac7e0..c92e8278 100644 --- a/lib/retrofit/data/page.dart +++ b/lib/retrofit/data/page.dart @@ -22,7 +22,7 @@ class PageInfo { List list; List records; - factory PageInfo.fromJson(Map json, D Function(dynamic d) fromJsonD) => _$PageInfoFromJson(json, fromJsonD); + factory PageInfo.fromJson(Map json, D Function(dynamic d) fromJsonD) => _$PageInfoFromJson(json, fromJsonD); Map toJson(Object Function(D value) toJsonD) => _$PageInfoToJson(this, toJsonD); } diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 53d6ccc9..e6b33d1f 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -154,8 +154,8 @@ abstract class MinApiService { @POST("order/placeOrderFirst") Future placeOrderFirst(@Body() Map param); - /// 结算 @POST("order/settlement") Future settlementApi(@Body() Map param); + } diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index d9f4f607..16bd62b3 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -21,6 +21,7 @@ import 'data/address.dart'; import 'data/banner.dart'; import 'data/brand_data.dart'; import 'data/exchange_order.dart'; +import 'data/follow_list.dart'; import 'data/goods.dart'; import 'data/goods_category.dart'; import 'data/logistics.dart'; @@ -372,5 +373,13 @@ abstract class ApiService { @POST("/information/trend-list") Future>> trendList(@Body() Map map); + /// 我关注/粉丝的会员列表 + @POST("/member/follow/list") + Future>> followList(@Body() Map map); + + + ///关注/取关会员 + @PUT("/member/follow/{followId}") + Future follow(@Path("followId") String followId); } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 9fc29cfd..0e5e21d1 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -1254,4 +1254,53 @@ class _ApiService implements ApiService { ); return value; } + + @override + Future>> followList(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>( + '/member/follow/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => ListData.fromJson(json), + ), + ); + return value; + } + + + @override + Future> follow(followId) async { + ArgumentError.checkNotNull(followId, 'followId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/member/follow/$followId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } } diff --git a/lib/view_widget/coupon_widget.dart b/lib/view_widget/coupon_widget.dart index d1a5bbf1..17f0f21d 100644 --- a/lib/view_widget/coupon_widget.dart +++ b/lib/view_widget/coupon_widget.dart @@ -80,7 +80,6 @@ class CouponWidget extends StatelessWidget { : coupon.couponImg, ) // Image.network( - // width: 60, // height: 60, // fit: BoxFit.cover, diff --git a/lib/view_widget/hot_item.dart b/lib/view_widget/hot_item.dart index 3f8db488..a4523ea7 100644 --- a/lib/view_widget/hot_item.dart +++ b/lib/view_widget/hot_item.dart @@ -1,19 +1,23 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/retrofit/data/article.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class HotArticleItem extends StatefulWidget { final Article article; final bool isHot; HotArticleItem({this.article, this.isHot}); - @override State createState() { return _HotArticleItem(); @@ -21,7 +25,24 @@ class HotArticleItem extends StatefulWidget { } class _HotArticleItem extends State { + ApiService apiService; + + @override + void initState() { + super.initState(); + SharedPreferences.getInstance().then((value) => { + apiService = ApiService(Dio(), context: context, token: value.getString("token")), + }); + } + + ///关注/取关会员 + _vipFollow(followId) async { + BaseData baseData = await apiService.follow(followId); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("关注成功"); + } + } @override Widget build(BuildContext context) { @@ -63,7 +84,7 @@ class _HotArticleItem extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - height: 44, + margin: EdgeInsets.only(left: 5), child: Row( children: [ MImage( @@ -113,19 +134,23 @@ class _HotArticleItem extends State { ), GestureDetector( onTap: (){ + setState(() { + widget.article.isFollow = !(widget.article.isFollow??false); + _vipFollow(widget.article.updateUser); + }); }, child: RoundButton( padding: EdgeInsets.symmetric( horizontal: 8, vertical: 3, ), - backgroup: Color(0xFF32A060), - textColor: Colors.white , - text: "关注", + backgroup: (widget.article.isFollow??false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), + textColor: (widget.article.isFollow??false) ? Color(0xFF808080):Colors.white , + text:(widget.article.isFollow??false) ? "已关注":"关注", radius: 20, icons: Icon( - Icons.check, - color: Color(0xFF808080), + (widget.article.isFollow??false) ? Icons.check: Icons.add, + color:(widget.article.isFollow??false) ? Color(0xFF808080):Colors.white , size: 14, ), ), @@ -133,6 +158,7 @@ class _HotArticleItem extends State { ], ), Expanded(child:Row( + crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Container( @@ -140,6 +166,7 @@ class _HotArticleItem extends State { child: articleTextTow(context), ), ), + SizedBox(width: 12.w,), Visibility( visible: widget.article != null && widget.article.coverImg != null && @@ -147,13 +174,10 @@ class _HotArticleItem extends State { child:Stack( alignment: Alignment.center, children: [ - MImage( + Image.network( widget.article != null ? widget.article.coverImg : "", - fit: BoxFit.cover, - radius: BorderRadius.circular(2), - aspectRatio: 1, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", + fit: BoxFit.fill, + height: double.infinity, ), Visibility( visible: (widget.article != null && @@ -170,6 +194,7 @@ class _HotArticleItem extends State { ), ], )), + SizedBox(height: 10.h,) ], ) : Column( diff --git a/lib/web/web_view/input_comment.dart b/lib/web/web_view/input_comment.dart index 337aece4..41e696a3 100644 --- a/lib/web/web_view/input_comment.dart +++ b/lib/web/web_view/input_comment.dart @@ -15,6 +15,7 @@ class InputComment extends StatefulWidget { final Function(String text) queryMemberComment; final Function() queryInformationLikes; final TextEditingController commentTextController; + final bool isLike; InputComment( Key key, @@ -26,9 +27,10 @@ class InputComment extends StatefulWidget { this.queryMemberComment, this.queryInformationLikes, { - this.activity, this.article, + this.isLike + } ) : super(key: key); @@ -156,14 +158,14 @@ class _InputComment extends State { ? widget.activity.liked : widget.article != null ? widget.article.liked - : false), + : widget.isLike??false), onTap: (isLiked) async { await widget.queryInformationLikes(); return (widget.activity != null ? widget.activity.liked : widget.article != null ? widget.article.liked - : false); + : widget.isLike??false); }, countBuilder: (int count, bool isLiked, String text) { return Text( From 919bf102963255030a36b1ec3de601e2dcd38c42 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 22 Oct 2021 18:32:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A4=BE=E7=BE=A4=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/image/2x/dynamic.png | Bin 0 -> 2146 bytes assets/image/3x/dynamic.png | Bin 0 -> 3880 bytes assets/image/dynamic.png | Bin 0 -> 1055 bytes lib/community/community_child_page.dart | 1 + lib/community/community_details.dart | 30 ++- .../community_view/community_dynamic.dart | 183 ++++++++++++++---- lib/community/release_dynamic.dart | 6 +- lib/generated/intl/messages_en.dart | 3 + lib/generated/intl/messages_zh_CN.dart | 3 + lib/generated/intl/messages_zh_Hans_CN.dart | 3 + lib/generated/intl/messages_zh_Hant_CN.dart | 3 + lib/generated/intl/messages_zh_TW.dart | 3 + lib/generated/l10n.dart | 30 +++ lib/l10n/intl_en.arb | 3 + lib/l10n/intl_zh_CN.arb | 3 + lib/l10n/intl_zh_Hans_CN.arb | 3 + lib/l10n/intl_zh_Hant_CN.arb | 3 + lib/l10n/intl_zh_TW.arb | 3 + lib/mine/manage_address_page.dart | 1 + lib/mine/mine_page.dart | 56 +++--- lib/mine/mine_view/community_follow.dart | 6 +- lib/mine/mine_view/mine_item.dart | 17 ++ lib/mine/release_page.dart | 77 +++++--- lib/retrofit/data/article.dart | 12 +- lib/retrofit/data/social_info.dart | 37 ++++ lib/retrofit/retrofit_api.dart | 9 + lib/retrofit/retrofit_api.g.dart | 43 ++++ lib/view_widget/hot_item.dart | 163 ++++++++-------- lib/web/web_page.dart | 7 +- lib/web/web_view/comment_list.dart | 4 +- 30 files changed, 521 insertions(+), 191 deletions(-) create mode 100644 assets/image/2x/dynamic.png create mode 100644 assets/image/3x/dynamic.png create mode 100644 assets/image/dynamic.png create mode 100644 lib/retrofit/data/social_info.dart diff --git a/assets/image/2x/dynamic.png b/assets/image/2x/dynamic.png new file mode 100644 index 0000000000000000000000000000000000000000..ce532f0d1fb8a067b91d9b3a47718f5ad4f94e2a GIT binary patch literal 2146 zcmV-o2%YzdP)Px-97#k$RA@u(T77U_RTcl8`!?Bhw-lPjNNXWM(gcVJG`sI5DJrozZDA->EiDw< zq?K{R@%w9VoN>g@abQGS+d)g4lu8-xh|H8xM+(M~(#dps|HZY2%IK{N~BgrPa z?;hu-N!;DM&Axs47+`Y#+IjbU{qDKU4U5*d40N?2mo{iva1mET}FuO$G z<^js--i$=By1Kfsu&{8U5Mlul_4)n&lZOr+I-k?KDPWiufZ=f1AfgojZe`{gA_@X& zIhUDvh=`5@cm{xFS=LiifM=YFDFYY^g$guH`!q9u89-SEAUD3B0q}Dv<<@94`lcHJ zH#}1UP}lW)0Xzbr#EsD$JVVU<(7?dJce=W|h9;|TQUGgfYfJrp{}TW{I$1{?AQRE{cs%~Vkt0X?yf~xl`e&H=M?^H&LHE60BAFM!>gwvb zfk5CT09R)?FaTh^WmyNj085oI45Ly?`7{w-o1rTSV42D%`Pj${pkWyMnECDu1E-kz z=13&+w|opw#9Lci8}$4AzXR~$48G&RVDP&3_I3r<6}bjz7=}6!)V@oVNig#VBaw*d z%32;w_4W1hq?CsNT$d`wB}J_RpQ!w5*L}NAyHV#Fpswp`X@pahs?C45Wm&&+W5^3n zU0q#;rfDyy9%ekp2f3+okbHPbqrz{S%{z}xq}vt1`uh46Qp!JMMDMqjWqsU>_@!8hte%XT9=N$HSIWZ15kv+;r@(dyx+2{bzU9LSI#hu&ocA2R5|;u ztAPbYqo0n)TG}c-0St%3w-Av!(Z)zhxh@)w?$6gzulysY>VE(2pLJ}PUkE(5Ooe?34XJ``=cYG;&mUB8(tFFhzf zvIy{rblU>A$2PS&mWdNC(WR{|Tf{T}d`!H4A(d~dWm#XCNpw}awpAv*pN>Q#ADbzFb$d3iXO<5WXtBfodNv;D zyRB>8{;W5DM}RduHq0*w6uttWlwSBZ#LK;@0DB^lh||4o>M%2C>7FgC0r^b=49C6o zX5Wdk*I!=IbL+Oji3~deT-w(BAc4N61nKW*Af8tj@-dpWG*RB#QdBHxEttO!pvKX0 z$sqF-MC?ENEi-qq;Rvvc=V_jQw2%yaj-aw%F zS#|WrA)b2!^i~{1^cB-If1Jx+7Jw~kO&5%8I%vDPlNhwest6)_)HKceb1Ba{{_8un zrTu{$iNtDVzMX)H^Xj0TB=eL{{Ppy3@u|qR?dxN)nCkgVNZA0M0`Q(uNqX&kLL59% zfP@_V)R#;quj=gVd@Gj$HD0mxbN;#WFN8E3%NSTj;F}m2z7FJ|UJ$lvJG<9lFsYhc zqjc1=tm<6CYTOy%o|ebK*qEk3GH{{~bg~b0dJqKKlep!I?^B^Rgg7UJX3w#iiUqKM zNt6m{j7ThGpBXE-7e3p0B>k*St1CX094C; zrsymIPfFX~)%nT2!@W>l*HueW{eEAH6TSWY{pDRMhgqZNJ2&oD?TB$yQBmP9E-wBhGq24Uj9QkZ0NZZe$a$MkibDH7Rf0rf4Kp{P zKe-BiZ9zt{n`%#;M7;p@F!3=k^?>k-K+<%o_A?y~g+l6?P3^gcjInb*pD%Ry@Zt2F zl>@0OfT=n{q0p5=6NlKZEk=I#{NG1q)C{R}T-S)QjxZ4>{<*To+zr(ie9YnM! zLp~vdSkuwbk#_NRV(H8uJA`}ooE?rLJo&b)3EVpf2J-%F%#jxsjt4a7XGar>wo=~s5KA+ET+jc2{ zD%GhbqLl#Nn?=WYW?mnOM3fy*17rL&iWBv1L>3MjR-%mv94+u>o*Pg2~@~A4A)gA08fWJs7{}_!%JKQ>*58t!^bZ|hc zsi~P42n2%3WHKI)$Ing0`@0*UGX>C%FVn&^3vgPdbq1BrMsNlvds literal 0 HcmV?d00001 diff --git a/assets/image/3x/dynamic.png b/assets/image/3x/dynamic.png new file mode 100644 index 0000000000000000000000000000000000000000..5676c4ade95ec433b456438c67e2befa4409bc98 GIT binary patch literal 3880 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 Z{sWeSjx70)bVC3D002ovPDHLkV1kLb|A_zq literal 0 HcmV?d00001 diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index db8e8666..479b5e9e 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -40,6 +40,7 @@ class _CommunityChildPage extends State { setState(() {}); } + ///动态列表 queryCommunity() async { if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 705705d0..467ef9b0 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -5,6 +5,8 @@ import 'package:huixiang/community/community_view/community_comment.dart'; import 'package:huixiang/community/community_view/community_dynamic.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/retrofit/data/activity.dart'; +import 'package:huixiang/retrofit/data/article.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/member_comment_list.dart'; @@ -14,6 +16,7 @@ import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/comment_menu.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:huixiang/view_widget/tips_dialog.dart'; +import 'package:huixiang/web/web_view/comment_list.dart'; import 'package:huixiang/web/web_view/input_comment.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -43,8 +46,9 @@ class _CommunityDetails extends State String hintText = S.current.liuxianinjingcaidepinglunba; bool isKeyBoardShow = false; - int commentTotal = 0; + Article article; + @override void didChangeMetrics() { @@ -73,13 +77,20 @@ class _CommunityDetails extends State WidgetsBinding.instance.addObserver(this); _queryMemberCommentList(); - SharedPreferences.getInstance().then((value) { - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - ); - }); + queryDetails(); + } + + ///详情接口 + queryDetails() async { + SharedPreferences value = await SharedPreferences.getInstance(); + if (apiService == null) + apiService = + ApiService(Dio(), context: context, token: value.getString("token")); + BaseData
baseData = await apiService + .informationInfo(comunity.id) + .catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + } } @override @@ -280,7 +291,8 @@ class _CommunityDetails extends State if (baseData != null && baseData.isSuccess) { // commentKey.currentState.initState(); commentTextController.text = ""; - _toComment(); + FocusScope.of(context).unfocus(); + _queryMemberCommentList(); } } diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 4aa3aa15..87742550 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -5,6 +5,7 @@ import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/border_text.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -16,16 +17,18 @@ class CommunityDynamic extends StatefulWidget { final Function(double height) heightFun; final bool isDetails; final int commentType; + final Function removalDynamic; final ComunityComment comment; CommunityDynamic( this.comment, - this.commentType,{ + this.commentType, { Key key, this.itemCount = 9, this.heightFun, this.isDetails = false, + this.removalDynamic, }) : super(key: key); @override @@ -33,6 +36,7 @@ class CommunityDynamic extends StatefulWidget { return _CommunityDynamic(); } } + class _CommunityDynamic extends State { GlobalKey globalKey = GlobalKey(); double height = 0; @@ -42,16 +46,29 @@ class _CommunityDynamic extends State { void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), - context: context, token: value.getString('token')), - }); + apiService = ApiService(Dio(), + context: context, token: value.getString('token')), + }); } ///关注/取关会员 _vipFollow(followId) async { BaseData baseData = await apiService.follow(followId); if (baseData != null && baseData.isSuccess) { - SmartDialog.showToast("关注成功"); + SmartDialog.showToast("关注成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + + ///删除动态 + _deleteDynamic(id) async { + BaseData baseData = await apiService.deleteTrend(id); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("删除成功", alignment: Alignment.center); + + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } @@ -60,6 +77,7 @@ class _CommunityDynamic extends State { return Column( children: [ Container( + margin: EdgeInsets.only(top: 2), key: globalKey, alignment: Alignment.topCenter, padding: EdgeInsets.all(16), @@ -88,7 +106,9 @@ class _CommunityDynamic extends State { child: Row( children: [ MImage( - widget.comment != null ? widget.comment.memberInfo.avatar : "", + widget.comment != null + ? widget.comment.memberInfo.avatar + : "", width: 44, height: 44, isCircle: true, @@ -104,7 +124,9 @@ class _CommunityDynamic extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.comment != null ? widget.comment.memberInfo.nickname : "", + widget.comment != null + ? widget.comment.memberInfo.nickname + : "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, @@ -112,7 +134,9 @@ class _CommunityDynamic extends State { ), ), Text( - widget.comment != null ? widget.comment.createTime : "", + widget.comment != null + ? widget.comment.createTime + : "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -125,35 +149,48 @@ class _CommunityDynamic extends State { ), ), GestureDetector( - onTap: (){ + onTap: () { setState(() { - if(widget.commentType == 0){ - widget.comment.selfFollow = !(widget.comment.selfFollow??false); + if (widget.commentType == 0) { + widget.comment.selfFollow = + !(widget.comment.selfFollow ?? false); _vipFollow(widget.comment.memberInfo.mid); - }else{ - SmartDialog.showToast("删除成功", alignment: Alignment.center); + } else { + showDeleteDialog(); } }); }, - child: (widget.commentType == 0)?RoundButton( - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 3, - ), - backgroup: (widget.comment.selfFollow??false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), - textColor: (widget.comment.selfFollow??false) ? Color(0xFF808080):Colors.white , - text:(widget.comment.selfFollow??false) ? "已关注":"关注", - radius: 20, - icons: Icon( - (widget.comment.selfFollow??false) ? Icons.check: Icons.add, - color:(widget.comment.selfFollow??false) ? Color(0xFF808080):Colors.white , - size: 14, - ), - ):Icon( - Icons.close, - color:Colors.black, - size: 16, - ), + child: (widget.commentType == 0) + ? RoundButton( + padding: EdgeInsets.symmetric( + horizontal: 8, + vertical: 3, + ), + backgroup: (widget.comment.selfFollow ?? false) + ? Color(0xFFE6E6E6) + : Color(0xFF32A060), + textColor: (widget.comment.selfFollow ?? false) + ? Color(0xFF808080) + : Colors.white, + text: (widget.comment.selfFollow ?? false) + ? "已关注" + : "关注", + radius: 20, + icons: Icon( + (widget.comment.selfFollow ?? false) + ? Icons.check + : Icons.add, + color: (widget.comment.selfFollow ?? false) + ? Color(0xFF808080) + : Colors.white, + size: 14, + ), + ) + : Icon( + Icons.close, + color: Colors.black, + size: 16, + ), ), ], ), @@ -162,7 +199,7 @@ class _CommunityDynamic extends State { ), Text( widget.comment.subject ?? "", - maxLines: 5, + // maxLines: 5, overflow: TextOverflow.ellipsis, style: TextStyle( color: Color(0xFF1A1A1A), @@ -181,7 +218,10 @@ class _CommunityDynamic extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ IconText( - "${widget.comment.viewers ?? 0}", + (widget.comment != null) + ? "${widget.comment.viewers}" + : "", + // "${widget.comment.viewers ?? 0}", space: 4.w, leftImage: "assets/svg/liulanliang.svg", iconSize: 16, @@ -280,6 +320,81 @@ class _CommunityDynamic extends State { ); } + ///删除动态弹窗 + showDeleteDialog() { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: Container( + width: MediaQuery.of(context).size.width - 84, + height: 110.h, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "确定要删除这条动态?", + style: TextStyle( + fontSize: 17.sp, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + SizedBox( + height: 30.h, + ), + Row( + children: [ + Expanded( + child: InkWell( + child: BorderText( + text: "取消", + textColor: Color(0xFF32A060), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + borderColor: Color(0xFF32A060), + radius: 4, + padding: EdgeInsets.all(12), + borderWidth: 1, + ), + onTap: () { + Navigator.of(context).pop(); + }, + ), + flex: 1, + ), + SizedBox( + width: 16.w, + ), + Expanded( + child: InkWell( + child: RoundButton( + text: "确定", + textColor: Colors.white, + radius: 4, + padding: EdgeInsets.all(12), + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + fontWeight: FontWeight.bold, + ), + onTap: () { + _deleteDynamic(widget.comment.id); + Navigator.of(context).pop(); + }, + ), + flex: 1, + ), + ], + ) + ], + ), + ), + ); + }, + ); + } + @override void didChangeDependencies() { if (widget.heightFun != null) diff --git a/lib/community/release_dynamic.dart b/lib/community/release_dynamic.dart index c2415051..19146dc1 100644 --- a/lib/community/release_dynamic.dart +++ b/lib/community/release_dynamic.dart @@ -30,6 +30,7 @@ class _ReleaseDynamic extends State { TextEditingController textEditingController = TextEditingController(); ApiService apiService; + @override void initState() { super.initState(); @@ -118,7 +119,7 @@ class _ReleaseDynamic extends State { releaseDynamic() async { String dynamicText = textEditingController.text; if (dynamicText == null || dynamicText == "") { - SmartDialog.showToast("请输入您此刻的想法!~"); + SmartDialog.showToast("请输入您此刻的想法!"); return; } EasyLoading.show(status: S.of(context).zhengzaijiazai); @@ -152,7 +153,7 @@ class _ReleaseDynamic extends State { EasyLoading.dismiss(); }); if (baseData.isSuccess) { - SmartDialog.showToast("发布成功!~"); + SmartDialog.showToast("发布成功!"); Future.delayed(Duration(seconds: 1), () { Navigator.of(context).pop(true); }); @@ -367,6 +368,7 @@ class _ReleaseDynamic extends State { ), child: TextField( controller: textEditingController, + maxLines:5, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index f4f7651b..9e25969c 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -200,6 +200,7 @@ class MessageLookup extends MessageLookupByLibrary { "faxingshijian" : m4, "feishiwuduihuanma" : MessageLookupByLibrary.simpleMessage("非实物兑换吗"), "feishiwushangpin" : MessageLookupByLibrary.simpleMessage("非实物商品兑换后领取到卡包即可使用!"), + "fensi" : MessageLookupByLibrary.simpleMessage("粉丝"), "fenxiangdao" : MessageLookupByLibrary.simpleMessage("分享到"), "fenxiangyaoqing" : MessageLookupByLibrary.simpleMessage("也可以直接点击右上方的分享给到你想要邀请的人。"), "fenxiangzhiweixin" : MessageLookupByLibrary.simpleMessage("分享至微信"), @@ -218,6 +219,7 @@ class MessageLookup extends MessageLookupByLibrary { "guanlidizhi" : MessageLookupByLibrary.simpleMessage("管理地址"), "guanyu" : MessageLookupByLibrary.simpleMessage("关于"), "guanyuchuangshiren" : MessageLookupByLibrary.simpleMessage("关于创始人"), + "guanzhu" : MessageLookupByLibrary.simpleMessage("关注"), "guojiankangyoujishenghuo" : MessageLookupByLibrary.simpleMessage("过健康有机生活"), "haimeiyouxiaoxi" : MessageLookupByLibrary.simpleMessage("还没有消息~"), "haimeiyouyouhuiquankeyilingqu" : MessageLookupByLibrary.simpleMessage("还没有优惠券可以领取~"), @@ -491,6 +493,7 @@ class MessageLookup extends MessageLookupByLibrary { "wenzhang" : MessageLookupByLibrary.simpleMessage("文章"), "wenzhangxiangqing" : MessageLookupByLibrary.simpleMessage("文章详情"), "weulingqu" : MessageLookupByLibrary.simpleMessage("未领取"), + "wodedongtai" : MessageLookupByLibrary.simpleMessage("我的动态"), "wodegongju" : MessageLookupByLibrary.simpleMessage("我的工具"), "wodehuiyuandengji" : MessageLookupByLibrary.simpleMessage("我的会员等级"), "wodejifenzhi" : MessageLookupByLibrary.simpleMessage("我的积分值"), diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index d288ebf7..cfbea28d 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -200,6 +200,7 @@ class MessageLookup extends MessageLookupByLibrary { "faxingshijian" : m4, "feishiwuduihuanma" : MessageLookupByLibrary.simpleMessage("非实物兑换吗"), "feishiwushangpin" : MessageLookupByLibrary.simpleMessage("非实物商品兑换后领取到卡包即可使用!"), + "fensi" : MessageLookupByLibrary.simpleMessage("粉丝"), "fenxiangdao" : MessageLookupByLibrary.simpleMessage("分享到"), "fenxiangyaoqing" : MessageLookupByLibrary.simpleMessage("也可以直接点击右上方的分享给到你想要邀请的人。"), "fenxiangzhiweixin" : MessageLookupByLibrary.simpleMessage("分享至微信"), @@ -217,6 +218,7 @@ class MessageLookup extends MessageLookupByLibrary { "gouxuanxieyi" : MessageLookupByLibrary.simpleMessage("请勾选同意隐私服务和一心回乡服务协议"), "guanlidizhi" : MessageLookupByLibrary.simpleMessage("管理地址"), "guanyu" : MessageLookupByLibrary.simpleMessage("关于"), + "guanzhu" : MessageLookupByLibrary.simpleMessage("关注"), "guojiankangyoujishenghuo" : MessageLookupByLibrary.simpleMessage("过健康有机生活"), "haimeiyouxiaoxi" : MessageLookupByLibrary.simpleMessage("还没有消息~"), "haimeiyouyouhuiquankeyilingqu" : MessageLookupByLibrary.simpleMessage("还没有优惠券可以领取~"), @@ -490,6 +492,7 @@ class MessageLookup extends MessageLookupByLibrary { "wenzhang" : MessageLookupByLibrary.simpleMessage("文章"), "wenzhangxiangqing" : MessageLookupByLibrary.simpleMessage("文章详情"), "weulingqu" : MessageLookupByLibrary.simpleMessage("未领取"), + "wodedongtai" : MessageLookupByLibrary.simpleMessage("我的动态"), "wodegongju" : MessageLookupByLibrary.simpleMessage("我的工具"), "wodehuiyuandengji" : MessageLookupByLibrary.simpleMessage("我的会员等级"), "wodejifenzhi" : MessageLookupByLibrary.simpleMessage("我的积分值"), diff --git a/lib/generated/intl/messages_zh_Hans_CN.dart b/lib/generated/intl/messages_zh_Hans_CN.dart index 2674ccb0..98b6753f 100644 --- a/lib/generated/intl/messages_zh_Hans_CN.dart +++ b/lib/generated/intl/messages_zh_Hans_CN.dart @@ -200,6 +200,7 @@ class MessageLookup extends MessageLookupByLibrary { "faxingshijian" : m4, "feishiwuduihuanma" : MessageLookupByLibrary.simpleMessage("非实物兑换吗"), "feishiwushangpin" : MessageLookupByLibrary.simpleMessage("非实物商品兑换后领取到卡包即可使用!"), + "fensi" : MessageLookupByLibrary.simpleMessage("粉丝"), "fenxiangdao" : MessageLookupByLibrary.simpleMessage("分享到"), "fenxiangyaoqing" : MessageLookupByLibrary.simpleMessage("也可以直接点击右上方的分享给到你想要邀请的人。"), "fenxiangzhiweixin" : MessageLookupByLibrary.simpleMessage("分享至微信"), @@ -217,6 +218,7 @@ class MessageLookup extends MessageLookupByLibrary { "gouxuanxieyi" : MessageLookupByLibrary.simpleMessage("请勾选同意隐私服务和一心回乡服务协议"), "guanlidizhi" : MessageLookupByLibrary.simpleMessage("管理地址"), "guanyu" : MessageLookupByLibrary.simpleMessage("关于"), + "guanzhu" : MessageLookupByLibrary.simpleMessage("关注"), "guojiankangyoujishenghuo" : MessageLookupByLibrary.simpleMessage("过健康有机生活"), "haimeiyouxiaoxi" : MessageLookupByLibrary.simpleMessage("还没有消息~"), "haimeiyouyouhuiquankeyilingqu" : MessageLookupByLibrary.simpleMessage("还没有优惠券可以领取~"), @@ -490,6 +492,7 @@ class MessageLookup extends MessageLookupByLibrary { "wenzhang" : MessageLookupByLibrary.simpleMessage("文章"), "wenzhangxiangqing" : MessageLookupByLibrary.simpleMessage("文章详情"), "weulingqu" : MessageLookupByLibrary.simpleMessage("未领取"), + "wodedongtai" : MessageLookupByLibrary.simpleMessage("我的动态"), "wodegongju" : MessageLookupByLibrary.simpleMessage("我的工具"), "wodehuiyuandengji" : MessageLookupByLibrary.simpleMessage("我的会员等级"), "wodejifenzhi" : MessageLookupByLibrary.simpleMessage("我的积分值"), diff --git a/lib/generated/intl/messages_zh_Hant_CN.dart b/lib/generated/intl/messages_zh_Hant_CN.dart index 4f01a1e7..cfe6b504 100644 --- a/lib/generated/intl/messages_zh_Hant_CN.dart +++ b/lib/generated/intl/messages_zh_Hant_CN.dart @@ -200,6 +200,7 @@ class MessageLookup extends MessageLookupByLibrary { "faxingshijian" : m4, "feishiwuduihuanma" : MessageLookupByLibrary.simpleMessage("非實物兌換碼"), "feishiwushangpin" : MessageLookupByLibrary.simpleMessage("非實物商品!"), + "fensi" : MessageLookupByLibrary.simpleMessage("粉絲"), "fenxiangdao" : MessageLookupByLibrary.simpleMessage("分享到"), "fenxiangyaoqing" : MessageLookupByLibrary.simpleMessage("也可以直接點擊右上方的分享給到你想要邀請的人。"), "fenxiangzhiweixin" : MessageLookupByLibrary.simpleMessage("分享至微信"), @@ -217,6 +218,7 @@ class MessageLookup extends MessageLookupByLibrary { "gouxuanxieyi" : MessageLookupByLibrary.simpleMessage("請勾選同意隱私服務和一心回鄉服務協定"), "guanlidizhi" : MessageLookupByLibrary.simpleMessage("管理地址"), "guanyu" : MessageLookupByLibrary.simpleMessage("關於"), + "guanzhu" : MessageLookupByLibrary.simpleMessage("關注"), "guojiankangyoujishenghuo" : MessageLookupByLibrary.simpleMessage("過健康有機生活"), "haimeiyouxiaoxi" : MessageLookupByLibrary.simpleMessage("還沒有消息~"), "haimeiyouyouhuiquankeyilingqu" : MessageLookupByLibrary.simpleMessage("還沒有優惠券可以領取~"), @@ -490,6 +492,7 @@ class MessageLookup extends MessageLookupByLibrary { "wenzhang" : MessageLookupByLibrary.simpleMessage("文章"), "wenzhangxiangqing" : MessageLookupByLibrary.simpleMessage("文章詳情"), "weulingqu" : MessageLookupByLibrary.simpleMessage("未領取"), + "wodedongtai" : MessageLookupByLibrary.simpleMessage("我的動態"), "wodegongju" : MessageLookupByLibrary.simpleMessage("我的工具"), "wodehuiyuandengji" : MessageLookupByLibrary.simpleMessage("我的會員等級"), "wodejifenzhi" : MessageLookupByLibrary.simpleMessage("我的積分值"), diff --git a/lib/generated/intl/messages_zh_TW.dart b/lib/generated/intl/messages_zh_TW.dart index cd8c340c..3c39e71d 100644 --- a/lib/generated/intl/messages_zh_TW.dart +++ b/lib/generated/intl/messages_zh_TW.dart @@ -200,6 +200,7 @@ class MessageLookup extends MessageLookupByLibrary { "faxingshijian" : m4, "feishiwuduihuanma" : MessageLookupByLibrary.simpleMessage("非實物兌換碼"), "feishiwushangpin" : MessageLookupByLibrary.simpleMessage("非實物商品!"), + "fensi" : MessageLookupByLibrary.simpleMessage("粉絲"), "fenxiangdao" : MessageLookupByLibrary.simpleMessage("分享到"), "fenxiangyaoqing" : MessageLookupByLibrary.simpleMessage("也可以直接點擊右上方的分享給到你想要邀請的人。"), "fenxiangzhiweixin" : MessageLookupByLibrary.simpleMessage("分享至微信"), @@ -217,6 +218,7 @@ class MessageLookup extends MessageLookupByLibrary { "gouxuanxieyi" : MessageLookupByLibrary.simpleMessage("請勾選同意隱私服務和一心回鄉服務協定"), "guanlidizhi" : MessageLookupByLibrary.simpleMessage("管理地址"), "guanyu" : MessageLookupByLibrary.simpleMessage("關於"), + "guanzhu" : MessageLookupByLibrary.simpleMessage("關注"), "guojiankangyoujishenghuo" : MessageLookupByLibrary.simpleMessage("過健康有機生活"), "haimeiyouxiaoxi" : MessageLookupByLibrary.simpleMessage("還沒有消息~"), "haimeiyouyouhuiquankeyilingqu" : MessageLookupByLibrary.simpleMessage("還沒有優惠券可以領取~"), @@ -490,6 +492,7 @@ class MessageLookup extends MessageLookupByLibrary { "wenzhang" : MessageLookupByLibrary.simpleMessage("文章"), "wenzhangxiangqing" : MessageLookupByLibrary.simpleMessage("文章詳情"), "weulingqu" : MessageLookupByLibrary.simpleMessage("未領取"), + "wodedongtai" : MessageLookupByLibrary.simpleMessage("我的動態"), "wodegongju" : MessageLookupByLibrary.simpleMessage("我的工具"), "wodehuiyuandengji" : MessageLookupByLibrary.simpleMessage("我的會員等級"), "wodejifenzhi" : MessageLookupByLibrary.simpleMessage("我的積分值"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 34855b1d..5587fa8a 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -5145,6 +5145,36 @@ class S { ); } + /// `粉丝` + String get fensi { + return Intl.message( + '粉丝', + name: 'fensi', + desc: '', + args: [], + ); + } + + /// `关注` + String get guanzhu { + return Intl.message( + '关注', + name: 'guanzhu', + desc: '', + args: [], + ); + } + + /// `我的动态` + String get wodedongtai { + return Intl.message( + '我的动态', + name: 'wodedongtai', + desc: '', + args: [], + ); + } + /// `并使用本机号码登录` String get privacy_policy4 { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 0fcd825a..75915aeb 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -534,6 +534,9 @@ "yuanjia": "原价", "xuanguige": "选规格", "chaojiyouhuiquan": "超值优惠券", + "fensi": "粉丝", + "guanzhu": "关注", + "wodedongtai": "我的动态", diff --git a/lib/l10n/intl_zh_CN.arb b/lib/l10n/intl_zh_CN.arb index 7184477d..86a5a1b9 100644 --- a/lib/l10n/intl_zh_CN.arb +++ b/lib/l10n/intl_zh_CN.arb @@ -534,6 +534,9 @@ "yuanjia": "原价", "xuanguige": "选规格", "chaojiyouhuiquan": "超值优惠券", + "fensi": "粉丝", + "guanzhu": "关注", + "wodedongtai": "我的动态", diff --git a/lib/l10n/intl_zh_Hans_CN.arb b/lib/l10n/intl_zh_Hans_CN.arb index 5b337403..2dac914a 100644 --- a/lib/l10n/intl_zh_Hans_CN.arb +++ b/lib/l10n/intl_zh_Hans_CN.arb @@ -534,6 +534,9 @@ "yuanjia": "原价", "xuanguige": "选规格", "chaojiyouhuiquan": "超值优惠券", + "fensi": "粉丝", + "guanzhu": "关注", + "wodedongtai": "我的动态", diff --git a/lib/l10n/intl_zh_Hant_CN.arb b/lib/l10n/intl_zh_Hant_CN.arb index 4bea15d5..92d3ef37 100644 --- a/lib/l10n/intl_zh_Hant_CN.arb +++ b/lib/l10n/intl_zh_Hant_CN.arb @@ -529,6 +529,9 @@ "yuanjia": "原價", "xuanguige": "選規格", "chaojiyouhuiquan": "超值优惠券", + "fensi": "粉絲", + "guanzhu": "關注", + "wodedongtai": "我的動態", diff --git a/lib/l10n/intl_zh_TW.arb b/lib/l10n/intl_zh_TW.arb index 010f674f..3996d39d 100644 --- a/lib/l10n/intl_zh_TW.arb +++ b/lib/l10n/intl_zh_TW.arb @@ -528,6 +528,9 @@ "yuanjia": "原價", "xuanguige": "選規格", "chaojiyouhuiquan": "超值优惠券", + "fensi": "粉絲", + "guanzhu": "關注", + "wodedongtai": "我的動態", diff --git a/lib/mine/manage_address_page.dart b/lib/mine/manage_address_page.dart index 4ec9d1a7..8ae0c7fc 100644 --- a/lib/mine/manage_address_page.dart +++ b/lib/mine/manage_address_page.dart @@ -261,6 +261,7 @@ class _ManageAddressPage extends State { ); } + ///删除地址弹窗 showDeleteDialog(position) { showDialog( context: context, diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 6fb622f8..2e81586d 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -8,6 +8,8 @@ import 'package:huixiang/main.dart'; import 'package:huixiang/mine/mine_view/mine_order.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/rank.dart'; +import 'package:huixiang/retrofit/data/sign_info.dart'; +import 'package:huixiang/retrofit/data/social_info.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/event_type.dart'; @@ -35,6 +37,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; UserInfo userInfo; List ranks = []; + SocialInfo infoNumber; final RefreshController _refreshController = RefreshController(); _toUserInfo() async { @@ -58,6 +61,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { @override void initState() { super.initState(); + querySocialInfo(); eventBus.on().listen((event) { print("EventType: ${event.type}"); @@ -112,6 +116,24 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { EasyLoading.dismiss(); } + ///个人社交信息(粉丝/关注数量) + querySocialInfo() async { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + showLoading: false, + ); + + BaseData baseData = + await apiService.socialInfo().catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + infoNumber = baseData.data; + } + EasyLoading.dismiss(); + } + @override Widget build(BuildContext context) { super.build(context); @@ -282,10 +304,10 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ); } - ///关注度/粉丝/发布 + ///关注度/粉丝 Widget attention(){ return Container( - margin: EdgeInsets.only(left: 16,right: 17,top: 10), + margin: EdgeInsets.only(left: 16,top: 10), child:GestureDetector( onTap:(){ Navigator.of(context).pushNamed( @@ -294,33 +316,13 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ); }, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text( - "关注", - style: TextStyle( - color: Color(0xFF000000), - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - ), - Text( - "45", - style: TextStyle( - color: Color(0xFF000000), - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ], - ), - Row( - children: [ - Text( - "粉丝", + S.of(context).guanzhu, style: TextStyle( color: Color(0xFF000000), fontSize: 14.sp, @@ -328,7 +330,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ), ), Text( - "666", + "(" + (infoNumber != null ?infoNumber.follow.toString() :"()") +")", style: TextStyle( color: Color(0xFF000000), fontSize: 15.sp, @@ -340,7 +342,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { Row( children: [ Text( - "发布", + S.of(context).fensi, style: TextStyle( color: Color(0xFF000000), fontSize: 14.sp, @@ -348,7 +350,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ), ), Text( - "666", + "(" + (infoNumber != null ?infoNumber.fans.toString() :"()") +")", style: TextStyle( color: Color(0xFF000000), fontSize: 15.sp, diff --git a/lib/mine/mine_view/community_follow.dart b/lib/mine/mine_view/community_follow.dart index 81844dd5..94a2718c 100644 --- a/lib/mine/mine_view/community_follow.dart +++ b/lib/mine/mine_view/community_follow.dart @@ -1,7 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/mine/follow_page.dart'; -import 'package:huixiang/mine/release_page.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -31,7 +30,7 @@ class _CommunityFollow extends State @override Widget build(BuildContext context) { return DefaultTabController( - length: 3, + length: 2, child: Scaffold( appBar: MyAppBar( title: "", @@ -59,12 +58,11 @@ class _CommunityFollow extends State tabs: [ MyTab(text:"关注(0)",), MyTab(text: "粉丝(0)"), - MyTab(text: "发布(0)"), ], ), ), body: TabBarView( - children: [FollowPage(),FansPage(),ReleasePage()], + children: [FollowPage(),FansPage()], ), ), ); diff --git a/lib/mine/mine_view/mine_item.dart b/lib/mine/mine_view/mine_item.dart index 4f392be2..4ee2a33d 100644 --- a/lib/mine/mine_view/mine_item.dart +++ b/lib/mine/mine_view/mine_item.dart @@ -60,6 +60,23 @@ class _MineItem extends State { ), ), ), + InkWell( + onTap: () { + SharedPreferences.getInstance().then((value) { + if (value.getString("token") == null || + value.getString("token") == "") { + LoginTipsDialog().show(context); + return; + } + Navigator.of(context) + .pushNamed('/router/releasePage'); + }); + }, + child: mineItem( + S.of(context).wodedongtai, + "assets/image/dynamic.png", + ), + ), InkWell( onTap: () { SharedPreferences.getInstance().then((value) { diff --git a/lib/mine/release_page.dart b/lib/mine/release_page.dart index 3a1ec9b1..01c7dff0 100644 --- a/lib/mine/release_page.dart +++ b/lib/mine/release_page.dart @@ -2,11 +2,13 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/community/community_view/community_dynamic.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/classic_header.dart'; +import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/my_footer.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -77,38 +79,53 @@ class _ReleasePage extends State { return FutureBuilder( future: queryCommunity(), builder: (context, position) { - return SmartRefresher( - controller: refreshController, - enablePullDown: true, - enablePullUp: true, - physics: BouncingScrollPhysics(), - header: MyHeader(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); + return Scaffold( + appBar: MyAppBar( + background: Color(0xFFFFFFFF), + leadingColor: Colors.black, + title: "动态", + titleColor: Colors.black, + titleSize: 18.sp, + ), + body: SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: true, + physics: BouncingScrollPhysics(), + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh: _onRefresh, + onLoading: () { + setState(() {}); }, - ), - onRefresh: _onRefresh, - onLoading: () { - setState(() {}); - }, - child: ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return InkWell( - child: CommunityDynamic(comments[position],1), - onTap: () { - Navigator.of(context).pushNamed( - '/router/community_details', - arguments: { - "comment": comments[position], + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + child: CommunityDynamic( + comments[position], + 1, + removalDynamic: () { + _onRefresh(); }, - ); - }, - ); - }, - itemCount: comments.length, - )); + ), + onTap: () { + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "comment": comments[position], + }, + ); + }, + ); + }, + itemCount: comments.length, + )), + ); }, ); } diff --git a/lib/retrofit/data/article.dart b/lib/retrofit/data/article.dart index 620b84a6..e199a6c3 100644 --- a/lib/retrofit/data/article.dart +++ b/lib/retrofit/data/article.dart @@ -24,6 +24,7 @@ class Article { bool _isHot; bool _liked; int _viewers; + int _comments; bool isFollow; dynamic _storeName; @@ -47,6 +48,7 @@ class Article { bool get isHot => _isHot; bool get liked => _liked; int get viewers => _viewers; + int get comments => _comments; dynamic get storeName => _storeName; set likes(int value) { @@ -61,6 +63,10 @@ class Article { _viewers = value; } + set comments(int value) { + _comments = value; + } + Article({ String id, String createTime, @@ -72,7 +78,7 @@ class Article { dynamic viceTitle, String content, String coverImg, - Author author, + Author author, int type, String startTime, String endTime, @@ -81,6 +87,7 @@ class Article { int likes, bool isHot, int viewers, + int comments, dynamic storeName}){ _id = id; _createTime = createTime; @@ -102,6 +109,7 @@ class Article { _isHot = isHot; _liked = liked; _viewers = viewers; + _comments = comments; _storeName = storeName; } @@ -126,6 +134,7 @@ class Article { _isHot = json["isHot"]; _liked = json["liked"]; _viewers = json["viewers"]; + _comments = json["comments"]; _storeName = json["storeName"]; } @@ -151,6 +160,7 @@ class Article { map["isHot"] = _isHot; map["liked"] = _liked; map["viewers"] = _viewers; + map["comments"] = _comments; map["storeName"] = _storeName; return map; } diff --git a/lib/retrofit/data/social_info.dart b/lib/retrofit/data/social_info.dart new file mode 100644 index 00000000..a35c27af --- /dev/null +++ b/lib/retrofit/data/social_info.dart @@ -0,0 +1,37 @@ +/// fans : 0 +/// follow : 0 + +class SocialInfo { + SocialInfo({ + int fans, + int follow,}){ + _fans = fans; + _follow = follow; +} + + SocialInfo.fromJson(dynamic json) { + _fans = json['fans']; + _follow = json['follow']; + } + int _fans; + int _follow; + + int get fans => _fans; + int get follow => _follow; + + + set fans(int value) { + _fans = value; + } + + Map toJson() { + final map = {}; + map['fans'] = _fans; + map['follow'] = _follow; + return map; + } + + set follow(int value) { + _follow = value; + } +} \ No newline at end of file diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 16bd62b3..8074e2e4 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -30,6 +30,7 @@ import 'data/message.dart'; import 'data/page.dart'; import 'data/rank.dart'; import 'data/sign_info.dart'; +import 'data/social_info.dart'; import 'data/store.dart'; import 'data/upload_result.dart'; import 'data/user_bill.dart'; @@ -382,4 +383,12 @@ abstract class ApiService { @PUT("/member/follow/{followId}") Future follow(@Path("followId") String followId); + ///删除动态 + @DELETE("/information/trend/{id}") + Future deleteTrend(@Path("id") String id); + + ///个人社交信息(粉丝/关注数量) + @GET("/member/socialInfo") + Future> socialInfo(); + } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 0e5e21d1..456ad398 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -1303,4 +1303,47 @@ class _ApiService implements ApiService { ); return value; } + + @override + Future> deleteTrend(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/information/trend/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'DELETE', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> socialInfo() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/member/socialInfo', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => SocialInfo.fromJson(json), + ); + return value; + } } diff --git a/lib/view_widget/hot_item.dart b/lib/view_widget/hot_item.dart index a4523ea7..f6f28574 100644 --- a/lib/view_widget/hot_item.dart +++ b/lib/view_widget/hot_item.dart @@ -61,6 +61,7 @@ class _HotArticleItem extends State { setState(() {}); } + Widget hotItem(BuildContext context) { return Container( padding: EdgeInsets.all((widget.isHot == null || !widget.isHot) ? 4 : 0), @@ -79,87 +80,88 @@ class _HotArticleItem extends State { child: (widget.isHot == null || !widget.isHot) ? Column( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Row( - children: [ - MImage( - (widget.article != null && - widget.article.author != null) - ? widget.article.author.avatar - : "", - width: 44, - height: 44, - isCircle: true, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", - ), - SizedBox( - width: 8, - ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - (widget.article != null && - widget.article.author != null) - ? widget.article.author.name - : "", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF1A1A1A), - ), - ), - Text( - widget.article != null - ? (widget.article.createTime.split(" ")[0]) - : "", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF808080), - ), - ), - ], - ), - ], - ), - ), - GestureDetector( - onTap: (){ - setState(() { - widget.article.isFollow = !(widget.article.isFollow??false); - _vipFollow(widget.article.updateUser); - }); - }, - child: RoundButton( - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 3, - ), - backgroup: (widget.article.isFollow??false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), - textColor: (widget.article.isFollow??false) ? Color(0xFF808080):Colors.white , - text:(widget.article.isFollow??false) ? "已关注":"关注", - radius: 20, - icons: Icon( - (widget.article.isFollow??false) ? Icons.check: Icons.add, - color:(widget.article.isFollow??false) ? Color(0xFF808080):Colors.white , - size: 14, - ), - ), - ), - ], - ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Container( + // margin: EdgeInsets.only(left: 5), + // child: Row( + // children: [ + // MImage( + // (widget.article != null && + // widget.article.author != null) + // ? widget.article.author.avatar + // : "", + // width: 44, + // height: 44, + // isCircle: true, + // fit: BoxFit.cover, + // errorSrc: "assets/image/default_1.png", + // fadeSrc: "assets/image/default_1.png", + // ), + // SizedBox( + // width: 8, + // ), + // Column( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // (widget.article != null && + // widget.article.author != null) + // ? widget.article.author.name + // : "", + // style: TextStyle( + // fontSize: 14.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF1A1A1A), + // ), + // ), + // Text( + // widget.article != null + // ? (widget.article.createTime.split(" ")[0]) + // : "", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFF808080), + // ), + // ), + // ], + // ), + // ], + // ), + // ), + // GestureDetector( + // onTap: (){ + // setState(() { + // widget.article.isFollow = !(widget.article.isFollow??false); + // _vipFollow(widget.article.updateUser); + // }); + // }, + // child: RoundButton( + // padding: EdgeInsets.symmetric( + // horizontal: 8, + // vertical: 3, + // ), + // backgroup: (widget.article.isFollow??false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), + // textColor: (widget.article.isFollow??false) ? Color(0xFF808080):Colors.white , + // text:(widget.article.isFollow??false) ? "已关注":"关注", + // radius: 20, + // icons: Icon( + // (widget.article.isFollow??false) ? Icons.check: Icons.add, + // color:(widget.article.isFollow??false) ? Color(0xFF808080):Colors.white , + // size: 14, + // ), + // ), + // ), + // ], + // ), Expanded(child:Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ + SizedBox(height: 5.h), Expanded( child: Container( margin: EdgeInsets.only(left: 12.w), @@ -192,6 +194,7 @@ class _HotArticleItem extends State { ], ), ), + SizedBox(width:5.w,), ], )), SizedBox(height: 10.h,) @@ -327,7 +330,7 @@ class _HotArticleItem extends State { ), Text( (widget.article != null) - ? "${widget.article.viewers}" + ? "${widget.article.comments}" : "", style: TextStyle( fontSize: 12.sp, @@ -494,7 +497,7 @@ class _HotArticleItem extends State { ), Text( (widget.article != null) - ? "${widget.article.viewers}" + ? "${widget.article.comments}" : "", style: TextStyle( fontSize: 12.sp, diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index 65ec1cdb..e5949299 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -123,8 +123,10 @@ class _WebPage extends State with WidgetsBindingObserver { "relationalType": 1 }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { - commentKey.currentState.initState(); + CommentListState _commentList = commentKey.currentState; + _commentList.queryMemberCommentList(); commentTextController.text = ""; + FocusScope.of(context).unfocus(); _toComment(); } } @@ -310,7 +312,8 @@ class _WebPage extends State with WidgetsBindingObserver { BaseData baseData = await apiService.delComment( widget.arguments["activityId"] ?? widget.arguments["articleId"]); if (baseData != null && baseData.isSuccess) { - commentKey.currentState.initState(); + CommentListState _commentList = commentKey.currentState; + _commentList.queryMemberCommentList(); } } diff --git a/lib/web/web_view/comment_list.dart b/lib/web/web_view/comment_list.dart index 91f782fd..69a27904 100644 --- a/lib/web/web_view/comment_list.dart +++ b/lib/web/web_view/comment_list.dart @@ -30,11 +30,11 @@ class CommentList extends StatefulWidget { @override State createState() { - return _CommentList(); + return CommentListState(); } } -class _CommentList extends State { +class CommentListState extends State { int commentTotal = 0; List memberList = []; ApiService apiService;