Skip to content

Commit 78ee038

Browse files
committed
fix font issue and add an option for TransformAnimator
1 parent 07cfd38 commit 78ee038

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Sources/UIComponent/Animators/TransformAnimator.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public struct TransformAnimator: Animator {
1616
public var cascade: Bool
1717
/// A Boolean value that determines whether to show the initial insertion animation when the view is first loaded.
1818
public var showInitialInsertionAnimation: Bool = false
19+
/// A Boolean value that determines whether to show insertion animations for items that are out of the bounds of the hosting view.
20+
public var showInsertionAnimationOnOutOfBoundsItems: Bool = false
1921

2022
/// Initializes a new animator with the specified transform, duration, and cascade options.
2123
/// - Parameters:
@@ -26,12 +28,14 @@ public struct TransformAnimator: Animator {
2628
transform: CATransform3D = CATransform3DIdentity,
2729
duration: TimeInterval = 0.5,
2830
cascade: Bool = false,
29-
showInitialInsertionAnimation: Bool = false
31+
showInitialInsertionAnimation: Bool = false,
32+
showInsertionAnimationOnOutOfBoundsItems: Bool = false,
3033
) {
3134
self.transform = transform
3235
self.duration = duration
3336
self.cascade = cascade
3437
self.showInitialInsertionAnimation = showInitialInsertionAnimation
38+
self.showInsertionAnimationOnOutOfBoundsItems = showInsertionAnimationOnOutOfBoundsItems
3539
}
3640

3741
public func delete(hostingView: UIView, view: UIView, completion: @escaping () -> Void) {
@@ -64,7 +68,7 @@ public struct TransformAnimator: Animator {
6468
view.bounds.size = frame.size
6569
view.center = frame.center
6670
let baseTransform = view.layer.transform
67-
if hostingView.componentEngine.isReloading, showInitialInsertionAnimation || hostingView.componentEngine.hasReloaded, hostingView.bounds.intersects(frame) {
71+
if hostingView.componentEngine.isReloading, showInitialInsertionAnimation || hostingView.componentEngine.hasReloaded, showInsertionAnimationOnOutOfBoundsItems || hostingView.bounds.intersects(frame) {
6872
let offsetTime: TimeInterval = cascade ? TimeInterval(frame.origin.distance(hostingView.bounds.origin) / 3000) : 0
6973
UIView.performWithoutAnimation {
7074
view.layer.transform = transform

Sources/UIComponent/Components/View/Text.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ public struct Text: Component {
122122
/// - Parameter constraint: The constraints to use for laying out the text.
123123
/// - Returns: A `TextRenderNode` that represents the laid out text.
124124
public func layout(_ constraint: Constraint) -> TextRenderNode {
125+
var content = content
126+
if case .string(let string, _) = content, let envFont = font {
127+
content = .string(string, envFont)
128+
}
125129
if Self.useSharedLabelForSizing, Thread.isMainThread {
126130
// Fastest route, but not thread safe.
127131
layoutLabel.numberOfLines = numberOfLines

0 commit comments

Comments
 (0)