summaryrefslogtreecommitdiff
path: root/internal/client/ui/core/networkcreation
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-11-24 00:16:23 +0200
committerKyren223 <Kyren223@proton.me>2024-11-24 00:16:23 +0200
commit54564f397db03e7e10db764947dd05b533e0d87b (patch)
treed62d0736832e6a63a389eecfb4d9618ecb587d53 /internal/client/ui/core/networkcreation
parentc17319d6fd23a0c85668ec55ee2a3cea9995b6fe (diff)
Started working on netwrok creation popup
Diffstat (limited to 'internal/client/ui/core/networkcreation')
-rw-r--r--internal/client/ui/core/networkcreation/networkcreation.go81
1 files changed, 81 insertions, 0 deletions
diff --git a/internal/client/ui/core/networkcreation/networkcreation.go b/internal/client/ui/core/networkcreation/networkcreation.go
new file mode 100644
index 0000000..d41c734
--- /dev/null
+++ b/internal/client/ui/core/networkcreation/networkcreation.go
@@ -0,0 +1,81 @@
+package networkcreation
+
+import (
+ "github.com/charmbracelet/bubbles/textinput"
+ tea "github.com/charmbracelet/bubbletea"
+ "github.com/charmbracelet/lipgloss"
+ "github.com/kyren223/eko/internal/client/ui/field"
+)
+
+var (
+ style = lipgloss.NewStyle().Border(lipgloss.ThickBorder())
+
+ focusedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#5874FF"))
+
+ fieldBlurredStyle = lipgloss.NewStyle().
+ PaddingLeft(1).
+ Border(lipgloss.RoundedBorder()).
+ BorderForeground(lipgloss.Color("#007E8A"))
+ fieldFocusedStyle = fieldBlurredStyle.BorderForeground(focusedStyle.GetForeground()).Border(lipgloss.ThickBorder())
+
+ headerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#54D7A9"))
+
+ iconStyle = lipgloss.NewStyle().Border(lipgloss.ThickBorder(), false, false, true, false)
+)
+
+type Model struct {
+ Width int
+ Height int
+
+ name field.Model
+ icon textinput.Model
+ color textinput.Model
+
+ Style lipgloss.Style
+}
+
+func New() Model {
+ name := field.New(30)
+ name.Header = "Network Name"
+ name.HeaderStyle = headerStyle
+ name.FocusedStyle = fieldFocusedStyle
+ name.BlurredStyle = fieldBlurredStyle
+ name.Focus()
+
+ icon := textinput.New()
+ icon.Prompt = ""
+ icon.Placeholder = "ic"
+
+ color := textinput.New()
+ color.Prompt = ""
+ color.Placeholder = "000000"
+
+ return Model{
+ Width: 50,
+ Height: 10,
+ name: name,
+ icon: icon,
+ color: color,
+ Style: style,
+ }
+}
+
+func (m Model) Init() tea.Cmd {
+ return nil
+}
+
+func (m Model) View() string {
+ name := m.name.View()
+
+ iconText := lipgloss.JoinHorizontal(lipgloss.Top, "icon: ", iconStyle.Render(m.icon.View()))
+ iconColor := lipgloss.JoinHorizontal(lipgloss.Top, "# ", iconStyle.Render(m.color.View()))
+ icon := lipgloss.JoinHorizontal(lipgloss.Top, iconText, " ", iconColor)
+
+ content := lipgloss.JoinVertical(lipgloss.Left, name, "\n", icon)
+ popup := lipgloss.NewStyle().Width(m.Width).Height(m.Height).Render(content)
+ return m.Style.Render(popup)
+}
+
+func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ return m, nil
+}