bold-brew/internal/ui/components/modal.go
Vito f514bc3a30
Some checks are pending
Quality / golangci-lint (push) Waiting to run
Quality / Build (push) Waiting to run
feat: io service refactoring (#18)
* refactored io legend and handler

* implmented dedicated IOService

* refactored and fixed io service

* fixed quality issues

* fix general and copilot issues
2025-06-25 17:26:35 +02:00

45 lines
844 B
Go

package components
import (
"bbrew/internal/ui/theme"
"github.com/rivo/tview"
)
type Modal struct {
view *tview.Modal
theme *theme.Theme
}
func NewModal(theme *theme.Theme) *Modal {
modal := tview.NewModal().
SetBackgroundColor(theme.ModalBgColor).
SetTextColor(theme.DefaultTextColor).
SetButtonBackgroundColor(theme.ButtonBgColor).
SetButtonTextColor(theme.ButtonTextColor)
return &Modal{
view: modal,
theme: theme,
}
}
func (m *Modal) View() *tview.Modal {
return m.view
}
func (m *Modal) Build(text string, confirmFunc func(), cancelFunc func()) *tview.Modal {
m.view.ClearButtons()
m.view.
SetText(text).
AddButtons([]string{"Confirm", "Cancel"}).
SetDoneFunc(func(buttonIndex int, _ string) {
switch buttonIndex {
case 0:
confirmFunc()
case 1:
cancelFunc()
}
})
return m.view
}