Skip to content

Commit

Permalink
fixed scrolling regression
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Sep 30, 2023
1 parent 238dac3 commit c9878ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
9 changes: 6 additions & 3 deletions Mlem/Views/Shared/Cached Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ struct CachedImage: View {
} else if state.error != nil {
// Indicates an error
imageNotFound()
.frame(idealWidth: size.width, maxHeight: size.height)
.frame(idealWidth: size.width)
.frame(height: size.height)
.background(errorBackgroundColor)
} else {
ProgressView() // Acts as a placeholder
.frame(idealWidth: size.width, maxHeight: size.height)
.frame(idealWidth: size.width)
.frame(height: size.height)
}
}
.processors([
Expand All @@ -155,7 +157,8 @@ struct CachedImage: View {
contentMode: contentMode == .fill ? .aspectFill : .aspectFit
)
])
.frame(idealWidth: size.width, maxHeight: size.height)
.frame(idealWidth: size.width)
.frame(height: size.height)
}

static func imageNotFoundDefault() -> AnyView {
Expand Down
23 changes: 6 additions & 17 deletions Mlem/Views/Shared/Posts/Post Sizes/Large Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ 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(
post: PostModel,
Expand Down Expand Up @@ -208,20 +202,15 @@ struct LargePost: View {
if layoutMode != .minimize {
CachedImage(
url: url,
// maxHeight: layoutMode.getMaxHeight(limitHeight),
// CHANGEME: hack for TF release
fixedSize: CGSize(width: imageWidth, height: imageHeight),
maxHeight: layoutMode.getMaxHeight(limitHeight),
dismissCallback: markPostAsRead,
cornerRadius: AppConstants.largeItemCornerRadius
)
// CHANGEME: hack for TF release
.frame(height: imageHeight)
.frame(maxWidth: .infinity, alignment: .center)
// .frame(
// maxWidth: .infinity,
// maxHeight: layoutMode.getMaxHeight(limitHeight),
// alignment: .top
// )
.frame(
maxWidth: .infinity,
maxHeight: layoutMode.getMaxHeight(limitHeight),
alignment: .top
)
.applyNsfwOverlay(post.post.nsfw || post.community.nsfw, canTapFullImage: isExpanded)
.clipped()
}
Expand Down

0 comments on commit c9878ac

Please sign in to comment.