mirror of
https://github.com/mrusme/neonmodem.git
synced 2025-02-02 15:07:59 -05:00
Refactored DialogBox, implemented Focused/Blurred
This commit is contained in:
parent
c119cd9f73
commit
6f6e1c5fad
@ -46,8 +46,14 @@ type Config struct {
|
||||
|
||||
Theme struct {
|
||||
DialogBox struct {
|
||||
Window ThemeItemConfig
|
||||
Titlebar ThemeItemConfig
|
||||
Window struct {
|
||||
Focused ThemeItemConfig
|
||||
Blurred ThemeItemConfig
|
||||
}
|
||||
Titlebar struct {
|
||||
Focused ThemeItemConfig
|
||||
Blurred ThemeItemConfig
|
||||
}
|
||||
Bottombar ThemeItemConfig
|
||||
}
|
||||
|
||||
@ -223,29 +229,52 @@ func SetDefaults(cacheDir string) {
|
||||
viper.SetDefault("Theme.PostsList.ItemDetail.Selected.Foreground",
|
||||
lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"})
|
||||
|
||||
// DialogBox Window
|
||||
viper.SetDefault("Theme.DialogBox.Window.Margin",
|
||||
// DialogBox Window:Focused
|
||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Margin",
|
||||
[]int{0, 0, 0, 0})
|
||||
viper.SetDefault("Theme.DialogBox.Window.Padding",
|
||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Padding",
|
||||
[]int{0, 0, 0, 0})
|
||||
viper.SetDefault("Theme.DialogBox.Window.Border.Border",
|
||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Border",
|
||||
lipgloss.ThickBorder())
|
||||
viper.SetDefault("Theme.DialogBox.Window.Border.Sides",
|
||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Sides",
|
||||
[]bool{false, true, true, true},
|
||||
)
|
||||
viper.SetDefault("Theme.DialogBox.Window.Border.Foreground",
|
||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Foreground",
|
||||
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
|
||||
|
||||
// DialogBox Titlebar
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Margin",
|
||||
// DialogBox Window:Blurred
|
||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Margin",
|
||||
[]int{0, 0, 0, 0})
|
||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Padding",
|
||||
[]int{0, 0, 0, 0})
|
||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Border",
|
||||
lipgloss.ThickBorder())
|
||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Sides",
|
||||
[]bool{false, true, true, true},
|
||||
)
|
||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Foreground",
|
||||
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
||||
|
||||
// DialogBox Titlebar:Focused
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Margin",
|
||||
[]int{0, 0, 1, 0})
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Padding",
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Padding",
|
||||
[]int{0, 1, 0, 1})
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Foreground",
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Foreground",
|
||||
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Background",
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Background",
|
||||
lipgloss.AdaptiveColor{Light: "#00cccc", Dark: "#00cccc"})
|
||||
|
||||
// DialogBox Titlebar:Blurred
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Margin",
|
||||
[]int{0, 0, 1, 0})
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Padding",
|
||||
[]int{0, 1, 0, 1})
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Foreground",
|
||||
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Background",
|
||||
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
||||
|
||||
// DialogBox Bottombar
|
||||
viper.SetDefault("Theme.DialogBox.Bottombar.Margin",
|
||||
[]int{1, 0, 0, 0})
|
||||
|
@ -7,8 +7,14 @@ import (
|
||||
|
||||
type Theme struct {
|
||||
DialogBox struct {
|
||||
Window lipgloss.Style
|
||||
Titlebar lipgloss.Style
|
||||
Window struct {
|
||||
Focused lipgloss.Style
|
||||
Blurred lipgloss.Style
|
||||
}
|
||||
Titlebar struct {
|
||||
Focused lipgloss.Style
|
||||
Blurred lipgloss.Style
|
||||
}
|
||||
Bottombar lipgloss.Style
|
||||
}
|
||||
|
||||
@ -50,8 +56,10 @@ func New(cfg *config.Config) (*Theme) {
|
||||
t.PostsList.ItemDetail.Focused = t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Focused)
|
||||
t.PostsList.ItemDetail.Blurred = t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Blurred)
|
||||
t.PostsList.ItemDetail.Selected = t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Selected)
|
||||
t.DialogBox.Window = t.fromConfig(&cfg.Theme.DialogBox.Window)
|
||||
t.DialogBox.Titlebar = t.fromConfig(&cfg.Theme.DialogBox.Titlebar)
|
||||
t.DialogBox.Window.Focused = t.fromConfig(&cfg.Theme.DialogBox.Window.Focused)
|
||||
t.DialogBox.Window.Blurred = t.fromConfig(&cfg.Theme.DialogBox.Window.Blurred)
|
||||
t.DialogBox.Titlebar.Focused = t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Focused)
|
||||
t.DialogBox.Titlebar.Blurred = t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Blurred)
|
||||
t.DialogBox.Bottombar = t.fromConfig(&cfg.Theme.DialogBox.Bottombar)
|
||||
t.Post.Author = t.fromConfig(&cfg.Theme.Post.Author)
|
||||
t.Post.Subject = t.fromConfig(&cfg.Theme.Post.Subject)
|
||||
|
@ -199,8 +199,13 @@ func (m Model) View() string {
|
||||
))
|
||||
|
||||
if m.focused == "post" || m.focused == "reply" {
|
||||
titlebar := m.ctx.Theme.DialogBox.Titlebar.
|
||||
Align(lipgloss.Center).
|
||||
var style lipgloss.Style
|
||||
if m.focused == "post" {
|
||||
style = m.ctx.Theme.DialogBox.Titlebar.Focused
|
||||
} else {
|
||||
style = m.ctx.Theme.DialogBox.Titlebar.Blurred
|
||||
}
|
||||
titlebar := style.Align(lipgloss.Center).
|
||||
Width(m.viewport.Width + 4).
|
||||
Render("Post")
|
||||
|
||||
@ -215,16 +220,23 @@ func (m Model) View() string {
|
||||
bottombar,
|
||||
)
|
||||
|
||||
tmp := helpers.PlaceOverlay(3, 2,
|
||||
m.ctx.Theme.DialogBox.Window.Render(ui),
|
||||
view.String(), true)
|
||||
var tmp string
|
||||
if m.focused == "post" {
|
||||
tmp = helpers.PlaceOverlay(3, 2,
|
||||
m.ctx.Theme.DialogBox.Window.Focused.Render(ui),
|
||||
view.String(), true)
|
||||
} else {
|
||||
tmp = helpers.PlaceOverlay(3, 2,
|
||||
m.ctx.Theme.DialogBox.Window.Blurred.Render(ui),
|
||||
view.String(), true)
|
||||
}
|
||||
|
||||
view = strings.Builder{}
|
||||
view.WriteString(tmp)
|
||||
}
|
||||
|
||||
if m.focused == "reply" {
|
||||
titlebar := m.ctx.Theme.DialogBox.Titlebar.
|
||||
titlebar := m.ctx.Theme.DialogBox.Titlebar.Focused.
|
||||
Align(lipgloss.Center).
|
||||
Width(m.viewport.Width - 2).
|
||||
Render("Reply")
|
||||
@ -234,7 +246,7 @@ func (m Model) View() string {
|
||||
|
||||
bottombar := m.ctx.Theme.DialogBox.Bottombar.
|
||||
Width(m.viewport.Width - 2).
|
||||
Render("ctrl+r reply · esc close")
|
||||
Render("ctrl+enter reply · esc close")
|
||||
|
||||
replyWindow := lipgloss.JoinVertical(
|
||||
lipgloss.Center,
|
||||
@ -244,7 +256,7 @@ func (m Model) View() string {
|
||||
)
|
||||
|
||||
tmp := helpers.PlaceOverlay(5, m.ctx.Screen[1]-21,
|
||||
m.ctx.Theme.DialogBox.Window.Render(replyWindow),
|
||||
m.ctx.Theme.DialogBox.Window.Focused.Render(replyWindow),
|
||||
view.String(), true)
|
||||
|
||||
view = strings.Builder{}
|
||||
@ -352,7 +364,7 @@ func (m *Model) renderReplies(
|
||||
lipgloss.NewStyle().
|
||||
Foreground(m.ctx.Theme.Reply.Author.GetBackground()).
|
||||
Render(fmt.Sprintf("writes in reply to %s:", inReplyTo)),
|
||||
strings.Repeat(" ", (m.viewport.Width-len(author)-len(inReplyTo)-26)),
|
||||
strings.Repeat(" ", (m.viewport.Width-len(author)-len(inReplyTo)-28)),
|
||||
lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#777777")).
|
||||
Render(fmt.Sprintf("#%d", idx)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user