Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit 753c2e4

Browse files
committed
Merge branch 'core-text-logic' into editor-store
2 parents dcc8adb + ea3c70f commit 753c2e4

3 files changed

Lines changed: 93 additions & 74 deletions

File tree

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift‎

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,21 @@ struct ContentView: View {
246246
printDiagram()
247247
#endif
248248
}
249+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.sharePNG)) { _ in
250+
guard !isSimulationMode else { return }
251+
exportPNG()
252+
}
253+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.shareDocument)) { _ in
254+
guard !isSimulationMode else { return }
255+
shareDocumentAsFile()
256+
}
257+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.exportPDF)) { _ in
258+
guard !isSimulationMode else { return }
259+
shareDiagramPDF()
260+
}
261+
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.showAbout)) { _ in
262+
showInfo = true
263+
}
249264
.onReceive(NotificationCenter.default.publisher(for: DiagramMenuNotification.close)) { _ in
250265
guard !isSimulationMode else { return }
251266
requestCloseDiagramTab(id: tabsModel.selectedTabId)
@@ -590,65 +605,6 @@ struct ContentView: View {
590605
.accessibilityLabel(
591606
codeGeneratorAccessGranted ? lang.tr("a11y_generate_code") : lang.tr("a11y_generate_code_locked")
592607
)
593-
Button {
594-
exportPNG()
595-
} label: {
596-
Label(lang.tr("action_share_png"), systemImage: "square.and.arrow.up")
597-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
598-
}
599-
.buttonStyle(PaletteListElementButtonStyle())
600-
.disabledAndDimmed(isSimulationMode)
601-
.listRowInsets(
602-
isCompact
603-
? EdgeInsets(top: 3, leading: 10, bottom: 3, trailing: 10)
604-
: EdgeInsets(top: 5, leading: 12, bottom: 5, trailing: 12)
605-
)
606-
.listRowSeparator(.hidden)
607-
.listRowBackground(Color.clear)
608-
Button {
609-
shareDocumentAsFile()
610-
} label: {
611-
Label(lang.tr("action_share_document"), systemImage: "square.and.arrow.up.on.square")
612-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
613-
}
614-
.buttonStyle(PaletteListElementButtonStyle())
615-
.disabledAndDimmed(isSimulationMode)
616-
.listRowInsets(
617-
isCompact
618-
? EdgeInsets(top: 3, leading: 10, bottom: 3, trailing: 10)
619-
: EdgeInsets(top: 5, leading: 12, bottom: 5, trailing: 12)
620-
)
621-
.listRowSeparator(.hidden)
622-
.listRowBackground(Color.clear)
623-
Button {
624-
shareDiagramPDF()
625-
} label: {
626-
Label(lang.tr("action_export_pdf"), systemImage: "doc.text.magnifyingglass")
627-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
628-
}
629-
.buttonStyle(PaletteListElementButtonStyle())
630-
.disabledAndDimmed(isSimulationMode)
631-
.listRowInsets(
632-
isCompact
633-
? EdgeInsets(top: 3, leading: 10, bottom: 3, trailing: 10)
634-
: EdgeInsets(top: 5, leading: 12, bottom: 5, trailing: 12)
635-
)
636-
.listRowSeparator(.hidden)
637-
.listRowBackground(Color.clear)
638-
639-
Button {
640-
showInfo = true
641-
} label: {
642-
Label(lang.tr("action_about"), systemImage: "info.circle")
643-
}
644-
.buttonStyle(PaletteListElementButtonStyle())
645-
.listRowInsets(
646-
isCompact
647-
? EdgeInsets(top: 3, leading: 10, bottom: 4, trailing: 10)
648-
: EdgeInsets(top: 5, leading: 12, bottom: 8, trailing: 12)
649-
)
650-
.listRowSeparator(.hidden)
651-
.listRowBackground(Color.clear)
652608
}
653609
}
654610
.listStyle(.insetGrouped)
@@ -745,6 +701,10 @@ struct ContentView: View {
745701
onSave: performPrimarySave,
746702
onSaveAs: { showExporter = true },
747703
onPrint: printAction,
704+
onSharePNG: exportPNG,
705+
onShareDocument: shareDocumentAsFile,
706+
onExportPDF: shareDiagramPDF,
707+
onShowAbout: { showInfo = true },
748708
onKeyboardDismiss: {
749709
focusedField = nil
750710
if isPhone { hideInspectorOnPhone = true }

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/Toolbar/DiagramMainEditorToolbar.swift‎

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SwiftUI
22

3-
/// Hauptfenster-Toolbar: Titel, Undo/Redo, Datei-Menü, Palette (iPhone), Tastatur „Fertig“.
3+
/// Hauptfenster-Toolbar: Titel, Undo/Redo, Datei-Menü (inkl. Teilen/Export und Info), Palette (iPhone), Tastatur „Fertig“.
44
/// Diagramm-Reiter liegen in `DiagramTabStrip`.
55
struct DiagramMainEditorToolbar: ToolbarContent {
66
@Environment(\.appLanguage) private var lang
@@ -29,6 +29,11 @@ struct DiagramMainEditorToolbar: ToolbarContent {
2929
/// Nur unter UIKit (Druck); sonst `nil` und kein Eintrag.
3030
let onPrint: (() -> Void)?
3131

32+
let onSharePNG: () -> Void
33+
let onShareDocument: () -> Void
34+
let onExportPDF: () -> Void
35+
let onShowAbout: () -> Void
36+
3237
let onKeyboardDismiss: () -> Void
3338

3439
var body: some ToolbarContent {
@@ -76,8 +81,8 @@ struct DiagramMainEditorToolbar: ToolbarContent {
7681
Menu {
7782
Button(action: onOpenImporter) {
7883
Label(lang.tr("menu_open"), systemImage: "square.and.arrow.down")
79-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
8084
}
85+
.disabled(isSimulationMode)
8186
Menu {
8287
if recentFiles.isEmpty {
8388
Text(lang.tr("recent_files_empty"))
@@ -97,26 +102,43 @@ struct DiagramMainEditorToolbar: ToolbarContent {
97102
} label: {
98103
Label(lang.tr("recent_files_menu"), systemImage: "clock")
99104
}
105+
.disabled(isSimulationMode)
100106
Divider()
101-
Button(action: onSave) {
102-
Label(lang.tr("menu_save"), systemImage: "arrow.down.doc")
103-
}
104-
Button(action: onSaveAs) {
105-
Label(lang.tr("menu_save_as"), systemImage: "square.and.arrow.up")
107+
Group {
108+
Button(action: onSave) {
109+
Label(lang.tr("menu_save"), systemImage: "arrow.down.doc")
110+
}
111+
Button(action: onSaveAs) {
112+
Label(lang.tr("menu_save_as"), systemImage: "square.and.arrow.up")
113+
}
106114
}
107-
#if canImport(UIKit)
108-
if let onPrint {
109-
Divider()
110-
Button(action: onPrint) {
111-
Label(lang.tr("menu_print"), systemImage: "printer")
115+
.disabled(isSimulationMode)
116+
Section {
117+
Button(action: onShareDocument) {
118+
Label(lang.tr("action_share_document"), systemImage: "square.and.arrow.up.on.square")
119+
}
120+
Button(action: onSharePNG) {
121+
Label(lang.tr("action_share_png"), systemImage: "photo")
122+
}
123+
Button(action: onExportPDF) {
124+
Label(lang.tr("action_export_pdf"), systemImage: "doc.text.magnifyingglass")
112125
}
126+
#if canImport(UIKit)
127+
if let onPrint {
128+
Button(action: onPrint) {
129+
Label(lang.tr("menu_print"), systemImage: "printer")
130+
}
131+
}
132+
#endif
133+
}
134+
.disabled(isSimulationMode)
135+
Divider()
136+
Button(action: onShowAbout) {
137+
Label(lang.tr("action_about"), systemImage: "info.circle")
113138
}
114-
#endif
115139
} label: {
116140
Label(lang.tr("menu_file"), systemImage: "folder")
117-
.foregroundStyle(isSimulationMode ? .tertiary : .primary)
118141
}
119-
.disabledAndDimmed(isSimulationMode)
120142
}
121143
#if canImport(UIKit)
122144
ToolbarItemGroup(placement: .keyboard) {

‎VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/VisuStructApp.swift‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ enum DiagramMenuNotification {
4747
static let printDocument = Notification.Name("visustruct.menu.print")
4848
static let close = Notification.Name("visustruct.menu.close")
4949
static let openRecent = Notification.Name("visustruct.menu.openRecent")
50+
static let sharePNG = Notification.Name("visustruct.menu.sharePNG")
51+
static let shareDocument = Notification.Name("visustruct.menu.shareDocument")
52+
static let exportPDF = Notification.Name("visustruct.menu.exportPDF")
53+
static let showAbout = Notification.Name("visustruct.menu.showAbout")
5054

5155
static let recentFileIDKey = "id"
5256
}
@@ -124,6 +128,22 @@ final class DiagramCommandCenter: ObservableObject {
124128
NotificationCenter.default.post(name: DiagramMenuNotification.close, object: nil)
125129
}
126130

131+
func sharePNG() {
132+
NotificationCenter.default.post(name: DiagramMenuNotification.sharePNG, object: nil)
133+
}
134+
135+
func shareDocument() {
136+
NotificationCenter.default.post(name: DiagramMenuNotification.shareDocument, object: nil)
137+
}
138+
139+
func exportPDF() {
140+
NotificationCenter.default.post(name: DiagramMenuNotification.exportPDF, object: nil)
141+
}
142+
143+
func showAbout() {
144+
NotificationCenter.default.post(name: DiagramMenuNotification.showAbout, object: nil)
145+
}
146+
127147
func openRecent(_ file: RecentVisuStructFile) {
128148
NotificationCenter.default.post(
129149
name: DiagramMenuNotification.openRecent,
@@ -297,6 +317,11 @@ private struct VisuStructCommands: Commands {
297317
}
298318

299319
var body: some Commands {
320+
CommandGroup(replacing: .appInfo) {
321+
Button(lang.tr("action_about")) {
322+
commandCenter.showAbout()
323+
}
324+
}
300325
CommandGroup(replacing: .newItem) {
301326
Button(lang.tr("menu_new")) {
302327
commandCenter.newDocument()
@@ -316,6 +341,18 @@ private struct VisuStructCommands: Commands {
316341
.keyboardShortcut("s", modifiers: [.command, .shift])
317342
.disabled(!commandCenter.canSaveAs)
318343
Divider()
344+
Button(lang.tr("action_share_document")) {
345+
commandCenter.shareDocument()
346+
}
347+
.disabled(!commandCenter.canPrint)
348+
Button(lang.tr("action_share_png")) {
349+
commandCenter.sharePNG()
350+
}
351+
.disabled(!commandCenter.canPrint)
352+
Button(lang.tr("action_export_pdf")) {
353+
commandCenter.exportPDF()
354+
}
355+
.disabled(!commandCenter.canPrint)
319356
Button(lang.tr("menu_print")) {
320357
commandCenter.printDocument()
321358
}

0 commit comments

Comments
 (0)