@@ -5,6 +5,7 @@ package content
55
66import (
77 "context"
8+ "time"
89
910 "github.com/charmbracelet/bubbles/help"
1011 tea "github.com/charmbracelet/bubbletea"
@@ -13,6 +14,7 @@ import (
1314 "github.com/toeirei/keymaster/ui/tui/models/components/router"
1415 "github.com/toeirei/keymaster/ui/tui/models/components/stack"
1516 "github.com/toeirei/keymaster/ui/tui/models/views/dashboard"
17+ popupviews "github.com/toeirei/keymaster/ui/tui/models/views/popup"
1618 "github.com/toeirei/keymaster/ui/tui/models/views/publickey"
1719 "github.com/toeirei/keymaster/ui/tui/util"
1820)
@@ -41,6 +43,7 @@ func New() *Model {
4143 menuPtr := util .ModelPointer (menu .New (
4244 // menu.WithItem("dashboard", "Dashboard"),
4345 menu .WithItem ("publickey.list" , "Public Keys" ),
46+ menu .WithItem ("test.progress_popup" , "Test Progress" ),
4447 ))
4548 dashboardPtr := util .ModelPointer (dashboard .New (client ))
4649 routerModel , routerControll := router .New (dashboardPtr )
@@ -68,15 +71,24 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd {
6871 // handle menu messages
6972 if msg , ok := msg .(menu.ItemSelected ); ok {
7073 switch msg .Id {
71- // case "test.popup1":
72- // // popup example 1
73- // return popup.Open(util.ModelPointer(testpopup1.New()))
74- // case "test.view1":
75- // // view example 1
76- // return m.routerControll.Push(util.ModelPointer(testview1.New(m.routerControll)))
77- // }
7874 case "publickey.list" :
7975 return m .routerControll .Push (util .ModelPointer (publickey .NewList (m .client , m .routerControll )))
76+ case "test.progress_popup" :
77+ cmd , pc := popupviews .OpenProgress ("Test Progress" )
78+
79+ go func () {
80+ time .Sleep (time .Second )
81+ for i := range 100 {
82+ pc <- popupviews.Progress {
83+ Progress : float64 (i ) / 100 ,
84+ }
85+ time .Sleep (time .Second / 10 )
86+
87+ }
88+ close (pc )
89+ }()
90+
91+ return cmd
8092 }
8193 }
8294
0 commit comments