MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / CreateConfirmDialog

Function CreateConfirmDialog

internal/ui/components/dialogs_creators.go:36–73  ·  view source on GitHub ↗

CreateConfirmDialog creates a confirmation dialog.

(title, message string, onConfirm, onCancel func())

Source from the content-addressed store, hash-verified

34
35// CreateConfirmDialog creates a confirmation dialog.
36func CreateConfirmDialog(title, message string, onConfirm, onCancel func()) *tview.Modal {
37 modal := tview.NewModal()
38 modal.SetText(message)
39 // modal.SetBackgroundColor(theme.Colors.Background)
40 modal.SetTextColor(theme.Colors.Primary)
41 modal.SetBorderColor(theme.Colors.Border)
42 modal.SetTitle(title)
43 modal.SetTitleColor(theme.Colors.Title)
44
45 // Add buttons
46 modal.AddButtons([]string{"Yes", "No"})
47 modal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
48 if buttonIndex == 0 && onConfirm != nil {
49 onConfirm()
50 } else if onCancel != nil {
51 onCancel()
52 }
53 })
54
55 // Add keyboard shortcuts for Y/N keys
56 modal.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
57 switch event.Rune() {
58 case 'y', 'Y':
59 if onConfirm != nil {
60 onConfirm()
61 }
62 return nil
63 case 'n', 'N':
64 if onCancel != nil {
65 onCancel()
66 }
67 return nil
68 }
69 return event
70 })
71
72 return modal
73}
74
75// createBaseModal creates a base modal with common configuration.
76func createBaseModal(title, message string, textColor tcell.Color, onClose func()) *tview.Modal {

Callers 11

NewConfigWizardPageFunction · 0.85
showQuitConfirmationMethod · 0.85
showDeleteGroupDialogMethod · 0.85
restoreBackupMethod · 0.85
deleteBackupMethod · 0.85

Calls 5

SetTextColorMethod · 0.80
AddButtonsMethod · 0.80
SetDoneFuncMethod · 0.80
SetTitleMethod · 0.65
SetTextMethod · 0.45

Tested by

no test coverage detected