@@ -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