Skip to content

Commit 2484625

Browse files
committed
Update constraint and test case
1 parent 1b40f2a commit 2484625

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Mixin/UserInterface/Controllers/Chat/Model/PhotoSizeCalculator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ enum PhotoSizeCalculator {
2020
if contentRatio > 1 {
2121
if contentRatio > Height.max / Width.max {
2222
height = Height.max
23-
width = round(height / contentRatio)
23+
width = max(Width.min, round(height / contentRatio))
2424
} else {
2525
width = Width.max
26-
height = round(width * contentRatio)
26+
height = min(Height.max, round(width * contentRatio))
2727
}
2828
} else {
2929
width = Width.max

MixinTests/PhotoDisplayTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ class PhotoDisplayTests: XCTestCase {
3636
let expected = [
3737
// Bad input
3838
CGSize(width: 120, height: 120),
39-
39+
4040
// General photos
4141
CGSize(width: 210, height: 280),
4242
CGSize(width: 210, height: 158),
4343

4444
// Panoramas
4545
CGSize(width: 210, height: 120),
46-
CGSize(width: 97, height: 280),
46+
CGSize(width: 120, height: 280),
4747

4848
// Article
49-
CGSize(width: 8, height: 280),
49+
CGSize(width: 120, height: 280),
5050

5151
// Irregular shapes
52-
CGSize(width: 112, height: 280),
52+
CGSize(width: 120, height: 280),
5353
CGSize(width: 120, height: 280),
5454
CGSize(width: 120, height: 280),
5555

0 commit comments

Comments
 (0)