@@ -87,6 +87,7 @@ private final class ReaderPostCellView: UIView {
8787
8888 private var viewModel : ReaderPostCellViewModel ? // important: has to retain
8989 private let coverAspectRatio : CGFloat = 239.0 / 358.0
90+ private static let regularCoverWidth : CGFloat = 200
9091 private var imageViewConstraints : [ NSLayoutConstraint ] = [ ]
9192 private var cancellables : [ AnyCancellable ] = [ ]
9293
@@ -202,7 +203,7 @@ private final class ReaderPostCellView: UIView {
202203 } else {
203204 imageViewConstraints = [
204205 imageView. heightAnchor. constraint ( equalTo: imageView. widthAnchor, multiplier: coverAspectRatio) ,
205- imageView. widthAnchor. constraint ( equalToConstant: 200 )
206+ imageView. widthAnchor. constraint ( equalToConstant: Self . regularCoverWidth )
206207 ]
207208 }
208209 NSLayoutConstraint . activate ( imageViewConstraints)
@@ -271,14 +272,29 @@ private final class ReaderPostCellView: UIView {
271272 detailsLabel. text = viewModel. details
272273
273274 imageView. isHidden = viewModel. imageURL == nil
275+
274276 if let imageURL = viewModel. imageURL {
275- imageView. setImage ( with: imageURL)
277+ imageView. setImage ( with: imageURL, size : preferredCoverSize )
276278 }
277279
278280 configureToolbar ( with: viewModel. toolbar)
279281 configureToolbarAccessibility ( with: viewModel. toolbar)
280282 }
281283
284+ private var preferredCoverSize : CGSize ? {
285+ guard let window = window ?? UIApplication . shared. mainWindow else { return nil }
286+ return Self . preferredCoverSize ( in: window, isCompact: isCompact)
287+ }
288+
289+ static func preferredCoverSize( in window: UIWindow , isCompact: Bool ) -> CGSize {
290+ var coverWidth = Self . regularCoverWidth
291+ if isCompact {
292+ coverWidth = min ( window. bounds. width, window. bounds. height) - ReaderStreamBaseCell. insets. left * 2
293+ }
294+ return CGSize ( width: coverWidth, height: coverWidth)
295+ . scaled ( by: min ( 2 , window. traitCollection. displayScale) )
296+ }
297+
282298 private func configureToolbar( with viewModel: ReaderPostToolbarViewModel ) {
283299 buttons. bookmark. configuration = {
284300 var configuration = buttons. bookmark. configuration ?? . plain( )
0 commit comments