Skip to content

Commit f7e8337

Browse files
committed
More UI Stuff
1 parent 9b16cf3 commit f7e8337

2 files changed

Lines changed: 84 additions & 30 deletions

File tree

StikJIT/JSSupport/ScriptEditorView.swift

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct ScriptEditorView: View {
2525
text: $scriptContent,
2626
position: $position,
2727
messages: $messages,
28-
language: .swift()
28+
language: .swift() // ← JavaScript syntax highlighting
2929
)
3030
.font(.system(.footnote, design: .monospaced))
3131
.frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -36,22 +36,18 @@ struct ScriptEditorView: View {
3636

3737
Divider()
3838

39-
HStack {
40-
Button("Cancel") {
39+
// Equal-width, centered, rounded-rectangle buttons
40+
HStack(spacing: 12) {
41+
WideGlassyButton(title: "Cancel", systemImage: "xmark") {
4142
dismiss()
4243
}
43-
.buttonStyle(.bordered)
44-
45-
Spacer()
46-
47-
Button("Save") {
44+
WideGlassyButton(title: "Save", systemImage: "checkmark") {
4845
saveScript()
4946
dismiss()
5047
}
51-
.buttonStyle(.borderedProminent)
52-
.foregroundColor(.black)
5348
}
54-
.padding()
49+
.padding(.horizontal)
50+
.padding(.vertical, 12)
5551
}
5652
.navigationTitle(scriptURL.lastPathComponent)
5753
.navigationBarTitleDisplayMode(.inline)
@@ -67,3 +63,39 @@ struct ScriptEditorView: View {
6763
try? scriptContent.write(to: scriptURL, atomically: true, encoding: .utf8)
6864
}
6965
}
66+
67+
// MARK: - Equal-width rounded-rectangle button (centered content)
68+
private struct WideGlassyButton: View {
69+
let title: String
70+
let systemImage: String
71+
let action: () -> Void
72+
73+
var body: some View {
74+
Button(action: action) {
75+
HStack(spacing: 8) {
76+
Image(systemName: systemImage)
77+
.imageScale(.medium)
78+
.font(.body.weight(.semibold))
79+
Text(title)
80+
.font(.body.weight(.semibold))
81+
.lineLimit(1)
82+
.minimumScaleFactor(0.85)
83+
}
84+
.frame(maxWidth: .infinity, alignment: .center) // center label+icon
85+
.padding(.vertical, 10)
86+
.padding(.horizontal, 14)
87+
}
88+
.frame(height: 44)
89+
.frame(maxWidth: .infinity) // equal widths within HStack
90+
.background(
91+
RoundedRectangle(cornerRadius: 12, style: .continuous)
92+
.fill(.ultraThinMaterial)
93+
)
94+
.overlay(
95+
RoundedRectangle(cornerRadius: 12, style: .continuous)
96+
.strokeBorder(Color.white.opacity(0.12), lineWidth: 1)
97+
)
98+
.contentShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
99+
.buttonStyle(.plain)
100+
}
101+
}

StikJIT/JSSupport/ScriptListView.swift

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ struct ScriptListView: View {
127127
Button("Cancel", role: .cancel) { }
128128
}
129129
.alert("Delete Script?", isPresented: $showDeleteConfirmation, presenting: pendingDelete) { script in
130-
Button("Delete", role: .destructive) {
131-
deleteScript(script)
132-
}
130+
Button("Delete", role: .destructive) { deleteScript(script) }
133131
Button("Cancel", role: .cancel) { pendingDelete = nil }
134132
} message: { script in
135133
Text("Are you sure you want to delete \(script.lastPathComponent)? This cannot be undone.")
@@ -158,23 +156,13 @@ struct ScriptListView: View {
158156
.strokeBorder(Color.white.opacity(0.12), lineWidth: 1)
159157
)
160158

161-
HStack {
162-
Button {
159+
// Equal-width rounded-rectangle buttons with centered content
160+
HStack(spacing: 12) {
161+
WideGlassyButton(title: "New", systemImage: "doc.badge.plus") {
163162
showNewFileAlert = true
164-
} label: {
165-
Label("New", systemImage: "doc.badge.plus")
166-
.font(.callout.weight(.semibold))
167-
.padding(10)
168-
.background(.ultraThinMaterial, in: Capsule())
169163
}
170-
171-
Button {
164+
WideGlassyButton(title: "Import", systemImage: "tray.and.arrow.down") {
172165
showImporter = true
173-
} label: {
174-
Label("Import", systemImage: "tray.and.arrow.down")
175-
.font(.callout.weight(.semibold))
176-
.padding(10)
177-
.background(.ultraThinMaterial, in: Capsule())
178166
}
179167
}
180168
}
@@ -259,9 +247,8 @@ struct ScriptListView: View {
259247
do {
260248
if exists && !isDir.boolValue {
261249
try FileManager.default.removeItem(at: dir)
262-
exists = false
263250
}
264-
if !exists {
251+
if !exists || !isDir.boolValue {
265252
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
266253
if let bundleURL = Bundle.main.url(forResource: "attachDetach", withExtension: "js") {
267254
let dest = dir.appendingPathComponent("attachDetach.js")
@@ -370,3 +357,38 @@ struct ScriptListView: View {
370357
}
371358
}
372359
}
360+
361+
// MARK: - Equal-width rounded-rectangle button (centered content)
362+
private struct WideGlassyButton: View {
363+
let title: String
364+
let systemImage: String
365+
let action: () -> Void
366+
367+
var body: some View {
368+
Button(action: action) {
369+
HStack(spacing: 8) {
370+
Image(systemName: systemImage)
371+
.imageScale(.medium)
372+
.font(.body.weight(.semibold))
373+
Text(title)
374+
.font(.body.weight(.semibold))
375+
.lineLimit(1)
376+
.minimumScaleFactor(0.8)
377+
}
378+
.frame(maxWidth: .infinity, alignment: .center) // center contents horizontally
379+
.padding(.horizontal, 14)
380+
}
381+
.frame(height: 44)
382+
.frame(maxWidth: .infinity) // make both buttons equal width
383+
.background(
384+
RoundedRectangle(cornerRadius: 12, style: .continuous)
385+
.fill(.ultraThinMaterial)
386+
)
387+
.overlay(
388+
RoundedRectangle(cornerRadius: 12, style: .continuous)
389+
.strokeBorder(Color.white.opacity(0.12), lineWidth: 1)
390+
)
391+
.contentShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
392+
.buttonStyle(.plain)
393+
}
394+
}

0 commit comments

Comments
 (0)