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)
#if os(iOS)
.padding([.leading, .trailing])
.navigationBarTitleDisplayMode(.inline)
#endif
@@ -71,22 +71,23 @@ public struct DashboardView: View {
@State private var alert: Alert?
var body: some View {
ActiveDashboardView()
.environmentObject(profile)
EmptyView()
.alertBinding($alert)
.onChangeCompat(of: profile.status) { newValue in
if newValue == .disconnecting || newValue == .connected {
Task.detached {
if let serviceError = try? String(contentsOf: ExtensionProvider.errorFile) {
DispatchQueue.main.async {
alert = Alert(errorMessage: serviceError)
}
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
VStack {
ActiveDashboardView()
.environmentObject(profile)
}
.alertBinding($alert)
.onChangeCompat(of: profile.status) { newValue in
if newValue == .disconnecting || newValue == .connected {
Task.detached {
if let serviceError = try? String(contentsOf: ExtensionProvider.errorFile) {
DispatchQueue.main.async {
alert = Alert(title: Text("Service Error"), message: Text(serviceError))
}
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
}
}
}
}
}
}
}
@@ -25,29 +25,34 @@ public struct OverviewView: View {
if ApplicationLibrary.inPreview || profile.status.isConnected {
ExtensionStatusView()
}
FormView {
#if os(iOS) || os(tvOS)
StartStopButton()
Section("Profile") {
Picker(selection: $selectedProfileID) {
ForEach(profileList, id: \.id) { profile in
Text(profile.name).tag(profile.id)
}
} label: {}
.pickerStyle(.inline)
}
#elseif os(macOS)
Section("Profile") {
ForEach(profileList, id: \.id) { profile in
Picker(profile.name, selection: $selectedProfileID) {
Text("").tag(profile.id)
}
if profileList.isEmpty {
Text("Empty profiles")
} else {
FormView {
#if os(iOS) || os(tvOS)
StartStopButton()
Section("Profile") {
Picker(selection: $selectedProfileID) {
ForEach(profileList, id: \.id) { profile in
Text(profile.name).tag(profile.id)
}
} label: {}
.pickerStyle(.inline)
}
.pickerStyle(.radioGroup)
}
#endif
#elseif os(macOS)
Section("Profile") {
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)
.onChangeCompat(of: selectedProfileID) {
reasserting = true
@@ -27,7 +27,7 @@ public struct GroupListView: View {
}.padding()
}
} else {
Text("Empty groups")
Text("Empty Groups")
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
@@ -79,7 +79,7 @@ public struct ProfileView: View {
}
#endif
if profileList.isEmpty {
Text("Empty Profiles")
Text("Empty profiles")
} else {
List {
ForEach(profileList, id: \.mustID) { profile in
@@ -99,7 +99,7 @@ public struct ProfileView: View {
}
#elseif os(macOS)
if profileList.isEmpty {
Text("Empty Profiles")
Text("Empty profiles")
} else {
FormView {
List {