1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 22:00:31 +05:30
yattee/Shared/Views/OpenSettingsButton.swift

38 lines
957 B
Swift
Raw Normal View History

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)
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 {
let button = Button {
2021-11-28 20:07:55 +05:30
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")
}
.buttonStyle(.plain)
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()
}
}