1
0
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:
makeworld 2020-12-25 18:53:54 -05:00
parent 39f19bf643
commit 722d32a385
4 changed files with 15 additions and 13 deletions

View File

@ -2,7 +2,6 @@ package display
import ( import (
"fmt" "fmt"
"strconv"
"github.com/gdamore/tcell/v2" "github.com/gdamore/tcell/v2"
"github.com/makeworld-the-better-one/amfora/bookmarks" "github.com/makeworld-the-better-one/amfora/bookmarks"
@ -103,7 +102,7 @@ func openBkmkModal(name string, exists bool, favicon string) (string, int) {
App.Draw() App.Draw()
action := <-bkmkCh action := <-bkmkCh
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("bkmk")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()

View File

@ -33,8 +33,8 @@ var dlChoiceCh = make(chan string)
var dlModal = cview.NewModal() var dlModal = cview.NewModal()
func dlInit() { func dlInit() {
panels.AddPanel("dlChoice", dlChoiceModal, false, false)
panels.AddPanel("dl", dlModal, false, false) panels.AddPanel("dl", dlModal, false, false)
panels.AddPanel("dlChoice", dlChoiceModal, false, false)
dlm := dlModal dlm := dlModal
chm := dlChoiceModal chm := dlChoiceModal
@ -84,7 +84,7 @@ func dlInit() {
frame.SetTitle(" Download ") frame.SetTitle(" Download ")
dlm.SetDoneFunc(func(buttonIndex int, buttonLabel string) { dlm.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Ok" { if buttonLabel == "Ok" {
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("dl")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
} }
@ -148,7 +148,9 @@ func dlChoice(text, u string, resp *gemini.Response) {
open(u, resp) open(u, resp)
return return
} }
browser.SetCurrentTab(strconv.Itoa(curTab))
// They chose the "Cancel" button
panels.HidePanel("dlChoice")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
} }
@ -184,9 +186,11 @@ func open(u string, resp *gemini.Response) {
if path == "" { if path == "" {
return return
} }
browser.SetCurrentTab(strconv.Itoa(curTab))
panels.HidePanel("dl")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
if mediaHandler.Cmd == nil { if mediaHandler.Cmd == nil {
// Open with system default viewer // Open with system default viewer
_, err := sysopen.Open(path) _, err := sysopen.Open(path)

View File

@ -2,7 +2,6 @@ package display
import ( import (
"fmt" "fmt"
"strconv"
"strings" "strings"
"time" "time"
@ -120,7 +119,7 @@ func modalInit() {
frame.SetTitleAlign(cview.AlignCenter) frame.SetTitleAlign(cview.AlignCenter)
frame.SetTitle(" Info ") frame.SetTitle(" Info ")
infoModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) { infoModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("info")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
}) })
@ -128,7 +127,7 @@ func modalInit() {
errorModal.SetBorder(true) errorModal.SetBorder(true)
errorModal.GetFrame().SetTitleAlign(cview.AlignCenter) errorModal.GetFrame().SetTitleAlign(cview.AlignCenter)
errorModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) { errorModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("error")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
}) })
@ -213,7 +212,7 @@ func Input(prompt string) (string, bool) {
resp := <-inputCh resp := <-inputCh
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("input")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
@ -248,7 +247,7 @@ func YesNo(prompt string) bool {
App.Draw() App.Draw()
resp := <-yesNoCh resp := <-yesNoCh
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("yesno")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
return resp return resp
@ -286,7 +285,7 @@ func Tofu(host string, expiry time.Time) bool {
App.Draw() App.Draw()
resp := <-yesNoCh resp := <-yesNoCh
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("yesno")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
return resp return resp

View File

@ -266,7 +266,7 @@ func openSubscriptionModal(validFeed, subscribed bool) bool {
App.Draw() App.Draw()
resp := <-yesNoCh resp := <-yesNoCh
browser.SetCurrentTab(strconv.Itoa(curTab)) panels.HidePanel("yesno")
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()
return resp return resp