Some refactoring and fixing in confirmation popup implementation

- Restoring focus to previous (taskPane) panel after closing modal (works only when invoked with shortcut)
- `projectPane.RemoveActivateProject()` and `taskPane.ClearCompletedTasks()` do comply with `func()`. So no need to wrap within `func() {}`
- Fixed issue - Project dosen't exit with Ctrl+C once (maybe because of re-running `.Run()` in `AskYesNo()`).
- When focusing back to tasklist from task detail, re-showing projectDetail pane
This commit is contained in:
Anis Ahmad
2022-01-07 21:33:59 +06:00
parent e466e2f801
commit ca0479b28a
3 changed files with 19 additions and 13 deletions

View File

@@ -139,6 +139,7 @@ func makeTitleBar() *tview.Flex {
func AskYesNo(text string, f func()) {
activePane := app.GetFocus()
modal := tview.NewModal().
SetText(text).
AddButtons([]string{"Yes", "No"}).
@@ -146,12 +147,12 @@ func AskYesNo(text string, f func()) {
if buttonLabel == "Yes" {
f()
}
pages := tview.NewPages().
AddPage("background", layout, true, true)
_ = app.SetRoot(pages, true).EnableMouse(true).Run()
app.SetRoot(layout, true).EnableMouse(true)
app.SetFocus(activePane)
})
pages := tview.NewPages().
AddPage("background", layout, true, true).
AddPage("modal", modal, true, true)
_ = app.SetRoot(pages, true).EnableMouse(true).Run()
_ = app.SetRoot(pages, true).EnableMouse(true)
}