From c29cb46ef743bc76cbc007cd844301bd9baad46c Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 28 May 2022 20:17:46 +0400 Subject: [PATCH] Various improvements --- .../PremiumUI/Sources/PhoneDemoComponent.swift | 12 ++++++++---- submodules/PremiumUI/Sources/PremiumDemoScreen.swift | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/submodules/PremiumUI/Sources/PhoneDemoComponent.swift b/submodules/PremiumUI/Sources/PhoneDemoComponent.swift index a4705a0587..0adc14a891 100644 --- a/submodules/PremiumUI/Sources/PhoneDemoComponent.swift +++ b/submodules/PremiumUI/Sources/PhoneDemoComponent.swift @@ -231,22 +231,26 @@ final class PhoneDemoComponent: Component { var mappedPosition = environment[DemoPageEnvironment.self].position mappedPosition *= abs(mappedPosition) + let scale: CGFloat = availableSize.width / 390.0 + + let phoneX = mappedPosition * 50.0 * scale let phoneY: CGFloat switch component.position { case .top: - phoneY = phoneSize.height / 2.0 + 24.0 + abs(mappedPosition) * 24.0 + phoneY = availableSize.height + (-phoneSize.height / 2.0 + 24.0 + 149.0 + abs(mappedPosition) * 24.0) * scale case .bottom: - phoneY = availableSize.height - phoneSize.height / 2.0 - 24.0 - abs(mappedPosition) * 24.0 + phoneY = (-149.0 + phoneSize.height / 2.0 - 24.0 - abs(mappedPosition) * 24.0) * scale } + let isVisible = environment[DemoPageEnvironment.self].isDisplaying let isCentral = environment[DemoPageEnvironment.self].isCentral self.isCentral = isCentral - self.phoneView.center = CGPoint(x: availableSize.width / 2.0 + mappedPosition * 50.0, y: phoneY) + self.phoneView.center = CGPoint(x: availableSize.width / 2.0 + phoneX, y: phoneY) self.phoneView.screenRotation = mappedPosition * -0.7 - var perspective = CATransform3DIdentity + var perspective = CATransform3DMakeScale(scale, scale, 1.0) perspective.m34 = mappedPosition / 50.0 self.phoneView.layer.transform = CATransform3DRotate(perspective, 0.1, 0, 1, 0) diff --git a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift index 73f0196f60..e12ab04005 100644 --- a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift @@ -855,7 +855,7 @@ private final class DemoSheetContent: CombinedComponent { transition: context.transition ) - var contentHeight: CGFloat = context.availableSize.width + 154.0 + var contentHeight: CGFloat = context.availableSize.width + 146.0 if case .other = component.source { contentHeight -= 40.0 } @@ -865,7 +865,9 @@ private final class DemoSheetContent: CombinedComponent { .position(CGPoint(x: buttonFrame.midX, y: buttonFrame.midY)) ) - let contentSize = CGSize(width: context.availableSize.width, height: buttonFrame.maxY + 5.0 + environment.safeInsets.bottom) + let bottomPanelPadding: CGFloat = 12.0 + let bottomInset: CGFloat = environment.safeInsets.bottom > 0.0 ? environment.safeInsets.bottom + 5.0 : bottomPanelPadding + let contentSize = CGSize(width: context.availableSize.width, height: buttonFrame.maxY + bottomInset) return contentSize }