Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Oct 22, 2024
1 parent d0e4e58 commit 955920e
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions cmd/slackdump/internal/ui/cfgui/updaters/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
datepicker "github.com/ethanefung/bubble-datepicker"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/bubbles/btime"
)

type DateModel struct {
Value *time.Time
dm datepicker.Model
tm *btime.Model
focusstyle lipgloss.Style
blurstyle lipgloss.Style
finishing bool
timeEnabled bool
state state
Expand All @@ -23,10 +26,14 @@ func NewDTTM(ptrTime *time.Time) DateModel {
m := datepicker.New(*ptrTime)
t := btime.New(m.Time)
m.SelectDate()
focusStyle := lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).BorderForeground(cfg.Theme.Focused.Title.GetForeground())
blurStyle := lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).BorderForeground(cfg.Theme.Blurred.Description.GetForeground())
return DateModel{
Value: ptrTime,
dm: m,
tm: t,
focusstyle: focusStyle,
blurstyle: blurStyle,
timeEnabled: true,
}
}
Expand Down Expand Up @@ -99,11 +106,33 @@ func (m DateModel) View() string {
}

var b strings.Builder

help := cfg.Theme.Help.Ellipsis.Render("arrow keys: adjust • tab/shift+tab: switch fields • enter: select")

var dateStyle lipgloss.Style
var timeStyle lipgloss.Style

if m.state == scalendar {
dateStyle = m.focusstyle
timeStyle = m.blurstyle
} else {
dateStyle = m.blurstyle
timeStyle = m.focusstyle
}

if m.timeEnabled {
b.WriteString(lipgloss.JoinVertical(lipgloss.Center, m.dm.View(), m.tm.View()))
b.WriteString(lipgloss.JoinVertical(
lipgloss.Center,
dateStyle.Render(m.dm.View()),
timeStyle.Render(m.tm.View()),
help,
))
} else {
b.WriteString(m.dm.View())
b.WriteString(lipgloss.JoinVertical(
lipgloss.Center,
dateStyle.Render(m.dm.View()),
help,
))
}
b.WriteString("\n\n" + m.dm.Styles.Text.Render("Use arrow keys to navigate, tab/shift+tab to switch between fields, and enter to select."))
return b.String()
}

0 comments on commit 955920e

Please sign in to comment.