diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 2b5c52d3..662e6f46 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -170,9 +170,20 @@ 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'; + + String get newEventList => '/user/gambit/list'; + + ///社区活动: 写帖子(添加主题信息) + String get addEvent => '/user/gambit/writePost'; + + ///社区话题:app用户点赞/取消点赞 + String get like => '/user/gambit/likes'; + + ///社区话题:查询活跃话题(取前4个) + String get hotTopic => '/user/gambit/findActivityGambit'; } class _Upload { @@ -184,4 +195,6 @@ class _Upload { ///上传报事报修信息 报事报修照片 String get uploadRepair => '/user/upload/uploadRepair'; + + String get uploadEvent => '/user/upload/uploadGambit'; } 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/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/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, 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 4d58a2d9..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); @@ -39,6 +41,11 @@ class _CommunityPageState extends State path: R.ASSETS_ICONS_ALARM_PNG, ), ], + fab: FloatingActionButton( + onPressed: () => Get.to(AddNewEventPage()), + heroTag: 'event_add', + child: Icon(Icons.add), + ), appBarBottom: PreferredSize( preferredSize: Size.fromHeight(48), child: Align( 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/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart index 626bfbf8..8f49c4b2 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,42 @@ 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( + content: item.content, + name: item.createName ?? '', + topic: item.gambitTitle ?? '', + contentImg: item.imgUrls, + date: item.date, + id: item.createId, + headImg: item.headSculptureImgUrl, + themeId: item.id, + initLike: item.isLike == 1, + ); + }, + itemCount: items.length, + ); + }, + ); } @override 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 704d41a6..4ee5c422 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'; @@ -28,6 +27,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 @@ -55,11 +59,15 @@ 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, - title: item.gambitTitle, + topic: item.gambitTitle, 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..15849441 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -1,25 +1,44 @@ 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/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'; +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'; class ChatCard extends StatefulWidget { final String name; - final String title; + final String topic; final List headImg; final List contentImg; final DateTime date; - final bool canDelete; + final bool initLike; + final String content; + + ///userID + final int id; + + final int themeId; + ChatCard({ Key key, - this.name, - this.title, - this.headImg, - this.contentImg, + @required this.name, + @required this.topic, + @required this.headImg, + @required this.contentImg, @required this.date, - this.canDelete, + this.initLike = false, + @required this.id, + @required this.content, + @required this.themeId, }) : super(key: key); @override @@ -27,6 +46,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 ''; @@ -37,20 +63,146 @@ 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() { + 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: () async { + cancel(); + await NetUtil().get( + API.community.like, + params: {'themeId': widget.id}, + showMessage: true, + ); + 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 +212,95 @@ 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: () { + Get.to(EventDetailPage()); + }, + 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.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) + .timeAgo + .text + .size(28.sp) + .color(Color(0xFF999999)) + .make(), + _isMyself + ? FlatButton( + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + height: 48.w, + onPressed: () async { + bool result = + await Get.dialog(CupertinoAlertDialog( + title: '你确定删除吗'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '取消'.text.black.isIntrinsic.make(), + onPressed: () => Get.back(), + ), + CupertinoDialogAction( + child: '确定' + .text + .color(Colors.orange) + .isIntrinsic + .make(), + onPressed: () => Get.back(result: true), + ), + ], + )); + + if (result == true) { + //TODO delete operation + } + }, + child: '删除'.text.black.size(28.sp).make(), + ) + : SizedBox(), + Spacer(), + _buildMoreButton(), + ], + ), + ], + ).expand(), + ], + ).p(20.w), + ), ); } } 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, 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), ), ), );