-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35a8b39
commit 214a46a
Showing
4 changed files
with
99 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/londek/reactea" | ||
"github.com/londek/reactea/router" | ||
) | ||
|
||
type App struct { | ||
reactea.BasicComponent // AfterUpdate() | ||
reactea.BasicPropfulComponent[reactea.NoProps] // UpdateProps() and Props() | ||
|
||
mainRouter reactea.Component[router.Props] | ||
} | ||
|
||
func (c *App) Init(reactea.NoProps) tea.Cmd { | ||
return c.mainRouter.Init(map[string]router.RouteInitializer{ | ||
"default": func(router.Params) (reactea.SomeComponent, tea.Cmd) { | ||
// component := input.New() | ||
|
||
// return component, component.Init(input.Props{ | ||
// SetText: c.setText, // Can also use "lambdas" (function can be created here) | ||
// }) | ||
|
||
return nil, nil | ||
}, | ||
}) | ||
} | ||
|
||
func (c *App) Update(msg tea.Msg) tea.Cmd { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
if msg.String() == "ctrl+c" { | ||
return reactea.Destroy | ||
} | ||
} | ||
|
||
return c.mainRouter.Update(msg) | ||
} | ||
|
||
func (c *App) Render(width, height int) string { | ||
return c.mainRouter.Render(width, height) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/londek/reactea" | ||
"github.com/londek/reactea/router" | ||
) | ||
|
||
const ( | ||
APPNAME = "flower-tui" | ||
APPVERSION = "0.1.0" | ||
) | ||
|
||
func main() { | ||
app := &App{mainRouter: router.New()} | ||
program := reactea.NewProgram(app) | ||
if _, err := program.Run(); err != nil { | ||
panic(err) | ||
} | ||
} |
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
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