From c7f9ebfd13f59b0f6b74f771bec20525b70c5d21 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 15:45:22 +0800 Subject: [PATCH 01/11] update chat card. working on chat detail page. --- .../topic/topic_detail_page.dart | 1 + .../community_views/widgets/chat_card.dart | 200 +++++++++++++++--- 2 files changed, 168 insertions(+), 33 deletions(-) diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 704d41a6..ac748c49 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -60,6 +60,7 @@ class _TopicDetailPageState extends State { headImg: item.headSculptureImgUrl, contentImg: item.imgUrls, date: item.date, + id: item.createId, ); }, childCount: items.length, diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index 4d0e6fbd..974c836c 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -1,8 +1,12 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/common/img_model.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_date_util.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; class ChatCard extends StatefulWidget { @@ -11,7 +15,10 @@ class ChatCard extends StatefulWidget { final List headImg; final List contentImg; final DateTime date; - final bool canDelete; + final bool initLike; + + ///userID + final int id; ChatCard({ Key key, this.name, @@ -19,7 +26,8 @@ class ChatCard extends StatefulWidget { this.headImg, this.contentImg, @required this.date, - this.canDelete, + this.initLike = false, + @required this.id, }) : super(key: key); @override @@ -27,6 +35,13 @@ class ChatCard extends StatefulWidget { } class _ChatCardState extends State { + bool _like = false; + + bool get _isMyself { + final userProvider = Provider.of(context, listen: false); + return (userProvider?.userInfoModel?.id ?? -1) == widget.id; + } + String get firstHead { if (widget.headImg == null || widget.headImg.isEmpty) return ''; @@ -49,8 +64,110 @@ class _ChatCardState extends State { ); } + _buildMoreButton() { + return Builder(builder: (context) { + return MaterialButton( + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6.w), + ), + padding: EdgeInsets.zero, + height: 40.w, + minWidth: 0, + color: Color(0xFFD8D8D8), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onPressed: () { + BotToast.showAttachedWidget( + targetContext: context, + preferDirection: PreferDirection.leftCenter, + attachedBuilder: (cancel) { + return Padding( + padding: EdgeInsets.only(right: 10.w), + child: Material( + color: Color(0xFFD8D8D8), + borderRadius: BorderRadius.circular(8.w), + clipBehavior: Clip.antiAlias, + child: SizedBox( + height: 78.w, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + MaterialButton( + height: 78.w, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + onPressed: () { + cancel(); + //TODO 点赞 + setState(() { + _like = !_like; + }); + }, + child: [ + _like + ? Icon(Icons.favorite, + size: 30.w, color: Colors.red) + : Icon(Icons.favorite_border, size: 30.w), + 10.wb, + '赞'.text.make(), + ].row(), + ), + VerticalDivider(width: 1.w, thickness: 1.w), + MaterialButton( + height: 78.w, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + onPressed: () {}, + child: [ + Icon(CupertinoIcons.bubble_right, size: 30.w), + 10.wb, + '评论'.text.make(), + ].row(), + ), + ], + ), + ), + ), + ); + }, + ); + }, + child: Row( + children: [ + 20.wb, + Container( + height: 8.w, + width: 8.w, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4.w), + ), + ), + 8.wb, + Container( + height: 8.w, + width: 8.w, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4.w), + ), + ), + 20.wb, + ], + ), + ); + }); + } + + @override + void initState() { + super.initState(); + _like = widget.initLike ?? false; + } + @override Widget build(BuildContext context) { + final userProvider = Provider.of(context); return DecoratedBox( decoration: BoxDecoration( color: Colors.white, @@ -60,38 +177,55 @@ class _ChatCardState extends State { ), ), ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Material( - color: Color(0xFFF5F5F5), - borderRadius: BorderRadius.circular(6.w), - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(firstHead), - height: 86.w, - width: 86.w, - ), - ), - 24.wb, - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - widget.name.text.size(36.sp).make(), - 6.hb, - widget.title.text.make(), - 20.hb, - _renderImage(), - Row( - children: [ - BeeDateUtil(widget.date).timeAgo.text.make(), - Spacer(), - ], + child: MaterialButton( + padding: EdgeInsets.zero, + onPressed: () { + //TODO go to chat detail page. + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Material( + color: Color(0xFFF5F5F5), + borderRadius: BorderRadius.circular(6.w), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(firstHead), + height: 86.w, + width: 86.w, ), - ], - ).expand(), - ], - ).p(20.w), + ), + 24.wb, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + widget.name.text.size(36.sp).make(), + 6.hb, + widget.title.text.make(), + 20.hb, + _renderImage(), + Row( + children: [ + BeeDateUtil(widget.date).timeAgo.text.make(), + _isMyself + ? FlatButton( + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + height: 48.w, + onPressed: () {}, + child: '删除'.text.black.size(28.sp).make(), + ) + : SizedBox(), + Spacer(), + _buildMoreButton(), + ], + ), + ], + ).expand(), + ], + ).p(20.w), + ), ); } } From d7b02d1f8c11ceb45c8ac0d8b2a92a426d877d1d Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 15:50:29 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community_views/widgets/chat_card.dart | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index 974c836c..d252d119 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/provider/user_provider.dart'; @@ -6,6 +7,7 @@ import 'package:akuCommunity/utils/headers.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -213,7 +215,30 @@ class _ChatCardState extends State { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, height: 48.w, - onPressed: () {}, + onPressed: () async { + bool result = + await Get.dialog(CupertinoAlertDialog( + title: '你确定删除吗'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '取消'.text.isIntrinsic.make(), + onPressed: () => Get.back(), + ), + CupertinoDialogAction( + child: '确定' + .text + .color(kPrimaryColor) + .isIntrinsic + .make(), + onPressed: () => Get.back(result: true), + ), + ], + )); + + if (result == true) { + //TODO delete operation + } + }, child: '删除'.text.black.size(28.sp).make(), ) : SizedBox(), From 7f0c1e2c2e1a266941a326ccd4a6789aedd2a8aa Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 16:11:56 +0800 Subject: [PATCH 03/11] =?UTF-8?q?chat=20card=20=E6=B7=BB=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community_views/widgets/chat_card.dart | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index d252d119..b1387436 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -4,6 +4,8 @@ import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_date_util.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; +import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -54,16 +56,36 @@ class _ChatCardState extends State { _renderImage() { if (widget.contentImg.isEmpty) return SizedBox(); if (widget.contentImg.length == 1) - return ConstrainedBox( - constraints: BoxConstraints( - maxHeight: 300.w, - minWidth: 300.w, + return MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: EdgeInsets.zero, + clipBehavior: Clip.antiAlias, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w), ), - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(widget.contentImg.first.url), + onPressed: () { + Get.to( + BeeImagePreview.path(path: widget.contentImg.first.url), + opaque: false, + ); + }, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: 300.w, + maxWidth: 300.w, + ), + child: Hero( + tag: widget.contentImg.first.url, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(widget.contentImg.first.url), + ), + ), ), ); + else + return BeeGridImageView( + urls: widget.contentImg.map((e) => e.url).toList()); } _buildMoreButton() { @@ -209,7 +231,12 @@ class _ChatCardState extends State { _renderImage(), Row( children: [ - BeeDateUtil(widget.date).timeAgo.text.make(), + BeeDateUtil(widget.date) + .timeAgo + .text + .size(28.sp) + .color(Color(0xFF999999)) + .make(), _isMyself ? FlatButton( materialTapTargetSize: From ccdc83bd53dd70c9a0633c122259ca203becc552 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 16:22:03 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A4=BE=E5=8C=BA?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 2 ++ .../community_views/new_community_view.dart | 36 ++++++++++++++++++- .../community_views/widgets/chat_card.dart | 8 ++--- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index ec2087f8..807db143 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -167,6 +167,8 @@ class _Community { String get topicList => '/user/gambit/list'; String get eventByTopicId => '/user/gambit/listByGambitId'; + + String get newEventList => '/user/gambit/list'; } class _Upload { diff --git a/lib/ui/community/community_views/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart index 626bfbf8..1b02a6ca 100644 --- a/lib/ui/community/community_views/new_community_view.dart +++ b/lib/ui/community/community_views/new_community_view.dart @@ -1,4 +1,9 @@ +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/event_item_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/ui/community/community_views/widgets/chat_card.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; class NewCommunityView extends StatefulWidget { NewCommunityView({Key key}) : super(key: key); @@ -9,10 +14,39 @@ class NewCommunityView extends StatefulWidget { class _NewCommunityViewState extends State with AutomaticKeepAliveClientMixin { + EasyRefreshController _refreshController = EasyRefreshController(); + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { super.build(context); - return Container(); + return BeeListView( + path: API.community.newEventList, + controller: _refreshController, + convert: (model) { + return model.tableList.map((e) => EventItemModel.fromJson(e)).toList(); + }, + builder: (items) { + return ListView.builder( + itemBuilder: (context, index) { + final item = items[index] as EventItemModel; + return ChatCard( + name: item.createName ?? '', + title: item.gambitTitle ?? '', + contentImg: item.imgUrls, + date: item.date, + id: item.id, + headImg: item.headSculptureImgUrl, + ); + }, + itemCount: items.length, + ); + }, + ); } @override diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index b1387436..e84de0aa 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -25,10 +25,10 @@ class ChatCard extends StatefulWidget { final int id; ChatCard({ Key key, - this.name, - this.title, - this.headImg, - this.contentImg, + @required this.name, + @required this.title, + @required this.headImg, + @required this.contentImg, @required this.date, this.initLike = false, @required this.id, From 78a12bb0a3d0ae6dcc4c63949d12e5e21ea14345 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 16:25:10 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=A2=9E=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/community/community_views/community_page.dart | 5 +++++ .../community/community_views/topic/topic_detail_page.dart | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 4d58a2d9..48cb5c31 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -39,6 +39,11 @@ class _CommunityPageState extends State path: R.ASSETS_ICONS_ALARM_PNG, ), ], + fab: FloatingActionButton( + onPressed: () {}, + heroTag: 'event_add', + child: Icon(Icons.add), + ), appBarBottom: PreferredSize( preferredSize: Size.fromHeight(48), child: Align( diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index ac748c49..4405a778 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -28,6 +28,11 @@ class _TopicDetailPageState extends State { @override Widget build(BuildContext context) { return Scaffold( + floatingActionButton: FloatingActionButton( + heroTag: 'event_add', + onPressed: () {}, + child: Icon(Icons.add), + ), body: BeeListView( convert: (model) { return model.tableList From 4556db6f8f895559d3b89fb2e5f3c27de84339aa Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 17:40:02 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 5 + .../community_views/add_new_event_page.dart | 148 ++++++++++++++++++ .../community_views/community_page.dart | 4 +- .../community_views/new_community_view.dart | 5 +- .../topic/topic_detail_page.dart | 3 +- .../community_views/widgets/chat_card.dart | 24 ++- lib/widget/picker/bee_image_picker.dart | 1 + 7 files changed, 181 insertions(+), 9 deletions(-) create mode 100644 lib/ui/community/community_views/add_new_event_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 807db143..410233be 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -169,6 +169,9 @@ class _Community { String get eventByTopicId => '/user/gambit/listByGambitId'; String get newEventList => '/user/gambit/list'; + + ///社区活动: 写帖子(添加主题信息) + String get addEvent => '/user/gambit/writePost'; } class _Upload { @@ -180,4 +183,6 @@ class _Upload { ///上传报事报修信息 报事报修照片 String get uploadRepair => '/user/upload/uploadRepair'; + + String get uploadEvent => '/user/upload/uploadGambit'; } diff --git a/lib/ui/community/community_views/add_new_event_page.dart b/lib/ui/community/community_views/add_new_event_page.dart new file mode 100644 index 00000000..e45845d1 --- /dev/null +++ b/lib/ui/community/community_views/add_new_event_page.dart @@ -0,0 +1,148 @@ +import 'dart:io'; + +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/constants/api.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/picker/grid_image_picker.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AddNewEventPage extends StatefulWidget { + AddNewEventPage({Key key}) : super(key: key); + + @override + _AddNewEventPageState createState() => _AddNewEventPageState(); +} + +class _AddNewEventPageState extends State { + bool _commentable = true; + List _files = []; + TextEditingController _textEditingController = TextEditingController(); + + ///发表动态 + _addEvent() async { + VoidCallback cancel = BotToast.showLoading(); + final String content = _textEditingController.text; + List imgs; + if (_files.isNotEmpty) { + imgs = await NetUtil().uploadFiles(_files, API.upload.uploadEvent); + } + + Map params = { + //TODO 话题ID + 'gambitId': -1, + 'content': content, + 'isComment': _commentable ? 1 : 0, + 'isPublic': 1, + 'imgUrls': imgs, + }; + + BaseModel baseModel = await NetUtil().post( + API.community.addEvent, + params: params, + showMessage: true, + ); + cancel(); + if (baseModel.status) { + Get.back(result: true); + } + } + + _buildSelectable() { + return MaterialButton( + onPressed: () { + setState(() { + _commentable = !_commentable; + }); + }, + height: 96.w, + child: Row( + children: [ + Icon( + CupertinoIcons.bubble_left, + size: 32.w, + ), + 8.wb, + '不可评论'.text.size(28.sp).make(), + Spacer(), + AnimatedOpacity( + opacity: _commentable ? 0 : 1, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + child: Icon( + Icons.check_rounded, + color: Colors.black, + size: 40.w, + ), + ), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0, + leading: MaterialButton( + padding: EdgeInsets.zero, + onPressed: Get.back, + child: '取消'.text.size(34.sp).make(), + ), + leadingWidth: 108.w, + centerTitle: true, + title: '社区'.text.make(), + actions: [ + Hero( + tag: 'event_add', + child: MaterialButton( + elevation: 0, + minWidth: 116.w, + padding: EdgeInsets.zero, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.w), + ), + color: kPrimaryColor, + onPressed: _addEvent, + child: '发表'.text.size(34.sp).make(), + ).centered(), + ), + 32.wb, + ], + ), + body: ListView( + padding: EdgeInsets.symmetric(horizontal: 64.w, vertical: 32.w), + children: [ + TextField( + minLines: 3, + maxLines: 99, + controller: _textEditingController, + decoration: InputDecoration( + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + hintText: '这一刻的想法', + hintStyle: TextStyle( + color: Color(0xFF999999), + fontSize: 34.sp, + ), + ), + ), + GridImagePicker(onChange: (files) => _files = files), + 100.hb, + Divider(height: 1.w), + _buildSelectable(), + Divider(height: 1.w), + 28.hb, + //TODO 选择话题 + ], + ).material(color: Colors.white), + ); + } +} diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 48cb5c31..b716ddfa 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/ui/community/community_views/add_new_event_page.dart'; import 'package:akuCommunity/ui/community/community_views/my_community_view.dart'; import 'package:akuCommunity/ui/community/community_views/new_community_view.dart'; import 'package:akuCommunity/ui/community/community_views/topic/topic_community_view.dart'; @@ -6,6 +7,7 @@ import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/buttons/column_action_button.dart'; import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; class CommunityPage extends StatefulWidget { CommunityPage({Key key}) : super(key: key); @@ -40,7 +42,7 @@ class _CommunityPageState extends State ), ], fab: FloatingActionButton( - onPressed: () {}, + onPressed: () => Get.to(AddNewEventPage()), heroTag: 'event_add', child: Icon(Icons.add), ), diff --git a/lib/ui/community/community_views/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart index 1b02a6ca..24ca4709 100644 --- a/lib/ui/community/community_views/new_community_view.dart +++ b/lib/ui/community/community_views/new_community_view.dart @@ -35,11 +35,12 @@ class _NewCommunityViewState extends State itemBuilder: (context, index) { final item = items[index] as EventItemModel; return ChatCard( + content: item.content, name: item.createName ?? '', - title: item.gambitTitle ?? '', + topic: item.gambitTitle ?? '', contentImg: item.imgUrls, date: item.date, - id: item.id, + id: item.createId, headImg: item.headSculptureImgUrl, ); }, diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 4405a778..4958529c 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -60,8 +60,9 @@ class _TopicDetailPageState extends State { (context, index) { final item = items[index] as EventItemModel; return ChatCard( + content: item.content, name: item.createName, - title: item.gambitTitle, + topic: item.gambitTitle, headImg: item.headSculptureImgUrl, contentImg: item.imgUrls, date: item.date, diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index e84de0aa..b3996497 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -15,23 +15,25 @@ import 'package:velocity_x/velocity_x.dart'; class ChatCard extends StatefulWidget { final String name; - final String title; + final String topic; final List headImg; final List contentImg; final DateTime date; final bool initLike; + final String content; ///userID final int id; ChatCard({ Key key, @required this.name, - @required this.title, + @required this.topic, @required this.headImg, @required this.contentImg, @required this.date, this.initLike = false, @required this.id, + @required this.content, }) : super(key: key); @override @@ -226,9 +228,21 @@ class _ChatCardState extends State { children: [ widget.name.text.size(36.sp).make(), 6.hb, - widget.title.text.make(), + widget.content.text.make(), 20.hb, _renderImage(), + widget.topic.isEmpty + ? SizedBox() + : Chip( + label: '#${widget.topic}'.text.size(22.sp).make(), + padding: EdgeInsets.symmetric( + horizontal: 16.w, vertical: 5.w), + labelPadding: EdgeInsets.zero, + backgroundColor: Colors.transparent, + shape: StadiumBorder( + side: BorderSide(), + ), + ), Row( children: [ BeeDateUtil(widget.date) @@ -248,13 +262,13 @@ class _ChatCardState extends State { title: '你确定删除吗'.text.isIntrinsic.make(), actions: [ CupertinoDialogAction( - child: '取消'.text.isIntrinsic.make(), + child: '取消'.text.black.isIntrinsic.make(), onPressed: () => Get.back(), ), CupertinoDialogAction( child: '确定' .text - .color(kPrimaryColor) + .color(Colors.orange) .isIntrinsic .make(), onPressed: () => Get.back(result: true), diff --git a/lib/widget/picker/bee_image_picker.dart b/lib/widget/picker/bee_image_picker.dart index 2b115a4e..3ba7a7b8 100644 --- a/lib/widget/picker/bee_image_picker.dart +++ b/lib/widget/picker/bee_image_picker.dart @@ -12,6 +12,7 @@ import 'package:velocity_x/velocity_x.dart'; // Project imports: import 'package:akuCommunity/utils/headers.dart'; +//TODO 图片大小限制 class BeeImagePicker { static Future pick({ String title, From 7e31df2bca7ae1d3fae8dd25cd25aead4a52edd9 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 19:06:03 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=9D=E9=A2=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 2 +- .../community/community_topic_model.dart | 151 +++--------------- .../topic/topic_community_view.dart | 6 +- .../topic/topic_detail_page.dart | 1 - lib/widget/picker/bee_image_preview.dart | 13 +- 5 files changed, 33 insertions(+), 140 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 410233be..e6247362 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -164,7 +164,7 @@ class _Community { String get boardDetail => '/user/announcement/findById'; ///社区话题:查询最新的所有主题信息 - String get topicList => '/user/gambit/list'; + String get topicList => '/user/gambit/listGambit'; String get eventByTopicId => '/user/gambit/listByGambitId'; diff --git a/lib/model/community/community_topic_model.dart b/lib/model/community/community_topic_model.dart index cc029304..798521e0 100644 --- a/lib/model/community/community_topic_model.dart +++ b/lib/model/community/community_topic_model.dart @@ -2,153 +2,52 @@ import 'package:akuCommunity/model/common/img_model.dart'; class CommunityTopicModel { int id; - int createId; - int isComment; - int isLike; - String createName; + String title; + String summary; String content; - String gambitTitle; - String createDate; - List likeNames; - List imgUrls; - List headSculptureImgUrl; - List gambitThemeCommentVoList; + List imgUrl; + int activityNum; String get firstImg { - var firstImg = ''; - if (imgUrls?.isNotEmpty ?? false) { - firstImg = imgUrls?.first?.url ?? ''; - } - return firstImg; + if (imgUrl.isEmpty) + return ''; + else + return imgUrl.first.url; } CommunityTopicModel( {this.id, - this.createId, - this.isComment, - this.isLike, - this.createName, + this.title, + this.summary, this.content, - this.gambitTitle, - this.createDate, - this.likeNames, - this.imgUrls, - this.headSculptureImgUrl, - this.gambitThemeCommentVoList}); + this.imgUrl, + this.activityNum}); CommunityTopicModel.fromJson(Map json) { id = json['id']; - createId = json['createId']; - isComment = json['isComment']; - isLike = json['isLike']; - createName = json['createName']; + title = json['title']; + summary = json['summary']; content = json['content']; - gambitTitle = json['gambitTitle']; - createDate = json['createDate']; - if (json['likeNames'] != null) { - likeNames = new List(); - json['likeNames'].forEach((v) { - likeNames.add(new LikeNames.fromJson(v)); - }); - } - if (json['imgUrls'] != null) { - imgUrls = new List(); - json['imgUrls'].forEach((v) { - imgUrls.add(new ImgModel.fromJson(v)); + if (json['imgUrl'] != null) { + imgUrl = new List(); + json['imgUrl'].forEach((v) { + imgUrl.add(new ImgModel.fromJson(v)); }); } else - imgUrls = []; - if (json['headSculptureImgUrl'] != null) { - headSculptureImgUrl = new List(); - json['headSculptureImgUrl'].forEach((v) { - headSculptureImgUrl.add(new ImgModel.fromJson(v)); - }); - } else - headSculptureImgUrl = []; - if (json['gambitThemeCommentVoList'] != null) { - gambitThemeCommentVoList = new List(); - json['gambitThemeCommentVoList'].forEach((v) { - gambitThemeCommentVoList.add(new GambitThemeCommentVoList.fromJson(v)); - }); - } + imgUrl = []; + activityNum = json['activityNum']; } Map toJson() { final Map data = new Map(); data['id'] = this.id; - data['createId'] = this.createId; - data['isComment'] = this.isComment; - data['isLike'] = this.isLike; - data['createName'] = this.createName; + data['title'] = this.title; + data['summary'] = this.summary; data['content'] = this.content; - data['gambitTitle'] = this.gambitTitle; - data['createDate'] = this.createDate; - if (this.likeNames != null) { - data['likeNames'] = this.likeNames.map((v) => v.toJson()).toList(); - } - if (this.imgUrls != null) { - data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); - } - if (this.headSculptureImgUrl != null) { - data['headSculptureImgUrl'] = - this.headSculptureImgUrl.map((v) => v.toJson()).toList(); + if (this.imgUrl != null) { + data['imgUrl'] = this.imgUrl.map((v) => v.toJson()).toList(); } - if (this.gambitThemeCommentVoList != null) { - data['gambitThemeCommentVoList'] = - this.gambitThemeCommentVoList.map((v) => v.toJson()).toList(); - } - return data; - } -} - -class LikeNames { - int id; - String name; - - LikeNames({this.id, this.name}); - - LikeNames.fromJson(Map json) { - id = json['id']; - name = json['name']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['name'] = this.name; - return data; - } -} - -class GambitThemeCommentVoList { - int id; - String parentName; - String content; - String createName; - String createDate; - - GambitThemeCommentVoList( - {this.id, - this.parentName, - this.content, - this.createName, - this.createDate}); - - GambitThemeCommentVoList.fromJson(Map json) { - id = json['id']; - parentName = json['parentName']; - content = json['content']; - createName = json['createName']; - createDate = json['createDate']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['parentName'] = this.parentName; - data['content'] = this.content; - data['createName'] = this.createName; - data['createDate'] = this.createDate; + data['activityNum'] = this.activityNum; return data; } } diff --git a/lib/ui/community/community_views/topic/topic_community_view.dart b/lib/ui/community/community_views/topic/topic_community_view.dart index 22a08746..c1902612 100644 --- a/lib/ui/community/community_views/topic/topic_community_view.dart +++ b/lib/ui/community/community_views/topic/topic_community_view.dart @@ -56,9 +56,7 @@ class _TopicCommunityViewState extends State ), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), - //TODO 等待后端接口补充话题摘要 - // model.summary - child: ('#${''}') + child: ('#${model.summary}') .text .center .size(28.sp) @@ -76,7 +74,7 @@ class _TopicCommunityViewState extends State Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - (model?.gambitTitle ?? '') + (model?.title ?? '') .text .maxLines(2) .size(28.sp) diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 4958529c..02a318a8 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -4,7 +4,6 @@ import 'package:akuCommunity/model/community/event_item_model.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/ui/community/community_views/topic/topic_sliver_header.dart'; import 'package:akuCommunity/ui/community/community_views/widgets/chat_card.dart'; -import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; diff --git a/lib/widget/picker/bee_image_preview.dart b/lib/widget/picker/bee_image_preview.dart index 3c70c36b..4ad8561e 100644 --- a/lib/widget/picker/bee_image_preview.dart +++ b/lib/widget/picker/bee_image_preview.dart @@ -50,14 +50,11 @@ class _BeeImagePreviewState extends State { onTap: Get.back, child: Scaffold( backgroundColor: Colors.black54, - body: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), - child: InteractiveViewer( - boundaryMargin: EdgeInsets.all(48), - minScale: 0.2, - maxScale: 10, - child: Center(child: image), - ), + body: InteractiveViewer( + boundaryMargin: EdgeInsets.all(48), + minScale: 0.2, + maxScale: 10, + child: Center(child: image), ), ), ); From 786ce262a0088831845e57e50aca2ecd3f336778 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 19:30:41 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E8=AF=9D=E9=A2=98=E7=82=B9=E8=B5=9E?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 +++ .../community_views/new_community_view.dart | 2 ++ .../community_views/topic/topic_detail_page.dart | 2 ++ .../community_views/widgets/chat_card.dart | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index e6247362..bca7b289 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -172,6 +172,9 @@ class _Community { ///社区活动: 写帖子(添加主题信息) String get addEvent => '/user/gambit/writePost'; + + ///社区话题:app用户点赞/取消点赞 + String get like => '/user/gambit/likes'; } class _Upload { diff --git a/lib/ui/community/community_views/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart index 24ca4709..8f49c4b2 100644 --- a/lib/ui/community/community_views/new_community_view.dart +++ b/lib/ui/community/community_views/new_community_view.dart @@ -42,6 +42,8 @@ class _NewCommunityViewState extends State date: item.date, id: item.createId, headImg: item.headSculptureImgUrl, + themeId: item.id, + initLike: item.isLike == 1, ); }, itemCount: items.length, diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 02a318a8..4ee5c422 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -59,6 +59,8 @@ class _TopicDetailPageState extends State { (context, index) { final item = items[index] as EventItemModel; return ChatCard( + initLike: item.isLike == 1, + themeId: item.id, content: item.content, name: item.createName, topic: item.gambitTitle, diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index b3996497..200f7ebe 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -4,6 +4,8 @@ import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_date_util.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/picker/bee_image_preview.dart'; import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; @@ -24,6 +26,9 @@ class ChatCard extends StatefulWidget { ///userID final int id; + + final int themeId; + ChatCard({ Key key, @required this.name, @@ -34,6 +39,7 @@ class ChatCard extends StatefulWidget { this.initLike = false, @required this.id, @required this.content, + @required this.themeId, }) : super(key: key); @override @@ -122,9 +128,13 @@ class _ChatCardState extends State { height: 78.w, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () { + onPressed: () async { cancel(); - //TODO 点赞 + await NetUtil().get( + API.community.like, + params: {'themeId': widget.id}, + showMessage: true, + ); setState(() { _like = !_like; }); From 869213c1e18a3c76b02728afbcb03ed7ec23f383 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 19:35:04 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=9D=E9=A2=98?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community_views/event_detail_page.dart | 18 ++++++++++++++++++ .../community_views/widgets/chat_card.dart | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 lib/ui/community/community_views/event_detail_page.dart diff --git a/lib/ui/community/community_views/event_detail_page.dart b/lib/ui/community/community_views/event_detail_page.dart new file mode 100644 index 00000000..bafc1b5e --- /dev/null +++ b/lib/ui/community/community_views/event_detail_page.dart @@ -0,0 +1,18 @@ +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; + +class EventDetailPage extends StatefulWidget { + EventDetailPage({Key key}) : super(key: key); + + @override + _EventDetailPageState createState() => _EventDetailPageState(); +} + +class _EventDetailPageState extends State { + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '详情', + ); + } +} diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index 200f7ebe..be5c8cd2 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -2,6 +2,7 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/ui/community/community_views/event_detail_page.dart'; import 'package:akuCommunity/utils/bee_date_util.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; @@ -216,7 +217,7 @@ class _ChatCardState extends State { child: MaterialButton( padding: EdgeInsets.zero, onPressed: () { - //TODO go to chat detail page. + Get.to(EventDetailPage()); }, child: Row( crossAxisAlignment: CrossAxisAlignment.start, From e5ec96302bd3fad3e717ace9fca70b2ba092bade Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 19:47:04 +0800 Subject: [PATCH 10/11] deprecated activityDetailPage --- lib/constants/api.dart | 3 +++ .../activities_details_page/activities_details_page.dart | 2 ++ lib/ui/community/community_views/widgets/chat_card.dart | 2 -- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index bca7b289..6c5d4581 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -175,6 +175,9 @@ class _Community { ///社区话题:app用户点赞/取消点赞 String get like => '/user/gambit/likes'; + + ///社区话题:查询活跃话题(取前4个) + String get hotTopic => '/user/gambit/findActivityGambit'; } class _Upload { diff --git a/lib/pages/activities_page/activities_details_page/activities_details_page.dart b/lib/pages/activities_page/activities_details_page/activities_details_page.dart index 1c249117..78e1af00 100644 --- a/lib/pages/activities_page/activities_details_page/activities_details_page.dart +++ b/lib/pages/activities_page/activities_details_page/activities_details_page.dart @@ -17,6 +17,8 @@ import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bottom_button.dart'; import 'package:akuCommunity/widget/cached_image_wrapper.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t activities_details_page need to be cleaned.") class ActivitiesDetailsPage extends StatefulWidget { final Bundle bundle; ActivitiesDetailsPage({Key key, this.bundle}) : super(key: key); diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index be5c8cd2..15849441 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -1,11 +1,9 @@ -import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/ui/community/community_views/event_detail_page.dart'; import 'package:akuCommunity/utils/bee_date_util.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/picker/bee_image_preview.dart'; import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; From 900f366b2a47d172b6ea3ebef1780e3fa1edba69 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 4 Feb 2021 19:52:03 +0800 Subject: [PATCH 11/11] update user profile avatar's placeholder --- lib/pages/personal/personal_page.dart | 3 +-- lib/pages/personal/user_profile_page.dart | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index 3f768796..d7d51abf 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -124,8 +124,7 @@ class _PersonalIndexState extends State tag: 'AVATAR', child: ClipOval( child: FadeInImage.assetNetwork( - //TODO PLACEHOLDER - placeholder: R.ASSETS_ICONS_PROPOSAL_PNG, + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image( userProvider?.userInfoModel?.imgUrl ?? ''), height: 106.w, diff --git a/lib/pages/personal/user_profile_page.dart b/lib/pages/personal/user_profile_page.dart index c663239f..063178c8 100644 --- a/lib/pages/personal/user_profile_page.dart +++ b/lib/pages/personal/user_profile_page.dart @@ -98,7 +98,7 @@ class _UserProfilePageState extends State { tag: 'AVATAR', child: ClipOval( child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_ICONS_PROPOSAL_PNG, + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image(userProvider.userInfoModel.imgUrl), height: 56.w, width: 56.w,