Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit b8bacd5

Browse files
authored
Web image height capped, center images (#1421)
* larger overlay min height * cap html image heights, center image crops
1 parent 14d17df commit b8bacd5

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

Classes/Issues/Comments/Html/IssueCommentHtmlCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class IssueCommentHtmlCell: IssueCommentBaseCell, ListBindable, UIWebViewD
6464
table{border-spacing: 0; border-collapse: collapse;}
6565
th, td{border: 1px solid #\(Styles.Colors.Gray.border); padding: 6px 13px;}
6666
th{font-weight: \(Styles.Sizes.HTML.boldWeight); text-align: center;}
67-
img{max-width:100%; box-sizing: border-box;}
67+
img{max-width:100%; box-sizing: border-box; max-height: \(Styles.Sizes.maxImageHeight)px;}
6868
</style>
6969
</head><body>
7070
"""

Classes/Issues/Comments/IssueCommentBaseCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protocol IssueCommentDoubleTapDelegate: class {
1414

1515
class IssueCommentBaseCell: UICollectionViewCell, UIGestureRecognizerDelegate {
1616

17-
static let collapseCellMinHeight: CGFloat = 20
17+
static let collapseCellMinHeight: CGFloat = 30
1818

1919
enum BorderType {
2020
case head
@@ -158,7 +158,7 @@ class IssueCommentBaseCell: UICollectionViewCell, UIGestureRecognizerDelegate {
158158

159159
collapseButton.center = CGPoint(
160160
x: collapseFrame.width / 2,
161-
y: collapseFrame.maxY - collapseButton.bounds.height / 2 - 1
161+
y: collapseFrame.maxY - collapseButton.bounds.height / 2
162162
)
163163
}
164164
}

Classes/Views/BoundedImageSize.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
import UIKit
1010

1111
func BoundedImageSize(originalSize: CGSize, containerWidth: CGFloat) -> CGSize {
12-
guard originalSize.width > containerWidth else { return originalSize }
12+
guard originalSize.width > containerWidth else {
13+
return CGSize(
14+
width: containerWidth,
15+
height: min(originalSize.height, Styles.Sizes.maxImageHeight)
16+
)
17+
}
1318
let ratio = originalSize.width / originalSize.height
14-
return CGSize(width: containerWidth, height: min(ceil(containerWidth / ratio), 300))
19+
return CGSize(
20+
width: containerWidth,
21+
height: min(ceil(containerWidth / ratio), Styles.Sizes.maxImageHeight)
22+
)
1523
}

Classes/Views/Styles.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum Styles {
5050
bottom: 0,
5151
right: Styles.Sizes.commentGutter
5252
)
53+
static let maxImageHeight: CGFloat = 300
5354

5455
enum Text {
5556

0 commit comments

Comments
 (0)