diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-01 19:17:57 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-01 19:17:57 +0300 |
commit | b49416ed808e9a9802506cb5e0543dbf3b0e3dcd (patch) | |
tree | 8d4a331f1e29af077a2236419d5cd67bb05b5daa /ui | |
parent | 986c84b7689e29c4bbe6b124bee3e24707e6d51a (diff) |
Refactoring
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.go | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -22,6 +22,14 @@ import ( "maunium.net/go/tview" ) +type View string + +// Allowed views in GomuksUI +const ( + ViewLogin View = "login" + ViewMain View = "main" +) + type GomuksUI struct { gmx ifc.Gomuks app *tview.Application @@ -68,20 +76,24 @@ func (ui *GomuksUI) Render() { ui.app.Draw() } -func (ui *GomuksUI) SetView(name ifc.View) { +func (ui *GomuksUI) OnLogin() { + ui.SetView(ViewMain) +} + +func (ui *GomuksUI) OnLogout() { + ui.SetView(ViewLogin) +} + +func (ui *GomuksUI) SetView(name View) { ui.views.SwitchToPage(string(name)) } func (ui *GomuksUI) InitViews() tview.Primitive { - ui.views.AddPage(string(ifc.ViewLogin), ui.NewLoginView(), true, true) - ui.views.AddPage(string(ifc.ViewMain), ui.NewMainView(), true, false) + ui.views.AddPage(string(ViewLogin), ui.NewLoginView(), true, true) + ui.views.AddPage(string(ViewMain), ui.NewMainView(), true, false) return ui.views } func (ui *GomuksUI) MainView() ifc.MainView { return ui.mainView } - -func (ui *GomuksUI) LoginView() ifc.LoginView { - return ui.loginView -} |