Add base addressbook to GUI #102
2 changed files with 44 additions and 8 deletions
|
@ -238,4 +238,5 @@ printUsage = do
|
|||
putStrLn "Available commands:"
|
||||
{-putStrLn "legacy\tLegacy CLI for zcashd"-}
|
||||
putStrLn "tui\tTUI for zebrad"
|
||||
putStrLn "gui\tGUI for zebrad"
|
||||
putStrLn "rescan\tRescan the existing wallet(s)"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
|
||||
module Zenith.GUI where
|
||||
|
||||
|
@ -102,6 +103,9 @@ data AppEvent
|
|||
| CheckRecipient !T.Text
|
||||
| CheckAmount !Float
|
||||
| ShowTxId !T.Text
|
||||
| ShowAdrBook
|
||||
| CloseAdrBook
|
||||
| NotImplemented
|
||||
deriving (Eq, Show)
|
||||
|
||||
data AppModel = AppModel
|
||||
|
@ -144,6 +148,7 @@ data AppModel = AppModel
|
|||
, _amountValid :: !Bool
|
||||
, _showId :: !(Maybe T.Text)
|
||||
, _home :: !FilePath
|
||||
, _showAdrBook :: !Bool
|
||||
} deriving (Eq, Show)
|
||||
|
||||
makeLenses ''AppModel
|
||||
|
@ -185,6 +190,8 @@ buildUI wenv model = widgetTree
|
|||
, txIdOverlay `nodeVisible` isJust (model ^. showId)
|
||||
, msgOverlay `nodeVisible` isJust (model ^. msg)
|
||||
, modalOverlay `nodeVisible` isJust (model ^. modalMsg)
|
||||
, adrbookOverlay `nodeVisible` model ^. showAdrBook
|
||||
, msgAdrBookOverlay `nodeVisible` model ^. notImplemented
|
||||
]
|
||||
mainWindow =
|
||||
vstack
|
||||
|
@ -247,6 +254,8 @@ buildUI wenv model = widgetTree
|
|||
[bgColor white, borderB 1 gray, padding 3]
|
||||
, box_ [alignLeft, onClick ShowSeed] (label "Backup Wallet") `styleBasic`
|
||||
[bgColor white, borderB 1 gray, padding 3]
|
||||
, box_ [alignLeft, onClick ShowAdrBook] (label "Address Book") `styleBasic`
|
||||
[bgColor white, borderB 1 gray, padding 3]
|
||||
]) `styleBasic`
|
||||
[bgColor btnColor, padding 3]
|
||||
newBox =
|
||||
|
@ -750,6 +759,26 @@ buildUI wenv model = widgetTree
|
|||
]
|
||||
]) `styleBasic`
|
||||
[padding 2, bgColor white, width 280, borderB 1 gray, borderT 1 gray]
|
||||
adrbookOverlay =
|
||||
alert CloseAdrBook $
|
||||
vstack
|
||||
[ box_
|
||||
[]
|
||||
(label "Address Book" `styleBasic`
|
||||
[textFont "Bold", textSize 12, textColor white]) `styleBasic`
|
||||
[bgColor btnColor, radius 2, padding 3]
|
||||
, spacer
|
||||
, hstack [
|
||||
button "New" notImplemented
|
||||
, spacer
|
||||
, button "Edit" notImplemented
|
||||
, spacer
|
||||
, button "Copy" notImplemented
|
||||
|
||||
]
|
||||
]
|
||||
|
||||
notImplemented = NotImplemented
|
||||
|
||||
generateQRCodes :: Config -> IO ()
|
||||
generateQRCodes config = do
|
||||
|
@ -1060,6 +1089,9 @@ handleEvent wenv node model evt =
|
|||
(i < (fromIntegral (model ^. balance) / 100000000.0))
|
||||
]
|
||||
ShowTxId tx -> [Model $ model & showId ?~ tx & modalMsg .~ Nothing]
|
||||
ShowAdrBook -> [Model $ model & showAdrBook .~ True & menuPopup .~ False]
|
||||
CloseAdrBook -> [Model $ model & showAdrBook .~ False]
|
||||
NotImplemented -> [Model $ model & msg ?~ "Function not implemented..." & menuPopup .~ False & modalMsg .~ Nothing]
|
||||
where
|
||||
currentWallet =
|
||||
if null (model ^. wallets)
|
||||
|
@ -1325,10 +1357,9 @@ runZenithGUI config = do
|
|||
Nothing
|
||||
""
|
||||
""
|
||||
(SaveAddress $
|
||||
if not (null accList)
|
||||
then Just (head accList)
|
||||
else Nothing)
|
||||
(SaveAddress (if not (null accList)
|
||||
then Just (head accList)
|
||||
else Nothing ) )
|
||||
False
|
||||
False
|
||||
Nothing
|
||||
|
@ -1342,7 +1373,9 @@ runZenithGUI config = do
|
|||
False
|
||||
False
|
||||
Nothing
|
||||
hD
|
||||
""
|
||||
False
|
||||
-- hD
|
||||
startApp model handleEvent buildUI (params hD)
|
||||
Left e -> do
|
||||
initDb dbFilePath
|
||||
|
@ -1358,9 +1391,9 @@ runZenithGUI config = do
|
|||
0
|
||||
[]
|
||||
0
|
||||
(Just $
|
||||
(Just (
|
||||
"Couldn't connect to Zebra on " <>
|
||||
host <> ":" <> showt port <> ". Check your configuration.")
|
||||
host <> ":" <> showt port <> ". Check your configuration." ) )
|
||||
False
|
||||
314259000
|
||||
(Just 30000)
|
||||
|
@ -1388,7 +1421,9 @@ runZenithGUI config = do
|
|||
False
|
||||
False
|
||||
Nothing
|
||||
hD
|
||||
""
|
||||
False
|
||||
-- hD
|
||||
startApp model handleEvent buildUI (params hD)
|
||||
where
|
||||
params hd =
|
||||
|
|
Loading…
Reference in a new issue