From 522b499c6324683db59986fc42a5003154a8b83c Mon Sep 17 00:00:00 2001 From: Eric Andrews Date: Sat, 16 Sep 2023 18:10:10 -0400 Subject: [PATCH 1/2] hacked images to be smooth --- .../Links/Community/CommunityLinkView.swift | 3 ++- .../Shared/Posts/Post Sizes/Large Post.swift | 14 +++++++++++--- Mlem/Views/Shared/Website Icon Complex.swift | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Mlem/Views/Shared/Links/Community/CommunityLinkView.swift b/Mlem/Views/Shared/Links/Community/CommunityLinkView.swift index c9c5eaba9..6efff86dc 100644 --- a/Mlem/Views/Shared/Links/Community/CommunityLinkView.swift +++ b/Mlem/Views/Shared/Links/Community/CommunityLinkView.swift @@ -26,7 +26,8 @@ struct CommunityLinkView: View { } var body: some View { - NavigationLink(value: community) { + // NavigationLink(value: community) { + NavigationLink(.apiCommunity(community)) { HStack { CommunityLabelView( community: community, diff --git a/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift b/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift index 84f3435d2..8d54caf02 100644 --- a/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift +++ b/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift @@ -92,6 +92,9 @@ struct LargePost: View { } } + // REMOVEME: needed for TF hack + var screenWidth: CGFloat = UIScreen.main.bounds.width - (AppConstants.postAndCommentSpacing * 2) + // initializer--used so we can set showNsfwFilterToggle to false when expanded or true when not init( post: PostModel, @@ -202,13 +205,18 @@ struct LargePost: View { if layoutMode != .minimize { CachedImage( url: url, - maxHeight: layoutMode.getMaxHeight(limitHeight), + // maxHeight: layoutMode.getMaxHeight(limitHeight), + // CHANGEME: hack for TF release + fixedSize: CGSize(width: screenWidth, height: screenWidth), dismissCallback: markPostAsRead, cornerRadius: AppConstants.largeItemCornerRadius ) .frame( - maxWidth: .infinity, - maxHeight: layoutMode.getMaxHeight(limitHeight), + // CHANGEME: hack for TF release + width: screenWidth, + height: screenWidth, + // maxWidth: .infinity, + // maxHeight: layoutMode.getMaxHeight(limitHeight), alignment: .top ) .applyNsfwOverlay(post.post.nsfw || post.community.nsfw, canTapFullImage: isExpanded) diff --git a/Mlem/Views/Shared/Website Icon Complex.swift b/Mlem/Views/Shared/Website Icon Complex.swift index 19b18b1ed..187f3126b 100644 --- a/Mlem/Views/Shared/Website Icon Complex.swift +++ b/Mlem/Views/Shared/Website Icon Complex.swift @@ -55,14 +55,23 @@ struct WebsiteIconComplex: View { } return "some website" } + + // REMOVEME: needed for TF hack + var screenWidth: CGFloat = UIScreen.main.bounds.width - (AppConstants.postAndCommentSpacing * 2) var body: some View { VStack(spacing: 0) { if shouldShowWebsitePreviews, let thumbnailURL = post.thumbnailImageUrl { - CachedImage(url: thumbnailURL, shouldExpand: false) - .frame(maxHeight: 400) - .applyNsfwOverlay(post.nsfw) - .clipped() + CachedImage( + url: thumbnailURL, + shouldExpand: false, + // CHANGEME: hack for TF release + fixedSize: CGSize(width: screenWidth, height: screenWidth * 0.66) + ) + // .frame(maxHeight: 400) + .frame(width: screenWidth, height: screenWidth * 0.66) + .applyNsfwOverlay(post.nsfw) + .clipped() } VStack(alignment: .leading, spacing: AppConstants.postAndCommentSpacing) { From aae96e5c8686b7dcaf64a63f3e7a11bb7d79e0b6 Mon Sep 17 00:00:00 2001 From: Eric Andrews Date: Sat, 16 Sep 2023 18:30:10 -0400 Subject: [PATCH 2/2] added more hack for ipad --- .../Shared/Posts/Post Sizes/Large Post.swift | 21 +++++++++++-------- Mlem/Views/Shared/Website Icon Complex.swift | 7 +++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift b/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift index 8d54caf02..663eca7d5 100644 --- a/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift +++ b/Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift @@ -93,7 +93,10 @@ struct LargePost: View { } // REMOVEME: needed for TF hack + @Environment(\.horizontalSizeClass) var horizontalSizeClass var screenWidth: CGFloat = UIScreen.main.bounds.width - (AppConstants.postAndCommentSpacing * 2) + var imageWidth: CGFloat { horizontalSizeClass == .regular ? screenWidth * 0.8 : screenWidth } + var imageHeight: CGFloat { horizontalSizeClass == .regular ? 600 : screenWidth } // initializer--used so we can set showNsfwFilterToggle to false when expanded or true when not init( @@ -207,18 +210,18 @@ struct LargePost: View { url: url, // maxHeight: layoutMode.getMaxHeight(limitHeight), // CHANGEME: hack for TF release - fixedSize: CGSize(width: screenWidth, height: screenWidth), + fixedSize: CGSize(width: imageWidth, height: imageHeight), dismissCallback: markPostAsRead, cornerRadius: AppConstants.largeItemCornerRadius ) - .frame( - // CHANGEME: hack for TF release - width: screenWidth, - height: screenWidth, - // maxWidth: .infinity, - // maxHeight: layoutMode.getMaxHeight(limitHeight), - alignment: .top - ) + // CHANGEME: hack for TF release + .frame(height: imageHeight) + .frame(maxWidth: .infinity, alignment: .center) +// .frame( +// maxWidth: .infinity, +// maxHeight: layoutMode.getMaxHeight(limitHeight), +// alignment: .top +// ) .applyNsfwOverlay(post.post.nsfw || post.community.nsfw, canTapFullImage: isExpanded) .clipped() } diff --git a/Mlem/Views/Shared/Website Icon Complex.swift b/Mlem/Views/Shared/Website Icon Complex.swift index 187f3126b..bd99e2f35 100644 --- a/Mlem/Views/Shared/Website Icon Complex.swift +++ b/Mlem/Views/Shared/Website Icon Complex.swift @@ -57,7 +57,10 @@ struct WebsiteIconComplex: View { } // REMOVEME: needed for TF hack + @Environment(\.horizontalSizeClass) var horizontalSizeClass var screenWidth: CGFloat = UIScreen.main.bounds.width - (AppConstants.postAndCommentSpacing * 2) + var imageWidth: CGFloat { horizontalSizeClass == .regular ? screenWidth * 0.8 : screenWidth } + var imageHeight: CGFloat { horizontalSizeClass == .regular ? 400 : screenWidth * 0.66 } var body: some View { VStack(spacing: 0) { @@ -66,10 +69,10 @@ struct WebsiteIconComplex: View { url: thumbnailURL, shouldExpand: false, // CHANGEME: hack for TF release - fixedSize: CGSize(width: screenWidth, height: screenWidth * 0.66) + fixedSize: CGSize(width: imageWidth, height: imageHeight) ) // .frame(maxHeight: 400) - .frame(width: screenWidth, height: screenWidth * 0.66) + .frame(width: imageWidth, height: imageHeight) .applyNsfwOverlay(post.nsfw) .clipped() }