Reworked how frequency notifications work

This commit is contained in:
2025-02-01 17:36:23 +02:00
parent 0659bdaf81
commit 69bbde190e
2 changed files with 23 additions and 17 deletions

View File

@@ -45,12 +45,18 @@ var (
BackgroundStyle = lipgloss.NewStyle().Background(colors.BackgroundDim)
notifSymbol = []string{
"  ", " 󰲠 ", " 󰲢 ", " 󰲤 ", " 󰲦 ", " 󰲨 ", " 󰲪 ", " 󰲬 ", " 󰲮 ", " 󰲰 ", " 󰲲 ",
}
notifStyleDot = lipgloss.NewStyle().Foreground(colors.White)
notifStyle = lipgloss.NewStyle().Foreground(colors.Red)
notifWidth = 3
notifSymbol = "◗"
notifSymbols = func() []string {
notifs := []string{
" 󰲠", " 󰲢", " 󰲤", " 󰲦 ", " 󰲨 ", " 󰲪 ", " 󰲬 ", " 󰲮 ", " 󰲰 ", " 󰲲 ",
}
for i, notif := range notifs {
notifs[i] = notifStyle.Render(notif)
}
return notifs
}()
notifStyle = lipgloss.NewStyle().Foreground(colors.Red)
notifWidth = 2
)
type Model struct {
@@ -99,6 +105,7 @@ func (m Model) View() string {
frequencies = frequencies[m.base:upper]
for i, frequency := range frequencies {
backgroundStyle := backgroundStyle
maxFrequencyWidth := maxFrequencyWidth
frequencyStyle := frequencyStyle.Foreground(lipgloss.Color(frequency.HexColor))
@@ -120,22 +127,21 @@ func (m Model) View() string {
}
notif := ""
notifStyle := notifStyle
pings, hasNotif := state.State.Notifications[frequency.ID]
if pings == 0 && hasNotif {
notif = notifSymbol[0]
// notifStyle = notifStyleDot
} else if hasNotif {
notif = notifSymbol[min(pings, 10)]
if hasNotif {
builder.WriteString(notifSymbol)
frequencyStyle = frequencyStyle.MarginLeft(margin - 1)
backgroundStyle = backgroundStyle.Width(m.width - 1)
if pings != 0 {
notif = notifSymbols[min(pings, 10)-1]
maxFrequencyWidth -= notifWidth
}
}
if m.index == m.base+i {
notifStyle = notifStyle.Background(colors.BackgroundHighlight)
}
if notif != "" {
maxFrequencyWidth -= notifWidth
notif = notifStyle.Render(notif)
}
frequencyName := ""
if lipgloss.Width(frequency.Name) <= maxFrequencyWidth {

View File

@@ -17,7 +17,7 @@ var (
Border(lipgloss.ThickBorder(), false, true, false, false)
selectedIndicator = "🭀\n▌\n🭛"
notification = " \n◗\n " //   🭬
notification = " \n◗\n "
peersIcon = ui.IconStyle(" ", colors.Turquoise, colors.DarkerCyan, colors.BackgroundDimmer)
peersButton = peersIcon.Background(colors.BackgroundDimmer).Padding(0, 1, 1).String()
peersButtonSelected = lipgloss.JoinHorizontal(