Fix interfaces for tvOS

This commit is contained in:
世界
2024-02-23 23:37:42 +08:00
parent be67111425
commit 45b4e58b3f
8 changed files with 95 additions and 47 deletions
@@ -0,0 +1,14 @@
import Foundation
import SwiftUI
public struct BackButton: View {
@Environment(\.dismiss) private var dismiss
public var body: some View {
Button {
dismiss()
} label: {
Image(systemName: "chevron.backward")
}
}
}
@@ -83,3 +83,18 @@ public func FormButton(role: ButtonRole?, action: @escaping () -> Void, @ViewBui
.foregroundColor(.accentColor)
#endif
}
public func FormNavigationLink(@ViewBuilder destination: () -> some View, @ViewBuilder label: () -> some View) -> some View {
#if !os(tvOS)
return NavigationLink(destination: destination, label: label)
#else
return NavigationLink(destination: {
destination()
.toolbar {
ToolbarItemGroup(placement: .topBarLeading) {
BackButton()
}
}
}, label: label)
#endif
}