@@ -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+ }
0 commit comments