Aggressive hyacinth macaw
This commit is contained in:
@@ -140,8 +140,8 @@ func RenderBigClock(t time.Time) string {
|
|||||||
|
|
||||||
timeStr := fmt.Sprintf("%02d:%02d:%02d", h, m, s)
|
timeStr := fmt.Sprintf("%02d:%02d:%02d", h, m, s)
|
||||||
|
|
||||||
// Colon visible for first 500ms of each second, hidden for last 500ms.
|
// 1500ms cycle: visible for 1000ms, hidden for 500ms.
|
||||||
colonVisible := t.UnixMilli()%1000 < 500
|
colonVisible := t.UnixMilli() % 1500 < 1000
|
||||||
|
|
||||||
var lines [7]string
|
var lines [7]string
|
||||||
for i := range lines {
|
for i := range lines {
|
||||||
|
|||||||
25
ui/model.go
25
ui/model.go
@@ -47,6 +47,8 @@ type Model struct {
|
|||||||
firingBlink bool
|
firingBlink bool
|
||||||
firingStart time.Time
|
firingStart time.Time
|
||||||
snoozeCount int
|
snoozeCount int
|
||||||
|
snoozeUntil time.Time
|
||||||
|
snoozeName string
|
||||||
|
|
||||||
// Form state
|
// Form state
|
||||||
form *formModel
|
form *formModel
|
||||||
@@ -66,14 +68,14 @@ func NewModel(store *db.Store, sched *scheduler.Scheduler, pl *player.Player) Mo
|
|||||||
|
|
||||||
func (m Model) Init() tea.Cmd {
|
func (m Model) Init() tea.Cmd {
|
||||||
return tea.Batch(
|
return tea.Batch(
|
||||||
tickEveryHalfSecond(),
|
tick(),
|
||||||
listenForAlarms(m.scheduler),
|
listenForAlarms(m.scheduler),
|
||||||
loadAlarmsCmd(m.store),
|
loadAlarmsCmd(m.store),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func tickEveryHalfSecond() tea.Cmd {
|
func tick() tea.Cmd {
|
||||||
return tea.Every(500*time.Millisecond, func(t time.Time) tea.Msg {
|
return tea.Every(100*time.Millisecond, func(t time.Time) tea.Msg {
|
||||||
return tickMsg(t)
|
return tickMsg(t)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
if m.firingAlarm != nil {
|
if m.firingAlarm != nil {
|
||||||
m.firingBlink = !m.firingBlink
|
m.firingBlink = !m.firingBlink
|
||||||
}
|
}
|
||||||
return m, tickEveryHalfSecond()
|
return m, tick()
|
||||||
|
|
||||||
case alarmFiredMsg:
|
case alarmFiredMsg:
|
||||||
alarm := msg.Alarm
|
alarm := msg.Alarm
|
||||||
@@ -127,6 +129,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case snoozeFireMsg:
|
case snoozeFireMsg:
|
||||||
alarm := db.Alarm(msg)
|
alarm := db.Alarm(msg)
|
||||||
m.snoozeCount++
|
m.snoozeCount++
|
||||||
|
m.snoozeUntil = time.Time{}
|
||||||
|
m.snoozeName = ""
|
||||||
m.startFiring(&alarm)
|
m.startFiring(&alarm)
|
||||||
return m, autoTimeoutCmd()
|
return m, autoTimeoutCmd()
|
||||||
|
|
||||||
@@ -172,6 +176,8 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
m.player.Stop()
|
m.player.Stop()
|
||||||
alarm := *m.firingAlarm
|
alarm := *m.firingAlarm
|
||||||
m.firingAlarm = nil
|
m.firingAlarm = nil
|
||||||
|
m.snoozeUntil = time.Now().Add(snoozeDuration)
|
||||||
|
m.snoozeName = alarm.Name
|
||||||
m.statusMsg = fmt.Sprintf("Snoozed '%s' for 5 minutes", alarm.Name)
|
m.statusMsg = fmt.Sprintf("Snoozed '%s' for 5 minutes", alarm.Name)
|
||||||
return m, snoozeCmd(alarm, snoozeDuration)
|
return m, snoozeCmd(alarm, snoozeDuration)
|
||||||
}
|
}
|
||||||
@@ -295,11 +301,22 @@ func (m Model) View() string {
|
|||||||
clockStr = lipgloss.PlaceHorizontal(m.width, lipgloss.Center, clockStr)
|
clockStr = lipgloss.PlaceHorizontal(m.width, lipgloss.Center, clockStr)
|
||||||
sections = append(sections, clockStr)
|
sections = append(sections, clockStr)
|
||||||
|
|
||||||
|
// Spacer
|
||||||
|
sections = append(sections, "")
|
||||||
|
|
||||||
// Date line
|
// Date line
|
||||||
dateLine := StatusStyle.Render(m.now.Format("Monday, 02 January 2006"))
|
dateLine := StatusStyle.Render(m.now.Format("Monday, 02 January 2006"))
|
||||||
dateLine = lipgloss.PlaceHorizontal(m.width, lipgloss.Center, dateLine)
|
dateLine = lipgloss.PlaceHorizontal(m.width, lipgloss.Center, dateLine)
|
||||||
sections = append(sections, dateLine)
|
sections = append(sections, dateLine)
|
||||||
|
|
||||||
|
// Snooze indicator
|
||||||
|
if !m.snoozeUntil.IsZero() && m.now.Before(m.snoozeUntil) {
|
||||||
|
snoozeText := fmt.Sprintf("[Snoozing %s until %s]", m.snoozeName, m.snoozeUntil.Format("15:04:05"))
|
||||||
|
snoozeLine := AlarmFiringStyle.Render(snoozeText)
|
||||||
|
snoozeLine = lipgloss.PlaceHorizontal(m.width, lipgloss.Center, snoozeLine)
|
||||||
|
sections = append(sections, snoozeLine)
|
||||||
|
}
|
||||||
|
|
||||||
// Firing alarm overlay
|
// Firing alarm overlay
|
||||||
if m.firingAlarm != nil {
|
if m.firingAlarm != nil {
|
||||||
firingText := fmt.Sprintf("ALARM: %s", m.firingAlarm.Name)
|
firingText := fmt.Sprintf("ALARM: %s", m.firingAlarm.Name)
|
||||||
|
|||||||
Reference in New Issue
Block a user