]> git.r.bdr.sh - rbdr/map/blob - Map/Presentation/Commands/MapCommands.swift
b0fbf9cf2447112b13998a34d18028e187514cc4
[rbdr/map] / Map / Presentation / Commands / MapCommands.swift
1 /*
2 Copyright (C) 2024 Rubén Beltrán del Río
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://map.tranquil.systems.
16 */
17 import SwiftUI
18
19 struct MapCommands: Commands {
20
21 @AppStorage("viewStyle") var viewStyle: ViewStyle = .horizontal
22 @AppStorage("zoom") var zoom = 1.0
23
24 var body: some Commands {
25
26 // View
27
28 CommandGroup(after: CommandGroupPlacement.toolbar) {
29 if viewStyle == .horizontal {
30 Button("Use Vertical Layout") {
31 viewStyle = .vertical
32 }.keyboardShortcut(
33 "l", modifiers: EventModifiers([.command])
34 )
35 } else {
36 Button("Use Horizontal Layout") {
37 viewStyle = .horizontal
38 }.keyboardShortcut(
39 "l", modifiers: EventModifiers([.command])
40 )
41 }
42 Divider()
43 Button("Zoom In") {
44 zoom = min(Constants.kMaxZoom, zoom + 0.1)
45 }.keyboardShortcut(
46 "+", modifiers: EventModifiers([.command])
47 )
48 Button("Zoom Out") {
49 zoom = max(Constants.kMinZoom, zoom - 0.1)
50 }.keyboardShortcut(
51 "-", modifiers: EventModifiers([.command])
52 )
53 Divider()
54 }
55
56 CommandGroup(replacing: CommandGroupPlacement.help) {
57 Button("Map Help") { NSWorkspace.shared.open(URL(string: "https://map.tranquil.systems")!) }
58 }
59 }
60 }