Skip to content

Commit 0d6b708

Browse files
committed
Refactoring and color improvements
1 parent d8677ca commit 0d6b708

File tree

5 files changed

+79
-63
lines changed

5 files changed

+79
-63
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [x] Set Task due date with quick input buttons (today, +1 day, -1 day)
3636
- [x] Update Task Title
3737
- [x] Tasklist items should indicate status (done, pending, overdue) using colors
38+
- [ ] Pin Tasks
3839
- [x] Shortcut for Adding new Project and Task
3940
- [x] Global shortcuts for jumping to Projects or Tasks panel anytime
4041
- [x] Cleanup all completed tasks of project
@@ -46,7 +47,9 @@
4647
- Today - Due Today and overdue
4748
- Tomorrow
4849
- Upcoming - Due in next 7 days
49-
- [ ] [Habitica](https://habitica.com/)<sup>3</sup> integration - Use it as Habitica client or use Habitica for cloud backup
50+
- [ ] Integrations
51+
- Google Tasks
52+
- (Share your ideas)
5053
- [ ] Time tracking
5154

5255
### :rocket: Ready for action (installing and running)
@@ -80,25 +83,25 @@ You'll see a currently focused pane bordered with double line.
8083

8184
In case writing in a text input (e,g, new project/task, due date), you have to `Enter` to submit/save.
8285

83-
| Context | Shortcut | Action |
84-
|---|:---:|---|
85-
| Global | `p` | Go to Project list |
86-
| Global | `t` | Go to Task list |
87-
| Projects | `n` | New Project |
88-
| Projects | ``/`k`/`Shift+Tab` | Go up in project list |
89-
| Projects | ``/`j`/`Tab` | Go down in project list |
90-
| Tasks | `n` | New Task |
91-
| Tasks | `Esc`/`h` | Go back to Projects Pane |
92-
| Tasks | ``/`k`/`Shift+Tab` | Go up in task list |
93-
| Tasks | ``/`j`/`Tab` | Go down in task list |
94-
| Task Detail | `Esc`/`h` | Go back to Tasks Pane |
95-
| Task Detail | `Space` | Toggle task as done/pending |
96-
| Task Detail | `d` | Set Due date |
97-
| Task Detail | ``/`` | Scroll Up/Down the note editor |
98-
| Task Detail | `e` | Activate note editor for modification |
99-
| Task Detail | `v` | Edit task details in external editor (default `vim`) _Known Bug<sup>[4](#footnotes)</sup>_ |
100-
| Task Detail | `r` | Rename Task Title |
101-
| Active Note Editor | `Esc` | Deactivate note editor and save content |
86+
| Context | Shortcut | Action |
87+
| --- | :---: | --- |
88+
| Global | `p` | Go to Project list |
89+
| Global | `t` | Go to Task list |
90+
| Projects | `n` | New Project |
91+
| Projects | ``/`k`/`Shift+Tab` | Go up in project list |
92+
| Projects | ``/`j`/`Tab` | Go down in project list |
93+
| Tasks | `n` | New Task |
94+
| Tasks | `Esc`/`h` | Go back to Projects Pane |
95+
| Tasks | ``/`k`/`Shift+Tab` | Go up in task list |
96+
| Tasks | ``/`j`/`Tab` | Go down in task list |
97+
| Task Detail | `Esc`/`h` | Go back to Tasks Pane |
98+
| Task Detail | `Space` | Toggle task as done/pending |
99+
| Task Detail | `d` | Set Due date |
100+
| Task Detail | ``/`` | Scroll Up/Down the note editor |
101+
| Task Detail | `e` | Activate note editor for modification |
102+
| Task Detail | `v` | Edit task details in external editor (default `vim`) |
103+
| Task Detail | `r` | Rename Task Title |
104+
| Active Note Editor | `Esc` | Deactivate note editor and save content |
102105

103106
**Tips about using shortcuts efficiently:**
104107

@@ -174,7 +177,5 @@ You may :thumbsup: issues if you want to increase priority of a feature.
174177
### Footnotes
175178
1. In my Macbook Air, 1.6 GHz Dual-Core Intel Core i5, RAM: 8 GB 1600 MHz DDR3
176179
2. Using [monakai](https://github.com/sickill/vim-monokai) color scheme for markdown syntax
177-
3. Habitica is a free habit and productivity app that treats your real life like a game
178-
4. Known Bug: Mouse events (click) don't work after getting back from Editor.
179180
---
180181
> "This is the Book about which there is no doubt, a guidance for those conscious of Allah" - [Al-Quran](http://quran.com)

app/cli.go

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,44 +40,28 @@ func main() {
4040
}()
4141

4242
if len(os.Args) > 1 && os.Args[1] == "migrate" {
43-
migrate()
44-
}
45-
46-
projectRepo = repo.NewProjectRepository(db)
47-
taskRepo = repo.NewTaskRepository(db)
43+
migrate(db)
44+
} else {
45+
projectRepo = repo.NewProjectRepository(db)
46+
taskRepo = repo.NewTaskRepository(db)
4847

49-
titleText := tview.NewTextView().SetText("[lime::b]Geek-life [::-]- Task Manager for geeks!").SetDynamicColors(true)
50-
cloudStatus := tview.NewTextView().SetText("[::d]Version: 0.1.0").SetTextAlign(tview.AlignRight).SetDynamicColors(true)
51-
52-
titleBar := tview.NewFlex().
53-
AddItem(titleText, 0, 2, false).
54-
AddItem(cloudStatus, 0, 1, false)
48+
layout = tview.NewFlex().SetDirection(tview.FlexRow).
49+
AddItem(makeTitleBar(), 2, 1, false).
50+
AddItem(prepareContentPages(), 0, 2, true).
51+
AddItem(prepareStatusBar(app), 1, 1, false)
5552

56-
statusBar = makeStatusBar(app)
57-
projectPane = NewProjectPane(projectRepo)
58-
taskPane = NewTaskPane(projectRepo, taskRepo)
59-
projectDetailPane = NewProjectDetailPane()
60-
taskDetailPane = NewTaskDetailPane(taskRepo)
53+
setKeyboardShortcuts()
6154

62-
contents = tview.NewFlex().
63-
AddItem(projectPane, 25, 1, true).
64-
AddItem(taskPane, 0, 2, false)
65-
66-
layout = tview.NewFlex().SetDirection(tview.FlexRow).
67-
AddItem(titleBar, 2, 1, false).
68-
AddItem(contents, 0, 2, true).
69-
AddItem(statusBar, 1, 1, false)
70-
71-
setKeyboardShortcuts()
72-
73-
if err := app.SetRoot(layout, true).EnableMouse(true).Run(); err != nil {
74-
panic(err)
55+
if err := app.SetRoot(layout, true).EnableMouse(true).Run(); err != nil {
56+
panic(err)
57+
}
7558
}
59+
7660
}
7761

78-
func migrate() {
79-
util.FatalIfError(db.ReIndex(&model.Project{}), "Error in migrating Projects")
80-
util.FatalIfError(db.ReIndex(&model.Task{}), "Error in migrating Tasks")
62+
func migrate(database *storm.DB) {
63+
util.FatalIfError(database.ReIndex(&model.Project{}), "Error in migrating Projects")
64+
util.FatalIfError(database.ReIndex(&model.Task{}), "Error in migrating Tasks")
8165

8266
fmt.Println("Migration completed. Start geek-life normally.")
8367
os.Exit(0)
@@ -112,3 +96,26 @@ func setKeyboardShortcuts() *tview.Application {
11296
return event
11397
})
11498
}
99+
100+
func prepareContentPages() *tview.Flex {
101+
projectPane = NewProjectPane(projectRepo)
102+
taskPane = NewTaskPane(projectRepo, taskRepo)
103+
projectDetailPane = NewProjectDetailPane()
104+
taskDetailPane = NewTaskDetailPane(taskRepo)
105+
106+
contents = tview.NewFlex().
107+
AddItem(projectPane, 25, 1, true).
108+
AddItem(taskPane, 0, 2, false)
109+
110+
return contents
111+
112+
}
113+
114+
func makeTitleBar() *tview.Flex {
115+
titleText := tview.NewTextView().SetText("[lime::b]Geek-life [::-]- Task Manager for geeks!").SetDynamicColors(true)
116+
versionInfo := tview.NewTextView().SetText("[::d]Version: 0.1.1").SetTextAlign(tview.AlignRight).SetDynamicColors(true)
117+
118+
return tview.NewFlex().
119+
AddItem(titleText, 0, 2, false).
120+
AddItem(versionInfo, 0, 1, false)
121+
}

app/status_bar.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const (
1919
messagePage = "message"
2020
)
2121

22-
func makeStatusBar(app *tview.Application) *StatusBar {
23-
statusBar := StatusBar{
22+
func prepareStatusBar(app *tview.Application) *StatusBar {
23+
statusBar = &StatusBar{
2424
Pages: tview.NewPages(),
2525
message: tview.NewTextView().SetDynamicColors(true).SetText("Loading..."),
2626
container: app,
@@ -39,7 +39,7 @@ func makeStatusBar(app *tview.Application) *StatusBar {
3939
true,
4040
)
4141

42-
return &statusBar
42+
return statusBar
4343
}
4444

4545
func (bar *StatusBar) showForSeconds(message string, timeout int) {

app/tasks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewTaskPane(projectRepo repository.ProjectRepository, taskRepo repository.T
3737
hint: tview.NewTextView().SetTextColor(tcell.ColorYellow).SetTextAlign(tview.AlignCenter),
3838
}
3939

40+
pane.list.SetSelectedBackgroundColor(tcell.ColorDarkBlue)
4041
pane.list.SetDoneFunc(func() {
4142
app.SetFocus(projectPane)
4243
})

app/util.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ func makeHorizontalLine(lineChar rune, color tcell.Color) *tview.TextView {
3434
func makeLightTextInput(placeholder string) *tview.InputField {
3535
return tview.NewInputField().
3636
SetPlaceholder(placeholder).
37-
SetPlaceholderTextColor(tcell.ColorYellow).
37+
SetPlaceholderTextColor(tcell.ColorDarkSlateBlue).
3838
SetFieldTextColor(tcell.ColorBlack).
39-
SetFieldBackgroundColor(tcell.ColorGray)
39+
SetFieldBackgroundColor(tcell.ColorLightBlue)
4040
}
4141

4242
// If input text is a valid date, parse it. Or get current date
@@ -78,11 +78,18 @@ func removeThirdCol() {
7878
}
7979

8080
func getTaskTitleColor(task model.Task) string {
81-
colorName := "olive"
81+
colorName := "smokewhite"
82+
8283
if task.Completed {
83-
colorName = "lime"
84-
} else if task.DueDate != 0 && task.DueDate < time.Now().Truncate(24*time.Hour).Unix() {
85-
colorName = "red"
84+
colorName = "green"
85+
} else if task.DueDate != 0 {
86+
dayDiff := int(time.Unix(task.DueDate, 0).Sub(time.Now()).Hours() / 24)
87+
88+
if dayDiff == 0 {
89+
colorName = "orange"
90+
} else if dayDiff < 0 {
91+
colorName = "red"
92+
}
8693
}
8794

8895
return colorName

0 commit comments

Comments
 (0)