-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Evan Harris <[email protected]>
- Loading branch information
1 parent
8be2dcb
commit e19359c
Showing
5 changed files
with
266 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package common | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
var ( | ||
// P the current tea program | ||
P *tea.Program | ||
Models []tea.Model | ||
) | ||
package common | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
var ( | ||
// P the current tea program | ||
P *tea.Program | ||
Models []tea.Model | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package common | ||
|
||
import "github.com/charmbracelet/lipgloss" | ||
|
||
var ( | ||
Bold = Regular.Bold(true) | ||
Border = Regular.Border(lipgloss.NormalBorder()) | ||
Regular = lipgloss.NewStyle() | ||
Padded = Regular.Padding(0, 1) | ||
HelpStyle = Regular.Padding(0, 1).Background(lipgloss.Color("#ffffff")).Foreground(lipgloss.Color("#000000")).Render | ||
) | ||
package common | ||
|
||
import "github.com/charmbracelet/lipgloss" | ||
|
||
var ( | ||
Bold = Regular.Bold(true) | ||
Border = Regular.Border(lipgloss.NormalBorder()) | ||
Regular = lipgloss.NewStyle() | ||
Padded = Regular.Padding(0, 1) | ||
HelpStyle = Regular.Padding(0, 1).Background(lipgloss.Color("#ffffff")).Foreground(lipgloss.Color("#000000")).Render | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
package home | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/charmbracelet/bubbles/key" | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/common" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/keys" | ||
) | ||
|
||
type mode int | ||
|
||
const ( | ||
nav mode = iota | ||
image | ||
debug | ||
) | ||
|
||
// Default Model | ||
type Model struct { | ||
mode mode | ||
} | ||
|
||
func InitialModel() (tea.Model, tea.Cmd) { | ||
m := &Model{mode: nav} | ||
log.Printf("Welcome model initialized: %v", m) | ||
return m, nil | ||
} | ||
|
||
func (m Model) Init() tea.Cmd { | ||
// Just return `nil`, which means "no I/O right now, please." | ||
return nil | ||
} | ||
|
||
// Update is called to handle user input and update the model's state. | ||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch { | ||
case key.Matches(msg, keys.Global.Quit): | ||
return m, tea.Quit // Quit the program. | ||
case key.Matches(msg, keys.Welcome.Images): | ||
m.mode = image | ||
// TODO - Unhardcode the model index | ||
return common.Models[1].Update(nil) | ||
|
||
// TODO - support debug model | ||
// case key.Matches(msg, keys.Welcome.Debug): | ||
// m.mode = debug | ||
// // TODO - Unhardcode the model index | ||
// return common.Models[2].Update(nil) | ||
} | ||
} | ||
return m, nil | ||
} | ||
|
||
// View returns the view that should be displayed. | ||
func (m Model) View() string { | ||
content := "Dashboard\n Select which view you would like to open\n" | ||
|
||
return lipgloss.JoinVertical(lipgloss.Left, | ||
content, | ||
m.help(), | ||
) | ||
} | ||
func (m Model) help() string { | ||
return common.HelpStyle("• i: Open images view • q: quit") | ||
// TODO - support debug view | ||
// return common.HelpStyle("• i: Open images view • d: Open debug view • q: quit") | ||
} | ||
package home | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/charmbracelet/bubbles/key" | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/common" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/keys" | ||
) | ||
|
||
type mode int | ||
|
||
const ( | ||
nav mode = iota | ||
image | ||
debug | ||
) | ||
|
||
// Default Model | ||
type Model struct { | ||
mode mode | ||
} | ||
|
||
func InitialModel() (tea.Model, tea.Cmd) { | ||
m := &Model{mode: nav} | ||
log.Printf("Welcome model initialized: %v", m) | ||
return m, nil | ||
} | ||
|
||
func (m Model) Init() tea.Cmd { | ||
// Just return `nil`, which means "no I/O right now, please." | ||
return nil | ||
} | ||
|
||
// Update is called to handle user input and update the model's state. | ||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch { | ||
case key.Matches(msg, keys.Global.Quit): | ||
return m, tea.Quit // Quit the program. | ||
case key.Matches(msg, keys.Welcome.Images): | ||
m.mode = image | ||
// TODO - Unhardcode the model index | ||
return common.Models[1].Update(nil) | ||
|
||
// TODO - support debug model | ||
// case key.Matches(msg, keys.Welcome.Debug): | ||
// m.mode = debug | ||
// // TODO - Unhardcode the model index | ||
// return common.Models[2].Update(nil) | ||
} | ||
} | ||
return m, nil | ||
} | ||
|
||
// View returns the view that should be displayed. | ||
func (m Model) View() string { | ||
content := "Dashboard\n Select which view you would like to open\n" | ||
|
||
return lipgloss.JoinVertical(lipgloss.Left, | ||
content, | ||
m.help(), | ||
) | ||
} | ||
func (m Model) help() string { | ||
return common.HelpStyle("• i: Open images view • q: quit") | ||
// TODO - support debug view | ||
// return common.HelpStyle("• i: Open images view • d: Open debug view • q: quit") | ||
} |
Oops, something went wrong.