Show confirmation popup for delete project and clear completed tasks (#35)

This commit is contained in:
Kuprijanov Roman
2022-01-07 15:01:52 +02:00
committed by GitHub
parent e4132138ab
commit e466e2f801
3 changed files with 31 additions and 4 deletions

View File

@@ -88,9 +88,12 @@ func setKeyboardShortcuts() *tview.Application {
switch unicode.ToLower(event.Rune()) {
case 'p':
app.SetFocus(projectPane)
contents.RemoveItem(taskDetailPane)
return nil
case 'q':
case 't':
app.SetFocus(taskPane)
contents.RemoveItem(taskDetailPane)
return nil
}
@@ -133,3 +136,22 @@ func makeTitleBar() *tview.Flex {
AddItem(titleText, 0, 2, false).
AddItem(versionInfo, 0, 1, false)
}
func AskYesNo(text string, f func()) {
modal := tview.NewModal().
SetText(text).
AddButtons([]string{"Yes", "No"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Yes" {
f()
}
pages := tview.NewPages().
AddPage("background", layout, true, true)
_ = app.SetRoot(pages, true).EnableMouse(true).Run()
})
pages := tview.NewPages().
AddPage("background", layout, true, true).
AddPage("modal", modal, true, true)
_ = app.SetRoot(pages, true).EnableMouse(true).Run()
}