Publish Zenith beta version #80
1 changed files with 54 additions and 9 deletions
|
@ -28,6 +28,7 @@ import Brick.Widgets.Core
|
|||
, (<=>)
|
||||
, emptyWidget
|
||||
, fill
|
||||
, hBox
|
||||
, hLimit
|
||||
, joinBorders
|
||||
, padAll
|
||||
|
@ -35,6 +36,7 @@ import Brick.Widgets.Core
|
|||
, str
|
||||
, strWrap
|
||||
, txt
|
||||
, txtWrap
|
||||
, txtWrapWith
|
||||
, vBox
|
||||
, vLimit
|
||||
|
@ -48,6 +50,7 @@ import Control.Monad (void)
|
|||
import Control.Monad.IO.Class (liftIO)
|
||||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as E
|
||||
import qualified Data.Vector as Vec
|
||||
import Database.Persist
|
||||
import qualified Graphics.Vty as V
|
||||
|
@ -88,6 +91,7 @@ data DialogType
|
|||
data DisplayType
|
||||
= AddrDisplay
|
||||
| MsgDisplay
|
||||
| PhraseDisplay
|
||||
| BlankDisplay
|
||||
|
||||
data State = State
|
||||
|
@ -135,7 +139,14 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(\(_, a) -> zcashAccountName $ entityVal a)
|
||||
(L.listSelectedElement (st ^. accounts))))) <=>
|
||||
listAddressBox "Addresses" (st ^. addresses) <+>
|
||||
B.vBorder <+> C.center (listBox "Transactions" (st ^. transactions)))
|
||||
B.vBorder <+> C.center (listBox "Transactions" (st ^. transactions))) <=>
|
||||
C.hCenter
|
||||
(hBox
|
||||
[ capCommand "W" "allets"
|
||||
, capCommand "A" "ccounts"
|
||||
, capCommand "V" "iew address"
|
||||
, capCommand "Q" "uit"
|
||||
])
|
||||
listBox :: Show e => String -> L.List Name e -> Widget Name
|
||||
listBox titleLabel l =
|
||||
C.vCenter $
|
||||
|
@ -158,7 +169,6 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(B.borderWithLabel (str titleLabel) $
|
||||
hLimit 25 $ vLimit 15 $ L.renderList drawF True l)
|
||||
, str " "
|
||||
, C.hCenter $ str "Select "
|
||||
]
|
||||
listAddressBox ::
|
||||
String -> L.List Name (Entity WalletAddress) -> Widget Name
|
||||
|
@ -209,11 +219,26 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
WSelect ->
|
||||
D.renderDialog
|
||||
(D.dialog (Just (str "Select Wallet")) Nothing 50)
|
||||
(selectListBox "Wallets" (st ^. wallets) listDrawWallet)
|
||||
(selectListBox "Wallets" (st ^. wallets) listDrawWallet <=>
|
||||
C.hCenter
|
||||
(hBox
|
||||
[ capCommand "↑↓ " "move"
|
||||
, capCommand "↲ " "select"
|
||||
, capCommand "N" "ew"
|
||||
, capCommand "S" "how phrase"
|
||||
, xCommand
|
||||
]))
|
||||
ASelect ->
|
||||
D.renderDialog
|
||||
(D.dialog (Just (str "Select Account")) Nothing 50)
|
||||
(selectListBox "Accounts" (st ^. accounts) listDrawAccount)
|
||||
(selectListBox "Accounts" (st ^. accounts) listDrawAccount <=>
|
||||
C.hCenter
|
||||
(hBox
|
||||
[ capCommand "↑↓ " "move"
|
||||
, capCommand "↲ " "select"
|
||||
, capCommand "N" "ew"
|
||||
, xCommand
|
||||
]))
|
||||
Blank -> emptyWidget
|
||||
splashDialog :: State -> Widget Name
|
||||
splashDialog st =
|
||||
|
@ -225,9 +250,13 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
titleAttr
|
||||
(str
|
||||
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
|
||||
C.hCenter (withAttr titleAttr (str "Zcash Wallet v0.4.3.0")) <=>
|
||||
C.hCenter (withAttr titleAttr (str "Zcash Wallet v0.4.4.0")) <=>
|
||||
C.hCenter (withAttr blinkAttr $ str "Press any key..."))
|
||||
else emptyWidget
|
||||
capCommand :: String -> String -> Widget Name
|
||||
capCommand k comm = hBox [withAttr titleAttr (str k), str comm, str " | "]
|
||||
xCommand :: Widget Name
|
||||
xCommand = hBox [str "E", withAttr titleAttr (str "x"), str "it"]
|
||||
displayDialog :: State -> Widget Name
|
||||
displayDialog st =
|
||||
case st ^. displayBox of
|
||||
|
@ -244,6 +273,17 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $
|
||||
getUA $ walletAddressUAddress $ entityVal a)
|
||||
Nothing -> emptyWidget
|
||||
PhraseDisplay ->
|
||||
case L.listSelectedElement $ st ^. wallets of
|
||||
Just (_, w) ->
|
||||
withBorderStyle unicodeBold $
|
||||
D.renderDialog
|
||||
(D.dialog (Just $ txt "Seed Phrase") Nothing 50)
|
||||
(padAll 1 $
|
||||
txtWrap $
|
||||
E.decodeUtf8Lenient $
|
||||
getBytes $ getPhrase $ zcashWalletSeedPhrase $ entityVal w)
|
||||
Nothing -> emptyWidget
|
||||
MsgDisplay ->
|
||||
withBorderStyle unicodeBold $
|
||||
D.renderDialog
|
||||
|
@ -319,6 +359,7 @@ appEvent (BT.VtyEvent e) = do
|
|||
case s ^. displayBox of
|
||||
AddrDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
MsgDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
PhraseDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
BlankDisplay -> do
|
||||
case s ^. dialogBox of
|
||||
WName -> do
|
||||
|
@ -372,26 +413,30 @@ appEvent (BT.VtyEvent e) = do
|
|||
BT.zoom inputForm $ handleFormEvent (BT.VtyEvent ev)
|
||||
WSelect -> do
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
|
||||
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 'c') [] -> do
|
||||
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
|
||||
ASelect -> do
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
|
||||
V.EvKey (V.KChar 'x') [] ->
|
||||
BT.modify $ set dialogBox Blank
|
||||
V.EvKey V.KEnter [] -> do
|
||||
ns <- liftIO $ refreshAccount s
|
||||
BT.put ns
|
||||
BT.modify $ set dialogBox Blank
|
||||
V.EvKey (V.KChar 'c') [] -> do
|
||||
V.EvKey (V.KChar 'n') [] -> do
|
||||
BT.modify $
|
||||
set inputForm $
|
||||
updateFormState (DialogInput "New Account") $
|
||||
|
|
Loading…
Reference in a new issue