diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-03-05 09:09:13 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-03-05 09:09:13 +0300 |
| commit | 645b7351a80713a40e2c823479a3605baeb231b8 (patch) | |
| tree | fbe9819bd63183a80afeb69f36cb9349e6794f7a /tui.go | |
| parent | 57088565bd7a3edbf55d63780573096124a1fc1b (diff) | |
Fix: add different kind of notifiction for fullscreen mode
Diffstat (limited to 'tui.go')
| -rw-r--r-- | tui.go | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -160,6 +160,40 @@ func showToast(title, message string) { if toastTimer != nil { toastTimer.Stop() } + // show blocking notification to not mess up flex + if fullscreenMode { + notification := tview.NewTextView(). + SetTextAlign(tview.AlignCenter). + SetDynamicColors(true). + SetRegions(true). + SetText(fmt.Sprintf("[yellow]%s[-]\n", message)). + SetChangedFunc(func() { + app.Draw() + }) + notification.SetTitleAlign(tview.AlignLeft). + SetBorder(true). + SetTitle(title) + // Wrap it in a full‑screen Flex to position it in the top‑right corner. + // Outer Flex (row) pushes content to the top; inner Flex (column) pushes to the right. + background := tview.NewFlex().SetDirection(tview.FlexRow). + AddItem(nil, 0, 1, false). // top spacer + AddItem(tview.NewFlex().SetDirection(tview.FlexColumn). + AddItem(nil, 0, 1, false). // left spacer + AddItem(notification, 40, 1, true), // notification width 40 + 5, 1, false) // notification height 5 + // Generate a unique page name (e.g., using timestamp) to allow multiple toasts. + pageName := fmt.Sprintf("toast-%d", time.Now().UnixNano()) + pages.AddPage(pageName, background, true, true) + // Auto‑dismiss after 2 seconds, since blocking is more annoying + time.AfterFunc(2*time.Second, func() { + app.QueueUpdateDraw(func() { + if pages.HasPage(pageName) { + pages.RemovePage(pageName) + } + }) + }) + return + } notificationWidget.SetTitle(title) notificationWidget.SetText(fmt.Sprintf("[yellow]%s[-]", message)) go func() { |
