diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index 517e7d0..2b8dfda 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -40,6 +40,8 @@ import Brick.Widgets.Core , joinBorders , padAll , padBottom + , padTop + , setAvailableSize , str , strWrap , strWrapWith @@ -48,6 +50,7 @@ import Brick.Widgets.Core , txtWrapWith , updateAttrMap , vBox + , viewport , vLimit , withAttr , withBorderStyle @@ -108,6 +111,7 @@ data Name | RecField | AmtField | MemoField + | ABViewport deriving (Eq, Show, Ord) data DialogInput = DialogInput @@ -132,6 +136,7 @@ data DialogType | ASelect | SendTx | Blank + | AdrBook data DisplayType = AddrDisplay @@ -341,6 +346,45 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s] C.hCenter (hBox [capCommand "↲ " "Send", capCommand " " "Cancel"])) Blank -> emptyWidget + AdrBook -> +-- D.renderDialog +-- (D.dialog (Just (str "Select Wallet")) Nothing 50) +-- (selectListBox "Wallets" (st ^. wallets) listDrawWallet <=> +-- C.hCenter +-- (hBox +-- [ capCommand "↑↓ " "move" +-- , capCommand "↲ " "select" +-- , capCommand "N" "ew" +-- , capCommand "S" "how phrase" +-- , xCommand +-- ])) + D.renderDialog + (D.dialog (Just $ str " Address Book ") Nothing 60) + (withAttr abDefAttr $ + setAvailableSize (50,20) $ + viewport ABViewport BT.Vertical $ + vLimit 20 $ + hLimit 50 $ + vBox $ [vLimit 16 $ + hLimit 50 $ + vBox $ --[ L.renderList listDrawAB True (s^.abaddresses) ], + [str "Addresses 1.................", + str "Addresses 2.....", + str "Addresses 3", + str "Addresses 4"], + padTop Max $ + vLimit 4 $ + hLimit 50 $ + withAttr abMBarAttr $ + vBox $ [C.hCenter $ + (capCommand "N" "ew Address" <+> + capCommand "E" "dit Address" <+> + capCommand3 "" "C" "opy Address"), + C.hCenter $ + (capCommand "D" "elete Address" <+> + capCommand "S" "end Zcash" <+> + capCommand3 "E" "x" "it")]]) + splashDialog :: State -> Widget Name splashDialog st = if st ^. splashBox @@ -586,6 +630,15 @@ barDoneAttr = A.attrName "done" barToDoAttr :: A.AttrName barToDoAttr = A.attrName "remaining" +abDefAttr :: A.AttrName +abDefAttr = A.attrName "abdefault" + +abSelAttr :: A.AttrName +abSelAttr = A.attrName "abselected" + +abMBarAttr :: A.AttrName +abMBarAttr = A.attrName "menubar" + validBarValue :: Float -> Float validBarValue = clamp 0 1 @@ -694,6 +747,7 @@ appEvent (BT.AppEvent t) = do WSelect -> return () ASelect -> return () SendTx -> return () + AdrBook -> return () Blank -> do if s ^. timer == 90 then do @@ -931,6 +985,23 @@ appEvent (BT.VtyEvent e) = do setFieldValid (isRecipientValid (fs ^. sendTo)) RecField + AdrBook -> do + case e of + V.EvKey (V.KChar 'x') [] -> + BT.modify $ set dialogBox Blank + V.EvKey V.KEnter [] -> do + ns <- liftIO $ refreshWallet s + BT.put ns + BT.modify $ set dialogBox Blank + V.EvKey (V.KChar 'n') [] -> do + BT.modify $ + set inputForm $ + updateFormState (DialogInput "New Wallet") $ + s ^. inputForm + BT.modify $ set dialogBox WName + V.EvKey (V.KChar 's') [] -> + BT.modify $ set displayBox PhraseDisplay + ev -> BT.zoom wallets $ L.handleListEvent ev Blank -> do case e of V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext @@ -954,8 +1025,8 @@ appEvent (BT.VtyEvent e) = do set txForm $ mkSendForm (s ^. balance) (SendInput "" 0.0 "") BT.modify $ set dialogBox SendTx - V.EvKey (V.KChar 'b') [] -> - BT.modify $ set dialogBox ASelect + V.EvKey (V.KChar 'b') [] -> + BT.modify $ set dialogBox AdrBook ev -> case r of Just AList -> @@ -986,6 +1057,9 @@ theMap = , (baseAttr, bg V.brightBlack) , (barDoneAttr, V.white `on` V.blue) , (barToDoAttr, V.white `on` V.black) + , (abDefAttr, V.white `on` V.blue) + , (abSelAttr, V.blue `on` V.white) + , (abMBarAttr, V.white `on` V.black) ] theApp :: M.App State Tick Name