Minor fixes
This commit is contained in:
@@ -87,20 +87,26 @@ public func FormItem(_ title: String, @ViewBuilder content: () -> some View) ->
|
||||
#endif
|
||||
}
|
||||
|
||||
public func FormToggle(_ titleKey: LocalizedStringKey, _ subtitleKey: LocalizedStringKey, _ isOn: Binding<Bool>, _ action: @escaping (_ newValue: Bool) async -> Void) -> some View {
|
||||
public func FormToggle(_ titleKey: LocalizedStringKey, _ subtitleKey: LocalizedStringKey, _ isOn: Binding<Bool>, header: LocalizedStringKey? = nil, _ action: @escaping (_ newValue: Bool) async -> Void) -> some View {
|
||||
#if os(macOS)
|
||||
Toggle(isOn: isOn) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(titleKey)
|
||||
Spacer()
|
||||
Text(subtitleKey)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
Section {
|
||||
Toggle(isOn: isOn) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(titleKey)
|
||||
Spacer()
|
||||
Text(subtitleKey)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChangeCompat(of: isOn.wrappedValue) { newValue in
|
||||
Task {
|
||||
await action(newValue)
|
||||
.onChangeCompat(of: isOn.wrappedValue) { newValue in
|
||||
Task {
|
||||
await action(newValue)
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
if let header {
|
||||
Text(header)
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -111,6 +117,10 @@ public func FormToggle(_ titleKey: LocalizedStringKey, _ subtitleKey: LocalizedS
|
||||
await action(newValue)
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
if let header {
|
||||
Text(header)
|
||||
}
|
||||
} footer: {
|
||||
Text(subtitleKey)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
@@ -193,15 +193,6 @@ public struct GlobalChecksModifier: ViewModifier {
|
||||
}
|
||||
|
||||
#if os(tvOS)
|
||||
var state = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
dismissButton: .cancel(String(localized: "Ok"))
|
||||
)
|
||||
state.onDismiss = continueChain
|
||||
alert = state
|
||||
#else
|
||||
if report.migrationLink.isEmpty {
|
||||
var state = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
@@ -209,17 +200,26 @@ public struct GlobalChecksModifier: ViewModifier {
|
||||
)
|
||||
state.onDismiss = continueChain
|
||||
alert = state
|
||||
} else {
|
||||
alert = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
primaryButton: .default(String(localized: "Documentation")) {
|
||||
openURL(URL(string: report.migrationLink)!)
|
||||
},
|
||||
secondaryButton: .cancel(String(localized: "Ok")),
|
||||
onDismiss: continueChain
|
||||
)
|
||||
}
|
||||
#else
|
||||
if report.migrationLink.isEmpty {
|
||||
var state = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
dismissButton: .cancel(String(localized: "Ok"))
|
||||
)
|
||||
state.onDismiss = continueChain
|
||||
alert = state
|
||||
} else {
|
||||
alert = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
primaryButton: .default(String(localized: "Documentation")) {
|
||||
openURL(URL(string: report.migrationLink)!)
|
||||
},
|
||||
secondaryButton: .cancel(String(localized: "Ok")),
|
||||
onDismiss: continueChain
|
||||
)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import SwiftUI
|
||||
|
||||
@MainActor
|
||||
public struct SheetContent<Content: View>: View {
|
||||
private let title: String
|
||||
private let title: LocalizedStringKey
|
||||
private let content: Content
|
||||
|
||||
public init(_ title: String, @ViewBuilder content: () -> Content) {
|
||||
public init(_ title: LocalizedStringKey, @ViewBuilder content: () -> Content) {
|
||||
self.title = title
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user