rvv0041 - Address Book - Show Address Book entry on mouse click completed

This commit is contained in:
Rene V. Vergara A. 2024-09-06 17:16:22 -04:00
parent 538216944d
commit 5ce0b5fa0f

View file

@ -119,6 +119,8 @@ data AppEvent
| CheckValidDescrip !T.Text
| SaveNewABEntry
| ShowMessage !T.Text
| ShowABAddress !T.Text !T.Text
| CloseShowABAddress
deriving (Eq, Show)
data AppModel = AppModel
@ -169,6 +171,7 @@ data AppModel = AppModel
, _abDescripValid :: !Bool
, _abaddressList :: ![Entity AddressBook]
, _msgAB :: !(Maybe T.Text)
, _showABAddress :: !Bool
} deriving (Eq, Show)
makeLenses ''AppModel
@ -212,6 +215,9 @@ buildUI wenv model = widgetTree
, modalOverlay `nodeVisible` isJust (model ^. modalMsg)
, adrbookOverlay `nodeVisible` model ^. showAdrBook
, newAdrBkOverlay `nodeVisible` model ^. newAdrBkEntry
, showABAddressOverlay
(model ^. abdescrip)
(model ^. abaddress) `nodeVisible` model ^. showABAddress
, msgAdrBookOverlay `nodeVisible` isJust (model ^. msgAB)
]
mainWindow =
@ -780,6 +786,9 @@ buildUI wenv model = widgetTree
]
]) `styleBasic`
[padding 2, bgColor white, width 280, borderB 1 gray, borderT 1 gray]
-- |
-- | Address Book overlays
-- |
adrbookOverlay =
alert CloseAdrBook $
vstack
@ -809,12 +818,16 @@ buildUI wenv model = widgetTree
abookRow :: Int -> Entity AddressBook -> WidgetNode AppModel AppEvent
abookRow idx ab =
box_
[onClick $ ShowMessage (addressBookAbaddress $ entityVal ab), alignLeft]
[ onClick $ ShowABAddress
(addressBookAbdescrip $ entityVal ab)
(addressBookAbaddress $ entityVal ab),
alignLeft
]
(hstack
[ label (T.pack $ padWithZero 3 $ show (fromSqlKey (entityKey ab))) `styleBasic`
[textFont "Bold"]
, spacer
, label (T.pack $ show (addressBookAbdescrip $ entityVal ab))
, label (addressBookAbdescrip $ entityVal ab)
]) `styleBasic`
[padding 2, borderB 1 gray]
newAdrBkOverlay =
@ -851,6 +864,27 @@ buildUI wenv model = widgetTree
, button "Cancel" CloseNewAdrBook `nodeEnabled` True
]
]
showABAddressOverlay abd aba =
alert CloseShowABAddress $
vstack
[ box_
[]
(label "Address Book Entry" `styleBasic`
[textFont "Bold", textColor white, textSize 12, padding 3]) `styleBasic`
[bgColor btnColor, radius 2, padding 3]
, spacer
, hstack
[ filler
, label_ (txtWrapN abd 64) [multiline]
, filler
]
, spacer
, hstack
[ filler
, label_ (txtWrapN aba 64) [multiline]
, filler
]
]
msgAdrBookOverlay =
alert CloseMsgAB $
hstack
@ -862,7 +896,6 @@ buildUI wenv model = widgetTree
, label_ (txtWrapN (fromMaybe "" (model ^. msgAB)) 64) [multiline]
, filler
]
notImplemented = NotImplemented
generateQRCodes :: Config -> IO ()
@ -1200,12 +1233,16 @@ handleEvent wenv node model evt =
abList <- getAdrBook dbPool $ model ^. network
return $ LoadAbList abList
]
ShowABAddress d a ->
[ Model $ model & abdescrip .~ d & abaddress .~ a & showABAddress .~ True & menuPopup .~ False ]
CloseShowABAddress ->
[Model $ model & showABAddress .~ False & inError .~ False]
ShowMessage a -> [Model $ model & msgAB ?~ a & menuPopup .~ False]
NotImplemented ->
[ Model $
model & msgAB ?~ "Function not implemented..." & menuPopup .~ False
]
CloseMsgAB -> [Model $ model & msgAB .~ Nothing & inError .~ False]
ShowMessage a -> [Model $ model & msgAB ?~ a & menuPopup .~ False]
LoadAbList a -> [Model $ model & abaddressList .~ a]
where
currentWallet =
@ -1299,19 +1336,13 @@ handleEvent wenv node model evt =
-- |
saveAddrBook :: Config -> ZcashNetDB -> T.Text -> T.Text -> IO AppEvent
saveAddrBook config n d a = do
let dbPath = c_dbPath config
pool <- runNoLoggingT $ initPool dbPath
pool <- runNoLoggingT $ initPool $ c_dbPath config
res <- liftIO $ saveAdrsInAdrBook pool $ AddressBook n d a
case res of
Nothing -> return $ ShowMessage "Error saving the AddressBook entry..."
Just _ -> return $ ShowMessage "New Address Book entry added!!"
-- |
-- |
-- |
-- loadABList :: Config -> ZcashNet -> IO AppEvent
-- loadABList config n = do
-- pool <- runNoLoggingT $ initPool $ c_dbPath config
scanZebra :: T.Text -> T.Text -> Int -> (AppEvent -> IO ()) -> IO ()
scanZebra dbPath zHost zPort sendMsg = do
_ <- liftIO $ initDb dbPath
@ -1519,6 +1550,7 @@ runZenithGUI config = do
False
abList
Nothing
False
startApp model handleEvent buildUI (params hD)
Left e -> do
initDb dbFilePath
@ -1573,6 +1605,7 @@ runZenithGUI config = do
False
[]
Nothing
False
startApp model handleEvent buildUI (params hD)
where
params hd =