Started working on notifications for networks (got to carried away with

how it looks lol)
This commit is contained in:
2025-01-30 20:33:02 +02:00
parent 088baa6d3a
commit ac01dff4e7
2 changed files with 23 additions and 2 deletions

View File

@@ -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(

View File

@@ -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)
}