diff --git a/README.md b/README.md index bb138b7..67a0729 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ - [x] Set Task due date with quick input buttons (today, +1 day, -1 day) - [x] Update Task Title - [x] Tasklist items should indicate status (done, pending, overdue) using colors +- [ ] Pin Tasks - [x] Shortcut for Adding new Project and Task - [x] Global shortcuts for jumping to Projects or Tasks panel anytime - [x] Cleanup all completed tasks of project @@ -46,7 +47,9 @@ - Today - Due Today and overdue - Tomorrow - Upcoming - Due in next 7 days -- [ ] [Habitica](https://habitica.com/)3 integration - Use it as Habitica client or use Habitica for cloud backup +- [ ] Integrations + - Google Tasks + - (Share your ideas) - [ ] Time tracking ### :rocket: Ready for action (installing and running) @@ -80,25 +83,25 @@ You'll see a currently focused pane bordered with double line. In case writing in a text input (e,g, new project/task, due date), you have to `Enter` to submit/save. -| Context | Shortcut | Action | -|---|:---:|---| -| Global | `p` | Go to Project list | -| Global | `t` | Go to Task list | -| Projects | `n` | New Project | -| Projects | `↑`/`k`/`Shift+Tab` | Go up in project list | -| Projects | `↓`/`j`/`Tab` | Go down in project list | -| Tasks | `n` | New Task | -| Tasks | `Esc`/`h` | Go back to Projects Pane | -| Tasks | `↑`/`k`/`Shift+Tab` | Go up in task list | -| Tasks | `↓`/`j`/`Tab` | Go down in task list | -| Task Detail | `Esc`/`h` | Go back to Tasks Pane | -| Task Detail | `Space` | Toggle task as done/pending | -| Task Detail | `d` | Set Due date | -| Task Detail | `↓`/`↑` | Scroll Up/Down the note editor | -| Task Detail | `e` | Activate note editor for modification | -| Task Detail | `v` | Edit task details in external editor (default `vim`) _Known Bug[4](#footnotes)_ | -| Task Detail | `r` | Rename Task Title | -| Active Note Editor | `Esc` | Deactivate note editor and save content | +| Context | Shortcut | Action | +| --- | :---: | --- | +| Global | `p` | Go to Project list | +| Global | `t` | Go to Task list | +| Projects | `n` | New Project | +| Projects | `↑`/`k`/`Shift+Tab` | Go up in project list | +| Projects | `↓`/`j`/`Tab` | Go down in project list | +| Tasks | `n` | New Task | +| Tasks | `Esc`/`h` | Go back to Projects Pane | +| Tasks | `↑`/`k`/`Shift+Tab` | Go up in task list | +| Tasks | `↓`/`j`/`Tab` | Go down in task list | +| Task Detail | `Esc`/`h` | Go back to Tasks Pane | +| Task Detail | `Space` | Toggle task as done/pending | +| Task Detail | `d` | Set Due date | +| Task Detail | `↓`/`↑` | Scroll Up/Down the note editor | +| Task Detail | `e` | Activate note editor for modification | +| Task Detail | `v` | Edit task details in external editor (default `vim`) | +| Task Detail | `r` | Rename Task Title | +| Active Note Editor | `Esc` | Deactivate note editor and save content | **Tips about using shortcuts efficiently:** @@ -174,7 +177,5 @@ You may :thumbsup: issues if you want to increase priority of a feature. ### Footnotes 1. In my Macbook Air, 1.6 GHz Dual-Core Intel Core i5, RAM: 8 GB 1600 MHz DDR3 2. Using [monakai](https://github.com/sickill/vim-monokai) color scheme for markdown syntax -3. Habitica is a free habit and productivity app that treats your real life like a game -4. Known Bug: Mouse events (click) don't work after getting back from Editor. --- > "This is the Book about which there is no doubt, a guidance for those conscious of Allah" - [Al-Quran](http://quran.com) diff --git a/app/cli.go b/app/cli.go index 3e30b91..1361ce7 100644 --- a/app/cli.go +++ b/app/cli.go @@ -40,44 +40,28 @@ func main() { }() if len(os.Args) > 1 && os.Args[1] == "migrate" { - migrate() + migrate(db) + } else { + projectRepo = repo.NewProjectRepository(db) + taskRepo = repo.NewTaskRepository(db) + + layout = tview.NewFlex().SetDirection(tview.FlexRow). + AddItem(makeTitleBar(), 2, 1, false). + AddItem(prepareContentPages(), 0, 2, true). + AddItem(prepareStatusBar(app), 1, 1, false) + + setKeyboardShortcuts() + + if err := app.SetRoot(layout, true).EnableMouse(true).Run(); err != nil { + panic(err) + } } - projectRepo = repo.NewProjectRepository(db) - taskRepo = repo.NewTaskRepository(db) - - titleText := tview.NewTextView().SetText("[lime::b]Geek-life [::-]- Task Manager for geeks!").SetDynamicColors(true) - cloudStatus := tview.NewTextView().SetText("[::d]Version: 0.1.0").SetTextAlign(tview.AlignRight).SetDynamicColors(true) - - titleBar := tview.NewFlex(). - AddItem(titleText, 0, 2, false). - AddItem(cloudStatus, 0, 1, false) - - statusBar = makeStatusBar(app) - projectPane = NewProjectPane(projectRepo) - taskPane = NewTaskPane(projectRepo, taskRepo) - projectDetailPane = NewProjectDetailPane() - taskDetailPane = NewTaskDetailPane(taskRepo) - - contents = tview.NewFlex(). - AddItem(projectPane, 25, 1, true). - AddItem(taskPane, 0, 2, false) - - layout = tview.NewFlex().SetDirection(tview.FlexRow). - AddItem(titleBar, 2, 1, false). - AddItem(contents, 0, 2, true). - AddItem(statusBar, 1, 1, false) - - setKeyboardShortcuts() - - if err := app.SetRoot(layout, true).EnableMouse(true).Run(); err != nil { - panic(err) - } } -func migrate() { - util.FatalIfError(db.ReIndex(&model.Project{}), "Error in migrating Projects") - util.FatalIfError(db.ReIndex(&model.Task{}), "Error in migrating Tasks") +func migrate(database *storm.DB) { + util.FatalIfError(database.ReIndex(&model.Project{}), "Error in migrating Projects") + util.FatalIfError(database.ReIndex(&model.Task{}), "Error in migrating Tasks") fmt.Println("Migration completed. Start geek-life normally.") os.Exit(0) @@ -112,3 +96,26 @@ func setKeyboardShortcuts() *tview.Application { return event }) } + +func prepareContentPages() *tview.Flex { + projectPane = NewProjectPane(projectRepo) + taskPane = NewTaskPane(projectRepo, taskRepo) + projectDetailPane = NewProjectDetailPane() + taskDetailPane = NewTaskDetailPane(taskRepo) + + contents = tview.NewFlex(). + AddItem(projectPane, 25, 1, true). + AddItem(taskPane, 0, 2, false) + + return contents + +} + +func makeTitleBar() *tview.Flex { + titleText := tview.NewTextView().SetText("[lime::b]Geek-life [::-]- Task Manager for geeks!").SetDynamicColors(true) + versionInfo := tview.NewTextView().SetText("[::d]Version: 0.1.1").SetTextAlign(tview.AlignRight).SetDynamicColors(true) + + return tview.NewFlex(). + AddItem(titleText, 0, 2, false). + AddItem(versionInfo, 0, 1, false) +} diff --git a/app/status_bar.go b/app/status_bar.go index bbf1882..1ee874b 100644 --- a/app/status_bar.go +++ b/app/status_bar.go @@ -19,8 +19,8 @@ const ( messagePage = "message" ) -func makeStatusBar(app *tview.Application) *StatusBar { - statusBar := StatusBar{ +func prepareStatusBar(app *tview.Application) *StatusBar { + statusBar = &StatusBar{ Pages: tview.NewPages(), message: tview.NewTextView().SetDynamicColors(true).SetText("Loading..."), container: app, @@ -39,7 +39,7 @@ func makeStatusBar(app *tview.Application) *StatusBar { true, ) - return &statusBar + return statusBar } func (bar *StatusBar) showForSeconds(message string, timeout int) { diff --git a/app/tasks.go b/app/tasks.go index 8153b04..2da2a76 100644 --- a/app/tasks.go +++ b/app/tasks.go @@ -37,6 +37,7 @@ func NewTaskPane(projectRepo repository.ProjectRepository, taskRepo repository.T hint: tview.NewTextView().SetTextColor(tcell.ColorYellow).SetTextAlign(tview.AlignCenter), } + pane.list.SetSelectedBackgroundColor(tcell.ColorDarkBlue) pane.list.SetDoneFunc(func() { app.SetFocus(projectPane) }) diff --git a/app/util.go b/app/util.go index b80c03b..83f2bb7 100644 --- a/app/util.go +++ b/app/util.go @@ -34,9 +34,9 @@ func makeHorizontalLine(lineChar rune, color tcell.Color) *tview.TextView { func makeLightTextInput(placeholder string) *tview.InputField { return tview.NewInputField(). SetPlaceholder(placeholder). - SetPlaceholderTextColor(tcell.ColorYellow). + SetPlaceholderTextColor(tcell.ColorDarkSlateBlue). SetFieldTextColor(tcell.ColorBlack). - SetFieldBackgroundColor(tcell.ColorGray) + SetFieldBackgroundColor(tcell.ColorLightBlue) } // If input text is a valid date, parse it. Or get current date @@ -78,11 +78,18 @@ func removeThirdCol() { } func getTaskTitleColor(task model.Task) string { - colorName := "olive" + colorName := "smokewhite" + if task.Completed { - colorName = "lime" - } else if task.DueDate != 0 && task.DueDate < time.Now().Truncate(24*time.Hour).Unix() { - colorName = "red" + colorName = "green" + } else if task.DueDate != 0 { + dayDiff := int(time.Unix(task.DueDate, 0).Sub(time.Now()).Hours() / 24) + + if dayDiff == 0 { + colorName = "orange" + } else if dayDiff < 0 { + colorName = "red" + } } return colorName