2021-10-18 04:36:00 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct OpenSettingsButton: View {
|
2021-11-28 20:07:55 +05:30
|
|
|
@Environment(\.presentationMode) private var presentationMode
|
2021-11-11 03:35:59 +05:30
|
|
|
|
|
|
|
#if !os(macOS)
|
2022-11-25 02:06:05 +05:30
|
|
|
private var navigation: NavigationModel { .shared }
|
2021-11-11 03:35:59 +05:30
|
|
|
#endif
|
2021-10-18 04:36:00 +05:30
|
|
|
|
|
|
|
var body: some View {
|
2021-11-28 20:07:55 +05:30
|
|
|
let button = Button {
|
|
|
|
presentationMode.wrappedValue.dismiss()
|
2021-10-18 04:36:00 +05:30
|
|
|
|
|
|
|
#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-26 05:06:46 +05:30
|
|
|
.buttonStyle(.plain)
|
2021-11-28 20:07:55 +05:30
|
|
|
|
|
|
|
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
|
|
|
|
button
|
|
|
|
.buttonStyle(.borderedProminent)
|
|
|
|
} else {
|
|
|
|
button
|
|
|
|
}
|
2021-10-18 04:36:00 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct OpenSettingsButton_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
OpenSettingsButton()
|
|
|
|
}
|
|
|
|
}
|