From c24905ea5fec45c63ae0653ea9744fd5f1f2d625 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 2 Mar 2022 14:28:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=91=8A=E5=92=8C=E8=B5=84=E8=AE=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/community/hot_news_model.dart | 1 + .../information_category_list_model.dart | 16 +++ .../information_category_list_model.g.dart | 14 +++ .../community/information_list_model.dart | 26 +++++ .../community/information_list_model.g.dart | 20 ++++ .../community/recommend_read_model.dart | 26 +++++ .../community/recommend_read_model.g.dart | 19 ++++ lib/models/home/home_announce_model.dart | 21 +++- lib/models/message/thumbs_up_list_model.dart | 27 +++++ .../message/thumbs_up_list_model.g.dart | 22 +++++ .../announce/announce_card.dart | 47 +++++---- .../announce/announce_view.dart | 61 +++++++++--- .../message_center_page/reply/reply_card.dart | 12 ++- .../thumbs_up/thumbs_up_card.dart | 16 +-- lib/ui/community/community_func.dart | 8 +- .../community_views/community_page.dart | 27 ++--- lib/ui/community/notice/notice_card.dart | 25 +++-- .../public_infomation_card.dart | 24 ++--- .../public_infomation_page.dart | 7 +- .../public_infomation_view.dart | 19 ++-- .../public_information_detail_page.dart | 98 ++++++++++++++++--- 21 files changed, 422 insertions(+), 114 deletions(-) create mode 100644 lib/models/community/information_category_list_model.dart create mode 100644 lib/models/community/information_category_list_model.g.dart create mode 100644 lib/models/community/information_list_model.dart create mode 100644 lib/models/community/information_list_model.g.dart create mode 100644 lib/models/community/recommend_read_model.dart create mode 100644 lib/models/community/recommend_read_model.g.dart create mode 100644 lib/models/message/thumbs_up_list_model.dart create mode 100644 lib/models/message/thumbs_up_list_model.g.dart diff --git a/lib/model/community/hot_news_model.dart b/lib/model/community/hot_news_model.dart index d8d0584e..7152beb3 100644 --- a/lib/model/community/hot_news_model.dart +++ b/lib/model/community/hot_news_model.dart @@ -1,5 +1,6 @@ import 'package:aku_new_community/model/common/img_model.dart'; +@Deprecated('弃用') class HotNewsModel { int? id; String? title; diff --git a/lib/models/community/information_category_list_model.dart b/lib/models/community/information_category_list_model.dart new file mode 100644 index 00000000..9d09981d --- /dev/null +++ b/lib/models/community/information_category_list_model.dart @@ -0,0 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'information_category_list_model.g.dart'; + +@JsonSerializable() +class InformationCategoryListModel { + final int id; + final String name; + factory InformationCategoryListModel.fromJson(Map json) => + _$InformationCategoryListModelFromJson(json); + + const InformationCategoryListModel({ + required this.id, + required this.name, + }); +} diff --git a/lib/models/community/information_category_list_model.g.dart b/lib/models/community/information_category_list_model.g.dart new file mode 100644 index 00000000..ea0fd2fd --- /dev/null +++ b/lib/models/community/information_category_list_model.g.dart @@ -0,0 +1,14 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'information_category_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +InformationCategoryListModel _$InformationCategoryListModelFromJson( + Map json) => + InformationCategoryListModel( + id: json['id'] as int, + name: json['name'] as String, + ); diff --git a/lib/models/community/information_list_model.dart b/lib/models/community/information_list_model.dart new file mode 100644 index 00000000..0b37b8ed --- /dev/null +++ b/lib/models/community/information_list_model.dart @@ -0,0 +1,26 @@ +import 'package:aku_new_community/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'information_list_model.g.dart'; + +@JsonSerializable() +class InformationListModel { + final int id; + final String title; + final String content; + final int viewsNum; + final String createDate; + final List imgList; + factory InformationListModel.fromJson(Map json) => + _$InformationListModelFromJson(json); + DateTime? get createDateDT => DateUtil.getDateTime(createDate); + const InformationListModel({ + required this.id, + required this.title, + required this.content, + required this.viewsNum, + required this.createDate, + required this.imgList, + }); +} diff --git a/lib/models/community/information_list_model.g.dart b/lib/models/community/information_list_model.g.dart new file mode 100644 index 00000000..a918d103 --- /dev/null +++ b/lib/models/community/information_list_model.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'information_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +InformationListModel _$InformationListModelFromJson( + Map json) => + InformationListModel( + id: json['id'] as int, + title: json['title'] as String, + content: json['content'] as String, + viewsNum: json['viewsNum'] as int, + createDate: json['createDate'] as String, + imgList: (json['imgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); diff --git a/lib/models/community/recommend_read_model.dart b/lib/models/community/recommend_read_model.dart new file mode 100644 index 00000000..72b70a1e --- /dev/null +++ b/lib/models/community/recommend_read_model.dart @@ -0,0 +1,26 @@ +import 'package:aku_new_community/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'recommend_read_model.g.dart'; + +@JsonSerializable() +class RecommendReadModel { + final int id; + final String title; + final String content; + final int viewsNum; + final String createDate; + final List imgList; + factory RecommendReadModel.fromJson(Map json) => + _$RecommendReadModelFromJson(json); + DateTime? get createDateDT => DateUtil.getDateTime(createDate); + const RecommendReadModel({ + required this.id, + required this.title, + required this.content, + required this.viewsNum, + required this.createDate, + required this.imgList, + }); +} diff --git a/lib/models/community/recommend_read_model.g.dart b/lib/models/community/recommend_read_model.g.dart new file mode 100644 index 00000000..6296135d --- /dev/null +++ b/lib/models/community/recommend_read_model.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'recommend_read_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +RecommendReadModel _$RecommendReadModelFromJson(Map json) => + RecommendReadModel( + id: json['id'] as int, + title: json['title'] as String, + content: json['content'] as String, + viewsNum: json['viewsNum'] as int, + createDate: json['createDate'] as String, + imgList: (json['imgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); diff --git a/lib/models/home/home_announce_model.dart b/lib/models/home/home_announce_model.dart index 4ccf558e..bf63e842 100644 --- a/lib/models/home/home_announce_model.dart +++ b/lib/models/home/home_announce_model.dart @@ -13,7 +13,10 @@ class HomeAnnounceModel { final String createDate; factory HomeAnnounceModel.fromJson(Map json) => _$HomeAnnounceModelFromJson(json); - DateTime? get createDateString => DateUtil.getDateTime(createDate); + DateTime? get createDateDT => DateUtil.getDateTime(createDate); + int? get month => createDateDT?.month; + + int? get year => createDateDT?.year; const HomeAnnounceModel({ required this.id, required this.title, @@ -21,4 +24,20 @@ class HomeAnnounceModel { required this.imgList, required this.createDate, }); + + HomeAnnounceModel copyWith({ + int? id, + String? title, + String? content, + List? imgList, + String? createDate, + }) { + return HomeAnnounceModel( + id: id ?? this.id, + title: title ?? this.title, + content: content ?? this.content, + imgList: imgList ?? this.imgList, + createDate: createDate ?? this.createDate, + ); + } } diff --git a/lib/models/message/thumbs_up_list_model.dart b/lib/models/message/thumbs_up_list_model.dart new file mode 100644 index 00000000..53f384a1 --- /dev/null +++ b/lib/models/message/thumbs_up_list_model.dart @@ -0,0 +1,27 @@ +import 'package:aku_new_community/model/common/img_model.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'thumbs_up_list_model.g.dart'; + +@JsonSerializable() +class ThumbsUpListModel { + final int id; + final int status; + final int sendId; + final String sendName; + final String sendDate; + final List avatarImgList; + final List dynamicImgList; + factory ThumbsUpListModel.fromJson(Map json) => + _$ThumbsUpListModelFromJson(json); + + const ThumbsUpListModel({ + required this.id, + required this.status, + required this.sendId, + required this.sendName, + required this.sendDate, + required this.avatarImgList, + required this.dynamicImgList, + }); +} diff --git a/lib/models/message/thumbs_up_list_model.g.dart b/lib/models/message/thumbs_up_list_model.g.dart new file mode 100644 index 00000000..e2c11dc3 --- /dev/null +++ b/lib/models/message/thumbs_up_list_model.g.dart @@ -0,0 +1,22 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'thumbs_up_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ThumbsUpListModel _$ThumbsUpListModelFromJson(Map json) => + ThumbsUpListModel( + id: json['id'] as int, + status: json['status'] as int, + sendId: json['sendId'] as int, + sendName: json['sendName'] as String, + sendDate: json['sendDate'] as String, + avatarImgList: (json['avatarImgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + dynamicImgList: (json['dynamicImgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); diff --git a/lib/pages/message_center_page/announce/announce_card.dart b/lib/pages/message_center_page/announce/announce_card.dart index c3d0b877..109b419e 100644 --- a/lib/pages/message_center_page/announce/announce_card.dart +++ b/lib/pages/message_center_page/announce/announce_card.dart @@ -1,22 +1,25 @@ +import 'package:aku_new_community/base/base_style.dart'; +import 'package:aku_new_community/extensions/widget_list_ext.dart'; +import 'package:aku_new_community/models/home/home_announce_model.dart'; +import 'package:aku_new_community/pages/message_center_page/announce/announce_view.dart'; +import 'package:aku_new_community/ui/community/notice/notice_detail_page.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -import 'package:common_utils/common_utils.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; -import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/extensions/widget_list_ext.dart'; -import 'package:aku_new_community/models/message/announce_list_model.dart'; -import 'package:aku_new_community/pages/message_center_page/announce/announce_view.dart'; - class AnnounceCard extends StatelessWidget { final ListDateModel modelList; final int index; + final bool visible; + const AnnounceCard({ Key? key, required this.modelList, required this.index, + required this.visible, }) : super(key: key); @override @@ -24,13 +27,19 @@ class AnnounceCard extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, children: [ - Container( - padding: EdgeInsets.symmetric(horizontal: 32.w), - alignment: Alignment.centerLeft, - width: double.infinity, - height: 98.w, - child: modelList.month.text.size(36.sp).black.make(), - ), + !visible + ? SizedBox() + : Container( + padding: EdgeInsets.symmetric(horizontal: 32.w), + alignment: Alignment.centerLeft, + width: double.infinity, + height: 98.w, + child: '${modelList.year}年${modelList.month}月' + .text + .size(36.sp) + .black + .make(), + ), ...modelList.models .map((e) => _card(e)) .toList() @@ -39,7 +48,7 @@ class AnnounceCard extends StatelessWidget { ); } - Widget _card(AnnounceListModel model) { + Widget _card(HomeAnnounceModel model) { return Container( color: Colors.white, padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), @@ -47,7 +56,7 @@ class AnnounceCard extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - '${DateUtil.formatDateStr(model.date, format: 'dd日 HH:mm')}' + '${DateUtil.formatDateStr(model.createDate, format: 'dd日 HH:mm')}' .text .size(28.sp) .color(ktextSubColor) @@ -67,13 +76,15 @@ class AnnounceCard extends StatelessWidget { ), ), child: InkWell( - onTap: () {}, + onTap: () { + Get.to(() => NoticeDetailPage(id: model.id)); + }, child: Row( children: [ '查看详情'.text.size(24.w).color(ktextSubColor).make(), Spacer(), Icon( - CupertinoIcons.chevron_down, + CupertinoIcons.chevron_right, size: 20.w, ) ], diff --git a/lib/pages/message_center_page/announce/announce_view.dart b/lib/pages/message_center_page/announce/announce_view.dart index 70508b62..efb774c9 100644 --- a/lib/pages/message_center_page/announce/announce_view.dart +++ b/lib/pages/message_center_page/announce/announce_view.dart @@ -1,19 +1,20 @@ +import 'package:aku_new_community/constants/sars_api.dart'; +import 'package:aku_new_community/models/home/home_announce_model.dart'; +import 'package:aku_new_community/pages/message_center_page/announce/announce_card.dart'; +import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:scroll_to_index/scroll_to_index.dart'; -import 'package:aku_new_community/models/message/announce_list_model.dart'; -import 'package:aku_new_community/pages/message_center_page/announce/announce_card.dart'; - class ListDateModel { final String month; final int index; - final List models; + final String year; + final List models; - ListDateModel(this.month, this.models, this.index); + ListDateModel(this.month, this.models, this.index, this.year); } class AnnounceView extends StatefulWidget { @@ -30,21 +31,37 @@ class _AnnounceViewState extends State { late AutoScrollController _autoScrollController; List _modelLists = []; + List _innerModelList = []; String _headMonth = ''; - void monthListDepart(List models) { + void monthListDepart(List models) { for (var item in models) { var index = _modelLists.indexWhere((element) => element.month == item.month); if (index >= 0) { _modelLists[index].models.add(item.copyWith()); } else { - _modelLists.insert(_modelLists.length, - ListDateModel(item.month, [item.copyWith()], _modelLists.length)); + _modelLists.insert( + _modelLists.length, + ListDateModel(item.month.toString(), [item.copyWith()], + _modelLists.length, item.year.toString())); } } } + int _page = 1; + int _size = 5; + + bool visible(int index) { + if (index == 0) { + return true; + } else if (_modelLists[index].month == _modelLists[index - 1].month) { + return false; + } else { + return true; + } + } + @override void initState() { _autoScrollController = AutoScrollController( @@ -91,14 +108,35 @@ class _AnnounceViewState extends State { footer: MaterialFooter(), scrollController: _autoScrollController, onRefresh: () async { + _page = 1; _modelLists.clear(); - // monthListDepart(); + _innerModelList.clear(); + var base = + await NetUtil().getList(SARSAPI.announce.list, params: { + 'page': _page, + 'size': _size, + }); + _innerModelList = + base.rows.map((e) => HomeAnnounceModel.fromJson(e)).toList(); + monthListDepart(_innerModelList); if (_modelLists.isNotEmpty) { _headMonth = _modelLists[0].month; } + setState(() {}); }, - onLoad: () async {}, + onLoad: () async { + _page++; + var base = + await NetUtil().getList(SARSAPI.announce.list, params: { + 'page': _page, + 'size': _size, + }); + if (base.total > _innerModelList.length) {} + _innerModelList = + base.rows.map((e) => HomeAnnounceModel.fromJson(e)).toList(); + monthListDepart(_innerModelList); + }, child: _modelLists.isEmpty ? Container() : ListView.separated( @@ -112,6 +150,7 @@ class _AnnounceViewState extends State { child: AnnounceCard( modelList: _modelLists[index], index: index, + visible: visible(index), ), ); }, diff --git a/lib/pages/message_center_page/reply/reply_card.dart b/lib/pages/message_center_page/reply/reply_card.dart index b6c3ed64..6b0161be 100644 --- a/lib/pages/message_center_page/reply/reply_card.dart +++ b/lib/pages/message_center_page/reply/reply_card.dart @@ -1,7 +1,7 @@ import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/models/message/reply_list_model.dart'; import 'package:aku_new_community/pages/message_center_page/message_func.dart'; +import 'package:aku_new_community/widget/beeImageNetwork.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -22,8 +22,8 @@ class ReplyCard extends StatelessWidget { child: Row( children: [ ClipOval( - child: Image.network( - SARSAPI.image(model.avatar), + child: BeeImageNetwork( + urls: [model.avatar], width: 100.w, height: 100.w, ), @@ -32,6 +32,7 @@ class ReplyCard extends StatelessWidget { SizedBox( width: 350.w, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ model.sendName.text.size(26.sp).black.bold.make(), model.content.text @@ -44,10 +45,11 @@ class ReplyCard extends StatelessWidget { ], ), ), + Spacer(), ClipRRect( borderRadius: BorderRadius.circular(9.w), - child: Image.network( - SARSAPI.image(model.pic), + child: BeeImageNetwork( + urls: [model.pic], width: 128.w, height: 128.w, ), diff --git a/lib/pages/message_center_page/thumbs_up/thumbs_up_card.dart b/lib/pages/message_center_page/thumbs_up/thumbs_up_card.dart index 0a6349e1..bf51df36 100644 --- a/lib/pages/message_center_page/thumbs_up/thumbs_up_card.dart +++ b/lib/pages/message_center_page/thumbs_up/thumbs_up_card.dart @@ -1,14 +1,14 @@ import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; -import 'package:aku_new_community/models/message/reply_list_model.dart'; +import 'package:aku_new_community/models/message/thumbs_up_list_model.dart'; import 'package:aku_new_community/pages/message_center_page/message_func.dart'; +import 'package:aku_new_community/widget/beeImageNetwork.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:velocity_x/velocity_x.dart'; class ThumbsUpCard extends StatelessWidget { - final ReplyListModel model; + final ThumbsUpListModel model; const ThumbsUpCard({Key? key, required this.model}) : super(key: key); @@ -23,8 +23,8 @@ class ThumbsUpCard extends StatelessWidget { child: Row( children: [ ClipOval( - child: Image.network( - SARSAPI.image(model.avatar), + child: BeeImageNetwork( + imgs: model.avatarImgList, width: 100.w, height: 100.w, ), @@ -33,6 +33,7 @@ class ThumbsUpCard extends StatelessWidget { SizedBox( width: 350.w, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ model.sendName.text.size(26.sp).black.bold.make(), Assets.icons.communityLikeIs @@ -41,10 +42,11 @@ class ThumbsUpCard extends StatelessWidget { ], ), ), + Spacer(), ClipRRect( borderRadius: BorderRadius.circular(9.w), - child: Image.network( - SARSAPI.image(model.pic), + child: BeeImageNetwork( + imgs: model.dynamicImgList, width: 128.w, height: 128.w, ), diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart index 30c7a5cc..2424d34c 100644 --- a/lib/ui/community/community_func.dart +++ b/lib/ui/community/community_func.dart @@ -1,8 +1,8 @@ import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/constants/sars_api.dart'; -import 'package:aku_new_community/model/community/hot_news_model.dart'; import 'package:aku_new_community/model/good/market_swiper_model.dart'; import 'package:aku_new_community/models/community/dynamic_my_list_body.dart'; +import 'package:aku_new_community/models/community/information_list_model.dart'; import 'package:aku_new_community/models/community/topic_model.dart'; import 'package:aku_new_community/models/home/home_activity_model.dart'; import 'package:aku_new_community/models/home/home_announce_model.dart'; @@ -38,13 +38,13 @@ class CommunityFunc { } ///查询热门资讯 - static Future> getHotNews() async { + static Future> getHotNews() async { BaseListModel model = await NetUtil().getList( - API.community.findHotNews, + SARSAPI.information.list, params: {'pageNum': 1, 'size': 4}, ); if (model.rows.length == 0) return []; - return model.rows.map((e) => HotNewsModel.fromJson(e)).toList(); + return model.rows.map((e) => InformationListModel.fromJson(e)).toList(); } ///给单个资讯增加浏览量 diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 5a2adade..e24b9824 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -4,10 +4,10 @@ import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/model/common/img_model.dart'; -import 'package:aku_new_community/model/community/hot_news_model.dart'; import 'package:aku_new_community/models/community/all_dynamic_list_model.dart'; +import 'package:aku_new_community/models/community/information_category_list_model.dart'; +import 'package:aku_new_community/models/community/information_list_model.dart'; import 'package:aku_new_community/models/community/topic_model.dart'; -import 'package:aku_new_community/models/news/news_category_model.dart'; import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/provider/user_provider.dart'; import 'package:aku_new_community/ui/community/community_func.dart'; @@ -50,7 +50,7 @@ class _CommunityPageState extends State List _newItems = []; List _gambitModels = []; - List _hotNewsModels = []; + List _hotNewsModels = []; int _pageNum = 1; int _size = 4; @@ -209,15 +209,16 @@ class _CommunityPageState extends State children: [ _homeTitle('热门资讯', () async { final cancel = BotToast.showLoading(); - BaseModel model = await NetUtil().get(API.news.category); - List? category; + BaseModel model = + await NetUtil().get(SARSAPI.information.categoryList); + var category = []; if (model.success == true && model.data != null) { category = (model.data as List) - .map((e) => NewsCategoryModel.fromJson(e)) + .map((e) => InformationCategoryListModel.fromJson(e)) .toList(); } cancel(); - Get.to(() => PublicInfomationPage(models: category ?? [])); + Get.to(() => PublicInfomationPage(models: category)); }, '更多'), 32.hb, Container( @@ -283,12 +284,12 @@ class _CommunityPageState extends State return result; } - _infoCard(HotNewsModel item) { + _infoCard(InformationListModel item) { return GestureDetector( onTap: () async { var result = - await Get.to(() => PublicInformationDetailPage(id: item.id!)); - CommunityFunc.addViews(item.id!); + await Get.to(() => PublicInformationDetailPage(id: item.id)); + CommunityFunc.addViews(item.id); if (result) { _easyRefreshController.callRefresh(); } @@ -337,7 +338,7 @@ class _CommunityPageState extends State width: 316.w, alignment: Alignment.center, child: Text( - item.title ?? '', + item.title, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -349,7 +350,7 @@ class _CommunityPageState extends State Row( children: [ Text( - '${item.views ?? 0}浏览', + '${item.viewsNum}浏览', maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -359,7 +360,7 @@ class _CommunityPageState extends State ), Spacer(), Text( - item.createDate?.substring(0, 10) ?? '', + item.createDate, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( diff --git a/lib/ui/community/notice/notice_card.dart b/lib/ui/community/notice/notice_card.dart index c3a3bfa6..691329d8 100644 --- a/lib/ui/community/notice/notice_card.dart +++ b/lib/ui/community/notice/notice_card.dart @@ -21,26 +21,25 @@ class NoticeCard extends StatelessWidget { }) : super(key: key); bool get sameDay => - model.createDateString?.year == (preModel?.createDateString?.year ?? 0) && - model.createDateString?.month == - (preModel?.createDateString?.month ?? 0) && - model.createDateString?.day == (preModel?.createDateString?.day ?? 0); + model.createDateDT?.year == (preModel?.createDateDT?.year ?? 0) && + model.createDateDT?.month == (preModel?.createDateDT?.month ?? 0) && + model.createDateDT?.day == (preModel?.createDateDT?.day ?? 0); bool get isYesterday { DateTime now = DateTime.now(); DateTime yesterday = DateTime(now.year, now.month, now.day - 1); - return yesterday.year == model.createDateString?.year && - yesterday.month == model.createDateString?.month && - yesterday.day == model.createDateString?.day; + return yesterday.year == model.createDateDT?.year && + yesterday.month == model.createDateDT?.month && + yesterday.day == model.createDateDT?.day; } bool get isFirst => preModel == null; bool get notSameYear => - model.createDateString?.year != (preModel?.createDateString?.year ?? 0); + model.createDateDT?.year != (preModel?.createDateDT?.year ?? 0); Widget title() { - if (DateUtil.isToday(model.createDateString?.millisecond)) + if (DateUtil.isToday(model.createDateDT?.millisecond)) return '今天'.text.size(52.sp).bold.make(); if (isYesterday) return '昨天'.text.size(52.sp).bold.make(); @@ -48,12 +47,12 @@ class NoticeCard extends StatelessWidget { return Row( mainAxisSize: MainAxisSize.min, children: [ - (model.createDateString?.day.toString() ?? '') + (model.createDateDT?.day.toString() ?? '') .text .size(52.sp) .bold .make(), - '${model.createDateString?.month}月'.text.size(36.sp).make(), + '${model.createDateDT?.month}月'.text.size(36.sp).make(), ], ); } @@ -64,8 +63,8 @@ class NoticeCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - (notSameYear && model.createDateString?.year != DateTime.now().year) - ? '${model.createDateString?.year}年' + (notSameYear && model.createDateDT?.year != DateTime.now().year) + ? '${model.createDateDT?.year}年' .text .bold .size(52.sp) diff --git a/lib/ui/home/public_infomation/public_infomation_card.dart b/lib/ui/home/public_infomation/public_infomation_card.dart index ea3720a1..e70c54c2 100644 --- a/lib/ui/home/public_infomation/public_infomation_card.dart +++ b/lib/ui/home/public_infomation/public_infomation_card.dart @@ -1,18 +1,14 @@ -import 'package:flutter/material.dart'; - -import 'package:common_utils/common_utils.dart'; -import 'package:get/get.dart'; - import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/constants/api.dart'; -import 'package:aku_new_community/constants/sars_api.dart'; -import 'package:aku_new_community/model/common/img_model.dart'; -import 'package:aku_new_community/models/news/news_item_model.dart'; +import 'package:aku_new_community/models/community/information_list_model.dart'; import 'package:aku_new_community/ui/home/public_infomation/public_information_detail_page.dart'; import 'package:aku_new_community/utils/headers.dart'; +import 'package:aku_new_community/widget/beeImageNetwork.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; class PublicInfomationCard extends StatelessWidget { - final NewsItemModel model; + final InformationListModel model; const PublicInfomationCard({Key? key, required this.model}) : super(key: key); @@ -47,7 +43,7 @@ class PublicInfomationCard extends StatelessWidget { // Text('测试'), Spacer(), Text('发布于 ${DateUtil.formatDate( - model.create, + model.createDateDT, format: 'yyyy-MM-dd HH:mm', )}'), ], @@ -57,12 +53,10 @@ class PublicInfomationCard extends StatelessWidget { ), ), 32.wb, - FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + BeeImageNetwork( width: 240.w, height: 200.w, - fit: BoxFit.cover, - image: SARSAPI.image(ImgModel.first(model.imgList)), + imgs: model.imgList, ), ], ), diff --git a/lib/ui/home/public_infomation/public_infomation_page.dart b/lib/ui/home/public_infomation/public_infomation_page.dart index 3bb2e957..c2d4a220 100644 --- a/lib/ui/home/public_infomation/public_infomation_page.dart +++ b/lib/ui/home/public_infomation/public_infomation_page.dart @@ -1,12 +1,11 @@ -import 'package:flutter/material.dart'; - -import 'package:aku_new_community/models/news/news_category_model.dart'; +import 'package:aku_new_community/models/community/information_category_list_model.dart'; import 'package:aku_new_community/ui/home/public_infomation/public_infomation_view.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/tab_bar/bee_tab_bar.dart'; +import 'package:flutter/material.dart'; class PublicInfomationPage extends StatefulWidget { - final List models; + final List models; PublicInfomationPage({ Key? key, diff --git a/lib/ui/home/public_infomation/public_infomation_view.dart b/lib/ui/home/public_infomation/public_infomation_view.dart index e856a403..162a1e4a 100644 --- a/lib/ui/home/public_infomation/public_infomation_view.dart +++ b/lib/ui/home/public_infomation/public_infomation_view.dart @@ -1,17 +1,14 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_easyrefresh/easy_refresh.dart'; - -import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/constants/sars_api.dart'; -import 'package:aku_new_community/models/news/news_category_model.dart'; -import 'package:aku_new_community/models/news/news_item_model.dart'; +import 'package:aku_new_community/models/community/information_category_list_model.dart'; +import 'package:aku_new_community/models/community/information_list_model.dart'; import 'package:aku_new_community/pages/things_page/widget/bee_list_view.dart'; import 'package:aku_new_community/ui/home/public_infomation/public_infomation_card.dart'; import 'package:aku_new_community/utils/headers.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; class PublicInfomationView extends StatefulWidget { - final NewsCategoryModel model; + final InformationCategoryListModel model; PublicInfomationView({Key? key, required this.model}) : super(key: key); @@ -27,11 +24,11 @@ class _PublicInfomationViewState extends State Widget build(BuildContext context) { super.build(context); return BeeListView( - path: API.news.list, + path: SARSAPI.information.list, controller: _refreshController, - extraParams: {'newsCategoryId': widget.model.id}, + extraParams: {'categoryId': widget.model.id}, convert: (model) => - model.rows.map((e) => NewsItemModel.fromJson(e)).toList(), + model.rows.map((e) => InformationListModel.fromJson(e)).toList(), builder: (items) { return ListView.separated( padding: EdgeInsets.symmetric(vertical: 24.w), diff --git a/lib/ui/home/public_infomation/public_information_detail_page.dart b/lib/ui/home/public_infomation/public_information_detail_page.dart index 7d8806d1..b7c1dfc5 100644 --- a/lib/ui/home/public_infomation/public_information_detail_page.dart +++ b/lib/ui/home/public_infomation/public_information_detail_page.dart @@ -1,24 +1,24 @@ +import 'package:aku_new_community/base/base_style.dart'; +import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/models/community/recommend_read_model.dart'; +import 'package:aku_new_community/models/news/news_detail_model.dart'; +import 'package:aku_new_community/utils/bee_date_util.dart'; +import 'package:aku_new_community/utils/link_text_parase.dart'; +import 'package:aku_new_community/utils/network/base_model.dart'; +import 'package:aku_new_community/utils/network/net_util.dart'; +import 'package:aku_new_community/widget/beeImageNetwork.dart'; +import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:common_utils/common_utils.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:velocity_x/velocity_x.dart'; -import 'package:aku_new_community/base/base_style.dart'; -import 'package:aku_new_community/constants/api.dart'; -import 'package:aku_new_community/constants/sars_api.dart'; -import 'package:aku_new_community/models/news/news_detail_model.dart'; -import 'package:aku_new_community/utils/link_text_parase.dart'; -import 'package:aku_new_community/utils/network/base_model.dart'; -import 'package:aku_new_community/utils/network/net_util.dart'; -import 'package:aku_new_community/widget/bee_scaffold.dart'; - class PublicInformationDetailPage extends StatefulWidget { final int id; @@ -139,4 +139,78 @@ class _PublicInformationDetailPageState Widget _emptyWidget() { return Container(); } + + Widget _recommendReading() { + var head = Padding( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 36.w), + child: Row( + children: [ + Container( + width: 8.w, + color: Colors.amber, + ), + 24.w.widthBox, + '推荐阅读'.text.size(28.sp).color(Colors.black).bold.make(), + ], + ), + ); + return Container( + decoration: BoxDecoration(color: Colors.white), + width: double.infinity, + child: Column( + children: [ + head, + ], + ), + ); + } + + Widget _recommendCard(RecommendReadModel model) { + return Padding( + padding: EdgeInsets.all(32.w), + child: Row( + children: [ + SizedBox( + width: 420.w, + height: 150.w, + child: Expanded( + child: Column( + children: [ + model.title.text.black.bold.maxLines(2).make(), + Spacer(), + Row( + children: [ + '${model.viewsNum}浏览' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + Spacer(), + BeeDateUtil(model.createDateDT) + .timeAgo + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + ], + ) + ], + ), + ), + ), + 32.w.widthBox, + Container( + width: 240.w, + height: 150.w, + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(16.w)), + clipBehavior: Clip.antiAlias, + child: BeeImageNetwork( + imgs: model.imgList, + ), + ), + ], + ), + ); + } }