From c11b177352070c8632ee74542d7b14ee57b84bbc Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 28 Jan 2021 11:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E6=B4=BB=E5=8A=A8=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=20=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8=E3=80=81=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E8=AF=A6=E6=83=85=E3=80=81=E6=B4=BB=E5=8A=A8=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=20BIGGGGG=20change.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 13 ++ lib/model/common/img_model.dart | 27 +++ .../community/activity_detail_model.dart | 75 ++++++ lib/model/community/activity_item_model.dart | 68 ++++++ .../community/activity_people_model.dart | 59 +++++ lib/model/manager/advice_detail_model.dart | 35 +-- lib/model/manager/fixed_detail_model.dart | 36 +-- .../manager/suggestion_or_complain_model.dart | 7 +- lib/model/user/fixed_submit_model.dart | 36 +-- lib/pages/home/home_page.dart | 213 +++++++++--------- lib/pages/home/widget/home_card.dart | 3 + lib/pages/home/widget/home_tag_bar.dart | 55 +++-- lib/ui/community/activity_card.dart | 94 ++++++++ lib/ui/community/activity_detail_page.dart | 184 +++++++++++++++ lib/ui/community/activity_list_page.dart | 48 ++++ .../community/activity_people_list_page.dart | 67 ++++++ lib/ui/community/community_func.dart | 15 ++ lib/ui/home/home_notification.dart | 50 ++++ lib/ui/home/home_title.dart | 60 +++++ lib/utils/network/net_util.dart | 7 - lib/widget/others/stack_avatar.dart | 41 ++++ 21 files changed, 956 insertions(+), 237 deletions(-) create mode 100644 lib/model/common/img_model.dart create mode 100644 lib/model/community/activity_detail_model.dart create mode 100644 lib/model/community/activity_item_model.dart create mode 100644 lib/model/community/activity_people_model.dart create mode 100644 lib/ui/community/activity_card.dart create mode 100644 lib/ui/community/activity_detail_page.dart create mode 100644 lib/ui/community/activity_list_page.dart create mode 100644 lib/ui/community/activity_people_list_page.dart create mode 100644 lib/ui/community/community_func.dart create mode 100644 lib/ui/home/home_notification.dart create mode 100644 lib/ui/home/home_title.dart create mode 100644 lib/widget/others/stack_avatar.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5e35bae5..6597f751 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -15,6 +15,7 @@ class API { static _User user = _User(); static _Manager manager = _Manager(); static _Upload upload = _Upload(); + static _Community community = _Community(); } class _Login { @@ -114,10 +115,22 @@ class _Manager { /// 报事报修:确认完成订单 String get reportRepairComplete => '/user/reportRepair/completeOrder'; + ///报事报修:用户评价 String get reportRepairEvaluate => '/user/reportRepair/evaluate'; } +class _Community { + ///社区活动:查询所有的活动信息 + String get activityList => '/user/activity/list'; + + ///社区活动:根据社区活动主键id查询社区活动详情 + String get activityDetail => '/user/activity/findById'; + + ///社区活动:查看参与人数 + String get activityPeopleList => '/user/activity/participantsList'; +} + class _Upload { ///上传咨询建议照片 String get uploadArticle => '/user/upload/uploadArticle'; diff --git a/lib/model/common/img_model.dart b/lib/model/common/img_model.dart new file mode 100644 index 00000000..e8a9dd2c --- /dev/null +++ b/lib/model/common/img_model.dart @@ -0,0 +1,27 @@ +class ImgModel { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgModel({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgModel.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} diff --git a/lib/model/community/activity_detail_model.dart b/lib/model/community/activity_detail_model.dart new file mode 100644 index 00000000..ed6912a1 --- /dev/null +++ b/lib/model/community/activity_detail_model.dart @@ -0,0 +1,75 @@ +import 'package:akuCommunity/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; + +class ActivityDetailModel { + int id; + String title; + String content; + String location; + String activityStartTime; + String activityEndTime; + String registrationEndTime; + int countRegistration; + List imgUrls; + List headImgURls; + + DateTime get startDate => DateUtil.getDateTime(activityStartTime); + DateTime get endDate => DateUtil.getDateTime(activityEndTime); + DateTime get registEndDate => DateUtil.getDateTime(registrationEndTime); + + ActivityDetailModel( + {this.id, + this.title, + this.content, + this.location, + this.activityStartTime, + this.activityEndTime, + this.registrationEndTime, + this.countRegistration, + this.imgUrls, + this.headImgURls}); + + ActivityDetailModel.fromJson(Map json) { + id = json['id']; + title = json['title']; + content = json['content']; + location = json['location']; + activityStartTime = json['activityStartTime']; + activityEndTime = json['activityEndTime']; + registrationEndTime = json['registrationEndTime']; + countRegistration = json['countRegistration']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + if (json['headImgURls'] != null) { + headImgURls = new List(); + json['headImgURls'].forEach((v) { + headImgURls.add(new ImgModel.fromJson(v)); + }); + } else + headImgURls = []; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['content'] = this.content; + data['location'] = this.location; + data['activityStartTime'] = this.activityStartTime; + data['activityEndTime'] = this.activityEndTime; + data['registrationEndTime'] = this.registrationEndTime; + data['countRegistration'] = this.countRegistration; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + if (this.headImgURls != null) { + data['headImgURls'] = this.headImgURls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/model/community/activity_item_model.dart b/lib/model/community/activity_item_model.dart new file mode 100644 index 00000000..8d57746f --- /dev/null +++ b/lib/model/community/activity_item_model.dart @@ -0,0 +1,68 @@ +import 'package:akuCommunity/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; + +class ActivityItemModel { + int id; + String title; + String location; + int status; + String registrationStartTime; + String registrationEndTime; + List imgUrls; + List headImgURls; + + DateTime get begin => DateUtil.getDateTime(registrationStartTime); + DateTime get end => DateUtil.getDateTime(registrationEndTime); + + ActivityItemModel( + {this.id, + this.title, + this.location, + this.status, + this.registrationStartTime, + this.registrationEndTime, + this.imgUrls, + this.headImgURls}); + + ActivityItemModel.fromJson(Map json) { + id = json['id']; + title = json['title']; + location = json['location']; + status = json['status']; + registrationStartTime = json['registrationStartTime']; + registrationEndTime = json['registrationEndTime']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else { + imgUrls = []; + } + if (json['headImgURls'] != null) { + headImgURls = new List(); + json['headImgURls'].forEach((v) { + headImgURls.add(new ImgModel.fromJson(v)); + }); + } else { + headImgURls = []; + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['location'] = this.location; + data['status'] = this.status; + data['registrationStartTime'] = this.registrationStartTime; + data['registrationEndTime'] = this.registrationEndTime; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + if (this.headImgURls != null) { + data['headImgURls'] = this.headImgURls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/model/community/activity_people_model.dart b/lib/model/community/activity_people_model.dart new file mode 100644 index 00000000..8fdb560a --- /dev/null +++ b/lib/model/community/activity_people_model.dart @@ -0,0 +1,59 @@ +class ActivityPeopleModel { + int id; + String name; + String tel; + List imgUrl; + + ActivityPeopleModel({this.id, this.name, this.tel, this.imgUrl}); + + ActivityPeopleModel.fromJson(Map json) { + id = json['id']; + name = json['name']; + tel = json['tel']; + if (json['imgUrl'] != null) { + imgUrl = new List(); + json['imgUrl'].forEach((v) { + imgUrl.add(new ImgUrl.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['tel'] = this.tel; + if (this.imgUrl != null) { + data['imgUrl'] = this.imgUrl.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ImgUrl { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgUrl({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgUrl.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} diff --git a/lib/model/manager/advice_detail_model.dart b/lib/model/manager/advice_detail_model.dart index b9ef61bf..88b80a47 100644 --- a/lib/model/manager/advice_detail_model.dart +++ b/lib/model/manager/advice_detail_model.dart @@ -1,4 +1,5 @@ // Package imports: +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:common_utils/common_utils.dart'; class AdviceDetailModel { @@ -58,7 +59,7 @@ class AppAdviceVo { int status; String content; String createDate; - List imgUrls; + List imgUrls; DateTime get date => DateUtil.getDateTime(createDate); @@ -77,9 +78,9 @@ class AppAdviceVo { content = json['content']; createDate = json['createDate']; if (json['imgUrls'] != null) { - imgUrls = new List(); + imgUrls = new List(); json['imgUrls'].forEach((v) { - imgUrls.add(new ImgUrls.fromJson(v)); + imgUrls.add(new ImgModel.fromJson(v)); }); } } @@ -98,34 +99,6 @@ class AppAdviceVo { } } -class ImgUrls { - String url; - String size; - int longs; - int paragraph; - int sort; - - ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); - - ImgUrls.fromJson(Map json) { - url = json['url']; - size = json['size']; - longs = json['longs']; - paragraph = json['paragraph']; - sort = json['sort']; - } - - Map toJson() { - final Map data = new Map(); - data['url'] = this.url; - data['size'] = this.size; - data['longs'] = this.longs; - data['paragraph'] = this.paragraph; - data['sort'] = this.sort; - return data; - } -} - class AppAdviceContentVos { int id; int createUserType; diff --git a/lib/model/manager/fixed_detail_model.dart b/lib/model/manager/fixed_detail_model.dart index 16f25eb4..4b41c9dd 100644 --- a/lib/model/manager/fixed_detail_model.dart +++ b/lib/model/manager/fixed_detail_model.dart @@ -1,3 +1,5 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + class FixedDetailModel { AppReportRepairVo appReportRepairVo; List appProcessRecordVo; @@ -48,7 +50,7 @@ class AppReportRepairVo { int type; int status; String reportDetail; - List imgUrls; + List imgUrls; AppReportRepairVo( {this.id, this.type, this.status, this.reportDetail, this.imgUrls}); @@ -59,9 +61,9 @@ class AppReportRepairVo { status = json['status']; reportDetail = json['reportDetail']; if (json['imgUrls'] != null) { - imgUrls = new List(); + imgUrls = new List(); json['imgUrls'].forEach((v) { - imgUrls.add(new ImgUrls.fromJson(v)); + imgUrls.add(new ImgModel.fromJson(v)); }); } } @@ -79,34 +81,6 @@ class AppReportRepairVo { } } -class ImgUrls { - String url; - String size; - int longs; - int paragraph; - int sort; - - ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); - - ImgUrls.fromJson(Map json) { - url = json['url']; - size = json['size']; - longs = json['longs']; - paragraph = json['paragraph']; - sort = json['sort']; - } - - Map toJson() { - final Map data = new Map(); - data['url'] = this.url; - data['size'] = this.size; - data['longs'] = this.longs; - data['paragraph'] = this.paragraph; - data['sort'] = this.sort; - return data; - } -} - class AppProcessRecordVo { String operationDate; int operationType; diff --git a/lib/model/manager/suggestion_or_complain_model.dart b/lib/model/manager/suggestion_or_complain_model.dart index a72a1f29..fda6c0c5 100644 --- a/lib/model/manager/suggestion_or_complain_model.dart +++ b/lib/model/manager/suggestion_or_complain_model.dart @@ -1,4 +1,5 @@ // Package imports: +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:common_utils/common_utils.dart'; class SuggestionOrComplainModel { @@ -8,7 +9,7 @@ class SuggestionOrComplainModel { String content; int score; DateTime createDate; - List imgUrls; + List imgUrls; SuggestionOrComplainModel( {this.id, @@ -27,9 +28,9 @@ class SuggestionOrComplainModel { score = json['score']; createDate = DateUtil.getDateTime(json['createDate']); if (json['imgUrls'] != null) { - imgUrls = new List(); + imgUrls = new List(); json['imgUrls'].forEach((v) { - imgUrls.add(new ImgUrls.fromJson(v)); + imgUrls.add(new ImgModel.fromJson(v)); }); } } diff --git a/lib/model/user/fixed_submit_model.dart b/lib/model/user/fixed_submit_model.dart index 15148933..1b94e7e2 100644 --- a/lib/model/user/fixed_submit_model.dart +++ b/lib/model/user/fixed_submit_model.dart @@ -1,9 +1,11 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + class FixedSubmitModel { int id; int type; int status; String reportDetail; - List imgUrls; + List imgUrls; FixedSubmitModel( {this.id, this.type, this.status, this.reportDetail, this.imgUrls}); @@ -14,9 +16,9 @@ class FixedSubmitModel { status = json['status']; reportDetail = json['reportDetail']; if (json['imgUrls'] != null) { - imgUrls = new List(); + imgUrls = new List(); json['imgUrls'].forEach((v) { - imgUrls.add(new ImgUrls.fromJson(v)); + imgUrls.add(new ImgModel.fromJson(v)); }); } } @@ -33,31 +35,3 @@ class FixedSubmitModel { return data; } } - -class ImgUrls { - String url; - String size; - int longs; - int paragraph; - int sort; - - ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); - - ImgUrls.fromJson(Map json) { - url = json['url']; - size = json['size']; - longs = json['longs']; - paragraph = json['paragraph']; - sort = json['sort']; - } - - Map toJson() { - final Map data = new Map(); - data['url'] = this.url; - data['size'] = this.size; - data['longs'] = this.longs; - data['paragraph'] = this.paragraph; - data['sort'] = this.sort; - return data; - } -} diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index d3c804bb..1ef84d3b 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -3,13 +3,19 @@ import 'dart:async'; import 'dart:convert'; // Flutter imports: +import 'package:akuCommunity/model/community/activity_item_model.dart'; +import 'package:akuCommunity/ui/community/activity_card.dart'; +import 'package:akuCommunity/ui/community/activity_list_page.dart'; +import 'package:akuCommunity/ui/community/community_func.dart'; +import 'package:akuCommunity/ui/home/home_notification.dart'; +import 'package:akuCommunity/ui/home/home_title.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; // Package imports: import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:velocity_x/velocity_x.dart'; // Project imports: @@ -17,7 +23,6 @@ import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/extensions/num_ext.dart'; import 'package:akuCommunity/extensions/page_router.dart'; import 'package:akuCommunity/model/aku_shop_model.dart'; -import 'package:akuCommunity/pages/activities_page/activities_page.dart'; import 'package:akuCommunity/pages/convenient_phone/convenient_phone_page.dart'; import 'package:akuCommunity/pages/home/widget/animate_app_bar.dart'; import 'package:akuCommunity/pages/industry_committee/industry_committee_page.dart'; @@ -54,11 +59,12 @@ class _HomePageState extends State List _shopList = []; List data; - RefreshController _refreshController = - RefreshController(initialRefresh: false); + EasyRefreshController _refreshController = EasyRefreshController(); int page = 1; + ActivityItemModel model; + List _gridList = [ GridButton('一键开门', R.ASSETS_ICONS_TOOL_YJKM_PNG, OpenDoorPage().to), GridButton('访客通行', R.ASSETS_ICONS_TOOL_FKYQ_PNG, VisitorAccessPage().to), @@ -98,14 +104,6 @@ class _HomePageState extends State }); } - void _onLoading() async { - await Future.delayed(Duration(milliseconds: 1500)); - page++; - // akuShop(page); - if (mounted) setState(() {}); - _refreshController.loadComplete(); - } - _buildColButton({IconData icon, String title, VoidCallback onTap}) { return MaterialButton( onPressed: onTap, @@ -141,106 +139,101 @@ class _HomePageState extends State 16.wb, ], ), - body: RefreshConfiguration( - child: SmartRefresher( - controller: _refreshController, - header: WaterDropHeader(), - footer: ClassicFooter(), - onLoading: _onLoading, - enablePullUp: true, - enablePullDown: false, - child: CustomScrollView( - controller: _scrollController, - slivers: [ - SliverToBoxAdapter( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - HomeSearch(), - HomeSwiper(), - SizedBox(height: 100.w), - ContainerComment( - radius: 8, - customWidget: GridButtons( - gridList: _gridList, - crossCount: 4, - ), + body: EasyRefresh( + controller: _refreshController, + header: MaterialHeader(), + firstRefresh: true, + onRefresh: () async { + model = await CommunityFunc.activity(); + setState(() {}); + }, + child: CustomScrollView( + controller: _scrollController, + slivers: [ + SliverToBoxAdapter( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + HomeSearch(), + HomeSwiper(), + SizedBox(height: 100.w), + ContainerComment( + radius: 8, + customWidget: GridButtons( + gridList: _gridList, + crossCount: 4, ), - // SingleAdSpace( - // imagePath: R.ASSETS_EXAMPLE_GUANGGAO2_PNG, - // ), - HomeTagBar( - title: '物业收费标准请查收~', - tag: '公告', - isShowImage: true, - ), - Column( - children: [ - HomeTagBar( - title: '社区活动', - tag: '活动', - isShowImage: false, - fun: () { - ActivitiesPage().to; - }, - ), - HomeCard( - isActivity: true, - title: '22日上午10点,阳光小镇在二期乒乓球场地举行了小区乒乓比赛', - subtitleOne: '活动时二楼', - subtitleTwo: '06月17日 12:00至06月17日 18:30', - imagePath: - 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1601275745883&di=e7b2a1afdb8812f8a9acd9742ea7e1a7&imgtype=0&src=http%3A%2F%2Fy3.ifengimg.com%2Fcmpp%2F2013%2F12%2F27%2F03%2F459f46cb-c07f-4083-9a65-27b90cb4562f.jpg', - ), - ], - ), - SizedBox(height: 24.w), - // Column( - // children: [ - // HomeTagBar( - // title: '社区团购', - // tag: '团购', - // isShowImage: false, - // ), - // HomeCard( - // isActivity: false, - // title: '新疆库尔阿勒4.5斤,仙人蕉 香甜可口', - // subtitleOne: '中国新疆', - // subtitleTwo: '2020年07月03日', - // imagePath: - // 'http://news.eastday.com/d/file/tga/2013-02-17/c2e7bd7fca1ed2ecf5d50dc9fb30275d.jpg', - // ), - // HomeCard( - // isActivity: false, - // title: '刚果柠檬大果4盒 鲜果新鲜采摘15斤', - // subtitleOne: '非洲刚果', - // subtitleTwo: '2020年08月09日', - // imagePath: - // 'http://5b0988e595225.cdn.sohucs.com/images/20180203/328e145f84c54dd08d1b11b890109862.jpeg', - // ), - // ], - // ), - // SizedBox(height: 30.w), - // HomeTagBar( - // title: '社区商城', - // tag: '团购', - // isShowImage: false, - // isShowTitle: true, - // ), - ], - ), + ), + // SingleAdSpace( + // imagePath: R.ASSETS_EXAMPLE_GUANGGAO2_PNG, + // ), + // Column( + // children: [ + // HomeTagBar( + // title: '社区团购', + // tag: '团购', + // isShowImage: false, + // ), + // HomeCard( + // isActivity: false, + // title: '新疆库尔阿勒4.5斤,仙人蕉 香甜可口', + // subtitleOne: '中国新疆', + // subtitleTwo: '2020年07月03日', + // imagePath: + // 'http://news.eastday.com/d/file/tga/2013-02-17/c2e7bd7fca1ed2ecf5d50dc9fb30275d.jpg', + // ), + // HomeCard( + // isActivity: false, + // title: '刚果柠檬大果4盒 鲜果新鲜采摘15斤', + // subtitleOne: '非洲刚果', + // subtitleTwo: '2020年08月09日', + // imagePath: + // 'http://5b0988e595225.cdn.sohucs.com/images/20180203/328e145f84c54dd08d1b11b890109862.jpeg', + // ), + // ], + // ), + // SizedBox(height: 30.w), + // HomeTagBar( + // title: '社区商城', + // tag: '团购', + // isShowImage: false, + // isShowTitle: true, + // ), + ], ), - // SliverPadding( - // padding: EdgeInsets.only( - // top: 30.w, - // left: 32.w, - // right: 32.w, - // ), - // sliver: _shopList.length == 0 - // ? SliverToBoxAdapter(child: GoodsCardSkeleton()) - // : SliverGoodsCard(shoplist: _shopList)), - ], - ), + ), + + SliverToBoxAdapter( + child: Column( + children: [ + HomeNotification(), + HomeTitle( + title: '社区活动', + suffixTitle: '更多活动', + onTap: ActivityListPage().to, + ), + model == null + ? SizedBox() + : ActivityCard(model: model).pSymmetric(h: 24.w, v: 24.w), + ], + ) + .box + .white + .withRounded(value: 8.w) + .clip(Clip.antiAlias) + .margin(EdgeInsets.symmetric(horizontal: 32.w)) + .make(), + ), + // SliverPadding( + // padding: EdgeInsets.only( + // top: 30.w, + // left: 32.w, + // right: 32.w, + // ), + // sliver: _shopList.length == 0 + // ? SliverToBoxAdapter(child: GoodsCardSkeleton()) + // : SliverGoodsCard(shoplist: _shopList)), + ], ), ), ); diff --git a/lib/pages/home/widget/home_card.dart b/lib/pages/home/widget/home_card.dart index 545384e5..107d2318 100644 --- a/lib/pages/home/widget/home_card.dart +++ b/lib/pages/home/widget/home_card.dart @@ -15,6 +15,9 @@ import 'package:akuCommunity/routers/page_routers.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/cached_image_wrapper.dart'; + +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t home_card need to be cleaned.") class HomeCard extends StatefulWidget { final String title; final String subtitleOne; diff --git a/lib/pages/home/widget/home_tag_bar.dart b/lib/pages/home/widget/home_tag_bar.dart index 208de829..72ab8ff0 100644 --- a/lib/pages/home/widget/home_tag_bar.dart +++ b/lib/pages/home/widget/home_tag_bar.dart @@ -9,12 +9,20 @@ import 'package:flutter_icons/flutter_icons.dart'; import 'package:akuCommunity/base/assets_image.dart'; import 'package:akuCommunity/utils/headers.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t home_tag_bar need to be cleaned.") class HomeTagBar extends StatefulWidget { final String title; final String tag; - final bool isShowImage,isShowTitle; + final bool isShowImage, isShowTitle; final Function fun; - HomeTagBar({Key key, this.title, this.tag, this.isShowImage,this.isShowTitle = false,this.fun}) + HomeTagBar( + {Key key, + this.title, + this.tag, + this.isShowImage, + this.isShowTitle = false, + this.fun}) : super(key: key); @override @@ -50,9 +58,7 @@ class _HomeTagBarState extends State { Text( widget.title, style: TextStyle( - fontSize: widget.isShowImage - ? 28.sp - : 32.sp, + fontSize: widget.isShowImage ? 28.sp : 32.sp, fontWeight: widget.isShowImage ? FontWeight.normal : FontWeight.w600, @@ -60,25 +66,26 @@ class _HomeTagBarState extends State { ), ], ), - widget.isShowTitle ? SizedBox() : InkWell( - onTap: () { - widget.fun(); - }, - child: Row(children: [ - Text( - '更多${widget.tag}', - style: TextStyle( - color: Color(0xff999999), - fontSize: 20.sp), - ), - SizedBox(width: 8.w), - Icon( - AntDesign.right, - color: Color(0xff999999), - size: 20.sp, - ), - ]), - ), + widget.isShowTitle + ? SizedBox() + : InkWell( + onTap: () { + widget.fun(); + }, + child: Row(children: [ + Text( + '更多${widget.tag}', + style: TextStyle( + color: Color(0xff999999), fontSize: 20.sp), + ), + SizedBox(width: 8.w), + Icon( + AntDesign.right, + color: Color(0xff999999), + size: 20.sp, + ), + ]), + ), ], ), widget.isShowImage diff --git a/lib/ui/community/activity_card.dart b/lib/ui/community/activity_card.dart new file mode 100644 index 00000000..3d3a23a0 --- /dev/null +++ b/lib/ui/community/activity_card.dart @@ -0,0 +1,94 @@ +import 'package:akuCommunity/model/common/img_model.dart'; +import 'package:akuCommunity/model/community/activity_item_model.dart'; +import 'package:akuCommunity/ui/community/activity_detail_page.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/widget/others/stack_avatar.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class ActivityCard extends StatelessWidget { + final ActivityItemModel model; + const ActivityCard({ + Key key, + @required this.model, + }) : super(key: key); + + String get firstPath => + (model.imgUrls?.isEmpty ?? true) ? null : model.imgUrls.first.url; + + Widget build(BuildContext context) { + return MaterialButton( + clipBehavior: Clip.antiAlias, + color: Colors.white, + padding: EdgeInsets.zero, + onPressed: ActivityDetailPage(id: model.id).to, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w), + side: BorderSide( + color: Colors.grey, + ), + ), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + firstPath == null + ? SizedBox() + : Hero( + tag: API.image(firstPath), + child: Material( + color: Colors.grey, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(firstPath), + height: 210.w, + width: double.infinity, + ), + ), + ), + model.title.text + .size(28.sp) + .black + .make() + .pSymmetric(h: 24.w, v: 16.w), + [ + '地 点:'.text.size(24.sp).color(Color(0xFF999999)).make(), + model.location.text.size(24.sp).make(), + ].row().pSymmetric(h: 24.w), + 6.hb, + [ + '活动时间:'.text.size(24.sp).color(Color(0xFF999999)).make(), + '${DateUtil.formatDate( + model.begin, + format: 'MM月dd日 HH:mm', + )}至${DateUtil.formatDate( + model.end, + format: 'MM月dd日 HH:mm', + )}' + .text + .size(24.sp) + .make(), + ].row().pSymmetric(h: 24.w), + [ + StackAvatar(avatars: model.headImgURls.map((e) => e.url).toList()), + Spacer(), + MaterialButton( + elevation: 0, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + color: Color(0xFFFFC40C), + shape: StadiumBorder(), + height: 44.w, + minWidth: 120.w, + onPressed: () {}, + child: '去看看'.text.size(20.sp).bold.make(), + ), + ].row().p(24.w), + ], + ), + ); + } +} diff --git a/lib/ui/community/activity_detail_page.dart b/lib/ui/community/activity_detail_page.dart new file mode 100644 index 00000000..f040f09b --- /dev/null +++ b/lib/ui/community/activity_detail_page.dart @@ -0,0 +1,184 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/activity_detail_model.dart'; +import 'package:akuCommunity/ui/community/activity_people_list_page.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/others/stack_avatar.dart'; +import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:shimmer/shimmer.dart'; + +class ActivityDetailPage extends StatefulWidget { + final int id; + ActivityDetailPage({Key key, @required this.id}) : super(key: key); + + @override + _ActivityDetailPageState createState() => _ActivityDetailPageState(); +} + +class _ActivityDetailPageState extends State { + ActivityDetailModel model; + EasyRefreshController _refreshController = EasyRefreshController(); + + Widget get emptyWidget => Shimmer.fromColors( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + VxBox().white.height(45.w).width(544.w).make(), + 48.hb, + VxBox() + .white + .height(228.w) + .width(double.infinity) + .withRounded(value: 8.w) + .make(), + 44.hb, + ...List.generate( + 3, + (index) => VxBox() + .white + .height(45.w) + .width(544.w) + .margin(EdgeInsets.symmetric(vertical: 5.w)) + .make(), + ), + ], + ).pSymmetric(h: 32.w, v: 24.w), + baseColor: Colors.black12, + highlightColor: Colors.white, + ); + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + + _buildTile(String title, String subTitle) { + return Row( + children: [ + title.text.size(28.sp).make().box.width(136.w).make(), + subTitle.text.size(28.sp).make().expand(), + ], + ).pSymmetric(h: 32.w); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '活动详情', + body: EasyRefresh( + header: MaterialHeader(), + onRefresh: () async { + BaseModel baseModel = await NetUtil().get( + API.community.activityDetail, + params: {'activityId': widget.id}, + ); + model = ActivityDetailModel.fromJson(baseModel.data); + setState(() {}); + }, + controller: _refreshController, + firstRefresh: true, + emptyWidget: model == null ? emptyWidget : null, + child: model == null + ? SizedBox() + : ListView( + children: [ + model.title.text + .size(32.sp) + .bold + .make() + .pSymmetric(h: 32.w, v: 24.w), + 48.hb, + ...model.imgUrls + .map((e) => GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: API.image(e.url)), + opaque: false, + ); + }, + child: Hero( + tag: API.image(e.url), + child: Container( + height: 228.w, + decoration: BoxDecoration( + color: Colors.black12, + borderRadius: BorderRadius.circular(8.w), + ), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: e.url, + ), + ), + ), + ).pSymmetric(h: 32.w)) + .toList(), + 44.hb, + model.content.text.size(28.sp).make().pSymmetric(h: 32.w), + 44.hb, + _buildTile( + '开始时间', + DateUtil.formatDate( + model.startDate, + format: 'yyyy年MM月dd日 HH:mm', + ), + ), + _buildTile( + '结束时间', + DateUtil.formatDate( + model.endDate, + format: 'yyyy年MM月dd日 HH:mm', + ), + ), + _buildTile('地 点', model.location), + _buildTile('参与人数', '不限'), + _buildTile( + '报名截止', + DateUtil.formatDate( + model.registEndDate, + format: 'yyyy年MM月dd日 HH:mm', + ), + ), + 115.hb, + Container( + height: 24.w, + color: Color(0xFFF9F9F9), + ), + MaterialButton( + height: 92.w, + onPressed: () => + Get.to(ActivityPeopleListPage(id: widget.id)), + child: Row( + children: [ + StackAvatar( + avatars: model.headImgURls.map((e) => e.url).toList(), + ), + Spacer(), + '已有${model.countRegistration}人参加' + .text + .size(28.sp) + .make(), + 16.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 30.w, + color: Color(0xFFD8D8D8), + ), + ], + ), + ), + Divider(height: 1.w, indent: 32.w, endIndent: 32.w), + ], + ), + ).material(color: Colors.white), + ); + } +} diff --git a/lib/ui/community/activity_list_page.dart b/lib/ui/community/activity_list_page.dart new file mode 100644 index 00000000..95e1977f --- /dev/null +++ b/lib/ui/community/activity_list_page.dart @@ -0,0 +1,48 @@ +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/activity_item_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/ui/community/activity_card.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class ActivityListPage extends StatefulWidget { + ActivityListPage({Key key}) : super(key: key); + + @override + _ActivityListPageState createState() => _ActivityListPageState(); +} + +class _ActivityListPageState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '往期精彩', + body: BeeListView( + controller: _refreshController, + path: API.community.activityList, + convert: (model) => + model.tableList.map((e) => ActivityItemModel.fromJson(e)).toList(), + builder: (items) { + return ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), + itemBuilder: (context, index) { + final ActivityItemModel model = items[index]; + return ActivityCard(model: model); + }, + separatorBuilder: (_, __) => 20.hb, + itemCount: items.length, + ); + }, + ), + ); + } +} diff --git a/lib/ui/community/activity_people_list_page.dart b/lib/ui/community/activity_people_list_page.dart new file mode 100644 index 00000000..2ee99aca --- /dev/null +++ b/lib/ui/community/activity_people_list_page.dart @@ -0,0 +1,67 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/activity_people_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/others/stack_avatar.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class ActivityPeopleListPage extends StatefulWidget { + final int id; + ActivityPeopleListPage({Key key, @required this.id}) : super(key: key); + + @override + _ActivityPeopleListPageState createState() => _ActivityPeopleListPageState(); +} + +class _ActivityPeopleListPageState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '参与人员', + body: BeeListView( + controller: _refreshController, + path: API.community.activityPeopleList, + extraParams: {'activityId': widget.id}, + convert: (model) => model.tableList + .map((e) => ActivityPeopleModel.fromJson(e)) + .toList(), + builder: (items) { + return ListView.separated( + padding: EdgeInsets.all(32.w), + itemBuilder: (context, index) { + final ActivityPeopleModel model = items[index]; + return Row( + children: [ + 96.hb, + 20.wb, + FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(model.imgUrl.first.url), + height: 60.w, + width: 60.w, + ), + 18.wb, + model.name.text.size(28.sp).make(), + Spacer(), + model.tel.text.size(28.sp).make(), + ], + ); + }, + separatorBuilder: (_, __) => Divider(height: 1.w), + itemCount: items.length, + ); + }, + ).material(color: Colors.white), + ); + } +} diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart new file mode 100644 index 00000000..f9a60796 --- /dev/null +++ b/lib/ui/community/community_func.dart @@ -0,0 +1,15 @@ +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/activity_item_model.dart'; +import 'package:akuCommunity/utils/network/base_list_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; + +class CommunityFunc { + static Future activity() async { + BaseListModel model = await NetUtil().getList( + API.community.activityList, + params: {'pageNum': 1, 'size': 1}, + ); + if (model.tableList.length == 0) return null; + return ActivityItemModel.fromJson(model.tableList.first); + } +} diff --git a/lib/ui/home/home_notification.dart b/lib/ui/home/home_notification.dart new file mode 100644 index 00000000..559e75dc --- /dev/null +++ b/lib/ui/home/home_notification.dart @@ -0,0 +1,50 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class HomeNotification extends StatefulWidget { + HomeNotification({Key key}) : super(key: key); + + @override + _HomeNotificationState createState() => _HomeNotificationState(); +} + +class _HomeNotificationState extends State { + @override + Widget build(BuildContext context) { + return Row( + children: [ + 85.hb, + 24.wb, + Image.asset( + R.ASSETS_ICONS_ICON_NOTIFICATION_PNG, + height: 40.w, + width: 40.w, + ), + 24.wb, + 'TTTTTTTTT'.text.size(28.sp).make(), + Spacer(), + MaterialButton( + shape: StadiumBorder(), + padding: EdgeInsets.symmetric(horizontal: 12.w), + onPressed: () {}, + child: Row( + children: [ + '更多公告'.text.size(20.sp).color(Color(0xFF999999)).make(), + 8.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 24.w, + color: Color(0xFF999999), + ), + ], + ), + ), + 12.wb, + ], + ); + } +} diff --git a/lib/ui/home/home_title.dart b/lib/ui/home/home_title.dart new file mode 100644 index 00000000..6df8309a --- /dev/null +++ b/lib/ui/home/home_title.dart @@ -0,0 +1,60 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class HomeTitle extends StatelessWidget { + final String title; + final String suffixTitle; + final VoidCallback onTap; + + const HomeTitle({ + Key key, + @required this.title, + @required this.suffixTitle, + @required this.onTap, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + 85.hb, + 24.wb, + Stack( + children: [ + Positioned( + left: 0, + right: 0, + bottom: 4.w, + child: Container( + color: kPrimaryColor, + height: 8.w, + ), + ), + title.text.size(32.sp).bold.make(), + ], + ), + Spacer(), + MaterialButton( + shape: StadiumBorder(), + padding: EdgeInsets.symmetric(horizontal: 12.w), + onPressed: onTap, + child: Row( + children: [ + suffixTitle.text.size(20.sp).color(Color(0xFF999999)).make(), + 8.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 24.w, + color: Color(0xFF999999), + ), + ], + ), + ), + 12.wb, + ], + ); + } +} diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 5173c8ed..c4eb7669 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -113,13 +113,6 @@ class NetUtil { }) async { try { Response res = await _dio.get(path, queryParameters: params); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); BaseListModel baseListModel = BaseListModel.fromJson(res.data); return baseListModel; } on DioError catch (e) { diff --git a/lib/widget/others/stack_avatar.dart b/lib/widget/others/stack_avatar.dart new file mode 100644 index 00000000..e2df0d80 --- /dev/null +++ b/lib/widget/others/stack_avatar.dart @@ -0,0 +1,41 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/material.dart'; + +class StackAvatar extends StatelessWidget { + final List avatars; + const StackAvatar({Key key, @required this.avatars}) : super(key: key); + double get offset => 35.w; + int get length => avatars?.length ?? 0; + @override + Widget build(BuildContext context) { + return Stack( + children: [ + SizedBox( + width: 44.w * 2 + 26.w, + height: 44.w + 6.w, + ), + ...List.generate(length, (index) { + return Positioned( + left: index * offset, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(22.w + 2.w), + border: Border.all(color: Color(0xFF999999)), + ), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + height: 44.w, + width: 44.w, + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(avatars[index]), + ), + ), + ); + }), + ], + ); + } +}