feat: add Screen interface and Context for UI architecture

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 13:21:04 +09:00
parent afe4ee1056
commit 7cb9290798
2 changed files with 30 additions and 0 deletions

19
ui/context.go Normal file
View File

@@ -0,0 +1,19 @@
package ui
import (
"github.com/tolelom/catacombs/game"
"github.com/tolelom/catacombs/store"
)
// Context holds shared state accessible to all screens.
type Context struct {
Width int
Height int
Fingerprint string
PlayerName string
Lobby *game.Lobby
Store *store.DB
Session *game.GameSession
RoomCode string
}

11
ui/screen.go Normal file
View File

@@ -0,0 +1,11 @@
package ui
import tea "github.com/charmbracelet/bubbletea"
// Screen represents an independent screen with its own Update and View logic.
// Update returns the next Screen (can return itself or a different screen for transitions)
// plus a tea.Cmd for async operations.
type Screen interface {
Update(msg tea.Msg, ctx *Context) (Screen, tea.Cmd)
View(ctx *Context) string
}