diff --git a/assets/icons/file.png b/assets/icons/file.png new file mode 100644 index 00000000..764cedbb Binary files /dev/null and b/assets/icons/file.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 4faec79e..89cd90e4 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -122,6 +122,9 @@ class R { /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/icons/consult.png) static const String ASSETS_ICONS_CONSULT_PNG = 'assets/icons/consult.png'; + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/icons/file.png) + static const String ASSETS_ICONS_FILE_PNG = 'assets/icons/file.png'; + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/icons/groupbuy_tab_selected.png) static const String ASSETS_ICONS_GROUPBUY_TAB_SELECTED_PNG = 'assets/icons/groupbuy_tab_selected.png'; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 6597f751..b4ec2908 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -129,6 +129,12 @@ class _Community { ///社区活动:查看参与人数 String get activityPeopleList => '/user/activity/participantsList'; + + ///社区公告:查询所有的社区公告 + String get boardList => '/user/announcement/list'; + + ///社区公告:根据社区公告主键id查询社区公告信息 + String get boardDetail => '/user/announcement/findById'; } class _Upload { diff --git a/lib/model/community/board_detail_model.dart b/lib/model/community/board_detail_model.dart new file mode 100644 index 00000000..d3038216 --- /dev/null +++ b/lib/model/community/board_detail_model.dart @@ -0,0 +1,49 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + +class BoardDetailModel { + int id; + String title; + String content; + String fileDocUrl; + String fileDocName; + String releaseTime; + List imgUrls; + + BoardDetailModel( + {this.id, + this.title, + this.content, + this.fileDocUrl, + this.fileDocName, + this.releaseTime, + this.imgUrls}); + + BoardDetailModel.fromJson(Map json) { + id = json['id']; + title = json['title']; + content = json['content']; + fileDocUrl = json['fileDocUrl']; + fileDocName = json['fileDocName']; + releaseTime = json['releaseTime']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['content'] = this.content; + data['fileDocUrl'] = this.fileDocUrl; + data['fileDocName'] = this.fileDocName; + data['releaseTime'] = this.releaseTime; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/model/community/board_model.dart b/lib/model/community/board_model.dart new file mode 100644 index 00000000..0d0c520a --- /dev/null +++ b/lib/model/community/board_model.dart @@ -0,0 +1,36 @@ +import 'package:akuCommunity/model/common/img_model.dart'; +import 'package:flustars/flustars.dart'; + +class BoardItemModel { + int id; + String title; + String releaseTime; + List imgUrls; + + DateTime get releaseDate => DateUtil.getDateTime(releaseTime); + + BoardItemModel({this.id, this.title, this.releaseTime, this.imgUrls}); + + BoardItemModel.fromJson(Map json) { + id = json['id']; + title = json['title']; + releaseTime = json['releaseTime']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['releaseTime'] = this.releaseTime; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index ec8697a1..4784a24d 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'dart:convert'; // Flutter imports: +import 'package:akuCommunity/model/community/board_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -28,8 +29,8 @@ import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; import 'package:akuCommunity/pages/total_application_page/total_applications_page.dart'; import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; import 'package:akuCommunity/service/base_model.dart'; -import 'package:akuCommunity/ui/community/activity_card.dart'; -import 'package:akuCommunity/ui/community/activity_list_page.dart'; +import 'package:akuCommunity/ui/community/activity/activity_card.dart'; +import 'package:akuCommunity/ui/community/activity/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'; @@ -61,7 +62,8 @@ class _HomePageState extends State int page = 1; - ActivityItemModel model; + ActivityItemModel _activityItemModel; + List _boardItemModels = []; List _gridList = [ GridButton('一键开门', R.ASSETS_ICONS_TOOL_YJKM_PNG, OpenDoorPage().to), @@ -142,7 +144,8 @@ class _HomePageState extends State header: MaterialHeader(), firstRefresh: true, onRefresh: () async { - model = await CommunityFunc.activity(); + _activityItemModel = await CommunityFunc.activity(); + _boardItemModels = await CommunityFunc.board(); setState(() {}); }, child: CustomScrollView( @@ -204,15 +207,16 @@ class _HomePageState extends State SliverToBoxAdapter( child: Column( children: [ - HomeNotification(), + HomeNotification(items: _boardItemModels), HomeTitle( title: '社区活动', suffixTitle: '更多活动', onTap: ActivityListPage().to, ), - model == null + _activityItemModel == null ? SizedBox() - : ActivityCard(model: model).pSymmetric(h: 24.w, v: 24.w), + : ActivityCard(model: _activityItemModel) + .pSymmetric(h: 24.w, v: 24.w), ], ) .box diff --git a/lib/pages/notice_page/notice_page.dart b/lib/pages/notice_page/notice_page.dart deleted file mode 100644 index a49b0844..00000000 --- a/lib/pages/notice_page/notice_page.dart +++ /dev/null @@ -1,163 +0,0 @@ -// Flutter imports: -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// Package imports: -import 'package:flutter_html/flutter_html.dart'; - -// Project imports: -import 'package:akuCommunity/routers/page_routers.dart'; -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/cached_image_wrapper.dart'; - -const htmlData = ''' -

今天,宁波市住房和城乡建设局、宁波市自然资源和规 - 划局联合发布《关于进一步完善商品住房销售行为切实 - 保障居民自住需求的通知》(以下简称《通知》)。该 - 《通知》旨在保障居民自住需求,抑制投机投资行为, - 《通知》明确符合条件的“无房家庭”可在市六区优先认 - 购1套商品住房,该套住房要求在取得不动产权属证书 - 满5年后方可转让。该新政从发布之日起实施。


- 根据《通知》要求,我市海曙区、江北区、镇海区、北 - 仑区、鄞州区、奉化区(以下简称“市六区”)行政区域 - 内无住房且符合下列条件之一的家庭,可以按照本通知 - 要求优先认购1套商品住房:
- 一是,家庭成员(配偶双方及未成年子女)之一具有市 - 六区户籍的;
- 二是,近三年内在市六区已连续缴纳24个月及以上社会 - 保险的;
- 三是,本人或配偶属于本市引进的顶尖人才、特优人才、 - 领军人才、拔尖人才、高级人才的。以上三类家庭统称 - “无房家庭”。
- “无房家庭”优先认购的商品住房,须取得不动产权属证 - 书满5年后方可转让。


- - 通知》要求,购房意向人通过市房产交易网或移动端 - APP登记购房意向,包括商品住宅项目名称、是否为“无 - 房家庭”、购房人姓名及身份证明、户籍所在地、联系 - 方式等,并上传相关资料。购房意向人在项目售楼处现 - 场登记购房意向的,房地产开发企业应当协助其进行线 - 上登记并上传相关资料。
- 申报“无房家庭”购房资格的,购房意向人应当提供家庭 - 成员信息并上传相关证明,非本市户籍家庭还需上传社 - 会保险缴纳证明或者人才证明。《通知》还明确,房地 - 产开发企业不得擅自泄露、使用购房意向人提供的相关 - 信息。
- 参加优先认购的“无房家庭”,自购房意向登记之日起至 - 该项目优先认购活动结束当日止,不得参加其他任何项 - 目的购房意向登记。
- 房地产开发企业应当通过宁波市房产交易监管服务平台 - 对参加优先认购的“无房家庭”住房情况进行查询。经查 - 询没有住房的,登记为“无房家庭”,并在市房产交易网 - 公示;经查询有住房的,登记为有房家庭并告知购房意 - 向人。
- 购房意向人对查询结果有异议的,可以向商品住宅项目 - 所在地住建部门申请复查。经复查,符合“无房家庭”要 - 求的,由当地住建部门出具相关证明,纳入公示名单。 - 商品住宅项目所在地住建部门应当就“无房家庭”公示名 - 单进行抽查,发现登记有误的,及时修正公示名单。
-

-'''; - - -class NoticePage extends StatelessWidget { - final Bundle bundle; - NoticePage({Key key,this.bundle}) : super(key: key); - - Widget _creater() { - return Container( - child: Row( - children: [ - Container( - margin: EdgeInsets.only(right: 12.w), - child: ClipOval( - child: CachedImageWrapper( - url: - 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1380335538,732392216&fm=26&gp=0.jpg', - width: 45.w, - height: 45.w, - ), - ), - ), - RichText( - text: TextSpan( - children: [ - TextSpan( - text: '管理员 ', - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff999999), - ), - ), - TextSpan( - text: ' 发布于 ', - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff666666), - ), - ), - TextSpan( - text: '2020-08-12', - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff999999), - ), - ), - ], - ), - ), - ], - ), - ); - } - - @override - Widget build(BuildContext context) { - return BeeScaffold( - title: '社区公告', - body: Stack( - children: [ - Container( - color: Colors.white, - child: ListView( - padding: EdgeInsets.only( - top: 26.w, - left: 32.w, - right: 32.w, - bottom: 60.w), - children: [ - Text( - bundle.getMap('details')['title'], - style: TextStyle( - fontSize: 32.sp, - color: Color(0xff333333), - fontWeight: FontWeight.w600,), - ), - Container( - margin: EdgeInsets.only(top: 45.w), - child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(6)), - child: CachedImageWrapper( - url: bundle.getMap('details')['imagePath'], - width: 686.w, - height: 228.w, - ), - ), - ), - Container( - margin: EdgeInsets.only(top: 44.w), - width: 647.w, - child: Html(data: htmlData), - ), - _creater(), - ], - ), - ), - ], - ), - ); - } -} - - diff --git a/lib/pages/property/property_index.dart b/lib/pages/property/property_index.dart index 5cb538d8..e8d2dc29 100644 --- a/lib/pages/property/property_index.dart +++ b/lib/pages/property/property_index.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/ui/community/notice/notice_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -15,7 +16,6 @@ import 'package:akuCommunity/pages/fitup_manage/fitup_manage_page.dart'; import 'package:akuCommunity/pages/goods_deto_page/goods_deto_page.dart'; import 'package:akuCommunity/pages/industry_committee/industry_committee_page.dart'; import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; -import 'package:akuCommunity/pages/notice_page/notice_page.dart'; import 'package:akuCommunity/pages/open_door_page/open_door_page.dart'; import 'package:akuCommunity/pages/opening_code_page/opening_code_page.dart'; import 'package:akuCommunity/pages/questionnaire_page/questionnaire_page.dart'; @@ -30,10 +30,10 @@ import 'package:akuCommunity/widget/circle_trend.dart'; import 'package:akuCommunity/widget/container_comment.dart'; import 'package:akuCommunity/widget/grid_buttons.dart'; import 'package:akuCommunity/widget/single_ad_space.dart'; -import 'widget/property_activity_card.dart'; -import 'widget/property_bar.dart'; import 'widget/property_card.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t property_index need to be cleaned.") class PropertyIndex extends StatefulWidget { PropertyIndex({Key key}) : super(key: key); @@ -41,6 +41,8 @@ class PropertyIndex extends StatefulWidget { _PropertyIndexState createState() => _PropertyIndexState(); } +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t property_index need to be cleaned.") class _PropertyIndexState extends State with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin { List _gridList = [ @@ -167,10 +169,7 @@ class _PropertyIndexState extends State } void noticeRouter(String theme, imagePath) { - NoticePage( - bundle: Bundle() - ..putMap('details', {'title': theme, 'imagePath': imagePath}), - ).to; + NoticePage().to; } @override @@ -212,19 +211,19 @@ class _PropertyIndexState extends State SliverToBoxAdapter( child: PropertyCard(), ), - PropertyBar( - title: '社区活动', - subtitle: '精彩往期', - more: '更多活动', - fun: activityRouter, - ), - SliverToBoxAdapter( - child: PropertyActivityCard(fun: activityDetailsRouter), - ), - PropertyBar( - title: '社区公告', - subtitle: '看看小区最近发生什么?', - ), + // PropertyBar( + // title: '社区活动', + // subtitle: '精彩往期', + // more: '更多活动', + // fun: activityRouter, + // ), + // SliverToBoxAdapter( + // child: PropertyActivityCard(fun: activityDetailsRouter), + // ), + // PropertyBar( + // title: '社区公告', + // subtitle: '看看小区最近发生什么?', + // ), SliverToBoxAdapter( child: ListView.builder( shrinkWrap: true, diff --git a/lib/pages/property/widget/property_activity_card.dart b/lib/pages/property/widget/property_activity_card.dart deleted file mode 100644 index 4dd4cf83..00000000 --- a/lib/pages/property/widget/property_activity_card.dart +++ /dev/null @@ -1,203 +0,0 @@ -// Flutter imports: -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// Package imports: -import 'package:image_stack/image_stack.dart'; - -// Project imports: -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/cached_image_wrapper.dart'; - -class PropertyActivityCard extends StatelessWidget { - final Function fun; - PropertyActivityCard({Key key, this.fun}) : super(key: key); - - final List images = [ - "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1151143562,4115642159&fm=26&gp=0.jpg", - "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2551412680,857245643&fm=26&gp=0.jpg", - "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3604827221,1047385274&fm=26&gp=0.jpg", - ]; - - final List> _listView = [ - { - 'imagePath': - 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3786472598,2225627644&fm=26&gp=0.jpg', - 'title': '宁化社区第一届煎蛋比赛报名开始', - 'subtitleFirst': '活动室二楼', - 'subtitleSecond': '06月17日 12:00至06月27日18:30', - 'peopleNum': '37', - 'isOver': false, - 'isVote': false, - 'isVoteOver': false, - }, - { - 'imagePath': - 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600339523640&di=be179b5e314f9e198c000e7726affef6&imgtype=0&src=http%3A%2F%2Fa.hiphotos.baidu.com%2Fbaike%2Fpic%2Fitem%2F7e3e6709c93d70cf7371f1f3f1dcd100bba12b40.jpg', - 'title': '美嘉社区第三届六一亲子活动开始啦', - 'subtitleFirst': '中央活动区', - 'subtitleSecond': '04月17日 13:00至04月23日18:30', - 'peopleNum': '37', - 'isOver': false, - 'isVote': false, - 'isVoteOver': false - }, - ]; - - TextStyle _textStyleTitle() { - return TextStyle(fontSize: 28.sp, color: Color(0xff4a4b51)); - } - - TextStyle _textStyleTag() { - return TextStyle(fontSize: 24.sp, color: Color(0xff999999)); - } - - TextStyle _textStyleSubtitle() { - return TextStyle(fontSize: 24.sp, color: Color(0xff4a4b51)); - } - - Container _activityCard(String imagePath, title, subtitleFirst, - subtitleSecond, peopleNum, bool isOver, isVote, isVoteOver, int index) { - return Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(8)), - ), - margin: EdgeInsets.only( - top: index == 0 ? 0 : 32.w, - left: 32.w, - right: 32.w, - ), - padding: EdgeInsets.only( - top: 12.w, - left: 10.w, - right: 22.w, - bottom: 20.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 20.w), - child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(6)), - child: CachedImageWrapper( - url: imagePath, - width: 160.w, - height: 120.w, - ), - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(bottom: 6.w), - child: Text( - title, - style: _textStyleTitle(), - ), - ), - Container( - margin: EdgeInsets.only(bottom: 8.w), - child: RichText( - text: TextSpan( - text: '地点:', - style: _textStyleTag(), - children: [ - TextSpan( - text: subtitleFirst, style: _textStyleSubtitle()), - ], - ), - ), - ), - RichText( - text: TextSpan( - text: '活动时间:', - style: _textStyleTag(), - children: [ - TextSpan( - text: subtitleSecond, style: _textStyleSubtitle()), - ], - ), - ), - ], - ), - ], - ), - SizedBox(height: 40.w), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 80.w), - child: ImageStack( - imageList: images, - imageRadius: 44.sp, - imageCount: 3, - imageBorderWidth: 1, - totalCount: 3, - ), - ), - SizedBox(width: 26.w), - Text( - '$peopleNum人已参加', - style: _textStyleSubtitle(), - ), - ], - ), - InkWell( - onTap: () { - fun(imagePath, title, isOver, isVote, isVoteOver, images); - }, - child: Container( - alignment: Alignment.center, - height: 44.w, - width: 120.w, - padding: EdgeInsets.symmetric( - vertical: 7.w, - ), - decoration: BoxDecoration( - color: Color(0xffffc40c), - borderRadius: BorderRadius.all(Radius.circular(22)), - ), - child: Text( - '去参与', - style: _textStyleSubtitle(), - ), - ), - ) - ], - ), - ], - ), - ); - } - - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: _listView - .asMap() - .keys - .map((index) => _activityCard( - _listView[index]['imagePath'], - _listView[index]['title'], - _listView[index]['subtitleFirst'], - _listView[index]['subtitleSecond'], - _listView[index]['peopleNum'], - _listView[index]['isOver'], - _listView[index]['isVote'], - _listView[index]['isVoteOver'], - index, - )) - .toList(), - ), - ); - } -} diff --git a/lib/pages/property/widget/property_bar.dart b/lib/pages/property/widget/property_bar.dart deleted file mode 100644 index 55e10153..00000000 --- a/lib/pages/property/widget/property_bar.dart +++ /dev/null @@ -1,84 +0,0 @@ -// Flutter imports: -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// Package imports: -import 'package:flutter_icons/flutter_icons.dart'; - -// Project imports: -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/sliver_app_bar_delegate.dart'; - -class PropertyBar extends StatelessWidget { - final String title; - final String subtitle; - final String more; - final Function fun; - PropertyBar({Key key, this.title, this.subtitle, this.more,this.fun}) - : super(key: key); - - TextStyle _textStyleTitle() { - return TextStyle( - fontSize: 36.sp, - color: Color(0xff333333), - ); - } - - TextStyle _textStyleSubtitle() { - return TextStyle( - fontSize: 24.sp, - color: Color(0xff999999), - ); - } - - @override - Widget build(BuildContext context) { - return SliverPersistentHeader( - // pinned: true, //是否固定在顶部 - // floating: true, - delegate: SliverAppBarDelegate( - minHeight: 93, - maxHeight: 93, - child: Container( - margin: EdgeInsets.only( - top: 40.w, - bottom: 32.w, - left: 32.w, - right: 32.w, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(title, style: _textStyleTitle()), - SizedBox(height: 10.w), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(subtitle, style: _textStyleSubtitle()), - more != null - ? InkWell( - onTap: () { - fun(); - }, - child: Row( - children: [ - Text(more, style: _textStyleSubtitle()), - SizedBox(width: 12.w), - Icon( - AntDesign.right, - color: Color(0xff999999), - size: 20.sp, - ), - ], - ), - ) - : SizedBox(), - ], - ), - ], - ), - ), - ), - ); - } -} diff --git a/lib/pages/things_page/widget/bee_list_view.dart b/lib/pages/things_page/widget/bee_list_view.dart index a3915c4c..0628eb05 100644 --- a/lib/pages/things_page/widget/bee_list_view.dart +++ b/lib/pages/things_page/widget/bee_list_view.dart @@ -62,10 +62,10 @@ class BeeListView extends StatefulWidget { final Map extraParams; BeeListView({ Key key, - this.path, + @required this.path, @required this.controller, - this.convert, - this.builder, + @required this.convert, + @required this.builder, this.size = 10, this.extraParams, }) : super(key: key); diff --git a/lib/ui/community/activity_card.dart b/lib/ui/community/activity/activity_card.dart similarity index 97% rename from lib/ui/community/activity_card.dart rename to lib/ui/community/activity/activity_card.dart index e6d4ad64..6683eca4 100644 --- a/lib/ui/community/activity_card.dart +++ b/lib/ui/community/activity/activity_card.dart @@ -10,7 +10,7 @@ import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/constants/api.dart'; 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/ui/community/activity/activity_detail_page.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/others/stack_avatar.dart'; diff --git a/lib/ui/community/activity_detail_page.dart b/lib/ui/community/activity/activity_detail_page.dart similarity index 98% rename from lib/ui/community/activity_detail_page.dart rename to lib/ui/community/activity/activity_detail_page.dart index 12620b55..f8e9efcb 100644 --- a/lib/ui/community/activity_detail_page.dart +++ b/lib/ui/community/activity/activity_detail_page.dart @@ -12,7 +12,7 @@ import 'package:shimmer/shimmer.dart'; 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/ui/community/activity/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'; diff --git a/lib/ui/community/activity_list_page.dart b/lib/ui/community/activity/activity_list_page.dart similarity index 95% rename from lib/ui/community/activity_list_page.dart rename to lib/ui/community/activity/activity_list_page.dart index 8bb31cfe..594a5afd 100644 --- a/lib/ui/community/activity_list_page.dart +++ b/lib/ui/community/activity/activity_list_page.dart @@ -8,7 +8,7 @@ import 'package:flutter_easyrefresh/easy_refresh.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/ui/community/activity/activity_card.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; diff --git a/lib/ui/community/activity_people_list_page.dart b/lib/ui/community/activity/activity_people_list_page.dart similarity index 100% rename from lib/ui/community/activity_people_list_page.dart rename to lib/ui/community/activity/activity_people_list_page.dart diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart index b21ff73e..69dff281 100644 --- a/lib/ui/community/community_func.dart +++ b/lib/ui/community/community_func.dart @@ -1,6 +1,7 @@ // Project imports: import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/community/activity_item_model.dart'; +import 'package:akuCommunity/model/community/board_model.dart'; import 'package:akuCommunity/utils/network/base_list_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; @@ -13,4 +14,13 @@ class CommunityFunc { if (model.tableList.length == 0) return null; return ActivityItemModel.fromJson(model.tableList.first); } + + static Future> board() async { + BaseListModel model = await NetUtil().getList( + API.community.boardList, + params: {'pageNum': 1, 'size': 5}, + ); + if (model.tableList.length == 0) return []; + return model.tableList.map((e) => BoardItemModel.fromJson(e)).toList(); + } } diff --git a/lib/ui/community/notice/notice_card.dart b/lib/ui/community/notice/notice_card.dart new file mode 100644 index 00000000..f2ad8dd0 --- /dev/null +++ b/lib/ui/community/notice/notice_card.dart @@ -0,0 +1,116 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/ui/community/notice/notice_detail_page.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/model/community/board_model.dart'; +import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; +import 'package:flustars/flustars.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class NoticeCard extends StatelessWidget { + final BoardItemModel model; + final BoardItemModel preModel; + const NoticeCard({ + Key key, + @required this.model, + @required this.preModel, + }) : super(key: key); + + bool get sameDay => + model.releaseDate.year == (preModel?.releaseDate?.year ?? 0) && + model.releaseDate.month == (preModel?.releaseDate?.month ?? 0) && + model.releaseDate.day == (preModel?.releaseDate?.day ?? 0); + + bool get isYesterday { + DateTime now = DateTime.now(); + DateTime yestoday = DateTime(now.year, now.month, now.day - 1); + return yestoday.year == model.releaseDate.year && + yestoday.month == model.releaseDate.month && + yestoday.day == model.releaseDate.day; + } + + bool get isFirst => preModel == null; + + bool get notSameYear => + model.releaseDate.year != (preModel?.releaseDate?.year ?? 0); + + Widget title() { + if (DateUtil.isToday(model.releaseDate.millisecond)) + return '今天'.text.size(52.sp).bold.make(); + if (isYesterday) + return '昨天'.text.size(52.sp).bold.make(); + else + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + model.releaseDate.day.toString().text.size(52.sp).bold.make(), + '${model.releaseDate.month}月'.text.size(36.sp).make(), + ], + ); + } + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + (notSameYear && model.releaseDate.year != DateTime.now().year) + ? '${model.releaseDate.year}年' + .text + .bold + .size(52.sp) + .make() + .paddingOnly(left: 32.w, top: isFirst ? 0 : 64.w, bottom: 32.w) + : SizedBox(), + MaterialButton( + onPressed: () { + Get.to(NoticeDetailPage(id: model.id)); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 200.w, + padding: EdgeInsets.only(left: 32.w), + alignment: Alignment.topLeft, + child: sameDay ? SizedBox() : title(), + ), + model.imgUrls.length == 0 + ? SizedBox(height: 152.w) + : GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: model.imgUrls.first.url), + opaque: false, + ); + }, + child: Hero( + tag: model.imgUrls.first.url, + child: Container( + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + color: Colors.black12, + borderRadius: BorderRadius.circular(8.w), + ), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(model.imgUrls.first.url), + width: 152.w, + height: 152.w, + fit: BoxFit.cover, + ), + ), + ), + ), + 10.wb, + model.title.text.make().expand(), + ], + ), + ), + ], + ); + } +} diff --git a/lib/ui/community/notice/notice_detail_page.dart b/lib/ui/community/notice/notice_detail_page.dart new file mode 100644 index 00000000..8a5cc14a --- /dev/null +++ b/lib/ui/community/notice/notice_detail_page.dart @@ -0,0 +1,119 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/board_detail_model.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/picker/bee_image_preview.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class NoticeDetailPage extends StatefulWidget { + final int id; + NoticeDetailPage({Key key, @required this.id}) : super(key: key); + + @override + _NoticeDetailPageState createState() => _NoticeDetailPageState(); +} + +class _NoticeDetailPageState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); + BoardDetailModel model; + + Widget get emptyWidget => Column( + children: [], + ); + + Widget docView(String title, String path) { + return Container( + margin: EdgeInsets.only(right: 113.w), + alignment: Alignment.centerLeft, + child: MaterialButton( + minWidth: 606.w, + height: 154.w, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Row( + children: [ + title.text.size(32.sp).make().expand(), + Image.asset( + R.ASSETS_ICONS_FILE_PNG, + height: 52.w, + width: 52.w, + ), + ], + ), + onPressed: () {}, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w), + side: BorderSide(color: Color(0xFFD4CFBE)), + ), + color: Colors.white, + ), + ); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '社区公告', + body: EasyRefresh( + controller: _refreshController, + header: MaterialHeader(), + onRefresh: () async { + BaseModel baseModel = await NetUtil().get( + API.community.boardDetail, + params: {'announcementId': widget.id}, + ); + model = BoardDetailModel.fromJson(baseModel.data); + setState(() {}); + }, + firstRefresh: true, + firstRefreshWidget: emptyWidget, + child: model == null + ? SizedBox() + : ListView( + padding: EdgeInsets.all(32.w), + children: [ + model.title.text.size(32.sp).bold.make(), + 50.hb, + ...model.imgUrls + .map( + (e) => GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: e.url), + opaque: false, + ); + }, + child: Hero( + tag: e.url, + child: Container( + height: 228.w, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + color: Colors.black12, + ), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(e.url), + fit: BoxFit.cover, + ), + ), + ), + ), + ) + .toList(), + 44.hb, + model.content.text.size(28.sp).make(), + 43.hb, + docView(model.fileDocName, model.fileDocUrl), + ], + ), + ).material(color: Colors.white), + ); + } +} diff --git a/lib/ui/community/notice/notice_page.dart b/lib/ui/community/notice/notice_page.dart new file mode 100644 index 00000000..cc9d3ff8 --- /dev/null +++ b/lib/ui/community/notice/notice_page.dart @@ -0,0 +1,47 @@ +import 'package:akuCommunity/ui/community/notice/notice_card.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/board_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class NoticePage extends StatefulWidget { + NoticePage({Key key}) : super(key: key); + + @override + _NoticePageState createState() => _NoticePageState(); +} + +class _NoticePageState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '社区公告', + body: BeeListView( + controller: _refreshController, + path: API.community.boardList, + convert: (model) => + model.tableList.map((e) => BoardItemModel.fromJson(e)).toList(), + builder: (items) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 32.w), + itemBuilder: (context, index) { + final BoardItemModel model = items[index]; + BoardItemModel preModel; + if (index >= 1) preModel = items[index - 1]; + return NoticeCard( + model: model, + preModel: preModel, + ); + }, + separatorBuilder: (_, __) => 8.hb, + itemCount: items.length, + ); + }, + ), + ); + } +} diff --git a/lib/ui/home/home_notification.dart b/lib/ui/home/home_notification.dart index df1e3b6b..76022477 100644 --- a/lib/ui/home/home_notification.dart +++ b/lib/ui/home/home_notification.dart @@ -1,4 +1,9 @@ // Flutter imports: +import 'dart:async'; +import 'dart:math'; + +import 'package:akuCommunity/model/community/board_model.dart'; +import 'package:akuCommunity/ui/community/notice/notice_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -10,13 +15,35 @@ import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/utils/headers.dart'; class HomeNotification extends StatefulWidget { - HomeNotification({Key key}) : super(key: key); + final List items; + HomeNotification({Key key, @required this.items}) : super(key: key); @override _HomeNotificationState createState() => _HomeNotificationState(); } class _HomeNotificationState extends State { + String get randomItem { + if (widget.items.isEmpty) return ''; + int index = Random().nextInt(widget.items.length - 1); + return widget.items[index].title ?? ''; + } + + Timer _timer; + + @override + void initState() { + super.initState(); + _timer = Timer.periodic( + Duration(milliseconds: 5000), (timer) => setState(() {})); + } + + @override + void dispose() { + _timer?.cancel(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Row( @@ -29,12 +56,25 @@ class _HomeNotificationState extends State { width: 40.w, ), 24.wb, - 'TTTTTTTTT'.text.size(28.sp).make(), - Spacer(), + widget.items.isEmpty + ? Spacer() + : GestureDetector( + onTap: () {}, + child: AnimatedSwitcher( + duration: Duration(milliseconds: 1000), + child: Align( + alignment: Alignment.centerLeft, + key: ValueKey(randomItem), + child: Text(randomItem), + ), + ), + ).expand(), MaterialButton( shape: StadiumBorder(), padding: EdgeInsets.symmetric(horizontal: 12.w), - onPressed: () {}, + onPressed: () { + NoticePage().to(); + }, child: Row( children: [ '更多公告'.text.size(20.sp).color(Color(0xFF999999)).make(),