2021-10-17 23:06:00 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct OpenSettingsButton: View {
|
2021-11-28 14:37:55 +00:00
|
|
|
@Environment(\.presentationMode) private var presentationMode
|
2021-11-10 22:05:59 +00:00
|
|
|
|
|
|
|
#if !os(macOS)
|
2022-11-24 20:36:05 +00:00
|
|
|
private var navigation: NavigationModel { .shared }
|
2021-11-10 22:05:59 +00:00
|
|
|
#endif
|
2021-10-17 23:06:00 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2023-10-15 11:35:23 +00:00
|
|
|
let button = Button {
|
2021-11-28 14:37:55 +00:00
|
|
|
presentationMode.wrappedValue.dismiss()
|
2021-10-17 23:06:00 +00:00
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
|
|
|
|
#else
|
|
|
|
navigation.presentingSettings = true
|
|
|
|
#endif
|
|
|
|
} label: {
|
|
|
|
Label("Open Settings", systemImage: "gearshape.2")
|
|
|
|
}
|
2022-08-25 23:36:46 +00:00
|
|
|
.buttonStyle(.plain)
|
2023-10-15 11:35:23 +00:00
|
|
|
|
|
|
|
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
|
|
|
|
button
|
|
|
|
.buttonStyle(.borderedProminent)
|
|
|
|
} else {
|
|
|
|
button
|
|
|
|
}
|
2021-10-17 23:06:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct OpenSettingsButton_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
OpenSettingsButton()
|
|
|
|
}
|
|
|
|
}
|