From d0851ab24dfa92af3f1615f3a8495508bd59f463 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Tue, 15 Feb 2022 18:23:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community_view/community_dynamic.dart | 16 ++-- lib/home/home_page.dart | 8 +- lib/home/main_home_page.dart | 10 +-- lib/login/login_page.dart | 10 +-- lib/main.dart | 2 +- lib/main_page.dart | 15 +++- lib/message/system_details.dart | 2 +- lib/mine/release_page.dart | 86 ++++++++++--------- .../settlement_view/pay_method.dart | 2 +- 9 files changed, 85 insertions(+), 66 deletions(-) diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 6f2fae18..148d6d8a 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -227,10 +227,10 @@ class _CommunityDynamic extends State { onTap: () { setState(() { if (widget.commentType == 0) { - widget.article.liked = - !(widget.article.liked ?? false); + widget.article.isFollow = + !(widget.article.isFollow ?? false); _vipFollow(widget.article.updateUser, - widget.article.liked ?? false); + widget.article.isFollow ?? false); } else { showDeleteDialog(); } @@ -243,21 +243,21 @@ class _CommunityDynamic extends State { alignment: Alignment.center, child: RoundButton( height: 25.h, - backgroup: (widget?.article?.liked ?? false) + backgroup: (widget?.article?.isFollow ?? false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), - textColor: (widget?.article?.liked ?? false) + textColor: (widget?.article?.isFollow ?? false) ? Color(0xFF808080) : Colors.white, - text: (widget?.article?.liked ?? false) + text: (widget?.article?.isFollow ?? false) ? "已关注" : "关注", radius: 20, icons: Icon( - (widget?.article?.liked ?? false) + (widget?.article?.isFollow ?? false) ? Icons.check : Icons.add, - color: (widget?.article?.liked ?? false) + color: (widget?.article?.isFollow ?? false) ? Color(0xFF808080) : Colors.white, size: 15, diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index a7f5674d..e8231bf3 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -49,16 +49,16 @@ class HomePage extends StatefulWidget { final List interviewCouponList; final List firstLoginCouponList; - HomePage(this.changeTab, - {this.invite, this.interviewCouponList, this.firstLoginCouponList}); + HomePage(Key key, this.changeTab, + {this.invite, this.interviewCouponList, this.firstLoginCouponList}): super(key: key); @override State createState() { - return _HomePage(); + return HomePageState(); } } -class _HomePage extends State with AutomaticKeepAliveClientMixin { +class HomePageState extends State with AutomaticKeepAliveClientMixin { ApiService apiService; @override diff --git a/lib/home/main_home_page.dart b/lib/home/main_home_page.dart index ef8e4821..ff6efe0e 100644 --- a/lib/home/main_home_page.dart +++ b/lib/home/main_home_page.dart @@ -28,11 +28,11 @@ class _MainHomePage extends State tabcontroller = TabController(length: 3, vsync: this); _widgetOptions = [ - HomePage(() { - setState(() { - tabcontroller.index = 2; - }); - }), + // HomePage(() { + // setState(() { + // tabcontroller.index = 2; + // }); + // }), ActivityListPage(), PointsMallPage() ]; diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index 0560384a..db350f85 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -526,11 +526,11 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { controller: scrollController, physics: PageScrollPhysics().applyTo(ClampingScrollPhysics()), child: SizedBox( - height: MediaQuery.of(context).size.height * 1.47, + height: MediaQuery.of(context).size.height * 1.50, child: Column( children: [ SizedBox( - height: MediaQuery.of(context).size.height * 0.6244, + height: MediaQuery.of(context).size.height * 0.5980, ), Expanded( child: Container( @@ -706,7 +706,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), Container( - height:35.h, + height:25.h, width: MediaQuery.of(context).size.width - 80.h, // margin: EdgeInsets.only(top: 12.h), child: TextField( @@ -773,7 +773,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), Container( - height:35.h, + height:25.h, width: MediaQuery.of(context).size.width - 80.h, child: Row( mainAxisAlignment: MainAxisAlignment.end, @@ -923,7 +923,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), Container( - height:35.h, + height:25.h, width: MediaQuery.of(context).size.width - 80.h, child: TextField( style: TextStyle( diff --git a/lib/main.dart b/lib/main.dart index bda98505..be5430b7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -112,7 +112,7 @@ void main() async { runApp(MyApp(locale, isFirst)); // FlutterBugly.postCatchedException((){ // }); - // FlutterBugly.init(androidAppId: "85ed24e0ec",iOSAppId: "b8a258b0bc"); + // FlutterBugly.init(androidAppId: "204f207673",iOSAppId: "8bb92ba0f6"); } final XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin(); diff --git a/lib/main_page.dart b/lib/main_page.dart index e38f1926..8a117688 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -37,6 +37,7 @@ class _MainPage extends State with WidgetsBindingObserver { List _widgetOptions; List icons; + final GlobalKey homePageKey = GlobalKey(); // List iconn; @override @@ -95,7 +96,7 @@ class _MainPage extends State with WidgetsBindingObserver { _widgetOptions = [ // BrandPage(), - HomePage((index) { + HomePage(homePageKey,(index) { setState(() { pageController.jumpToPage(index); }); @@ -140,7 +141,7 @@ class _MainPage extends State with WidgetsBindingObserver { ); } - /// @typed: 1文章 2活动 3店铺 4积分商品 5订单 + /// @typed: 1文章 2活动 3店铺 4积分商品 5订单 6动态 xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { print("xgPushClickAction1: $event"); if (event["actionType"] == 2) return event; @@ -162,6 +163,12 @@ class _MainPage extends State with WidgetsBindingObserver { } return event; }, onReceiveNotificationResponse: (event) async { + try{ + if(jsonDecode(event["customMessage"])["typed"] == 6){ + HomePageState state = homePageKey.currentState; + state.queryMsgStats(); + } + }catch(ex){} print("onReceiveNotificationResponse: ${event.toString()}"); return event; }, onReceiveMessage: (event) async { @@ -215,6 +222,10 @@ class _MainPage extends State with WidgetsBindingObserver { routeName = "/router/order_details"; params["id"] = pushMap["info"]; break; + case 6: + routeName = "/router/community_details"; + params["businessId"] = pushMap["info"]; + break; } sharedPreferences.setString("pushData", ""); print("xgPushClickAction: routeName: $routeName"); diff --git a/lib/message/system_details.dart b/lib/message/system_details.dart index a433ad18..d64c85e9 100644 --- a/lib/message/system_details.dart +++ b/lib/message/system_details.dart @@ -565,7 +565,7 @@ class _SystemDetails extends State { ), SizedBox(width:2.w), Expanded(child:Text( - messageRelational["content"], + messageRelational["content"] ?? "", maxLines: 2, overflow:TextOverflow.ellipsis, style: TextStyle( diff --git a/lib/mine/release_page.dart b/lib/mine/release_page.dart index 5ac84996..c09215f2 100644 --- a/lib/mine/release_page.dart +++ b/lib/mine/release_page.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:huixiang/community/community_list.dart'; import 'package:huixiang/community/community_view/community_dynamic.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/article.dart'; @@ -26,25 +25,24 @@ class ReleasePage extends StatefulWidget { class _ReleasePage extends State { RefreshController refreshController = RefreshController(); - final ScrollController scrollController = ScrollController(); ApiService apiService; int pageNum = 0; String userId; - bool isLoadMore = false; - List comments = []; + List
articles = []; @override void initState() { super.initState(); + _onRefresh(); } _onRefresh() async { - queryCommunity(); + pageNum = 0; + setState(() {}); } - ///动态列表 queryCommunity() async { if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); @@ -55,10 +53,7 @@ class _ReleasePage extends State { token: value.getString("token"), ); } - if(isLoadMore){ - pageNum += 1; - isLoadMore = false; - }else pageNum = 1; + pageNum += 1; BaseData> baseData = await apiService.trendList({ "onlyFollow": false, "onlyMe": true, @@ -74,9 +69,23 @@ class _ReleasePage extends State { refreshController.loadComplete(); if (baseData.isSuccess) { if (pageNum == 1) { - comments.clear(); + articles.clear(); } - comments.addAll(baseData.data.list); + baseData.data.list.forEach((element) { + var article = Article(); + article.id = element.id; + article.content = jsonEncode(element.subjectInfo); + article.mainTitle =element.subject; + article.liked = element.selfFollow; + article.authorHeadImg = element.memberInfo?.avatar; + article.authorName = element.memberInfo?.nickname; + article.createTime = element.createTime; + article.updateUser = element.memberInfo?.mid; + article.viewers = element?.viewers; + article.likes = element?.likes; + article.comments = element?.comments; + articles.add(article); + }); // print("comments: ${comments.length}"); if (int.tryParse(baseData.data.total) < (pageNum * 10)) { refreshController.loadNoData(); @@ -110,35 +119,34 @@ class _ReleasePage extends State { ), onRefresh: _onRefresh, onLoading: () { - isLoadMore = true; - _onRefresh(); + setState(() {}); }, - scrollController: scrollController, - child: Container( - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - // color: Color(0xFFF7F7F7), - // margin: EdgeInsets.only(top: 16.h), - child: Column( - children: [ - CommunityList( - comments, - userId, - 1, - isList: true, - exitFull: () { - _onRefresh(); - }, - removalDynamic: () { - _onRefresh(); - }, - ), - ], + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + child: CommunityDynamic( + articles[position], + 1, + exitFull: (){setState(() { + _onRefresh(); + });}, + removalDynamic: () { + _onRefresh(); + }, ), - ), - ), - ),), + onTap: () { + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "businessId": articles[position].id,"userId":userId, + }, + ); + }, + ); + }, + itemCount: articles.length, + )), ); }, ); diff --git a/lib/settlement/settlement_view/pay_method.dart b/lib/settlement/settlement_view/pay_method.dart index e6a74e04..84b90b7f 100644 --- a/lib/settlement/settlement_view/pay_method.dart +++ b/lib/settlement/settlement_view/pay_method.dart @@ -190,7 +190,7 @@ class _PayMethod extends State { ); } - var checkIndex = 1; + var checkIndex = 3; Widget checkView(var index) { return Container(