From 777fd6df59634ebf613ba7ea34965cd67b34aae3 Mon Sep 17 00:00:00 2001 From: mntone <901816+mntone@users.noreply.github.com> Date: Fri, 5 Jan 2024 00:42:07 +0900 Subject: [PATCH] Disables entrance animation during restore on iOS 16+ or watchOS 9+. --- src/App/Views/Navigations/NavigationPathHost.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/App/Views/Navigations/NavigationPathHost.swift b/src/App/Views/Navigations/NavigationPathHost.swift index e1e98b6..debff14 100644 --- a/src/App/Views/Navigations/NavigationPathHost.swift +++ b/src/App/Views/Navigations/NavigationPathHost.swift @@ -17,7 +17,7 @@ struct NavigationPathHost: View { var body: some View { content($path) .task { - path = await RouteHelper.load(from: pathString) + await loadPath() } .onDisappear { storePath() @@ -25,6 +25,15 @@ struct NavigationPathHost: View { .onReceive(NotificationCenter.default.publisher(for: .platformWillResignActiveNotification), perform: storePath(_:)) } + private func loadPath() async { + let path = await RouteHelper.load(from: pathString) + var transaction = Transaction() + transaction.disablesAnimations = true + withTransaction(transaction) { + self.path = path + } + } + private func storePath(_: Notification) { storePath() }