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
@@ -57,7 +57,7 @@ public struct EditProfileView: View {
Section("Action") {
if profile.type != .remote {
#if os(iOS) || os(macOS)
NavigationLink {
FormNavigationLink {
EditProfileContentView(EditProfileContentView.Context(profileID: profile.id!, readOnly: false))
} label: {
Label("Edit Content", systemImage: "pencil")
@@ -66,7 +66,7 @@ public struct EditProfileView: View {
#endif
} else {
#if os(iOS) || os(macOS)
NavigationLink {
FormNavigationLink {
EditProfileContentView(EditProfileContentView.Context(profileID: profile.id!, readOnly: true))
} label: {
Label("View Content", systemImage: "doc.fill")
@@ -22,25 +22,37 @@
}
public var body: some View {
VStack {
VStack(alignment: .center) {
if !selected {
DevicePicker(
.applicationService(name: "sing-box:profile"))
{ endpoint in
selected = true
Task {
await handleEndpoint(endpoint)
Form {
Section {
EmptyView()
} footer: {
Text("To import configurations from your iPhone or iPad, make sure sing-box is the **same version** on both devices and **VPN is disabled**.")
}
DevicePicker(
.applicationService(name: "sing-box:profile"))
{ endpoint in
selected = true
Task {
await handleEndpoint(endpoint)
}
} label: {
Text("Select Device")
} fallback: {
EmptyView()
} parameters: {
.applicationService
}
} label: {
Text("Select Device")
} fallback: {
EmptyView()
} parameters: {
.applicationService
}
} else if let profiles {
Form {
Text("\(profiles.count) Profiles")
Section {
EmptyView()
} footer: {
Text("\(profiles.count) Profiles")
}
ForEach(profiles, id: \.profileID) { profile in
Button(profile.name) {
isLoading = true
@@ -45,27 +45,27 @@ public struct ProfileView: View {
}
FormView {
#if os(iOS)
NavigationLink {
FormNavigationLink {
NewProfileView()
} label: {
Text("New Profile").foregroundColor(.accentColor)
}
.disabled(editMode.isEditing)
#elseif os(macOS)
NavigationLink {
FormNavigationLink {
NewProfileView()
} label: {
Text("New Profile")
}
#elseif os(tvOS)
Section {
NavigationLink {
FormNavigationLink {
NewProfileView()
} label: {
Text("New Profile").foregroundColor(.accentColor)
}
if ApplicationLibrary.inPreview || devicePickerSupports(.applicationService(name: "sing-box"), parameters: { .applicationService }) {
NavigationLink {
FormNavigationLink {
ImportProfileView {
await doReload()
}
@@ -291,7 +291,7 @@ public struct ProfileView: View {
private var body0: some View {
viewBuilder {
#if !os(macOS)
NavigationLink {
FormNavigationLink {
EditProfileView().environmentObject(profile.origin)
} label: {
Text(profile.name)
@@ -329,7 +329,7 @@ public struct ProfileView: View {
}
}
#else
NavigationLink {
FormNavigationLink {
EditProfileView().environmentObject(profile.origin)
} label: {
HStack {