@@ -173,7 +173,6 @@ extension PromptToCodePanelView {
173173
174174 struct ActionButtons : View {
175175 @Perception . Bindable var store : StoreOf < PromptToCodePanel >
176- @Environment ( \. modifierFlags) var modifierFlags
177176
178177 var body : some View {
179178 WithPerceptionTracking {
@@ -201,9 +200,13 @@ extension PromptToCodePanelView {
201200 }
202201 } label: {
203202 Image ( systemName: " gearshape.fill " )
203+ . resizable ( )
204+ . scaledToFit ( )
204205 . foregroundStyle ( . secondary)
206+ . frame ( width: 16 )
207+ . frame ( maxHeight: . infinity)
208+ . contentShape ( Rectangle ( ) )
205209 }
206- . frame ( width: 16 )
207210 . buttonStyle ( . plain)
208211
209212 Button ( action: {
@@ -215,50 +218,10 @@ extension PromptToCodePanelView {
215218 . keyboardShortcut ( " w " , modifiers: [ . command] )
216219
217220 if !isCodeEmpty {
218- let defaultModeIsContinuous = store. isContinuous
219-
220- Button ( action: {
221- switch (
222- modifierFlags. contains ( . option) ,
223- defaultModeIsContinuous
224- ) {
225- case ( true , true ) :
226- store. send ( . acceptButtonTapped)
227- case ( false , true ) :
228- store. send ( . acceptAndContinueButtonTapped)
229- case ( true , false ) :
230- store. send ( . acceptAndContinueButtonTapped)
231- case ( false , false ) :
232- store. send ( . acceptButtonTapped)
233- }
234- } ) {
235- switch (
236- isAttached,
237- modifierFlags. contains ( . option) ,
238- defaultModeIsContinuous
239- ) {
240- case ( true , true , true ) :
241- Text ( " Accept(⌥ + ⌘ + ⏎) " )
242- case ( true , false , true ) :
243- Text ( " Accept and Continue(⌘ + ⏎) " )
244- case ( true , true , false ) :
245- Text ( " Accept and Continue(⌥ + ⌘ + ⏎) " )
246- case ( true , false , false ) :
247- Text ( " Accept(⌘ + ⏎) " )
248- case ( false , true , true ) :
249- Text ( " Replace(⌥ + ⌘ + ⏎) " )
250- case ( false , false , true ) :
251- Text ( " Replace and Continue(⌘ + ⏎) " )
252- case ( false , true , false ) :
253- Text ( " Replace and Continue(⌥ + ⌘ + ⏎) " )
254- case ( false , false , false ) :
255- Text ( " Replace(⌘ + ⏎) " )
256- }
257- }
258- . buttonStyle ( CommandButtonStyle ( color: . accentColor) )
259- . keyboardShortcut ( KeyEquivalent . return, modifiers: [ . command] )
221+ AcceptButton ( store: store)
260222 }
261223 }
224+ . fixedSize ( )
262225 . padding ( 8 )
263226 . background (
264227 . regularMaterial,
@@ -276,6 +239,139 @@ extension PromptToCodePanelView {
276239 }
277240 }
278241 }
242+
243+ struct AcceptButton : View {
244+ let store : StoreOf < PromptToCodePanel >
245+ @Environment ( \. modifierFlags) var modifierFlags
246+
247+ struct TheButtonStyle : ButtonStyle {
248+ func makeBody( configuration: Configuration ) -> some View {
249+ configuration. label
250+ . background (
251+ Rectangle ( )
252+ . fill ( Color . accentColor. opacity ( configuration. isPressed ? 0.8 : 1 ) )
253+ )
254+ }
255+ }
256+
257+ var body : some View {
258+ WithPerceptionTracking {
259+ let defaultModeIsContinuous = store. isContinuous
260+ let isAttached = store. promptToCodeState. isAttachedToTarget
261+
262+ HStack ( spacing: 0 ) {
263+ Button ( action: {
264+ switch (
265+ modifierFlags. contains ( . option) ,
266+ defaultModeIsContinuous
267+ ) {
268+ case ( true , true ) :
269+ store. send ( . acceptButtonTapped)
270+ case ( false , true ) :
271+ store. send ( . acceptAndContinueButtonTapped)
272+ case ( true , false ) :
273+ store. send ( . acceptAndContinueButtonTapped)
274+ case ( false , false ) :
275+ store. send ( . acceptButtonTapped)
276+ }
277+ } ) {
278+ Group {
279+ switch (
280+ isAttached,
281+ modifierFlags. contains ( . option) ,
282+ defaultModeIsContinuous
283+ ) {
284+ case ( true , true , true ) :
285+ Text ( " Accept(⌥ + ⌘ + ⏎) " )
286+ case ( true , false , true ) :
287+ Text ( " Accept and Continue(⌘ + ⏎) " )
288+ case ( true , true , false ) :
289+ Text ( " Accept and Continue(⌥ + ⌘ + ⏎) " )
290+ case ( true , false , false ) :
291+ Text ( " Accept(⌘ + ⏎) " )
292+ case ( false , true , true ) :
293+ Text ( " Replace(⌥ + ⌘ + ⏎) " )
294+ case ( false , false , true ) :
295+ Text ( " Replace and Continue(⌘ + ⏎) " )
296+ case ( false , true , false ) :
297+ Text ( " Replace and Continue(⌥ + ⌘ + ⏎) " )
298+ case ( false , false , false ) :
299+ Text ( " Replace(⌘ + ⏎) " )
300+ }
301+ }
302+ . padding ( . vertical, 4 )
303+ . padding ( . leading, 8 )
304+ . padding ( . trailing, 4 )
305+ }
306+ . buttonStyle ( TheButtonStyle ( ) )
307+ . keyboardShortcut ( KeyEquivalent . return, modifiers: [ . command] )
308+ . background {
309+ Button ( action: {
310+ switch (
311+ modifierFlags. contains ( . option) ,
312+ defaultModeIsContinuous
313+ ) {
314+ case ( true , true ) :
315+ store. send ( . acceptAndContinueButtonTapped)
316+ case ( false , true ) :
317+ store. send ( . acceptButtonTapped)
318+ case ( true , false ) :
319+ store. send ( . acceptButtonTapped)
320+ case ( false , false ) :
321+ store. send ( . acceptAndContinueButtonTapped)
322+ }
323+ } ) {
324+ EmptyView ( )
325+ }
326+ . buttonStyle ( . plain)
327+ . keyboardShortcut ( KeyEquivalent . return, modifiers: [ . command, . option] )
328+ }
329+
330+ Divider ( )
331+
332+ Menu {
333+ WithPerceptionTracking {
334+ if defaultModeIsContinuous {
335+ Button ( action: {
336+ store. send ( . acceptButtonTapped)
337+ } ) {
338+ Text ( " Accept(⌥ + ⌘ + ⏎) " )
339+ }
340+ } else {
341+ Button ( action: {
342+ store. send ( . acceptAndContinueButtonTapped)
343+ } ) {
344+ Text ( " Accept and Continue(⌥ + ⌘ + ⏎) " )
345+ }
346+ }
347+ }
348+ } label: {
349+ Text ( Image ( systemName: " chevron.down " ) )
350+ . font ( . footnote. weight ( . bold) )
351+ . scaleEffect ( 0.8 )
352+ . foregroundStyle ( . white. opacity ( 0.8 ) )
353+ . frame ( maxHeight: . infinity)
354+ . padding ( . leading, 1 )
355+ . padding ( . trailing, 2 )
356+ . contentShape ( Rectangle ( ) )
357+ }
358+ . buttonStyle ( . plain)
359+ }
360+ . fixedSize ( )
361+
362+ . foregroundColor ( . white)
363+ . clipShape ( RoundedRectangle ( cornerRadius: 4 , style: . continuous) )
364+ . background (
365+ RoundedRectangle ( cornerRadius: 4 , style: . continuous)
366+ . fill ( Color . accentColor)
367+ )
368+ . overlay {
369+ RoundedRectangle ( cornerRadius: 4 , style: . continuous)
370+ . stroke ( Color . white. opacity ( 0.2 ) , style: . init( lineWidth: 1 ) )
371+ }
372+ }
373+ }
374+ }
279375 }
280376
281377 struct Content : View {
0 commit comments