diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-01-30 20:33:02 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-01-30 20:33:02 +0200 |
| commit | ac01dff4e7b85198bd6c5179da93284cc57a96a8 (patch) | |
| tree | 91bad79063e65fc03df17d0e44ba24971ceeb538 | |
| parent | 088baa6d3a63a7a6dea80afd07c48da99e2d19e8 (diff) | |
Started working on notifications for networks (got to carried away with
how it looks lol)
| -rw-r--r-- | internal/client/ui/core/networklist/networklist.go | 4 | ||||
| -rw-r--r-- | internal/client/ui/ui.go | 21 |
2 files changed, 23 insertions, 2 deletions
diff --git a/internal/client/ui/core/networklist/networklist.go b/internal/client/ui/core/networklist/networklist.go index 47d44d3..f4463fd 100644 --- a/internal/client/ui/core/networklist/networklist.go +++ b/internal/client/ui/core/networklist/networklist.go @@ -66,10 +66,10 @@ func (m Model) View() string { for i, networkId := range networks { network := state.State.Networks[networkId] - icon := ui.IconStyle(network.Icon, + icon := ui.IconStyleNotif(network.Icon, lipgloss.Color(network.FgHexColor), lipgloss.Color(network.BgHexColor), - colors.BackgroundDimmer, + colors.BackgroundDimmer, 1, ) if m.index == m.base+i { builder.WriteString(lipgloss.JoinHorizontal( diff --git a/internal/client/ui/ui.go b/internal/client/ui/ui.go index 3d13ee8..1d07f40 100644 --- a/internal/client/ui/ui.go +++ b/internal/client/ui/ui.go @@ -219,6 +219,7 @@ func clamp(v, lower, upper int) int { 🭏🬽 🭈🭄 */ + func IconStyle(icon string, iconFg, iconBg, bg lipgloss.Color) lipgloss.Style { bgStyle := lipgloss.NewStyle().Background(iconBg).Foreground(bg) top := bgStyle.Render("🭠🭘 🭣🭕") @@ -229,3 +230,23 @@ func IconStyle(icon string, iconFg, iconBg, bg lipgloss.Color) lipgloss.Style { combined := lipgloss.JoinVertical(lipgloss.Left, top, middle, bottom) return lipgloss.NewStyle().SetString(combined) } + +var notifications = []string{ + "", "", "", "", "", "", "", "", "", "", +} + +func IconStyleNotif(icon string, iconFg, iconBg, bg lipgloss.Color, count int) lipgloss.Style { + notifStyle := lipgloss.NewStyle().Background(iconBg).Foreground(colors.Red) + notif := notifications[min(0, max(10, count)-1)] + notif = notifStyle.Render(notif) + + bgStyle := lipgloss.NewStyle().Background(iconBg).Foreground(bg) + top := bgStyle.Render("🭠🭘 🭣🭕") + middle := lipgloss.NewStyle().Width(6).Align(lipgloss.Center). + Background(iconBg).Foreground(iconFg).Render(icon) + bgStyle2 := lipgloss.NewStyle().Foreground(iconBg).Background(bg) + bottom := bgStyle2.Render("🭥🭓██") + notif + bgStyle.Render("") + combined := lipgloss.JoinVertical(lipgloss.Left, top, middle, bottom) + return lipgloss.NewStyle().SetString(combined) +} + |
