]> git.r.bdr.sh - rbdr/map/blob - Map/Data/FocusedValues+document.swift
Add search
[rbdr/map] / Map / Data / FocusedValues+document.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 DocumentFocusedValueKey: FocusedValueKey {
20 typealias Value = Binding<MapDocument>
21 }
22
23 struct IsSearchingValueKey: FocusedValueKey {
24 typealias Value = Binding<Bool>
25 }
26
27 struct SelectedEvolutionValueKey: FocusedValueKey {
28 typealias Value = Binding<StageType>
29 }
30
31 struct FileURLValueKey: FocusedValueKey {
32 typealias Value = URL
33 }
34
35 extension FocusedValues {
36 var document: DocumentFocusedValueKey.Value? {
37 get { self[DocumentFocusedValueKey.self] }
38 set { self[DocumentFocusedValueKey.self] = newValue }
39 }
40 var isSearching: IsSearchingValueKey.Value? {
41 get { self[IsSearchingValueKey.self] }
42 set { self[IsSearchingValueKey.self] = newValue }
43 }
44 var selectedEvolution: SelectedEvolutionValueKey.Value? {
45 get { self[SelectedEvolutionValueKey.self] }
46 set { self[SelectedEvolutionValueKey.self] = newValue }
47 }
48 var fileURL: FileURLValueKey.Value? {
49 get { self[FileURLValueKey.self] }
50 set { self[FileURLValueKey.self] = newValue }
51 }
52 }