mirror of
https://github.com/Valkyrie00/bold-brew.git
synced 2026-03-16 23:35:55 +01:00
* refactored io legend and handler * implmented dedicated IOService * refactored and fixed io service * fixed quality issues * fix general and copilot issues
45 lines
844 B
Go
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
|
|
}
|