Skip to content

Commit

Permalink
Merge pull request #57 from JunNishimura/#56
Browse files Browse the repository at this point in the history
update view for hey command
  • Loading branch information
JunNishimura authored Aug 20, 2023
2 parents 647e85b + 8697058 commit 8fd2e06
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
9 changes: 8 additions & 1 deletion ui/hey/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (

"github.com/JunNishimura/Chatify/ai/model"
"github.com/JunNishimura/Chatify/config"
"github.com/JunNishimura/Chatify/ui/hey/style"
"github.com/JunNishimura/Chatify/utils"
"github.com/JunNishimura/spotify/v2"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput"
"github.com/charmbracelet/lipgloss"
"github.com/sashabaranov/go-openai"
)

Expand Down Expand Up @@ -37,7 +39,11 @@ type Item struct {
uri spotify.URI
}

func (i Item) Title() string { return i.album }
func (i Item) Title() string {
return lipgloss.NewStyle().
Foreground(lipgloss.Color(style.White)).
Render(i.album)
}
func (i Item) Description() string { return strings.Join(i.artists, ", ") }
func (i Item) FilterValue() string { return i.album }

Expand Down Expand Up @@ -73,6 +79,7 @@ const ListTitle = "Chatify's recommendation"
func newListModel(items []list.Item, width, height int) list.Model {
newList := list.New(items, list.NewDefaultDelegate(), width, height)
newList.Title = ListTitle
newList.Styles.Title.Background(lipgloss.Color(style.FocusedColor))
return newList
}

Expand Down
31 changes: 27 additions & 4 deletions ui/hey/style/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,40 @@ package style

import "github.com/charmbracelet/lipgloss"

func GetNormal(width, height int) lipgloss.Style {
const (
White = "#ffffff"
FocusedColor = "#1DB954"
BgColor = "#191414"
)

func ChatNomal(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.HiddenBorder())
}

func GetFocused(width, height int) lipgloss.Style {
func ChatFocused(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(FocusedColor))
}

func RecommendationNormal(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.HiddenBorder()).
Background(lipgloss.AdaptiveColor{Dark: BgColor, Light: BgColor})
}

func RecommendationFocused(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("69"))
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(FocusedColor)).
Background(lipgloss.AdaptiveColor{Dark: BgColor, Light: BgColor})
}
8 changes: 4 additions & 4 deletions ui/hey/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ func (m Model) View() string {
s += lipgloss.Place(m.window.Width, m.window.Height, lipgloss.Center, lipgloss.Center,
lipgloss.JoinHorizontal(
lipgloss.Center,
style.GetFocused(m.getViewWidth(), m.getViewHeight()).Render(m.chatView()),
style.GetNormal(m.getViewWidth(), m.getViewHeight()).Render(m.recommendationView()),
style.RecommendationFocused(m.getViewWidth(), m.getViewHeight()).Render(m.chatView()),
style.ChatNomal(m.getViewWidth(), m.getViewHeight()).Render(m.recommendationView()),
),
)
} else {
s += lipgloss.Place(m.window.Width, m.window.Height, lipgloss.Center, lipgloss.Center,
lipgloss.JoinHorizontal(
lipgloss.Center,
style.GetNormal(m.getViewWidth(), m.getViewHeight()).Render(m.chatView()),
style.GetFocused(m.getViewWidth(), m.getViewHeight()).Render(m.recommendationView()),
style.RecommendationNormal(m.getViewWidth(), m.getViewHeight()).Render(m.chatView()),
style.ChatFocused(m.getViewWidth(), m.getViewHeight()).Render(m.recommendationView()),
),
)
}
Expand Down

0 comments on commit 8fd2e06

Please sign in to comment.