diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 702480d2..b154c9d4 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -20,7 +20,8 @@ class CommunityChildPage extends StatefulWidget { final Function onScroll; final Function toRelease; - CommunityChildPage(Key key, this.typeStr,this.onScroll,this.toRelease): super(key: key); + CommunityChildPage(Key key, this.typeStr, this.onScroll, this.toRelease) + : super(key: key); @override State createState() { @@ -28,7 +29,8 @@ class CommunityChildPage extends StatefulWidget { } } -class CommunityChildPageState extends State with AutomaticKeepAliveClientMixin { +class CommunityChildPageState extends State + with AutomaticKeepAliveClientMixin { RefreshController refreshController = RefreshController(); ApiService apiService; int pageNum = 1; @@ -54,68 +56,64 @@ class CommunityChildPageState extends State with AutomaticKe ///动态列表 queryCommunity(String searchKey) async { - if(!isRefresh){ + if (!isRefresh) { isRefresh = true; return; } - if(isLoadingData){ + if (isLoadingData) { return; } - isLoadingData = true; + isLoadingData = true; if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); userId = value.getString('userId'); - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - showLoading: false - ); + apiService = ApiService(Dio(), + context: context, + token: value.getString("token"), + showLoading: false); } - if(isLoadMore){ + if (isLoadMore) { pageNum += 1; isLoadMore = false; - } - else if(searchKey == null)pageNum = 1; + } else if (searchKey == null) pageNum = 1; BaseData> baseData = await apiService.trendList({ - "mid":"", + "mid": "", "onlyFollow": widget.typeStr == "关注" ? true : false, "onlyMe": false, - "pageNum": searchKey == null?pageNum:1, + "pageNum": searchKey == null ? pageNum : 1, "pageSize": 10, - "searchKey": searchKey??"" + "searchKey": searchKey ?? "" }).catchError((error) { - if(searchKey == null) { + if (searchKey == null) { refreshController.refreshFailed(); refreshController.loadFailed(); } }); - if(searchKey == null) { + if (searchKey == null) { refreshController.refreshCompleted(); refreshController.loadComplete(); } if (baseData.isSuccess) { - if(searchKey != null){ - if(baseData?.data?.list != null && baseData.data.list.isNotEmpty) - articles.forEach((element) { - if(element.id == searchKey){ - element.content = jsonEncode(baseData.data.list[0].subjectInfo); - element.mainTitle =baseData.data.list[0].subject; - element.followed = baseData.data.list[0].selfFollow; - element.authorHeadImg = baseData.data.list[0].memberInfo?.avatar; - element.authorName = baseData.data.list[0].memberInfo?.nickname; - element.location = baseData.data.list[0].location; - element.createTime = baseData.data.list[0].createTime; - element.author = baseData.data.list[0].memberInfo?.mid; - element.viewers = baseData.data.list[0]?.viewers; - element.likes = baseData.data.list[0]?.likes; - element.comments = baseData.data.list[0]?.comments; - this.isRefresh = false; - setState(() { - }); - } - }); - }else{ + if (searchKey != null) { + if (baseData?.data?.list != null && baseData.data.list.isNotEmpty) + articles.forEach((element) { + if (element.id == searchKey) { + element.content = jsonEncode(baseData.data.list[0].subjectInfo); + element.mainTitle = baseData.data.list[0].subject; + element.followed = baseData.data.list[0].selfFollow; + element.authorHeadImg = baseData.data.list[0].memberInfo?.avatar; + element.authorName = baseData.data.list[0].memberInfo?.nickname; + element.location = baseData.data.list[0].location; + element.createTime = baseData.data.list[0].createTime; + element.author = baseData.data.list[0].memberInfo?.mid; + element.viewers = baseData.data.list[0]?.viewers; + element.likes = baseData.data.list[0]?.likes; + element.comments = baseData.data.list[0]?.comments; + this.isRefresh = false; + setState(() {}); + } + }); + } else { if (pageNum == 1) { articles.clear(); } @@ -123,7 +121,7 @@ class CommunityChildPageState extends State with AutomaticKe var article = Article(); article.id = element.id; article.content = jsonEncode(element.subjectInfo); - article.mainTitle =element.subject; + article.mainTitle = element.subject; article.followed = element.selfFollow; article.authorHeadImg = element.memberInfo?.avatar; article.authorName = element.memberInfo?.nickname; @@ -152,81 +150,82 @@ class CommunityChildPageState extends State with AutomaticKe return FutureBuilder( future: queryCommunity(null), builder: (context, position) { - return SmartRefresher( - controller: refreshController, - enablePullDown: true, - enablePullUp: true, - physics: BouncingScrollPhysics(), - header: MyHeader(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: onRefresh, - onLoading: () { - isLoadMore = true; - setState(() {}); - }, - child: Stack( - alignment: Alignment.bottomRight, - children: [ - (articles == null || articles.length == 0)? NoDataView( - src: "assets/image/guan_zhu.webp", - isShowBtn: false, - text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), - ) - : - ListView.builder( - controller: sc, - shrinkWrap: true, - itemBuilder: (context, position) { - return InkWell( - child: CommunityDynamic( - articles[position], - 0, - userId: userId, - isList: true, - exitFull: () { - setState(() { - onRefresh(); - }); - }, - ), - onTap: () { - Navigator.of(context).pushNamed( - '/router/community_details', - arguments: { - "businessId": articles[position].id, - "userId": userId, - }, - ).then((value) { - onRefresh(); - setState(() {}); - }); - setState(() {}); - }, - ); + return Stack( + alignment: Alignment.bottomRight, + children: [ + SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: true, + physics: BouncingScrollPhysics(), + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); }, - itemCount: articles.length, ), - GestureDetector( - onTap: (){ - widget.toRelease(); - }, - child: Container( - margin: EdgeInsets.only(bottom:31,right: 14), - child: Image.asset( - "assets/image/fa_bu.webp", - width: 55, - height: 55, - ), + onRefresh: onRefresh, + onLoading: () { + isLoadMore = true; + setState(() {}); + }, + child: (articles == null || articles.length == 0) + ? NoDataView( + src: "assets/image/guan_zhu.webp", + isShowBtn: false, + text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", + fontSize: 16.sp, + margin: + EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w), + ) + : ListView.builder( + controller: sc, + shrinkWrap: true, + itemBuilder: (context, position) { + return InkWell( + child: CommunityDynamic( + articles[position], + 0, + userId: userId, + isList: true, + exitFull: () { + setState(() { + onRefresh(); + }); + }, + ), + onTap: () { + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "businessId": articles[position].id, + "userId": userId, + }, + ).then((value) { + onRefresh(); + setState(() {}); + }); + setState(() {}); + }, + ); + }, + itemCount: articles.length, + ), + ), + GestureDetector( + onTap: () { + widget.toRelease(); + }, + child: Container( + margin: EdgeInsets.only(bottom: 31, right: 14), + child: Image.asset( + "assets/image/fa_bu.webp", + width: 55, + height: 55, ), - ) - ], - ), + ), + ) + ], ); }, ); diff --git a/lib/main_page.dart b/lib/main_page.dart index 5b4f313e..717afd4a 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -129,6 +129,7 @@ class _MainPage extends State with WidgetsBindingObserver { UnionPage(unionPageKey,0), // (Theme.of(context).platform == TargetPlatform.android) ? OrderPage() :CommunityPage(), CommunityPage(), + // OrderPage(), MinePage(minePageKey), ]; @@ -353,7 +354,7 @@ class _MainPage extends State with WidgetsBindingObserver { PackageInfo packageInfo = await PackageInfo.fromPlatform(); BaseData baseData = await apiService.appVersion().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { - // baseData.data.appLastVersion = "1.0.4"; + // baseData.data.appLastVersion = "2.0.11"; // baseData.data.appLastVersionUp = "1.0.1"; if(AppUtils.versionCompare(packageInfo.version,baseData.data?.appLastVersion) && AppUtils.versionCompare(value.getString("appLastVersion")??"1.0.0",baseData.data?.appLastVersion)){ diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 372e858e..794d9694 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -26,7 +26,7 @@ class AppUtils { return false; if (int.tryParse(localVersionArr[1]) > int.tryParse(serverVersionArr[1])) return false; - if (int.tryParse(localVersionArr[2]) > int.tryParse(serverVersionArr[2])) + if (int.tryParse(localVersionArr[2]) >= int.tryParse(serverVersionArr[2])) return false; } catch (ex) {} return true; diff --git a/lib/view_widget/update_dialog.dart b/lib/view_widget/update_dialog.dart index 35460b29..3e0d9b27 100644 --- a/lib/view_widget/update_dialog.dart +++ b/lib/view_widget/update_dialog.dart @@ -30,46 +30,48 @@ class _UpdateDialog extends State { child: Center( child: Container( width: MediaQuery.of(context).size.width - 80.w, - height: 165.h, + // height: 216.h, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8.r), ), child: Column( + mainAxisSize: MainAxisSize.min, children: [ Container( - width: double.infinity, - // height: 110.h, - alignment: Alignment.center, - padding: EdgeInsets.all(20), - child: Column( - children: [ - Text( - "检测到新版本 v${widget.appUpdate.appLastVersion}", - style: TextStyle( - fontSize: 17.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF000000), + width: double.infinity, + // height: 110.h, + alignment: Alignment.center, + padding: EdgeInsets.all(20), + child: Column( + children: [ + Text( + "发现新版本 v${widget.appUpdate.appLastVersion}", + style: TextStyle( + fontSize: 17.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF000000), + ), ), - ), - SizedBox(height: 12.h,), - Text( - "是否需要更新到最新版本?", - style: TextStyle( - fontSize: 17.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF333333), + SizedBox(height: 12.h,), + Text( + widget.appUpdate.appLastVersionExplain ?? "", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 17.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF333333), + ), ), - ), - ], - ) + ], + ) ), Container( color: Color(0x1A000000), height: 1.h, ), Container( - height: 69.h, + height:55.h, child: Row( mainAxisSize: MainAxisSize.max, children: [ @@ -81,7 +83,7 @@ class _UpdateDialog extends State { }, child: Container( width: double.infinity, - height: 90.h, + // height: 90.h, alignment: Alignment.center, child: Text( "下次再说", @@ -107,7 +109,7 @@ class _UpdateDialog extends State { }, child: Container( width: double.infinity, - height: 90.h, + // height: 90.h, alignment: Alignment.center, child: Text( "立即更新", diff --git a/pubspec.yaml b/pubspec.yaml index 024de055..79ff9585 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: 一心回乡. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 2.0.12+9 +version: 2.0.14+9 environment: sdk: ">=2.7.0 <3.0.0"