Fix Settings first navigation animation missing
This commit is contained in:
@@ -1,17 +1,41 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public func NavigationStackCompat(@ViewBuilder content: () -> some View) -> some View {
|
public struct NavigationStackCompat<Content: View>: View {
|
||||||
Group {
|
private let content: Content
|
||||||
|
|
||||||
|
public init(@ViewBuilder content: () -> Content) {
|
||||||
|
self.content = content()
|
||||||
|
}
|
||||||
|
|
||||||
|
public var body: some View {
|
||||||
if #available(iOS 17.0, macOS 13.0, tvOS 17.0, *) {
|
if #available(iOS 17.0, macOS 13.0, tvOS 17.0, *) {
|
||||||
// view not updating in iOS 16, but why?
|
// view not updating in iOS 16, but why?
|
||||||
NavigationStack {
|
NavigationStackWithPath {
|
||||||
content()
|
content
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NavigationView(content: content)
|
NavigationView {
|
||||||
|
content
|
||||||
|
}
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
.navigationViewStyle(.stack)
|
.navigationViewStyle(.stack)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
|
||||||
|
private struct NavigationStackWithPath<Content: View>: View {
|
||||||
|
private let content: Content
|
||||||
|
@State private var path = NavigationPath()
|
||||||
|
|
||||||
|
init(@ViewBuilder content: () -> Content) {
|
||||||
|
self.content = content()
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
NavigationStack(path: $path.animation(.linear(duration: 0))) {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -99,9 +99,11 @@ public struct SettingView: View {
|
|||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
Tabs.app.navigationLink
|
Tabs.app.navigationLink
|
||||||
#endif
|
#endif
|
||||||
|
Section {
|
||||||
ForEach([Tabs.core, Tabs.packetTunnel, Tabs.onDemandRules, Tabs.profileOverride]) { it in
|
ForEach([Tabs.core, Tabs.packetTunnel, Tabs.onDemandRules, Tabs.profileOverride]) { it in
|
||||||
it.navigationLink
|
it.navigationLink
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
Section("About") {
|
Section("About") {
|
||||||
Link(destination: URL(string: String(localized: "https://sing-box.sagernet.org/"))!) {
|
Link(destination: URL(string: String(localized: "https://sing-box.sagernet.org/"))!) {
|
||||||
|
|||||||
Reference in New Issue
Block a user