mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
Switch to using HidePanel for modals
This commit is contained in:
parent
39f19bf643
commit
722d32a385
@ -2,7 +2,6 @@ package display
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/makeworld-the-better-one/amfora/bookmarks"
|
||||
@ -103,7 +102,7 @@ func openBkmkModal(name string, exists bool, favicon string) (string, int) {
|
||||
App.Draw()
|
||||
|
||||
action := <-bkmkCh
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("bkmk")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
|
||||
|
@ -33,8 +33,8 @@ var dlChoiceCh = make(chan string)
|
||||
var dlModal = cview.NewModal()
|
||||
|
||||
func dlInit() {
|
||||
panels.AddPanel("dlChoice", dlChoiceModal, false, false)
|
||||
panels.AddPanel("dl", dlModal, false, false)
|
||||
panels.AddPanel("dlChoice", dlChoiceModal, false, false)
|
||||
|
||||
dlm := dlModal
|
||||
chm := dlChoiceModal
|
||||
@ -84,7 +84,7 @@ func dlInit() {
|
||||
frame.SetTitle(" Download ")
|
||||
dlm.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||||
if buttonLabel == "Ok" {
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("dl")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
}
|
||||
@ -148,7 +148,9 @@ func dlChoice(text, u string, resp *gemini.Response) {
|
||||
open(u, resp)
|
||||
return
|
||||
}
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
|
||||
// They chose the "Cancel" button
|
||||
panels.HidePanel("dlChoice")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
}
|
||||
@ -184,9 +186,11 @@ func open(u string, resp *gemini.Response) {
|
||||
if path == "" {
|
||||
return
|
||||
}
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
|
||||
panels.HidePanel("dl")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
|
||||
if mediaHandler.Cmd == nil {
|
||||
// Open with system default viewer
|
||||
_, err := sysopen.Open(path)
|
||||
|
@ -2,7 +2,6 @@ package display
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -120,7 +119,7 @@ func modalInit() {
|
||||
frame.SetTitleAlign(cview.AlignCenter)
|
||||
frame.SetTitle(" Info ")
|
||||
infoModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("info")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
})
|
||||
@ -128,7 +127,7 @@ func modalInit() {
|
||||
errorModal.SetBorder(true)
|
||||
errorModal.GetFrame().SetTitleAlign(cview.AlignCenter)
|
||||
errorModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("error")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
})
|
||||
@ -213,7 +212,7 @@ func Input(prompt string) (string, bool) {
|
||||
|
||||
resp := <-inputCh
|
||||
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("input")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
|
||||
@ -248,7 +247,7 @@ func YesNo(prompt string) bool {
|
||||
App.Draw()
|
||||
|
||||
resp := <-yesNoCh
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("yesno")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
return resp
|
||||
@ -286,7 +285,7 @@ func Tofu(host string, expiry time.Time) bool {
|
||||
App.Draw()
|
||||
|
||||
resp := <-yesNoCh
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("yesno")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
return resp
|
||||
|
@ -266,7 +266,7 @@ func openSubscriptionModal(validFeed, subscribed bool) bool {
|
||||
App.Draw()
|
||||
|
||||
resp := <-yesNoCh
|
||||
browser.SetCurrentTab(strconv.Itoa(curTab))
|
||||
panels.HidePanel("yesno")
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
return resp
|
||||
|
Loading…
Reference in New Issue
Block a user