Load tasks on startup again
This commit is contained in:
parent
d8e0e1a867
commit
c1b1fddb76
5 changed files with 22 additions and 18 deletions
|
|
@ -10,4 +10,5 @@ import TaskMachine.UI
|
|||
main :: IO()
|
||||
main = do
|
||||
o <- parseOptions
|
||||
void $ B.defaultMain myApp (startUIState o)
|
||||
state <- loadTasks $ startUIState o
|
||||
void $ B.defaultMain myApp state
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
module TaskMachine.UI
|
||||
( myApp
|
||||
, startUIState
|
||||
, loadTasks
|
||||
) where
|
||||
|
||||
import qualified Brick as B
|
||||
|
|
@ -9,15 +10,20 @@ import qualified Brick.Themes as B
|
|||
import qualified Data.Vector as V
|
||||
import qualified Graphics.Vty.Input.Events as VTY
|
||||
|
||||
import TaskMachine.LTask
|
||||
import TaskMachine.Options
|
||||
import TaskMachine.UI.NewTask
|
||||
import TaskMachine.UI.Popup
|
||||
import TaskMachine.UI.TaskList
|
||||
import TaskMachine.UI.TopBar
|
||||
import TaskMachine.UI.Types
|
||||
|
||||
{- Rendering -}
|
||||
|
||||
placeholderTopBar :: B.Widget n
|
||||
placeholderTopBar = B.str "Prune | Reload | Search: " B.<+> B.vLimit 1 (B.fill '_')
|
||||
|
||||
placeholderNewTask :: B.Widget RName
|
||||
placeholderNewTask = B.str "New: " B.<+> B.vLimit 1 (B.fill '_')
|
||||
|
||||
drawBaseLayer :: UIState -> B.Widget RName
|
||||
drawBaseLayer s = B.vBox [placeholderTopBar, renderTaskList True (tasks s), placeholderNewTask]
|
||||
|
||||
|
|
@ -25,6 +31,17 @@ drawUIState :: UIState -> [B.Widget RName]
|
|||
drawUIState s@UIState{errorPopup=Just p} = [renderPopupOk p, drawBaseLayer s]
|
||||
drawUIState s = [drawBaseLayer s]
|
||||
|
||||
{- Actions -}
|
||||
|
||||
loadTasks :: UIState -> IO UIState
|
||||
loadTasks s = do
|
||||
let file = oTodofile $ options s
|
||||
result <- loadLTasks file
|
||||
case result of
|
||||
-- TODO: Improve error handling when loading files
|
||||
Left errorMessage -> pure s{errorPopup=Just $ popupOk "Error loading tasks" errorMessage}
|
||||
Right ltasks -> pure s{tasks=taskList RTaskList ltasks}
|
||||
|
||||
{- Updating the state -}
|
||||
|
||||
rootBehavior :: UIState -> VTY.Event -> NewState
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
module TaskMachine.UI.NewTask where
|
||||
|
||||
import qualified Brick as B
|
||||
|
||||
import TaskMachine.UI.Types
|
||||
|
||||
placeholderNewTask :: B.Widget RName
|
||||
placeholderNewTask = B.str "New: " B.<+> B.vLimit 1 (B.fill '_')
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
module TaskMachine.UI.TopBar where
|
||||
|
||||
import qualified Brick as B
|
||||
|
||||
placeholderTopBar :: B.Widget n
|
||||
placeholderTopBar = B.str "Prune | Reload | Search: " B.<+> B.vLimit 1 (B.fill '_')
|
||||
2
todo.txt
2
todo.txt
|
|
@ -3,5 +3,5 @@
|
|||
- c2018-09-18 Offer "retry" or "quit" +dialogue - syntax error in todo file
|
||||
- c2018-09-18 Offer to clean up file when loading (adding creation/completion dates)
|
||||
- c2018-09-18 Purge - move completed tasks to a separate file
|
||||
- c2018-09-18 Quit using Esc or q
|
||||
- c2018-09-18 Sort tasks by completion, priority, due date, description
|
||||
x2018-09-27 c2018-09-18 Quit using Esc or q
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue