-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeSnippetTextEditingViewOld
119 lines (99 loc) · 5.73 KB
/
codeSnippetTextEditingViewOld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import SwiftUI
struct textEditView: View {
@EnvironmentObject var globalfile: GlobalDataModel // Access environment object
@State private var showingTextMenu: Bool = false
var body: some View {
VStack {
TextEditor(text: $globalfile.contentsOfFileGlobal) // Bind to the environment object
.frame(minWidth: 600, minHeight: 500) // Specify frame size
.padding()
.onAppear {
// Optionally perform actions when the view appears
}
.toolbar {
// Set the window title for macOS
ToolbarItem(placement: .principal) {
Button("SXMac editing \(globalfile.filePathed)") {
showingTextMenu = true
}
.font(.headline)
.popover(isPresented: $showingTextMenu) {
VStack {
ScrollView {
VStack(spacing: 16) {
HStack {
Text("Save changes now")
.fontWeight(.bold)
Spacer()
Button("Save") {
showingTextMenu = false
}
}
.padding()
.background(Color.clear) // Ensure no background for the rows
Divider() // Separator between rows
HStack {
Text("Discard changes")
.fontWeight(.bold)
Spacer()
Button("Close editor") {
showingTextMenu = false
}
}
.padding()
.background(Color.clear)
Divider()
HStack {
Text("Markdown viewer")
.fontWeight(.bold)
Spacer()
Button("Preview") {
showingTextMenu = false
}
}
.padding()
.background(Color.clear)
Divider()
HStack {
Text("Other")
.fontWeight(.bold)
Spacer()
Button(action: {
showingTextMenu = false
}) {
Image(systemName: "gear")
.imageScale(.large) // You can customize the image size here if needed
}
}
.padding()
.background(Color.clear)
Divider()
HStack {
Text("Quit")
.fontWeight(.bold)
Spacer()
Button("Close Md manager") {
showingTextMenu = false
}
}
.padding()
.background(Color.clear)
Divider()
HStack {
Text("UI by Evan Matthew ♡")
.padding()
.font(.system(size: 11))
.italic()
.foregroundColor(.gray)
.frame(maxWidth: .infinity, alignment: .center)
}
}
}
.frame(width: 300, height: 200) // Fixed size for the popover
}
}
}
}
}
}
}