Creating Projects, Tasks and editing Task details, done/resume working.
This commit is contained in:
62
app/util.go
Normal file
62
app/util.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/rivo/tview"
|
||||
|
||||
"github.com/ajaxray/geek-life/util"
|
||||
)
|
||||
|
||||
func makeHorizontalLine(lineChar rune) *tview.TextView {
|
||||
hr := tview.NewTextView()
|
||||
hr.SetDrawFunc(func(screen tcell.Screen, x int, y int, width int, height int) (int, int, int, int) {
|
||||
// Draw a horizontal line across the middle of the box.
|
||||
style := tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorBlack)
|
||||
centerY := y + height/2
|
||||
for cx := x; cx < x+width; cx++ {
|
||||
screen.SetContent(cx, centerY, lineChar, nil, style)
|
||||
}
|
||||
|
||||
// Space for other content.
|
||||
return x + 1, centerY + 1, width - 2, height - (centerY + 1 - y)
|
||||
})
|
||||
|
||||
return hr
|
||||
}
|
||||
|
||||
func makeLightTextInput(placeholder string) *tview.InputField {
|
||||
return tview.NewInputField().
|
||||
SetPlaceholder(placeholder).
|
||||
SetPlaceholderTextColor(tcell.ColorLightSlateGray).
|
||||
SetFieldTextColor(tcell.ColorBlack).
|
||||
SetFieldBackgroundColor(tcell.ColorGray)
|
||||
}
|
||||
|
||||
func showMessage(text string) {
|
||||
message.SetText(text)
|
||||
statusBar.SwitchToPage(messagePage)
|
||||
|
||||
go func() {
|
||||
app.QueueUpdateDraw(func() {
|
||||
time.Sleep(time.Second * 5)
|
||||
statusBar.SwitchToPage(shortcutsPage)
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
func makeButton(label string, handler func()) *tview.Button {
|
||||
btn := tview.NewButton(label).SetSelectedFunc(handler).
|
||||
SetLabelColor(tcell.ColorWhite)
|
||||
|
||||
btn.SetBackgroundColor(tcell.ColorCornflowerBlue)
|
||||
|
||||
return btn
|
||||
}
|
||||
|
||||
func ignoreKeyEvt() bool {
|
||||
textInputs := []string{"*tview.InputField", "*femto.View"}
|
||||
return util.InArray(reflect.TypeOf(app.GetFocus()).String(), textInputs)
|
||||
}
|
||||
Reference in New Issue
Block a user