Browse Source

Merge remote-tracking branch 'origin/new_revision_app' into new_revision_app

zyh
fmk 3 years ago
parent
commit
dc3b76f320
  1. 37
      lib/community/community_child_page.dart
  2. 3
      lib/main_page.dart
  3. 2
      lib/utils/flutter_utils.dart
  4. 14
      lib/view_widget/update_dialog.dart
  5. 2
      pubspec.yaml

37
lib/community/community_child_page.dart

@ -20,7 +20,8 @@ class CommunityChildPage extends StatefulWidget {
final Function onScroll; final Function onScroll;
final Function toRelease; 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 @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -28,7 +29,8 @@ class CommunityChildPage extends StatefulWidget {
} }
} }
class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKeepAliveClientMixin { class CommunityChildPageState extends State<CommunityChildPage>
with AutomaticKeepAliveClientMixin {
RefreshController refreshController = RefreshController(); RefreshController refreshController = RefreshController();
ApiService apiService; ApiService apiService;
int pageNum = 1; int pageNum = 1;
@ -65,18 +67,15 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
if (apiService == null) { if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance(); SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId'); userId = value.getString('userId');
apiService = ApiService( apiService = ApiService(Dio(),
Dio(),
context: context, context: context,
token: value.getString("token"), token: value.getString("token"),
showLoading: false showLoading: false);
);
} }
if (isLoadMore) { if (isLoadMore) {
pageNum += 1; pageNum += 1;
isLoadMore = false; isLoadMore = false;
} } else if (searchKey == null) pageNum = 1;
else if(searchKey == null)pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"mid": "", "mid": "",
"onlyFollow": widget.typeStr == "关注" ? true : false, "onlyFollow": widget.typeStr == "关注" ? true : false,
@ -111,8 +110,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
element.likes = baseData.data.list[0]?.likes; element.likes = baseData.data.list[0]?.likes;
element.comments = baseData.data.list[0]?.comments; element.comments = baseData.data.list[0]?.comments;
this.isRefresh = false; this.isRefresh = false;
setState(() { setState(() {});
});
} }
}); });
} else { } else {
@ -152,7 +150,10 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
return FutureBuilder( return FutureBuilder(
future: queryCommunity(null), future: queryCommunity(null),
builder: (context, position) { builder: (context, position) {
return SmartRefresher( return Stack(
alignment: Alignment.bottomRight,
children: [
SmartRefresher(
controller: refreshController, controller: refreshController,
enablePullDown: true, enablePullDown: true,
enablePullUp: true, enablePullUp: true,
@ -168,18 +169,16 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
isLoadMore = true; isLoadMore = true;
setState(() {}); setState(() {});
}, },
child: Stack( child: (articles == null || articles.length == 0)
alignment: Alignment.bottomRight, ? NoDataView(
children: [
(articles == null || articles.length == 0)? NoDataView(
src: "assets/image/guan_zhu.webp", src: "assets/image/guan_zhu.webp",
isShowBtn: false, isShowBtn: false,
text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~",
fontSize: 16.sp, fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), margin:
EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
) )
: : ListView.builder(
ListView.builder(
controller: sc, controller: sc,
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (context, position) { itemBuilder: (context, position) {
@ -212,6 +211,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
}, },
itemCount: articles.length, itemCount: articles.length,
), ),
),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
widget.toRelease(); widget.toRelease();
@ -226,7 +226,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
), ),
) )
], ],
),
); );
}, },
); );

3
lib/main_page.dart

@ -129,6 +129,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
UnionPage(unionPageKey,0), UnionPage(unionPageKey,0),
// (Theme.of(context).platform == TargetPlatform.android) ? OrderPage() :CommunityPage(), // (Theme.of(context).platform == TargetPlatform.android) ? OrderPage() :CommunityPage(),
CommunityPage(), CommunityPage(),
// OrderPage(),
MinePage(minePageKey), MinePage(minePageKey),
]; ];
@ -353,7 +354,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
PackageInfo packageInfo = await PackageInfo.fromPlatform(); PackageInfo packageInfo = await PackageInfo.fromPlatform();
BaseData<AppUpdate> baseData = await apiService.appVersion().catchError((onError) {}); BaseData<AppUpdate> baseData = await apiService.appVersion().catchError((onError) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
// baseData.data.appLastVersion = "1.0.4"; // baseData.data.appLastVersion = "2.0.11";
// baseData.data.appLastVersionUp = "1.0.1"; // baseData.data.appLastVersionUp = "1.0.1";
if(AppUtils.versionCompare(packageInfo.version,baseData.data?.appLastVersion) if(AppUtils.versionCompare(packageInfo.version,baseData.data?.appLastVersion)
&& AppUtils.versionCompare(value.getString("appLastVersion")??"1.0.0",baseData.data?.appLastVersion)){ && AppUtils.versionCompare(value.getString("appLastVersion")??"1.0.0",baseData.data?.appLastVersion)){

2
lib/utils/flutter_utils.dart

@ -26,7 +26,7 @@ class AppUtils {
return false; return false;
if (int.tryParse(localVersionArr[1]) > int.tryParse(serverVersionArr[1])) if (int.tryParse(localVersionArr[1]) > int.tryParse(serverVersionArr[1]))
return false; return false;
if (int.tryParse(localVersionArr[2]) > int.tryParse(serverVersionArr[2])) if (int.tryParse(localVersionArr[2]) >= int.tryParse(serverVersionArr[2]))
return false; return false;
} catch (ex) {} } catch (ex) {}
return true; return true;

14
lib/view_widget/update_dialog.dart

@ -30,12 +30,13 @@ class _UpdateDialog extends State<UpdateDialog> {
child: Center( child: Center(
child: Container( child: Container(
width: MediaQuery.of(context).size.width - 80.w, width: MediaQuery.of(context).size.width - 80.w,
height: 165.h, // height: 216.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(8.r), borderRadius: BorderRadius.circular(8.r),
), ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Container( Container(
width: double.infinity, width: double.infinity,
@ -45,7 +46,7 @@ class _UpdateDialog extends State<UpdateDialog> {
child: Column( child: Column(
children: [ children: [
Text( Text(
"检测到新版本 v${widget.appUpdate.appLastVersion}", "发现新版本 v${widget.appUpdate.appLastVersion}",
style: TextStyle( style: TextStyle(
fontSize: 17.sp, fontSize: 17.sp,
fontWeight: MyFontWeight.semi_bold, fontWeight: MyFontWeight.semi_bold,
@ -54,7 +55,8 @@ class _UpdateDialog extends State<UpdateDialog> {
), ),
SizedBox(height: 12.h,), SizedBox(height: 12.h,),
Text( Text(
"是否需要更新到最新版本?", widget.appUpdate.appLastVersionExplain ?? "",
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 17.sp, fontSize: 17.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
@ -69,7 +71,7 @@ class _UpdateDialog extends State<UpdateDialog> {
height: 1.h, height: 1.h,
), ),
Container( Container(
height: 69.h, height:55.h,
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
@ -81,7 +83,7 @@ class _UpdateDialog extends State<UpdateDialog> {
}, },
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: 90.h, // height: 90.h,
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
"下次再说", "下次再说",
@ -107,7 +109,7 @@ class _UpdateDialog extends State<UpdateDialog> {
}, },
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: 90.h, // height: 90.h,
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
"立即更新", "立即更新",

2
pubspec.yaml

@ -3,7 +3,7 @@ description: 一心回乡.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev 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: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"

Loading…
Cancel
Save