aboutsummaryrefslogtreecommitdiff
path: root/Map
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-07-07 13:46:01 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-07-07 13:46:01 +0200
commita1a485f16e0f1720f2dcdf7ab03d52c29fe9e252 (patch)
treef856e787f18bcb8abcf15a8aa72793cf56630fd2 /Map
parent69f8f7e81ca73ffbf1a0d76ccbd6cf8545caff57 (diff)
Show custom fonts
Diffstat (limited to 'Map')
-rw-r--r--Map/Presentation/Base Components/MapRender/MapAxes.swift9
-rw-r--r--Map/Presentation/Base Components/MapRender/MapMask.swift3
-rw-r--r--Map/Presentation/Complex Components/MapRender/MapRenderView.swift8
-rw-r--r--Map/Presentation/MapEditor.swift2
-rw-r--r--Map/Presentation/Preferences/MapPreferencesView.swift31
-rw-r--r--Map/Presentation/Preferences/TemplatesPreferencesView.swift8
-rw-r--r--Map/Presentation/PreferencesWindow.swift2
-rw-r--r--Map/Presentation/Theme/Font+theme.swift25
8 files changed, 51 insertions, 37 deletions
diff --git a/Map/Presentation/Base Components/MapRender/MapAxes.swift b/Map/Presentation/Base Components/MapRender/MapAxes.swift
index d9fe189..9d0f43f 100644
--- a/Map/Presentation/Base Components/MapRender/MapAxes.swift
+++ b/Map/Presentation/Base Components/MapRender/MapAxes.swift
@@ -38,14 +38,15 @@ struct MapAxes: View {
// Y Labels
Text("map.axis.y.top").font(.Theme.Map.axisLabel).foregroundColor(.Theme.Map.labelColor)
.rotationEffect(
- Angle(degrees: -90.0)
+ Angle(degrees: -90.0), anchor: .topLeading
)
- .offset(CGSize(width: -35.0, height: 0.0))
+ .offset(CGSize(width: -20.0, height: 45))
+
Text("map.axis.y.bottom").font(.Theme.Map.axisLabel).foregroundColor(.Theme.Map.labelColor)
.rotationEffect(
- Angle(degrees: -90.0)
+ Angle(degrees: -90.0), anchor: .topLeading
)
- .offset(CGSize(width: -40.0, height: mapSize.height - 20))
+ .offset(CGSize(width: -20.0, height: mapSize.height))
// X Labels
diff --git a/Map/Presentation/Base Components/MapRender/MapMask.swift b/Map/Presentation/Base Components/MapRender/MapMask.swift
index 807310c..2c064b3 100644
--- a/Map/Presentation/Base Components/MapRender/MapMask.swift
+++ b/Map/Presentation/Base Components/MapRender/MapMask.swift
@@ -37,7 +37,8 @@ struct MapMask: View {
.offset(
CGSize(
width: w(vertex.position.x) + vertexSize.width + padding,
- height: h(vertex.position.y) + 7.0))
+ height: h(vertex.position.y) + 7.0)
+ )
.blendMode(.destinationOut)
}.zIndex(1)
}
diff --git a/Map/Presentation/Complex Components/MapRender/MapRenderView.swift b/Map/Presentation/Complex Components/MapRender/MapRenderView.swift
index 7fd4092..b821634 100644
--- a/Map/Presentation/Complex Components/MapRender/MapRenderView.swift
+++ b/Map/Presentation/Complex Components/MapRender/MapRenderView.swift
@@ -50,7 +50,7 @@ struct MapRenderView: View {
x: -padding, y: -padding, width: mapSize.width + padding * 2,
height: mapSize.height + padding * 4))
}.fill(.white)
-
+
// The order Matters. Think of this as layers.
if showMapBackground {
@@ -70,9 +70,9 @@ struct MapRenderView: View {
MapMask(
mapSize: mapSize, vertexSize: vertexSize, vertices: parsedMap.vertices)
}
- MapVertices(
- mapSize: mapSize, vertexSize: vertexSize, vertices: parsedMap.vertices,
- onDragVertex: onDragVertex)
+ MapVertices(
+ mapSize: mapSize, vertexSize: vertexSize, vertices: parsedMap.vertices,
+ onDragVertex: onDragVertex)
MapGroups(mapSize: mapSize, vertexSize: vertexSize, groups: parsedMap.groups).drawingGroup(
opaque: true
).opacity(0.1)
diff --git a/Map/Presentation/MapEditor.swift b/Map/Presentation/MapEditor.swift
index 267492c..4116171 100644
--- a/Map/Presentation/MapEditor.swift
+++ b/Map/Presentation/MapEditor.swift
@@ -106,7 +106,7 @@ struct MapEditor: View {
.background(Color.Theme.UI.background)
.cornerRadius(5.0)
GeometryReader { geometry in
- ScrollView([.horizontal, .vertical]) {
+ ScrollView([.horizontal, .vertical], showsIndicators: false) {
MapRenderView(
document: $document, evolution: $selectedEvolution, onDragVertex: onDragVertex
).scaleEffect(zoom, anchor: .center).frame(
diff --git a/Map/Presentation/Preferences/MapPreferencesView.swift b/Map/Presentation/Preferences/MapPreferencesView.swift
index c5a9236..264be14 100644
--- a/Map/Presentation/Preferences/MapPreferencesView.swift
+++ b/Map/Presentation/Preferences/MapPreferencesView.swift
@@ -20,23 +20,29 @@ struct MapPreferencesView: View {
@AppStorage("useSmartEditor") private var useSmartEditor = false
@AppStorage("useCustomFont") private var useCustomFont = false
@AppStorage("customFontName") private var customFontName = "Helvetica"
-
+
var body: some View {
VStack(alignment: .center, spacing: Dimensions.Spacing.loose) {
HStack(alignment: .firstTextBaseline, spacing: Dimensions.Spacing.regular) {
Text("preferences.map.map_style.title")
.font(.Theme.Body.emphasized)
.frame(maxWidth: .infinity, alignment: .trailing)
-
+
VStack(alignment: .leading, spacing: Dimensions.Spacing.cozy) {
- Toggle(isOn: $showBackground, label: { Text("preferences.map.map_style.show_background")
+ Toggle(
+ isOn: $showBackground,
+ label: {
+ Text("preferences.map.map_style.show_background")
.font(.Theme.Body.regular)
- })
-
- Toggle(isOn: $useCustomFont, label: { Text("preferences.map.map_style.use_custom_font")
+ })
+
+ Toggle(
+ isOn: $useCustomFont,
+ label: {
+ Text("preferences.map.map_style.use_custom_font")
.font(.Theme.Body.regular)
- })
-
+ })
+
Picker("", selection: $customFontName) {
ForEach(NSFontManager.shared.availableFontFamilies, id: \.self) { fontFamily in
Text(fontFamily).tag(fontFamily)
@@ -47,16 +53,17 @@ struct MapPreferencesView: View {
}
.frame(maxWidth: .infinity, alignment: .leading)
}
-
+
Divider()
-
+
HStack(alignment: .firstTextBaseline, spacing: Dimensions.Spacing.regular) {
Text("preferences.map.editor.title")
.font(.Theme.Body.emphasized)
.frame(maxWidth: .infinity, alignment: .trailing)
-
+
VStack(alignment: .leading, spacing: Dimensions.Spacing.cozy) {
- Toggle(String(localized: "preferences.map.editor.use_smart_editor"), isOn: $useSmartEditor)
+ Toggle(
+ String(localized: "preferences.map.editor.use_smart_editor"), isOn: $useSmartEditor)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
diff --git a/Map/Presentation/Preferences/TemplatesPreferencesView.swift b/Map/Presentation/Preferences/TemplatesPreferencesView.swift
index 2b70b67..5de2428 100644
--- a/Map/Presentation/Preferences/TemplatesPreferencesView.swift
+++ b/Map/Presentation/Preferences/TemplatesPreferencesView.swift
@@ -128,9 +128,9 @@ struct TemplatesPreferencesView: View {
.border(Color.Theme.UI.foreground.opacity(0.2), width: 1)
HStack(spacing: Dimensions.Spacing.regular) {
-
+
Spacer()
-
+
Button(action: { showingHelpPopover = true }) {
Image(systemName: "questionmark.circle")
}
@@ -143,14 +143,14 @@ struct TemplatesPreferencesView: View {
.frame(width: 300)
.padding(Dimensions.Spacing.regular)
}
-
+
HStack(spacing: Dimensions.Spacing.coziest) {
Button(action: { showingAddSheet = true }) {
Image(systemName: "plus")
}
.keyboardShortcut("t", modifiers: [.command])
.help("preferences.templates.help.add")
-
+
Button(action: {
removeTemplate(selectedTemplate)
}) {
diff --git a/Map/Presentation/PreferencesWindow.swift b/Map/Presentation/PreferencesWindow.swift
index 202a637..962d5ca 100644
--- a/Map/Presentation/PreferencesWindow.swift
+++ b/Map/Presentation/PreferencesWindow.swift
@@ -16,7 +16,7 @@
import SwiftUI
enum PreferencesTab: CaseIterable {
-
+
case general
case appearance
case map
diff --git a/Map/Presentation/Theme/Font+theme.swift b/Map/Presentation/Theme/Font+theme.swift
index 079c0de..4660e48 100644
--- a/Map/Presentation/Theme/Font+theme.swift
+++ b/Map/Presentation/Theme/Font+theme.swift
@@ -48,27 +48,32 @@ extension Font {
struct Map {
static var note: Font {
if UserDefaults.standard.bool(forKey: "useCustomFont"),
- let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
- !customFontName.isEmpty {
+ let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
+ !customFontName.isEmpty
+ {
return Font.custom(customFontName, size: Dimensions.FontSize.Map.note).weight(.regular)
}
return Font.libertinus(size: Dimensions.FontSize.Map.note).weight(.regular)
}
-
+
static var axisLabel: Font {
if UserDefaults.standard.bool(forKey: "useCustomFont"),
- let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
- !customFontName.isEmpty {
- return Font.custom(customFontName, size: Dimensions.FontSize.Map.axisLabel).weight(.regular)
+ let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
+ !customFontName.isEmpty
+ {
+ return Font.custom(customFontName, size: Dimensions.FontSize.Map.axisLabel).weight(
+ .regular)
}
return Font.libertinus(size: Dimensions.FontSize.Map.axisLabel).weight(.regular)
}
-
+
static var vertexLabel: Font {
if UserDefaults.standard.bool(forKey: "useCustomFont"),
- let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
- !customFontName.isEmpty {
- return Font.custom(customFontName, size: Dimensions.FontSize.Map.vertexLabel).weight(.regular)
+ let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
+ !customFontName.isEmpty
+ {
+ return Font.custom(customFontName, size: Dimensions.FontSize.Map.vertexLabel).weight(
+ .regular)
}
return Font.libertinus(size: Dimensions.FontSize.Map.vertexLabel).weight(.regular)
}