From 69bbde190ec8e5df838a8b57ae486c0304aab0c5 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sat, 1 Feb 2025 17:36:23 +0200 Subject: Reworked how frequency notifications work --- .../client/ui/core/frequencylist/frequencylist.go | 38 +++++++++++++--------- internal/client/ui/core/networklist/networklist.go | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'internal/client/ui') diff --git a/internal/client/ui/core/frequencylist/frequencylist.go b/internal/client/ui/core/frequencylist/frequencylist.go index 2d2bec2..df33be4 100644 --- a/internal/client/ui/core/frequencylist/frequencylist.go +++ b/internal/client/ui/core/frequencylist/frequencylist.go @@ -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 { diff --git a/internal/client/ui/core/networklist/networklist.go b/internal/client/ui/core/networklist/networklist.go index 913eece..52c2240 100644 --- a/internal/client/ui/core/networklist/networklist.go +++ b/internal/client/ui/core/networklist/networklist.go @@ -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( -- cgit v1.3.1