* VIEWS */
()
| 1136 | /* VIEWS */ |
| 1137 | |
| 1138 | func (m *ircModel) View() string { |
| 1139 | if !m.ready { |
| 1140 | return "loading…" |
| 1141 | } |
| 1142 | |
| 1143 | topPadding := 2 |
| 1144 | serversTitle := styleDim.Render("Servers List") |
| 1145 | |
| 1146 | leftInner := lipgloss.JoinVertical( |
| 1147 | lipgloss.Left, |
| 1148 | titleStyle.Render("zuse irc beta"), |
| 1149 | lipgloss.NewStyle().MarginTop(1).MarginBottom(1).Render(serversTitle), |
| 1150 | m.serverList.View(), |
| 1151 | ) |
| 1152 | leftBox := box.Width(m.leftWidth).Height(m.height-topPadding).Render(leftInner) |
| 1153 | |
| 1154 | var rightInner string |
| 1155 | switch m.mode { |
| 1156 | case modeForm: |
| 1157 | rightInner = m.viewForm() |
| 1158 | case modeChat: |
| 1159 | rightInner = m.viewChat() |
| 1160 | } |
| 1161 | rightBox := box.Width(m.width - m.leftWidth - 4).Height(m.height-topPadding).Render(rightInner) |
| 1162 | |
| 1163 | spacer := lipgloss.NewStyle(). |
| 1164 | Width(2). |
| 1165 | Height(m.height-topPadding). |
| 1166 | Render(" ") |
| 1167 | |
| 1168 | joined := lipgloss.JoinHorizontal(lipgloss.Top, leftBox, rightBox, spacer) |
| 1169 | |
| 1170 | topSpacer := lipgloss.NewStyle(). |
| 1171 | Width(m.width). |
| 1172 | Height(topPadding). |
| 1173 | Render(strings.Repeat("\n", topPadding)) |
| 1174 | |
| 1175 | finalView := lipgloss.JoinVertical(lipgloss.Left, topSpacer, joined) |
| 1176 | |
| 1177 | return lipgloss.Place(m.width, m.height, 0, 0, finalView) |
| 1178 | } |
| 1179 | |
| 1180 | func (m *ircModel) viewForm() string { |
| 1181 | labels := []string{ |