Organizing the Interface’s Layout
Learn how to add an interface layout to our application.
We'll cover the following...
Now that we’ve added the main widgets, we can create the buttons to start and pause Pomodoro intervals. To make it easier to maintain and update the code, we’ll add the buttons in a different file. Save and close the widgets.go file and open a new file buttons.go for editing.
Creating the buttons
We start by adding the package definition and the import list. For this file, we’ll
use the following packages:
contextto carry cancellation signals.fmtto format strings.termdash/cell, which provides customization options for widgets.termdash/widgets/buttonto define abuttonwidget.pomodoro, which we created with the business logic.
package appimport ("context""fmt""github.com/mum4k/termdash/cell""github.com/mum4k/termdash/widgets/button""pragprog.com/rggo/interactiveTools/pomo/pomodoro")
Then we define a new custom type, buttonSet, that includes the btStart and btPause fields of type button.Button, which represents a Termdash button:
type buttonSet struct {btStart *button.ButtonbtPause *button.Button}
Creating the newButtonSet() function
Next, we add the function newButtonSet() to instantiate a buttonSet. This function
takes the following inputs: a Context to carry cancellation signals, an instance
of ...