🚸 Add main menu
This commit is contained in:
parent
5b2896c032
commit
d8e671d5ca
4 changed files with 83 additions and 28 deletions
69
app/menu.go
Normal file
69
app/menu.go
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codeberg.org/danjones000/strip-beats/input/list"
|
||||
)
|
||||
|
||||
func (st AppStep) Title() string {
|
||||
mustpick := "You need to pick a file"
|
||||
switch st {
|
||||
case Pick:
|
||||
return "Pick a new show"
|
||||
case Watch:
|
||||
if file == nil {
|
||||
return mustpick
|
||||
}
|
||||
return fmt.Sprintf("Watch %s", file.ShortPath())
|
||||
case Fade:
|
||||
if file == nil {
|
||||
return mustpick
|
||||
}
|
||||
return fmt.Sprintf("Trim and/or add fade to %s", file.ShortPath())
|
||||
case Restart:
|
||||
return "Forget current selection"
|
||||
case Quit:
|
||||
return "Quit"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (st AppStep) Text() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (st AppStep) Rune() rune {
|
||||
switch st {
|
||||
case Pick:
|
||||
return 'p'
|
||||
case Watch:
|
||||
return 'w'
|
||||
case Fade:
|
||||
return 'f'
|
||||
case Restart:
|
||||
return 'r'
|
||||
case Quit:
|
||||
return 'q'
|
||||
default:
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
|
||||
func (st AppStep) Selected() func() {
|
||||
return nil
|
||||
}
|
||||
|
||||
func mainMenu() AppStep {
|
||||
var steps []list.Option
|
||||
if file == nil {
|
||||
steps = []list.Option{Pick, Quit}
|
||||
} else {
|
||||
steps = []list.Option{Pick, Watch, Fade, Quit}
|
||||
}
|
||||
|
||||
step := list.List("What would you like to do next?", steps, nil)
|
||||
|
||||
return step.(AppStep)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue