diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-02-01 17:36:23 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-02-01 17:36:23 +0200 |
| commit | 69bbde190ec8e5df838a8b57ae486c0304aab0c5 (patch) | |
| tree | 35ba13085e2f41834238c751474b27c1633f4f71 /internal | |
| parent | 0659bdaf81583c4aa7437fd23703f14aa9c4f6e9 (diff) | |
Reworked how frequency notifications work
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/client/ui/core/frequencylist/frequencylist.go | 38 | ||||
| -rw-r--r-- | internal/client/ui/core/networklist/networklist.go | 2 |
2 files changed, 23 insertions, 17 deletions
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( |
