diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-01-19 18:53:57 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-01-19 18:53:57 +0200 |
| commit | abe7eabce9b359c6150d65e291a9fc460196bfba (patch) | |
| tree | cef2990775a7a4c2e1a3c590e5e8eafa4cdac0b3 /internal/client/ui/core | |
| parent | 0a5ed18ac8576b0f9d2d6fae87267a400feb2475 (diff) | |
Added frequency name at the top of chat (might flip the bg/fg later)
Diffstat (limited to 'internal/client/ui/core')
| -rw-r--r-- | internal/client/ui/core/chat/chat.go | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 1895c0d..80ccacc 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -71,6 +71,11 @@ var ( SetString("\n(edited)").String() WidthWithoutVi = PaddingCount*2 + lipgloss.Width(LeftCorner) + lipgloss.Width(RightCorner) + + FrequencyNameStyle = lipgloss.NewStyle(). + Background(colors.BackgroundDim). + AlignHorizontal(lipgloss.Center). + Border(lipgloss.ThickBorder(), false, false, true) ) const ( @@ -142,9 +147,13 @@ func (m Model) Init() tea.Cmd { } func (m *Model) Prerender() { + frequencyName := m.renderFrequencyName() + frequencyHeight := lipgloss.Height(frequencyName) + messagebox := m.renderMessageBox() - messagesHeight := ui.Height - lipgloss.Height(messagebox) - messagesHeight -= 1 // For the extra \n at the end + messageBoxHeight := lipgloss.Height(messagebox) + + messagesHeight := ui.Height - messageBoxHeight - frequencyHeight // if m.messagesCache == nil || messagesHeight != m.messagesHeight { // // Re-render @@ -154,7 +163,7 @@ func (m *Model) Prerender() { m.messagesCache = &messages m.messagesHeight = messagesHeight - m.prerender = *m.messagesCache + messagebox + m.prerender = frequencyName + *m.messagesCache + messagebox } func (m Model) View() string { @@ -870,3 +879,16 @@ func (m *Model) editMessage() tea.Cmd { func (m *Model) SetWidth(width int) { m.width = width } + +func (m *Model) renderFrequencyName() string { + networkId := state.NetworkId(m.networkIndex) + if m.frequencyIndex == -1 || networkId == nil { + return "" + } + + frequency := state.State.Frequencies[*networkId][m.frequencyIndex] + color := lipgloss.Color(frequency.HexColor) + + return FrequencyNameStyle.Width(m.width).Foreground(color). + Render(frequency.Name) + "\n" +} |
