forked from square/Blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request square#450 from square/watt/caffeinated-layout/8
Infinite size elements
- Loading branch information
Showing
23 changed files
with
244 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import CoreGraphics | ||
|
||
extension CGSize { | ||
/// A size with `infinity` in both dimensions. | ||
public static let infinity = CGSize(width: CGFloat.infinity, height: .infinity) | ||
|
||
/// Returns a size with infinite dimensions replaced by the values from the given replacement. | ||
public func replacingInfinity(with replacement: CGSize) -> CGSize { | ||
assert(replacement.isFinite, "Infinity replacement value must be finite") | ||
|
||
return CGSize( | ||
width: width.replacingInfinity(with: replacement.width), | ||
height: height.replacingInfinity(with: replacement.height) | ||
) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
BlueprintUI/Sources/Extensions/FloatingPoint+Blueprint.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Foundation | ||
|
||
extension FloatingPoint { | ||
/// Returns `replacement` if `self.isInfinite` is `true`, or `self` if `self` is finite. | ||
public func replacingInfinity(with replacement: Self) -> Self { | ||
assert(replacement.isFinite, "Infinity replacement value must be finite") | ||
|
||
return isInfinite ? replacement : self | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
BlueprintUI/Sources/Internal/Extensions/CGSize+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import CoreGraphics | ||
import UIKit | ||
|
||
extension CGSize { | ||
static func + (lhs: CGSize, rhs: CGSize) -> CGSize { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
BlueprintUICommonControls/Tests/Sources/LayoutMode+Testing.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import BlueprintUI | ||
|
||
extension LayoutMode { | ||
static let testModes: [LayoutMode] = [.legacy, .caffeinated] | ||
|
||
/// Run the given block with `self` as the default layout mode, restoring the previous default | ||
/// afterwards, and returning the result of the block. | ||
func performAsDefault<Result>(block: () throws -> Result) rethrows -> Result { | ||
let oldLayoutMode = LayoutMode.default | ||
defer { LayoutMode.default = oldLayoutMode } | ||
|
||
LayoutMode.default = self | ||
|
||
return try block() | ||
} | ||
} |
Binary file added
BIN
+643 Bytes
.../ReferenceImages/ScrollViewTests/test_infiniteContent_fittingContent_iOS-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+643 Bytes
.../ReferenceImages/ScrollViewTests/test_infiniteContent_fittingContent_iOS-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+631 Bytes
.../ReferenceImages/ScrollViewTests/test_infiniteContent_fittingContent_iOS-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+643 Bytes
...s/ReferenceImages/ScrollViewTests/test_infiniteContent_fittingHeight_iOS-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+643 Bytes
...s/ReferenceImages/ScrollViewTests/test_infiniteContent_fittingHeight_iOS-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+631 Bytes
...s/ReferenceImages/ScrollViewTests/test_infiniteContent_fittingHeight_iOS-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+643 Bytes
...es/ReferenceImages/ScrollViewTests/test_infiniteContent_fittingWidth_iOS-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+643 Bytes
...es/ReferenceImages/ScrollViewTests/test_infiniteContent_fittingWidth_iOS-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+631 Bytes
...es/ReferenceImages/ScrollViewTests/test_infiniteContent_fittingWidth_iOS-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.