summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-05 09:09:13 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-05 09:09:13 +0300
commit645b7351a80713a40e2c823479a3605baeb231b8 (patch)
treefbe9819bd63183a80afeb69f36cb9349e6794f7a
parent57088565bd7a3edbf55d63780573096124a1fc1b (diff)
Fix: add different kind of notifiction for fullscreen mode
-rw-r--r--tui.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/tui.go b/tui.go
index b9bf35f..36a34bb 100644
--- a/tui.go
+++ b/tui.go
@@ -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() {