diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-07-07 13:09:13 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-07-07 13:09:13 +0200 |
| commit | 3fdaeab6a7fa19b0c5424de487efc37c0994c86e (patch) | |
| tree | 09af4c1d54924350b4e6c89fb4f284170e89b945 /Map/Presentation/Base Components | |
| parent | 933078c10e99002c8a5f647e476819f0f1706a14 (diff) | |
More localization and map preferences
Diffstat (limited to 'Map/Presentation/Base Components')
7 files changed, 138 insertions, 62 deletions
diff --git a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift index 94a87d7..73837a0 100644 --- a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift +++ b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPickerMenu.swift @@ -55,30 +55,3 @@ struct EvolutionPickerMenu: View { #Preview { EvolutionPickerMenu(selectedEvolution: .constant(.ubiquity)) } - -/* -Picker(selection: $selectedEvolution) { - Divider() - ForEach(StageType.characteristics) { stage in - Text(Stage.title(stage)) - .font(selectedEvolution == stage ? .Theme.Body.emphasized : .Theme.Body.regular) - .tag(stage) - } - Divider() - ForEach(StageType.properties) { stage in - Text(Stage.title(stage)) - .font(selectedEvolution == stage ? .Theme.Body.emphasized : .Theme.Body.regular) - .tag(stage) - } - Divider() - ForEach(StageType.custom) { stage in - Text(Stage.title(stage)) - .font(selectedEvolution == stage ? .Theme.Body.emphasized : .Theme.Body.regular) - .tag(stage) - } -} label: { - Label("evolution_picker.label", image: "Icons/Evolution") - .font(.Theme.Body.regular) -}.padding(.horizontal, Dimensions.Spacing.regular) - .padding(.vertical, Dimensions.Spacing.cozy) - */ diff --git a/Map/Presentation/Base Components/MapRender/MapAxes.swift b/Map/Presentation/Base Components/MapRender/MapAxes.swift index 3a94a13..d9fe189 100644 --- a/Map/Presentation/Base Components/MapRender/MapAxes.swift +++ b/Map/Presentation/Base Components/MapRender/MapAxes.swift @@ -36,12 +36,12 @@ struct MapAxes: View { }.stroke(Color.Theme.Map.axisColor, lineWidth: lineWidth * 2) // Y Labels - Text("Visible").font(.Theme.Map.axisLabel).foregroundColor(.Theme.Map.labelColor) + Text("map.axis.y.top").font(.Theme.Map.axisLabel).foregroundColor(.Theme.Map.labelColor) .rotationEffect( Angle(degrees: -90.0) ) .offset(CGSize(width: -35.0, height: 0.0)) - Text("Invisible").font(.Theme.Map.axisLabel).foregroundColor(.Theme.Map.labelColor) + Text("map.axis.y.bottom").font(.Theme.Map.axisLabel).foregroundColor(.Theme.Map.labelColor) .rotationEffect( Angle(degrees: -90.0) ) @@ -49,12 +49,12 @@ struct MapAxes: View { // X Labels - Text("Uncharted") + Text("map.axis.x.leading") .font(.Theme.Map.axisLabel) .foregroundColor(.Theme.Map.labelColor) .frame(width: mapSize.width / 4, height: stageHeight / 2.0, alignment: .topLeading) .offset(CGSize(width: 0.0, height: -stageHeight / 4.0)) - Text("Industrialised") + Text("map.axis.x.trailing") .font(.Theme.Map.axisLabel) .foregroundColor(.Theme.Map.labelColor) .frame(width: mapSize.width / 4, height: stageHeight / 2.0, alignment: .topLeading) diff --git a/Map/Presentation/Base Components/MapRender/MapBackground.swift b/Map/Presentation/Base Components/MapRender/MapBackground.swift new file mode 100644 index 0000000..b33e791 --- /dev/null +++ b/Map/Presentation/Base Components/MapRender/MapBackground.swift @@ -0,0 +1,62 @@ +// Copyright (C) 2024 Rubén Beltrán del Río + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see https://map.tranquil.systems. +import Patterns +import SwiftUI + +struct MapBackground: View { + + let mapSize: CGSize + let lineWidth: CGFloat + let stages: [CGFloat] + let opacity = 0.1 + + var body: some View { + ZStack(alignment: .topLeading) { + PatternView( + design: .constant(.stitch), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, + backgroundColor: .Theme.Map.stageBackground + ) + .frame(width: w(stages[0]), height: mapSize.height) + PatternView( + design: .constant(.shingles), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, + backgroundColor: .Theme.Map.stageBackground + ) + .offset(CGSize(width: w(stages[0]), height: 0)) + .frame(width: w(stages[1]) - w(stages[0]), height: mapSize.height) + PatternView( + design: .constant(.shadowGrid), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, + backgroundColor: .Theme.Map.stageBackground + ) + .offset(CGSize(width: w(stages[1]), height: 0)) + .frame(width: w(stages[2]) - w(stages[1]), height: mapSize.height) + PatternView( + design: .constant(.wicker), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, + backgroundColor: .Theme.Map.stageBackground + ) + .offset(CGSize(width: w(stages[2]), height: 0)) + .frame(width: mapSize.width - w(stages[2]), height: mapSize.height) + } + } + + func w(_ dimension: CGFloat) -> CGFloat { + max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0)) + } +} + +#Preview { + MapBackground( + mapSize: CGSize(width: 200.0, height: 200.0), lineWidth: CGFloat(0.5), + stages: [25.0, 50.0, 75.0]) +} diff --git a/Map/Presentation/Base Components/MapRender/MapMask.swift b/Map/Presentation/Base Components/MapRender/MapMask.swift new file mode 100644 index 0000000..807310c --- /dev/null +++ b/Map/Presentation/Base Components/MapRender/MapMask.swift @@ -0,0 +1,67 @@ +// Copyright (C) 2024 Rubén Beltrán del Río + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see https://map.tranquil.systems. +import SwiftUI + +struct MapMask: View { + + let mapSize: CGSize + let vertexSize: CGSize + let vertices: [Vertex] + let padding = CGFloat(5.0) + + var body: some View { + ZStack(alignment: .topLeading) { + ForEach(vertices, id: \.id) { vertex in + ZStack(alignment: .topLeading) { + Text(vertex.label.replacingOccurrences(of: "\\n", with: "\n")) + .font(.Theme.Map.vertexLabel) + .lineSpacing( + Dimensions.LineHeight.Map.vertexLabel - Dimensions.FontSize.Map.vertexLabel + ) + .foregroundColor(.white) + .background(.white) + .padding(.horizontal, 1.0) + .clipShape(Capsule()) + .offset( + CGSize( + width: w(vertex.position.x) + vertexSize.width + padding, + height: h(vertex.position.y) + 7.0)) + .blendMode(.destinationOut) + }.zIndex(1) + } + Rectangle() + .fill(.black) + }.drawingGroup() + } + + func h(_ dimension: CGFloat) -> CGFloat { + max(0.0, min(mapSize.height, dimension * mapSize.height / 100.0)) + } + + func w(_ dimension: CGFloat) -> CGFloat { + max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0)) + } +} + +#Preview { + MapMask( + mapSize: CGSize(width: 400.0, height: 400.0), vertexSize: CGSize(width: 25.0, height: 25.0), + vertices: [ + Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)), + Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), + Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), + Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .x), + ]) +} diff --git a/Map/Presentation/Base Components/MapRender/MapStages.swift b/Map/Presentation/Base Components/MapRender/MapStages.swift index 08250f7..7d7e51e 100644 --- a/Map/Presentation/Base Components/MapRender/MapStages.swift +++ b/Map/Presentation/Base Components/MapRender/MapStages.swift @@ -24,30 +24,6 @@ struct MapStages: View { var body: some View { ZStack(alignment: .topLeading) { - PatternView( - design: .constant(.stitch), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, - backgroundColor: .Theme.Map.stageBackground - ) - .frame(width: w(stages[0]), height: mapSize.height) - PatternView( - design: .constant(.shingles), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, - backgroundColor: .Theme.Map.stageBackground - ) - .offset(CGSize(width: w(stages[0]), height: 0)) - .frame(width: w(stages[1]) - w(stages[0]), height: mapSize.height) - PatternView( - design: .constant(.shadowGrid), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, - backgroundColor: .Theme.Map.stageBackground - ) - .offset(CGSize(width: w(stages[1]), height: 0)) - .frame(width: w(stages[2]) - w(stages[1]), height: mapSize.height) - PatternView( - design: .constant(.wicker), pixelSize: 1.0, foregroundColor: .Theme.Map.stageForeground, - backgroundColor: .Theme.Map.stageBackground - ) - .offset(CGSize(width: w(stages[2]), height: 0)) - .frame(width: mapSize.width - w(stages[2]), height: mapSize.height) - Path { path in path.move(to: CGPoint(x: w(stages[0]), y: 0)) path.addLine(to: CGPoint(x: w(stages[0]), y: mapSize.height)) diff --git a/Map/Presentation/Base Components/MapRender/MapVertices.swift b/Map/Presentation/Base Components/MapRender/MapVertices.swift index 4f130c6..f03bb79 100644 --- a/Map/Presentation/Base Components/MapRender/MapVertices.swift +++ b/Map/Presentation/Base Components/MapRender/MapVertices.swift @@ -34,8 +34,6 @@ struct MapVertices: View { Dimensions.LineHeight.Map.vertexLabel - Dimensions.FontSize.Map.vertexLabel ) .foregroundColor(.Theme.Map.labelColor) - .shadow(color: .white, radius: 0, x: -0.5, y: -0.5) - .shadow(color: .white, radius: 0, x: 0.5, y: 0.5) .offset( CGSize( width: w(vertex.position.x) + vertexSize.width + padding, diff --git a/Map/Presentation/Base Components/SearchBar.swift b/Map/Presentation/Base Components/SearchBar.swift index cd2c378..cf19ddd 100644 --- a/Map/Presentation/Base Components/SearchBar.swift +++ b/Map/Presentation/Base Components/SearchBar.swift @@ -26,7 +26,7 @@ struct SearchBar: View { var body: some View { HStack(spacing: 2.0) { ZStack { - TextField("Search", text: $term) + TextField("search_bar.label", text: $term) .textFieldStyle(.roundedBorder) .padding(.trailing, 16.0) .focused($isSearchFocused) @@ -51,18 +51,18 @@ struct SearchBar: View { .font(.Theme.SmallControl.regular) }.keyboardShortcut( "g", modifiers: EventModifiers([.command, .shift]) - ).help("Find Previous (⇧⌘G)") + ).help("search_bar.previous.help") Button(action: onNext) { Image(systemName: "chevron.right") .font(.Theme.SmallControl.regular) }.keyboardShortcut( "g", modifiers: EventModifiers([.command]) - ).help("Find Next (⌘G)") + ).help("search_bar.next.help") Button(action: onDismiss) { - Text("Done") + Text("search_bar.done") .font(.Theme.SmallControl.regular) }.keyboardShortcut(.escape, modifiers: EventModifiers()) - .help("Done (⎋)") + .help("search_bar.done.help") }.padding(4.0) } } |