From 4152d6e7bfe3d0fd7d099d36311c4a57f4858964 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 9 Jul 2023 16:35:10 +0200 Subject: Add second view for roster This prepares the contact list / roster view. --- gui.go | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/gui.go b/gui.go index d3f6b2d..c3256eb 100644 --- a/gui.go +++ b/gui.go @@ -11,6 +11,36 @@ import ( ) func (l *Limox) draw(e system.FrameEvent) { + switch l.State { + case Connected: + l.rosterView(e) + default: + l.mainView(e) + } +} + +func (l *Limox) rosterView(e system.FrameEvent) { + gtx := layout.NewContext(&l.Operations, e) + + flex := layout.Flex{ + Axis: layout.Vertical, + Spacing: layout.SpaceStart, + } + + flex.Layout(gtx, + layout.Rigid( + func(gtx layout.Context) layout.Dimensions { + btn := material.Button(l.Theme, &l.DisconnectButton, + "Disconnect") + return btn.Layout(gtx) + }, + ), + ) + + e.Frame(gtx.Ops) +} + +func (l *Limox) mainView(e system.FrameEvent) { gtx := layout.NewContext(&l.Operations, e) flex := layout.Flex{ @@ -49,13 +79,6 @@ func (l *Limox) draw(e system.FrameEvent) { return btn.Layout(gtx) }, ), - layout.Rigid( - func(gtx layout.Context) layout.Dimensions { - btn := material.Button(l.Theme, &l.DisconnectButton, - "Disconnect") - return btn.Layout(gtx) - }, - ), ) e.Frame(gtx.Ops) -- cgit v1.2.3-70-g09d2