From cc6545df17939f6094a9440d201c47a07916f27e Mon Sep 17 00:00:00 2001 From: steven12138 Date: Fri, 15 Mar 2024 02:24:43 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AEbug,=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E5=88=B0=E5=87=86=E5=A4=87=E6=89=93?= =?UTF-8?q?=E5=8C=85=E7=9A=84=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了图片超出范围 加载不流畅 多重按钮的bug --- .../view/components/normal_comment_card.dart | 7 +- lib/feedback/view/components/post_card.dart | 241 ++++++++---------- .../view/image_view/image_view_page.dart | 14 +- lib/feedback/view/post_detail_page.dart | 39 ++- pubspec.yaml | 2 +- 5 files changed, 152 insertions(+), 151 deletions(-) diff --git a/lib/feedback/view/components/normal_comment_card.dart b/lib/feedback/view/components/normal_comment_card.dart index 1b615b72..623e0979 100644 --- a/lib/feedback/view/components/normal_comment_card.dart +++ b/lib/feedback/view/components/normal_comment_card.dart @@ -223,9 +223,10 @@ class _NCommentCardState extends State ), ), CupertinoActionSheetAction( - onPressed: (){ + onPressed: () { Navigator.pop(context); - if (Provider.of(context, listen: false) + if (Provider.of(context, + listen: false) .inputFieldEnabled) { context.read().clearAndClose(); } else { @@ -800,7 +801,7 @@ class _NCommentCardState extends State )), ], ), - Positioned(right: 8.w, child: commentMenuButton) + // Positioned(right: 8.w, child: commentMenuButton) ], ); } diff --git a/lib/feedback/view/components/post_card.dart b/lib/feedback/view/components/post_card.dart index e840faff..82afb2d2 100644 --- a/lib/feedback/view/components/post_card.dart +++ b/lib/feedback/view/components/post_card.dart @@ -184,12 +184,13 @@ class _PostCardNormalState extends State { )); /// 图片 - var outerImages = - post.imageUrls.length == 1 ? outerSingleImage : outerMultipleImage; + var outerImages = post.imageUrls.length == 1 + ? outerSingleImage + : multiImage(tapPreview: false); var innerImages = post.imageUrls.length == 1 ? InnerSingleImageWidget(post.imageUrls[0]) - : innerMultipleImage; + : multiImage(); /// 评论点赞点踩浏览量 var likeUnlikeVisit = Row( @@ -339,74 +340,75 @@ class _PostCardNormalState extends State { controller: widget.screenshotController ?? ScreenshotController(), child: Container( color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor), - child: widget.outer - // outer 框架 - ? GestureDetector( - onTap: () { - if (SplitUtil.needHorizontalView) { - context.read().clearAndSetSplitPost(post); - } else { - FeedbackService.visitPost( - id: widget.post.id, onFailure: (_) {}); - Navigator.pushNamed( - context, - FeedbackRouter.detail, - arguments: post, - ); - } - }, - child: Container( - padding: EdgeInsets.fromLTRB(0, 0, 0, SplitUtil.h * 8), - color: WpyTheme.of(context) - .get(WpyColorKey.primaryBackgroundColor), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ...head, - if (post.imageUrls.isNotEmpty) - Padding( - padding: EdgeInsets.only( - left: SplitUtil.w * 16, - right: SplitUtil.w * 16, - bottom: SplitUtil.h * 8), - child: outerImages), - Padding( - padding: EdgeInsets.only(left: SplitUtil.w * 10), - child: likeUnlikeVisit, - ) - ], - ), - ), - ) - - // inner 框架 - : Container( + child: Builder(builder: (context) { + if (widget.outer) { + return GestureDetector( + onTap: () { + if (SplitUtil.needHorizontalView) { + context.read().clearAndSetSplitPost(post); + } else { + FeedbackService.visitPost( + id: widget.post.id, onFailure: (_) {}); + Navigator.pushNamed( + context, + FeedbackRouter.detail, + arguments: post, + ); + } + }, + child: Container( padding: EdgeInsets.fromLTRB(0, 0, 0, SplitUtil.h * 8), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: WpyTheme.of(context) - .get(WpyColorKey.lightBorderColor), - width: 1.h))), + color: WpyTheme.of(context) + .get(WpyColorKey.primaryBackgroundColor), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ...head, if (post.imageUrls.isNotEmpty) Padding( - padding: EdgeInsets.only( - left: SplitUtil.w * 16, - right: SplitUtil.w * 16, - bottom: SplitUtil.h * 10), - child: innerImages, - ), + padding: EdgeInsets.only( + left: SplitUtil.w * 16, + right: SplitUtil.w * 16, + bottom: SplitUtil.h * 8), + child: outerImages), Padding( - padding: EdgeInsets.only(left: SplitUtil.w * 8), - child: tagCampusVisit, - ), + padding: EdgeInsets.only(left: SplitUtil.w * 10), + child: likeUnlikeVisit, + ) ], ), ), + ); + } else { + return Container( + padding: EdgeInsets.fromLTRB(0, 0, 0, SplitUtil.h * 8), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: WpyTheme.of(context) + .get(WpyColorKey.lightBorderColor), + width: 1.h))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...head, + if (post.imageUrls.isNotEmpty) + Padding( + padding: EdgeInsets.only( + left: SplitUtil.w * 16, + right: SplitUtil.w * 16, + bottom: SplitUtil.h * 10), + child: innerImages, + ), + Padding( + padding: EdgeInsets.only(left: SplitUtil.w * 8), + child: tagCampusVisit, + ), + ], + ), + ); + } + }), ), ); @@ -415,76 +417,59 @@ class _PostCardNormalState extends State { ///////////////////////////////////////////////////////// } - Widget get outerSingleImage { - return ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(8.r)), - child: Container( - width: SplitUtil.sw - SplitUtil.w * 20 - SplitUtil.toolbarWidth, - height: SplitUtil.w * 150, - color: WpyTheme.of(context).get(WpyColorKey.iconAnimationStartColor), - child: WpyPic( - picBaseUrl + 'origin/' + post.imageUrls[0], - width: 350.w, - height: 197.w, - fit: BoxFit.cover, - alignment: Alignment.topCenter, - ), - )); - } - - Widget get innerMultipleImage => Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: List.generate( - post.imageUrls.length, - (index) => WButton( - onPressed: () => Navigator.pushNamed( - context, - FeedbackRouter.imageView, - arguments: ImageViewPageArgs( - post.imageUrls, post.imageUrls.length, index, false), - ), - child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(8.r)), - child: WpyPic(picBaseUrl + 'thumb/' + post.imageUrls[index], - fit: BoxFit.cover, - width: ((SplitUtil.sw - - SplitUtil.w * 20 - - SplitUtil.toolbarWidth) - - (post.imageUrls.length - 1) * SplitUtil.w * 6) / - post.imageUrls.length, - height: ((SplitUtil.sw - - SplitUtil.w * 20 - - SplitUtil.toolbarWidth) - - (post.imageUrls.length - 1) * SplitUtil.w * 6) / - post.imageUrls.length, - withHolder: true), - ), - ), + Widget get outerSingleImage => ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(8.r)), + child: Container( + width: SplitUtil.sw - SplitUtil.w * 20 - SplitUtil.toolbarWidth, + height: SplitUtil.w * 150, + color: WpyTheme.of(context).get(WpyColorKey.iconAnimationStartColor), + child: WpyPic( + picBaseUrl + 'origin/' + post.imageUrls[0], + width: 350.w, + height: 197.w, + fit: BoxFit.cover, + alignment: Alignment.topCenter, ), - ); - - Widget get outerMultipleImage => Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: List.generate( - post.imageUrls.length, - (index) => ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(8.r)), - child: WpyPic(picBaseUrl + 'thumb/' + post.imageUrls[index], - fit: BoxFit.cover, - width: ((SplitUtil.sw - - SplitUtil.w * 20 - - SplitUtil.toolbarWidth) - - (post.imageUrls.length - 1) * SplitUtil.w * 6) / - post.imageUrls.length, - height: ((SplitUtil.sw - - SplitUtil.w * 20 - - SplitUtil.toolbarWidth) - - (post.imageUrls.length - 1) * SplitUtil.w * 6) / - post.imageUrls.length, - withHolder: true), + )); + + Widget multiImage({bool tapPreview = true}) => + LayoutBuilder(builder: (context, layout) { + double padding = 4.w; + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: List.generate( + post.imageUrls.length, + (index) => Padding( + padding: EdgeInsets.all(padding), + child: IgnorePointer( + ignoring: !tapPreview, + child: GestureDetector( + onTap: () { + Navigator.pushNamed( + context, + FeedbackRouter.imageView, + arguments: ImageViewPageArgs( + post.imageUrls, post.imageUrls.length, index, false), + ); + }, + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(8.r)), + child: WpyPic( + picBaseUrl + 'thumb/' + post.imageUrls[index], + fit: BoxFit.cover, + width: + layout.maxWidth / post.imageUrls.length - padding * 2, + height: + layout.maxWidth / post.imageUrls.length - padding * 2, + withHolder: true, + ), + ), + ), + ), + ), ), - ), - ); + ); + }); } class InnerSingleImageWidget extends StatefulWidget { diff --git a/lib/feedback/view/image_view/image_view_page.dart b/lib/feedback/view/image_view/image_view_page.dart index adb16f13..49cec68f 100644 --- a/lib/feedback/view/image_view/image_view_page.dart +++ b/lib/feedback/view/image_view/image_view_page.dart @@ -81,8 +81,8 @@ class _ImageViewPageState extends State { scrollDirection: Axis.horizontal, itemCount: widget.args.urlListLength, backgroundDecoration: BoxDecoration( - color: WpyTheme.of(context) - .get(WpyColorKey.reverseBackgroundColor)), + color: + WpyTheme.of(context).get(WpyColorKey.reverseBackgroundColor)), pageController: PageController( initialPage: indexNow, ), @@ -99,10 +99,12 @@ class _ImageViewPageState extends State { child: Container( decoration: BoxDecoration( color: WpyTheme.of(context) - .get(WpyColorKey.labelTextColor), + .get(WpyColorKey.labelTextColor) + .withOpacity(0.8), borderRadius: BorderRadius.all(Radius.circular(14.r))), - padding: EdgeInsets.fromLTRB(14.w, 10.w, 14.w, 14.w), + // 这里设置不一样是因为 返回图标的中心靠右 往左稍微拉一点 + padding: EdgeInsets.fromLTRB(12.w, 10.w, 14.w, 10.w), child: Icon( CupertinoIcons.back, color: WpyTheme.of(context) @@ -120,7 +122,9 @@ class _ImageViewPageState extends State { right: 10.w, child: Container( decoration: BoxDecoration( - color: WpyTheme.of(context).get(WpyColorKey.labelTextColor), + color: WpyTheme.of(context) + .get(WpyColorKey.labelTextColor) + .withOpacity(0.7), borderRadius: BorderRadius.all(Radius.circular(14.r))), padding: EdgeInsets.fromLTRB(14.w, 10.w, 14.w, 14.w), child: Row( diff --git a/lib/feedback/view/post_detail_page.dart b/lib/feedback/view/post_detail_page.dart index fd2f7e19..d46fef7a 100644 --- a/lib/feedback/view/post_detail_page.dart +++ b/lib/feedback/view/post_detail_page.dart @@ -122,17 +122,19 @@ class _PostDetailPageState extends State void initWhileChangingPost() { context.read().inputFieldEnabled = false; context.read().replyTo = 0; - _onRefresh(); + _onRefresh(isInitial: true); } /// iOS显示拉黑按钮 bool _showBlockButton = false; - _onRefresh() { + _onRefresh({ + bool isInitial = false, + }) { currentPage = 1; _refreshController.resetNoData(); setState(() { - _showPostCard = false; + _showPostCard = isInitial; }); _commentList.clear(); _initPostAndComments( @@ -377,7 +379,8 @@ class _PostDetailPageState extends State }, child: value == 1 ? Container( - padding: EdgeInsets.fromLTRB(0, SplitUtil.h * 2, 0, SplitUtil.h * 1), + padding: EdgeInsets.fromLTRB( + 0, SplitUtil.h * 2, 0, SplitUtil.h * 1), decoration: BoxDecoration( color: WpyTheme.of(context) .get(WpyColorKey.primaryActionColor), @@ -390,7 +393,8 @@ class _PostDetailPageState extends State .sp(14)), ) : Container( - padding: EdgeInsets.fromLTRB(0, SplitUtil.h * 2, 0, SplitUtil.h * 1), + padding: EdgeInsets.fromLTRB( + 0, SplitUtil.h * 2, 0, SplitUtil.h * 1), decoration: BoxDecoration( color: WpyTheme.of(context).get( WpyColorKey.secondaryBackgroundColor), @@ -622,7 +626,7 @@ class _PostDetailPageState extends State height: SplitUtil.w * 24, color: WpyTheme.of(context) .get(WpyColorKey - .basicTextColor), + .basicTextColor), ), onPressed: () => imageSelectionKey @@ -704,10 +708,13 @@ class _PostDetailPageState extends State }, child: Container( height: SplitUtil.h * 36, - margin: - EdgeInsets.fromLTRB(SplitUtil.w * 8, SplitUtil.h * 13, 0, SplitUtil.h * 13), - padding: - EdgeInsets.symmetric(horizontal: SplitUtil.w * 8), + margin: EdgeInsets.fromLTRB( + SplitUtil.w * 8, + SplitUtil.h * 13, + 0, + SplitUtil.h * 13), + padding: EdgeInsets.symmetric( + horizontal: SplitUtil.w * 8), child: Align( alignment: Alignment.centerLeft, child: widget.post.type == 1 @@ -723,10 +730,12 @@ class _PostDetailPageState extends State .sp(12)), ), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18.r), + borderRadius: + BorderRadius.circular(18.r), color: WpyTheme.of(context).get( WpyColorKey - .secondaryBackgroundColor), )), + .secondaryBackgroundColor), + )), ), ), ], @@ -1008,7 +1017,8 @@ class _PostDetailPageState extends State : MediaQuery.of(context).padding.top) : EdgeInsets.zero, child: Scaffold( - backgroundColor: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor), + backgroundColor: + WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor), appBar: appBar, body: body, ), @@ -1144,7 +1154,8 @@ class CommentInputFieldState extends State { border: OutlineInputBorder( borderSide: BorderSide.none, ), - contentPadding: EdgeInsets.symmetric(vertical: SplitUtil.h * 8, horizontal: SplitUtil.w * 20), + contentPadding: EdgeInsets.symmetric( + vertical: SplitUtil.h * 8, horizontal: SplitUtil.w * 20), fillColor: WpyTheme.of(context).get(WpyColorKey.secondaryBackgroundColor), hintStyle: TextStyle( diff --git a/pubspec.yaml b/pubspec.yaml index 50f85564..232a0462 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # 请保证 'package:we_pei_yang_flutter/commons/environment/config.dart' # 中的 version 和 versionCode 保持一致 -version: 4.3.19+136 +version: 4.4.0+137 # 打包代码 flutter build apk --split-per-abi # flutter build apk --target-platform android-arm,android-arm64 --split-per-abi