From 2bdbd99efb3ead94e7a8d2600e12883070071703 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sun, 7 Feb 2021 16:42:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E6=8A=A5=E5=90=8D=E6=8E=A5?= =?UTF-8?q?=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 | 2 ++ lib/ui/community/activity/activity_card.dart | 10 +++++++--- .../activity/activity_detail_page.dart | 20 ++++++++++++++++++- lib/widget/others/stack_avatar.dart | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 3628907f..e9dae505 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -203,6 +203,8 @@ class _Community { ///社区话题:评论 String get sendAComment => '/user/gambit/comment'; + ///社区活动:报名 + String get signUpActivity => '/user/activity/signUp'; } class _Upload { diff --git a/lib/ui/community/activity/activity_card.dart b/lib/ui/community/activity/activity_card.dart index bb47faf5..b21884dc 100644 --- a/lib/ui/community/activity/activity_card.dart +++ b/lib/ui/community/activity/activity_card.dart @@ -22,7 +22,7 @@ class ActivityCard extends StatelessWidget { String get firstPath => (model.imgUrls?.isEmpty ?? true) ? null : model.imgUrls.first.url; - + bool get outdate => model.end.compareTo(DateTime.now()) == -1; Widget build(BuildContext context) { return MaterialButton( clipBehavior: Clip.antiAlias, @@ -51,6 +51,7 @@ class ActivityCard extends StatelessWidget { image: API.image(firstPath), height: 210.w, width: double.infinity, + fit: BoxFit.cover, ), ), ), @@ -87,8 +88,11 @@ class ActivityCard extends StatelessWidget { shape: StadiumBorder(), height: 44.w, minWidth: 120.w, - onPressed: () {}, - child: '去看看'.text.size(20.sp).bold.make(), + disabledColor: Color(0xFFABABAB), + onPressed: outdate ? null : ActivityDetailPage(id: model.id).to, + child: outdate + ? '已结束'.text.size(20.sp).bold.make() + : '去看看'.text.size(20.sp).bold.make(), ), ].row().p(24.w), ], diff --git a/lib/ui/community/activity/activity_detail_page.dart b/lib/ui/community/activity/activity_detail_page.dart index 4a3d2ca1..b7534570 100644 --- a/lib/ui/community/activity/activity_detail_page.dart +++ b/lib/ui/community/activity/activity_detail_page.dart @@ -1,4 +1,6 @@ // Flutter imports: +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -31,7 +33,8 @@ class ActivityDetailPage extends StatefulWidget { class _ActivityDetailPageState extends State { ActivityDetailModel model; EasyRefreshController _refreshController = EasyRefreshController(); - + bool get outdate => + (model?.registEndDate ?? DateTime(0)).compareTo(DateTime.now()) == -1; Widget get emptyWidget => Shimmer.fromColors( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -121,6 +124,7 @@ class _ActivityDetailPageState extends State { child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: e.url, + fit: BoxFit.cover, ), ), ), @@ -184,6 +188,20 @@ class _ActivityDetailPageState extends State { ], ), ).material(color: Colors.white), + bottomNavi: outdate + ? SizedBox() + : BottomButton( + onPressed: () async { + VoidCallback cancel = BotToast.showLoading(); + NetUtil().get( + API.community.signUpActivity, + params: {'activityId': widget.id}, + showMessage: true, + ); + cancel(); + }, + child: '我要报名'.text.make(), + ), ); } } diff --git a/lib/widget/others/stack_avatar.dart b/lib/widget/others/stack_avatar.dart index 05662077..606b664a 100644 --- a/lib/widget/others/stack_avatar.dart +++ b/lib/widget/others/stack_avatar.dart @@ -34,6 +34,7 @@ class StackAvatar extends StatelessWidget { width: 44.w, placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image(avatars[index]), + fit: BoxFit.cover, ), ), );