Explorar el Código

Animate paywall entry from top of screen.

Present the paywall with a smooth top-down slide and fade each time it opens, including when reopening an existing paywall window.

Made-with: Cursor
huzaifahayat12 hace 1 semana
padre
commit
dc8a1d5abc
Se han modificado 1 ficheros con 25 adiciones y 0 borrados
  1. 25 0
      meetings_app/ViewController.swift

+ 25 - 0
meetings_app/ViewController.swift

@@ -749,6 +749,7 @@ private extension ViewController {
749 749
 
750 750
     private func showPaywall() {
751 751
         if let existing = paywallWindow {
752
+            animatePaywallPresentation(existing)
752 753
             existing.makeKeyAndOrderFront(nil)
753 754
             NSApp.activate(ignoringOtherApps: true)
754 755
             return
@@ -777,9 +778,11 @@ private extension ViewController {
777 778
         panel.standardWindowButton(.zoomButton)?.isHidden = true
778 779
         panel.center()
779 780
         panel.contentViewController = controller
781
+        panel.alphaValue = 0
780 782
         panel.makeKeyAndOrderFront(nil)
781 783
         NSApp.activate(ignoringOtherApps: true)
782 784
         paywallWindow = panel
785
+        animatePaywallPresentation(panel)
783 786
 
784 787
         Task { [weak self] in
785 788
             guard let self else { return }
@@ -788,6 +791,28 @@ private extension ViewController {
788 791
         }
789 792
     }
790 793
 
794
+    private func animatePaywallPresentation(_ window: NSWindow) {
795
+        let finalFrame = window.frame
796
+        let targetScreen = window.screen ?? NSScreen.main
797
+        let startY: CGFloat
798
+        if let screen = targetScreen {
799
+            startY = screen.visibleFrame.maxY + 12
800
+        } else {
801
+            startY = finalFrame.origin.y + 120
802
+        }
803
+        let startFrame = NSRect(x: finalFrame.origin.x, y: startY, width: finalFrame.width, height: finalFrame.height)
804
+
805
+        window.setFrame(startFrame, display: false)
806
+        window.alphaValue = 0
807
+
808
+        NSAnimationContext.runAnimationGroup { context in
809
+            context.duration = 0.28
810
+            context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
811
+            window.animator().alphaValue = 1
812
+            window.animator().setFrame(finalFrame, display: true)
813
+        }
814
+    }
815
+
791 816
     @objc private func closePaywallClicked(_ sender: Any?) {
792 817
         if let win = paywallWindow {
793 818
             win.performClose(nil)