rvv041 - New AddressBook entry form - Check for valid address added.
This commit is contained in:
parent
e3de5c7624
commit
cdd28d2184
2 changed files with 83 additions and 5 deletions
|
@ -58,6 +58,7 @@ import Zenith.Utils
|
||||||
, parseAddress
|
, parseAddress
|
||||||
, showAddress
|
, showAddress
|
||||||
, validBarValue
|
, validBarValue
|
||||||
|
, validateAddressBool
|
||||||
)
|
)
|
||||||
|
|
||||||
data AppEvent
|
data AppEvent
|
||||||
|
@ -105,7 +106,11 @@ data AppEvent
|
||||||
| ShowTxId !T.Text
|
| ShowTxId !T.Text
|
||||||
| ShowAdrBook
|
| ShowAdrBook
|
||||||
| CloseAdrBook
|
| CloseAdrBook
|
||||||
|
| NewAdrBkEntry
|
||||||
|
| CloseNewAdrBook
|
||||||
| NotImplemented
|
| NotImplemented
|
||||||
|
| CloseMsgAB
|
||||||
|
| CheckValidAddress !T.Text
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data AppModel = AppModel
|
data AppModel = AppModel
|
||||||
|
@ -149,6 +154,11 @@ data AppModel = AppModel
|
||||||
, _showId :: !(Maybe T.Text)
|
, _showId :: !(Maybe T.Text)
|
||||||
, _home :: !FilePath
|
, _home :: !FilePath
|
||||||
, _showAdrBook :: !Bool
|
, _showAdrBook :: !Bool
|
||||||
|
, _newAdrBkEntry :: !Bool
|
||||||
|
, _abdescrip :: !(Maybe T.Text)
|
||||||
|
, _abaddress :: !T.Text
|
||||||
|
, _abAddressValid :: !Bool
|
||||||
|
, _msgAB :: !(Maybe T.Text)
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
makeLenses ''AppModel
|
makeLenses ''AppModel
|
||||||
|
@ -191,7 +201,8 @@ buildUI wenv model = widgetTree
|
||||||
, msgOverlay `nodeVisible` isJust (model ^. msg)
|
, msgOverlay `nodeVisible` isJust (model ^. msg)
|
||||||
, modalOverlay `nodeVisible` isJust (model ^. modalMsg)
|
, modalOverlay `nodeVisible` isJust (model ^. modalMsg)
|
||||||
, adrbookOverlay `nodeVisible` model ^. showAdrBook
|
, adrbookOverlay `nodeVisible` model ^. showAdrBook
|
||||||
, msgAdrBookOverlay `nodeVisible` model ^. notImplemented
|
, newAdrBkOverlay `nodeVisible` model ^. newAdrBkEntry
|
||||||
|
, msgAdrBookOverlay `nodeVisible` isJust (model ^. msgAB)
|
||||||
]
|
]
|
||||||
mainWindow =
|
mainWindow =
|
||||||
vstack
|
vstack
|
||||||
|
@ -769,7 +780,7 @@ buildUI wenv model = widgetTree
|
||||||
[bgColor btnColor, radius 2, padding 3]
|
[bgColor btnColor, radius 2, padding 3]
|
||||||
, spacer
|
, spacer
|
||||||
, hstack [
|
, hstack [
|
||||||
button "New" notImplemented
|
button "New" NewAdrBkEntry
|
||||||
, spacer
|
, spacer
|
||||||
, button "Edit" notImplemented
|
, button "Edit" notImplemented
|
||||||
, spacer
|
, spacer
|
||||||
|
@ -777,6 +788,53 @@ buildUI wenv model = widgetTree
|
||||||
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
newAdrBkOverlay =
|
||||||
|
alert CloseNewAdrBook $
|
||||||
|
vstack
|
||||||
|
[ box_
|
||||||
|
[]
|
||||||
|
(label "New Address Book Entry" `styleBasic`
|
||||||
|
[textFont "Bold", textSize 10, textColor white]) `styleBasic`
|
||||||
|
[bgColor btnColor, radius 2, padding 3]
|
||||||
|
, spacer
|
||||||
|
, hstack
|
||||||
|
[ label "Description: " `styleBasic` [width 80]
|
||||||
|
, spacer
|
||||||
|
, textField_ sendRecipient [onChange CheckRecipient] `styleBasic`
|
||||||
|
[ width 320
|
||||||
|
-- , styleIf
|
||||||
|
-- (not $ model ^. recipientValid)
|
||||||
|
-- (textColor red)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, spacer
|
||||||
|
, hstack
|
||||||
|
[ label "Address:" `styleBasic` [width 50]
|
||||||
|
, spacer
|
||||||
|
, textField_ abaddress [onChange CheckValidAddress] `styleBasic`
|
||||||
|
[ width 350
|
||||||
|
, styleIf
|
||||||
|
(not $ model ^. abAddressValid)
|
||||||
|
(textColor red)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, spacer
|
||||||
|
, hstack [
|
||||||
|
button "Save" NotImplemented `nodeEnabled`
|
||||||
|
(model ^. abAddressValid)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
msgAdrBookOverlay=
|
||||||
|
alert CloseMsgAB $
|
||||||
|
hstack
|
||||||
|
[ filler
|
||||||
|
, remixIcon remixErrorWarningFill `styleBasic`
|
||||||
|
[textSize 32, textColor btnColor] `nodeVisible`
|
||||||
|
(model ^. inError)
|
||||||
|
, spacer
|
||||||
|
, label $ fromMaybe "" (model ^. msgAB)
|
||||||
|
, filler
|
||||||
|
]
|
||||||
|
|
||||||
notImplemented = NotImplemented
|
notImplemented = NotImplemented
|
||||||
|
|
||||||
|
@ -1089,9 +1147,13 @@ handleEvent wenv node model evt =
|
||||||
(i < (fromIntegral (model ^. balance) / 100000000.0))
|
(i < (fromIntegral (model ^. balance) / 100000000.0))
|
||||||
]
|
]
|
||||||
ShowTxId tx -> [Model $ model & showId ?~ tx & modalMsg .~ Nothing]
|
ShowTxId tx -> [Model $ model & showId ?~ tx & modalMsg .~ Nothing]
|
||||||
|
CheckValidAddress a -> [Model $ model & abAddressValid .~ isRecipientValid a]
|
||||||
ShowAdrBook -> [Model $ model & showAdrBook .~ True & menuPopup .~ False]
|
ShowAdrBook -> [Model $ model & showAdrBook .~ True & menuPopup .~ False]
|
||||||
CloseAdrBook -> [Model $ model & showAdrBook .~ False]
|
CloseAdrBook -> [Model $ model & showAdrBook .~ False]
|
||||||
NotImplemented -> [Model $ model & msg ?~ "Function not implemented..." & menuPopup .~ False & modalMsg .~ Nothing]
|
NewAdrBkEntry -> [Model $ model & newAdrBkEntry .~ True & menuPopup .~ False]
|
||||||
|
CloseNewAdrBook -> [Model $ model & newAdrBkEntry .~ False]
|
||||||
|
NotImplemented -> [Model $ model & msgAB ?~ "Function not implemented..." & menuPopup .~ False]
|
||||||
|
CloseMsgAB -> [Model $ model & msgAB .~ Nothing & inError .~ False]
|
||||||
where
|
where
|
||||||
currentWallet =
|
currentWallet =
|
||||||
if null (model ^. wallets)
|
if null (model ^. wallets)
|
||||||
|
@ -1375,6 +1437,11 @@ runZenithGUI config = do
|
||||||
Nothing
|
Nothing
|
||||||
""
|
""
|
||||||
False
|
False
|
||||||
|
False
|
||||||
|
Nothing
|
||||||
|
""
|
||||||
|
False
|
||||||
|
Nothing
|
||||||
-- hD
|
-- hD
|
||||||
startApp model handleEvent buildUI (params hD)
|
startApp model handleEvent buildUI (params hD)
|
||||||
Left e -> do
|
Left e -> do
|
||||||
|
@ -1423,6 +1490,11 @@ runZenithGUI config = do
|
||||||
Nothing
|
Nothing
|
||||||
""
|
""
|
||||||
False
|
False
|
||||||
|
False
|
||||||
|
Nothing
|
||||||
|
""
|
||||||
|
False
|
||||||
|
Nothing
|
||||||
-- hD
|
-- hD
|
||||||
startApp model handleEvent buildUI (params hD)
|
startApp model handleEvent buildUI (params hD)
|
||||||
where
|
where
|
||||||
|
|
|
@ -84,6 +84,13 @@ validateAddress txt --(tReg || sReg && isJust chk) || (uReg && isJust chk)
|
||||||
chk = isJust $ isValidUnifiedAddress $ E.encodeUtf8 txt
|
chk = isJust $ isValidUnifiedAddress $ E.encodeUtf8 txt
|
||||||
chkS = isValidShieldedAddress $ E.encodeUtf8 txt
|
chkS = isValidShieldedAddress $ E.encodeUtf8 txt
|
||||||
|
|
||||||
|
-- | Return True if Address is valid
|
||||||
|
validateAddressBool :: T.Text -> Bool
|
||||||
|
validateAddressBool a = do
|
||||||
|
case (validateAddress a) of
|
||||||
|
Nothing -> False
|
||||||
|
_ -> True
|
||||||
|
|
||||||
-- | Copy an address to the clipboard
|
-- | Copy an address to the clipboard
|
||||||
copyAddress :: ZcashAddress -> IO ()
|
copyAddress :: ZcashAddress -> IO ()
|
||||||
copyAddress a =
|
copyAddress a =
|
||||||
|
@ -94,8 +101,7 @@ copyAddress a =
|
||||||
-- | Get current user and build zenith path
|
-- | Get current user and build zenith path
|
||||||
getZenithPath :: IO String
|
getZenithPath :: IO String
|
||||||
getZenithPath = do
|
getZenithPath = do
|
||||||
d <- getHomeDirectory
|
homeDirectory <- getHomeDirectory
|
||||||
let homeDirectory = d
|
|
||||||
return (homeDirectory ++ "/Zenith/")
|
return (homeDirectory ++ "/Zenith/")
|
||||||
|
|
||||||
-- | Bound a value to the 0..1 range, used for progress reporting on UIs
|
-- | Bound a value to the 0..1 range, used for progress reporting on UIs
|
||||||
|
|
Loading…
Reference in a new issue