From e8198c98b1e4dfa8b8c548388091e0ee2ee6cfcf Mon Sep 17 00:00:00 2001 From: Joel Hernandez Date: Thu, 28 Mar 2019 18:08:15 +0100 Subject: [PATCH] :fire: remove post height calculation --- ios/Podfile.lock | 4 +- ios/Runner.xcodeproj/project.pbxproj | 2 +- lib/widgets/post/post.dart | 100 ++++++--------------------- 3 files changed, 25 insertions(+), 81 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a13235dd7..8d603742c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -37,7 +37,7 @@ PODS: DEPENDENCIES: - device_info (from `.symlinks/plugins/device_info/ios`) - - Flutter (from `.symlinks/flutter/ios`) + - Flutter (from `.symlinks/flutter/ios-release`) - flutter_exif_rotation (from `.symlinks/plugins/flutter_exif_rotation/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - image_cropper (from `.symlinks/plugins/image_cropper/ios`) @@ -62,7 +62,7 @@ EXTERNAL SOURCES: device_info: :path: ".symlinks/plugins/device_info/ios" Flutter: - :path: ".symlinks/flutter/ios" + :path: ".symlinks/flutter/ios-release" flutter_exif_rotation: :path: ".symlinks/plugins/flutter_exif_rotation/ios" flutter_secure_storage: diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 199bf340e..af421a92a 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -703,7 +703,7 @@ ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", + "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( diff --git a/lib/widgets/post/post.dart b/lib/widgets/post/post.dart index 0306abb23..caa460363 100644 --- a/lib/widgets/post/post.dart +++ b/lib/widgets/post/post.dart @@ -12,91 +12,35 @@ import 'package:flutter/material.dart'; class OBPost extends StatelessWidget { final Post post; final OnPostDeleted onPostDeleted; - static const HEIGHT_POST_HEADER = 72.0; - static const HEIGHT_POST_REACTIONS = 35.0; - static const HEIGHT_POST_CIRCLES = 26.0; - static const HEIGHT_POST_ACTIONS = 46.0; - static const HEIGHT_POST_COMMENTS = 34.0; - static const HEIGHT_POST_DIVIDER = 5.5; - static const HEIGHT_SIZED_BOX = 16.0; - static const TOTAL_PADDING_POST_TEXT = 40.0; - static const SCHRODINGERS_HEIGHT = 2.0; // @todo: find out where its coming from - static const TOTAL_FIXED_HEIGHT = HEIGHT_POST_HEADER - + HEIGHT_POST_REACTIONS + HEIGHT_POST_ACTIONS + HEIGHT_SIZED_BOX + HEIGHT_POST_DIVIDER + SCHRODINGERS_HEIGHT; const OBPost(this.post, {Key key, @required this.onPostDeleted}) : super(key: key); @override Widget build(BuildContext context) { - - return SizedBox( - height: _getTotalPostHeight(context), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - OBPostHeader( - post: post, - onPostDeleted: onPostDeleted, - ), - OBPostBody(post), - OBPostReactions(post), - OBPostCircles(post), - OBPostComments( - post, - ), - OBPostActions( - post, - ), - const SizedBox( - height: 16, - ), - OBPostDivider(), - ], + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + OBPostHeader( + post: post, + onPostDeleted: onPostDeleted, + ), + OBPostBody(post), + OBPostReactions(post), + OBPostCircles(post), + OBPostComments( + post, + ), + OBPostActions( + post, ), + const SizedBox( + height: 16, + ), + OBPostDivider(), + ], ); } - - double _getTotalPostHeight(BuildContext context) { - double aspectRatio; - double finalMediaScreenHeight = 0.0; - double finalTextHeight = 0.0; - double totalHeightPost = 0.0; - double screenWidth = MediaQuery.of(context).size.width; - if (post.hasImage()) { - aspectRatio = post.getImageWidth() / post.getImageHeight(); - finalMediaScreenHeight = screenWidth/aspectRatio; - } - if (post.hasVideo()) { - aspectRatio = post.getVideoWidth() / post.getVideoHeight(); - finalMediaScreenHeight = screenWidth/aspectRatio; - } - - if (post.hasText()) { - TextStyle style = TextStyle(fontSize: 16.0); - TextSpan text = - new TextSpan(text: post.text, style: style); - - TextPainter textPainter = new TextPainter( - text: text, - textDirection: TextDirection.ltr, - textAlign: TextAlign.left, - ); - textPainter.layout(maxWidth: screenWidth - 40.0); //padding is 20 in OBPostBodyText - finalTextHeight = textPainter.size.height + TOTAL_PADDING_POST_TEXT; - } - - if (post.hasCircles() || (post.isEncircled != null && post.isEncircled)) { - totalHeightPost = totalHeightPost + HEIGHT_POST_CIRCLES; - } - - if (post.hasCommentsCount()) { - totalHeightPost = totalHeightPost + HEIGHT_POST_COMMENTS; - } - - totalHeightPost = totalHeightPost + finalMediaScreenHeight + finalTextHeight + TOTAL_FIXED_HEIGHT; - - return totalHeightPost; - } }