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

38 lines
964 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)
@EnvironmentObject<NavigationModel> private var navigation
#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")
}
.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()
}
}