This commit is contained in:
世界
2023-08-05 21:27:52 +08:00
parent b5e682021b
commit ba8cd27b70
6 changed files with 46 additions and 37 deletions
@@ -32,7 +32,6 @@ public struct ActiveDashboardView: View {
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
#if os(iOS) #if os(iOS)
.padding([.leading, .trailing]) .padding([.leading, .trailing])
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
#endif #endif
@@ -71,22 +71,23 @@ public struct DashboardView: View {
@State private var alert: Alert? @State private var alert: Alert?
var body: some View { var body: some View {
ActiveDashboardView() VStack {
.environmentObject(profile) ActiveDashboardView()
EmptyView() .environmentObject(profile)
.alertBinding($alert) }
.onChangeCompat(of: profile.status) { newValue in .alertBinding($alert)
if newValue == .disconnecting || newValue == .connected { .onChangeCompat(of: profile.status) { newValue in
Task.detached { if newValue == .disconnecting || newValue == .connected {
if let serviceError = try? String(contentsOf: ExtensionProvider.errorFile) { Task.detached {
DispatchQueue.main.async { if let serviceError = try? String(contentsOf: ExtensionProvider.errorFile) {
alert = Alert(errorMessage: serviceError) DispatchQueue.main.async {
} alert = Alert(title: Text("Service Error"), message: Text(serviceError))
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
} }
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
} }
} }
} }
}
} }
} }
} }
@@ -25,29 +25,34 @@ public struct OverviewView: View {
if ApplicationLibrary.inPreview || profile.status.isConnected { if ApplicationLibrary.inPreview || profile.status.isConnected {
ExtensionStatusView() ExtensionStatusView()
} }
FormView { if profileList.isEmpty {
#if os(iOS) || os(tvOS) Text("Empty profiles")
StartStopButton() } else {
Section("Profile") { FormView {
Picker(selection: $selectedProfileID) { #if os(iOS) || os(tvOS)
ForEach(profileList, id: \.id) { profile in StartStopButton()
Text(profile.name).tag(profile.id) Section("Profile") {
} Picker(selection: $selectedProfileID) {
} label: {} ForEach(profileList, id: \.id) { profile in
.pickerStyle(.inline) Text(profile.name).tag(profile.id)
} }
#elseif os(macOS) } label: {}
Section("Profile") { .pickerStyle(.inline)
ForEach(profileList, id: \.id) { profile in
Picker(profile.name, selection: $selectedProfileID) {
Text("").tag(profile.id)
}
} }
.pickerStyle(.radioGroup) #elseif os(macOS)
} Section("Profile") {
#endif ForEach(profileList, id: \.id) { profile in
Picker(profile.name, selection: $selectedProfileID) {
Text("").tag(profile.id)
}
}
.pickerStyle(.radioGroup)
}
#endif
}
} }
} }
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
.alertBinding($alert) .alertBinding($alert)
.onChangeCompat(of: selectedProfileID) { .onChangeCompat(of: selectedProfileID) {
reasserting = true reasserting = true
@@ -27,7 +27,7 @@ public struct GroupListView: View {
}.padding() }.padding()
} }
} else { } else {
Text("Empty groups") Text("Empty Groups")
} }
} }
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
@@ -79,7 +79,7 @@ public struct ProfileView: View {
} }
#endif #endif
if profileList.isEmpty { if profileList.isEmpty {
Text("Empty Profiles") Text("Empty profiles")
} else { } else {
List { List {
ForEach(profileList, id: \.mustID) { profile in ForEach(profileList, id: \.mustID) { profile in
@@ -99,7 +99,7 @@ public struct ProfileView: View {
} }
#elseif os(macOS) #elseif os(macOS)
if profileList.isEmpty { if profileList.isEmpty {
Text("Empty Profiles") Text("Empty profiles")
} else { } else {
FormView { FormView {
List { List {
+5 -1
View File
@@ -1,7 +1,11 @@
import Foundation import Foundation
public enum FilePath { public enum FilePath {
public static let packageName = "io.nekohasekai.sfa" #if !NEXT
public static let packageName = "io.nekohasekai.sfa"
#else
public static let packageName = "io.nekohasekai.sfa.next"
#endif
} }
public extension FilePath { public extension FilePath {