Fix input field animation

This commit is contained in:
Isaac 2025-09-25 15:21:06 +08:00
parent c99a642669
commit 9dd6d95be6

View File

@ -300,6 +300,7 @@ public class GlassBackgroundView: UIView {
let glassEffect = UIGlassEffect(style: .regular) let glassEffect = UIGlassEffect(style: .regular)
glassEffect.isInteractive = false glassEffect.isInteractive = false
let nativeView = UIVisualEffectView(effect: glassEffect) let nativeView = UIVisualEffectView(effect: glassEffect)
//nativeView.layer.anchorPoint = CGPoint()
self.nativeView = nativeView self.nativeView = nativeView
let glassContainerEffect = UIGlassContainerEffect() let glassContainerEffect = UIGlassContainerEffect()
@ -367,21 +368,21 @@ public class GlassBackgroundView: UIView {
} }
public func update(size: CGSize, cornerRadius: CGFloat, isDark: Bool, tintColor: TintColor, isInteractive: Bool = false, transition: ComponentTransition) { public func update(size: CGSize, cornerRadius: CGFloat, isDark: Bool, tintColor: TintColor, isInteractive: Bool = false, transition: ComponentTransition) {
if let nativeContainerView = self.nativeContainerView, let nativeView = self.nativeView { if let nativeContainerView = self.nativeContainerView, let nativeView = self.nativeView, nativeView.bounds.size != size {
let previousFrame = nativeView.frame //let previousFrame = nativeView.frame
if transition.animation.isImmediate { if transition.animation.isImmediate {
nativeView.layer.cornerRadius = cornerRadius nativeView.layer.cornerRadius = cornerRadius
nativeView.frame = CGRect(origin: CGPoint(), size: size) nativeView.frame = CGRect(origin: CGPoint(), size: size)
nativeContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: max(size.height, 400.0)))
} else { } else {
transition.containedViewLayoutTransition.animateView { transition.containedViewLayoutTransition.animateView {
nativeView.layer.cornerRadius = cornerRadius nativeView.layer.cornerRadius = cornerRadius
nativeView.frame = CGRect(origin: CGPoint(), size: size) nativeView.frame = CGRect(origin: CGPoint(), size: size)
nativeContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: max(size.height, 400.0)))
} }
nativeView.layer.animateFrame(from: previousFrame, to: CGRect(origin: CGPoint(), size: size), duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring) //nativeView.layer.animateFrame(from: previousFrame, to: CGRect(origin: CGPoint(), size: size), duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring)
} }
transition.setFrame(view: nativeContainerView, frame: CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: max(size.height, 400.0))))
} }
if let backgroundNode = self.backgroundNode { if let backgroundNode = self.backgroundNode {
backgroundNode.updateColor(color: .clear, forceKeepBlur: tintColor.color.alpha != 1.0, transition: transition.containedViewLayoutTransition) backgroundNode.updateColor(color: .clear, forceKeepBlur: tintColor.color.alpha != 1.0, transition: transition.containedViewLayoutTransition)