mirror of
https://github.com/boolean-maybe/tiki
synced 2026-04-21 13:37:20 +00:00
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"github.com/rivo/tview"
|
|
|
|
"github.com/boolean-maybe/tiki/controller"
|
|
"github.com/boolean-maybe/tiki/model"
|
|
"github.com/boolean-maybe/tiki/plugin"
|
|
"github.com/boolean-maybe/tiki/store"
|
|
)
|
|
|
|
// Controllers holds all application controllers.
|
|
type Controllers struct {
|
|
Nav *controller.NavigationController
|
|
Board *controller.BoardController
|
|
Task *controller.TaskController
|
|
Plugins map[string]controller.PluginControllerInterface
|
|
}
|
|
|
|
// BuildControllers constructs navigation/domain/plugin controllers for the application.
|
|
func BuildControllers(
|
|
app *tview.Application,
|
|
taskStore store.Store,
|
|
boardConfig *model.BoardConfig,
|
|
plugins []plugin.Plugin,
|
|
pluginConfigs map[string]*model.PluginConfig,
|
|
) *Controllers {
|
|
navController := controller.NewNavigationController(app)
|
|
boardController := controller.NewBoardController(taskStore, boardConfig, navController)
|
|
taskController := controller.NewTaskController(taskStore, navController)
|
|
|
|
pluginControllers := make(map[string]controller.PluginControllerInterface)
|
|
for _, p := range plugins {
|
|
if tp, ok := p.(*plugin.TikiPlugin); ok {
|
|
pluginControllers[p.GetName()] = controller.NewPluginController(
|
|
taskStore,
|
|
pluginConfigs[p.GetName()],
|
|
tp,
|
|
navController,
|
|
)
|
|
continue
|
|
}
|
|
if dp, ok := p.(*plugin.DokiPlugin); ok {
|
|
pluginControllers[p.GetName()] = controller.NewDokiController(dp, navController)
|
|
}
|
|
}
|
|
|
|
return &Controllers{
|
|
Nav: navController,
|
|
Board: boardController,
|
|
Task: taskController,
|
|
Plugins: pluginControllers,
|
|
}
|
|
}
|