aboutsummaryrefslogtreecommitdiff
path: root/Map/Presentation/Preferences
diff options
context:
space:
mode:
Diffstat (limited to 'Map/Presentation/Preferences')
-rw-r--r--Map/Presentation/Preferences/StagesPreferencesView.swift1
-rw-r--r--Map/Presentation/Preferences/TemplatesPreferencesView.swift128
2 files changed, 76 insertions, 53 deletions
diff --git a/Map/Presentation/Preferences/StagesPreferencesView.swift b/Map/Presentation/Preferences/StagesPreferencesView.swift
index b1ce31c..cd347bf 100644
--- a/Map/Presentation/Preferences/StagesPreferencesView.swift
+++ b/Map/Presentation/Preferences/StagesPreferencesView.swift
@@ -113,7 +113,6 @@ struct StagesPreferencesView: View {
Button(action: addStage) {
Image(systemName: "plus")
}
- .buttonStyle(.borderless)
}
}
.padding(.vertical, Dimensions.Spacing.loose)
diff --git a/Map/Presentation/Preferences/TemplatesPreferencesView.swift b/Map/Presentation/Preferences/TemplatesPreferencesView.swift
index 2994450..92b9b09 100644
--- a/Map/Presentation/Preferences/TemplatesPreferencesView.swift
+++ b/Map/Presentation/Preferences/TemplatesPreferencesView.swift
@@ -89,43 +89,32 @@ struct TemplatesPreferencesView: View {
.lineSpacing(Dimensions.LineHeight.body - Dimensions.FontSize.body)
.padding(.top, Dimensions.Spacing.loose)
.padding(.bottom, Dimensions.Spacing.regular)
- HStack(spacing: 0) {
+ HStack(spacing: Dimensions.Spacing.cozy) {
VStack(alignment: .leading, spacing: Dimensions.Spacing.regular) {
- HStack {
- Text("preferences.templates.table.title")
- .font(.Theme.Body.emphasized)
-
- Spacer()
-
- Button(action: { showingAddSheet = true }) {
- Image(systemName: "plus")
- }
- .buttonStyle(.borderless)
-
- Button(action: {
- removeTemplate(selectedTemplate)
- }) {
- Image(systemName: "minus")
- }
- .buttonStyle(.borderless)
- .disabled(selectedTemplate == nil)
- }
-
List(templates.wrappedValue) { template in
- HStack {
- Button(action: { setDefaultTemplate(template) }) {
- Image(systemName: template.isDefault ? "largecircle.fill.circle" : "circle")
- .foregroundColor(
- selectedTemplate?.id == template.id
- ? Color.white
- : (template.isDefault
+ HStack(spacing: Dimensions.Spacing.coziest) {
+ if selectedTemplate?.id == template.id {
+ Button(action: { setDefaultTemplate(template) }) {
+ Image(systemName: template.isDefault ? "largecircle.fill.circle" : "circle")
+ .foregroundColor(Color.white)
+ }
+ .buttonStyle(.plain)
+ .keyboardShortcut("d", modifiers: [.command])
+ .help("preferences.templates.help.set_as_default")
+ } else {
+ Button(action: { setDefaultTemplate(template) }) {
+ Image(systemName: template.isDefault ? "largecircle.fill.circle" : "circle")
+ .foregroundColor(
+ template.isDefault
? Color.Theme.UI.accent : Color.Theme.UI.foreground.opacity(0.5))
- )
+ }
+ .buttonStyle(.plain)
+ .help("preferences.templates.help.set_as_default")
}
- .buttonStyle(.plain)
- .help("Set as default template")
Text(template.name)
+ .font(.Theme.Body.regular)
+ .kerning(Dimensions.Kerning.body)
.tag(template)
.foregroundColor(
selectedTemplate?.id == template.id ? Color.white : Color.Theme.UI.foreground
@@ -144,24 +133,40 @@ struct TemplatesPreferencesView: View {
}
}
.listStyle(.plain)
+ .border(Color.Theme.UI.foreground.opacity(0.2), width: 1)
+
+ HStack(spacing: Dimensions.Spacing.coziest) {
+
+ Spacer()
+
+ Button(action: { showingAddSheet = true }) {
+ Image(systemName: "plus")
+ }
+ .keyboardShortcut("t", modifiers: [.command])
+ .help("preferences.templates.help.add")
+
+ Button(action: {
+ removeTemplate(selectedTemplate)
+ }) {
+ Image(systemName: "minus")
+ }
+ .keyboardShortcut(.delete, modifiers: [.command])
+ .help("preferences.templates.help.remove \(selectedTemplate?.name ?? "")")
+ .disabled(selectedTemplate == nil)
+ }
}
.frame(width: Dimensions.Preferences.Sidebar.width)
Divider()
- VStack(alignment: .leading, spacing: 8) {
- if let selected = selectedTemplate {
- HStack {
- Text("Template: \(selected.name)")
- .font(.headline)
- Spacer()
- }
-
+ VStack(alignment: .leading, spacing: Dimensions.Spacing.regular) {
+ if selectedTemplate != nil {
MapTextEditor(text: selectedTemplateContent)
+ .border(Color.Theme.UI.foreground.opacity(0.2), width: 1)
} else {
VStack {
Spacer()
- Text("Select a template to edit")
+ Text("preferences.templates.empty_view")
.foregroundColor(.secondary)
Spacer()
}
@@ -169,7 +174,6 @@ struct TemplatesPreferencesView: View {
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
- .padding(.leading)
}
.onAppear {
// Initialize default templates if needed
@@ -185,24 +189,44 @@ struct TemplatesPreferencesView: View {
}
.sheet(isPresented: $showingAddSheet) {
VStack(spacing: Dimensions.Spacing.indulgent) {
- Text("Add New Template")
+ Text("preferences.templates.new_template.title")
.font(.Theme.Body.emphasized)
+ .kerning(Dimensions.Kerning.body)
- TextField("Template Name", text: $newTemplateName)
+ TextField("preferences.templates.new_template.placeholder", text: $newTemplateName)
.textFieldStyle(.roundedBorder)
.font(.Theme.Body.regular)
-
- HStack {
- Button("Cancel") {
- showingAddSheet = false
- newTemplateName = ""
+ .kerning(Dimensions.Kerning.body)
+ .onSubmit {
+ addTemplate()
}
- Spacer()
+ HStack(spacing: Dimensions.Spacing.coziest) {
- Button("Add") {
- addTemplate()
- }
+ Spacer()
+ Button(
+ action: {
+ showingAddSheet = false
+ newTemplateName = ""
+ },
+ label: {
+ Text("preferences.templates.new_template.cancel")
+ .font(.Theme.Body.regular)
+ .kerning(Dimensions.Kerning.body)
+ }
+ )
+ .keyboardShortcut(.escape)
+ Button(
+ action: {
+ addTemplate()
+ },
+ label: {
+ Text("preferences.templates.new_template.add")
+ .font(.Theme.Body.regular)
+ .kerning(Dimensions.Kerning.body)
+ }
+ )
+ .keyboardShortcut(.return)
.disabled(newTemplateName.isEmpty)
}
}