ui

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const APP_NAME = "yt-playlists"

Variables

View Source
var (
	COLOR_HIGHLIGHT  = tcell.NewRGBColor(45, 49, 57)
	COLOR_BACKGROUND = tcell.NewRGBColor(40, 44, 52)
)

Functions

func Dialog

func Dialog(message string, confirm func(), cancel func()) *tview.Modal

A Dialog with 2 choices 'Yes' and 'No', pass the confirm function for callback when 'Yes' is selected, pass the cancel function when exiting the modal.

func Modal(p tview.Primitive, onCancel func(), width, height int) tview.Primitive

Renders the given primitive as a modal. onCancel function will be called when pressnig 'ESC' key which will cancel the modal.

Types

type App

type App struct {
	*tview.Application
	// contains filtered or unexported fields
}

func New

func New() *App

func (*App) CloseModal

func (a *App) CloseModal(name string)

func (*App) DisplayModal

func (a *App) DisplayModal(p tview.Primitive, name string)

func (*App) ModalActive

func (a *App) ModalActive() bool

func (*App) Run

func (a *App) Run() error

func (*App) SetHelpText

func (a *App) SetHelpText(keyGroups ...map[string]string)

type Help

type Help struct {
	// contains filtered or unexported fields
}

func NewHelp

func NewHelp(a *App) *Help

func (*Help) SetHelpText

func (h *Help) SetHelpText(keyGroups ...map[string]string)

Updates the

type HelpModal

type HelpModal struct {
	// contains filtered or unexported fields
}

func NewHelpModal

func NewHelpModal(app *App) *HelpModal

type Keybindings

type Keybindings struct {
	// contains filtered or unexported fields
}

type Playlist

type Playlist struct {
	// contains filtered or unexported fields
}

Component to display playlists

func NewPlaylists

func NewPlaylists(a *App, p *controllers.PlaylistsController) *Playlist

Creates a new Playlist component

func (*Playlist) AddListener

func (p *Playlist) AddListener(listener SelectedPlaylistListener)

Adds a new listener

func (*Playlist) NotifySelected

func (p *Playlist) NotifySelected(playlist *youtube.Playlist)

Notifie listeners when playlist was selected

func (*Playlist) SetPlaylists

func (p *Playlist) SetPlaylists()

Updates the view with updated set of playlists. The selected playlist will be displayed in green text and all the other unselected ones will be displayed in white text.

type PlaylistForm

type PlaylistForm struct {
	// contains filtered or unexported fields
}

Form component for creating a new playlist. Contains a input field for the name, a dropdown to choose the privacy status and a text area to fill out the description.

func NewPlaylistForm

func NewPlaylistForm(app *App) *PlaylistForm

Creates a new playlist form component. Accepts an instance of the app and a function 'onSubmit' to be called when form was submitted.

func (*PlaylistForm) Close

func (p *PlaylistForm) Close()

closes the form.

func (*PlaylistForm) SetAfterSubmitFunc

func (p *PlaylistForm) SetAfterSubmitFunc(afterSubmit func(error)) *PlaylistForm

func (*PlaylistForm) Show

func (p *PlaylistForm) Show()

shows the form.

func (*PlaylistForm) Submit

func (p *PlaylistForm) Submit() error

Submits the form and creates the playlist with the current form data.

type SelectPlaylist

type SelectPlaylist struct {
	// contains filtered or unexported fields
}

func NewSelectPlaylist

func NewSelectPlaylist(a *App, name string, playlists []*youtube.Playlist, selected func(*youtube.Playlist)) *SelectPlaylist

type SelectedPlaylistListener

type SelectedPlaylistListener interface {
	PlaylistSelected(*youtube.Playlist)
}

Listen for playlist being selected

type Video

type Video struct {
	// contains filtered or unexported fields
}

Component to display videos of a playlist

func NewVideos

func NewVideos(a *App, controller *controllers.VideosController) *Video

Creates a new Video component

func (*Video) AddVideos

func (v *Video) AddVideos(playlistId string)

Adds the selected videos from current playlist to one specified by 'playlistId'. Redraws the screen right after in case of modifications to the list of videos.

func (*Video) ClearSelectedUI

func (v *Video) ClearSelectedUI()

Removes all selected videos, additionally unselects all the selected videos displayed.

func (*Video) DeleteVideos

func (v *Video) DeleteVideos()

Deletes the selected videos in the current playlist, redraws the screen right after in case of modifications to the list of videos.

func (*Video) MoveVideos

func (v *Video) MoveVideos(playlistId string)

Moves the selected videos from current playlist to one specified by 'playlistId'. The selected videos will be removed from the current playlist and will be added to the new playlist. Redraws the screen right after in case of modifications to the list of videos.

func (*Video) OpenInBrowser

func (v *Video) OpenInBrowser()

func (*Video) PlaylistSelected

func (v *Video) PlaylistSelected(playlist *youtube.Playlist)

Callback when playlist was selected, implements the SelectedPlaylistListener interface.

func (*Video) ToggleSelected

func (v *Video) ToggleSelected(i int)

Toggles selection status of video in the list. Selected videos will be in green text and unselected videos will be in white text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳