rvv001 - Issue 084
- Form to capture input from the user implemented for TUI & GUI Outgoing Viewing Key display support removed from TUI & GUI
This commit is contained in:
parent
63aa5e5984
commit
56bf19a6f6
2 changed files with 48 additions and 14 deletions
|
@ -182,6 +182,13 @@ newtype ShDshEntry = ShDshEntry
|
||||||
|
|
||||||
makeLenses ''ShDshEntry
|
makeLenses ''ShDshEntry
|
||||||
|
|
||||||
|
data PaymentInput = PaymentInput
|
||||||
|
{ _pmtAmt :: !Scientific
|
||||||
|
, _pmtMemo :: !T.Text
|
||||||
|
} deriving (Show)
|
||||||
|
|
||||||
|
makeLenses ''PaymentInput
|
||||||
|
|
||||||
data DialogType
|
data DialogType
|
||||||
= WName
|
= WName
|
||||||
| AName
|
| AName
|
||||||
|
@ -199,6 +206,7 @@ data DialogType
|
||||||
| ShowFIATBalance
|
| ShowFIATBalance
|
||||||
| ViewingKeyMenu
|
| ViewingKeyMenu
|
||||||
| ViewingKeyShow
|
| ViewingKeyShow
|
||||||
|
| PaymentURIShow
|
||||||
|
|
||||||
data DisplayType
|
data DisplayType
|
||||||
= AddrDisplay
|
= AddrDisplay
|
||||||
|
@ -254,6 +262,7 @@ data State = State
|
||||||
, _zprice :: !Double
|
, _zprice :: !Double
|
||||||
, _vkName :: !T.Text
|
, _vkName :: !T.Text
|
||||||
, _vkData :: !T.Text
|
, _vkData :: !T.Text
|
||||||
|
, _pmtURIForm :: !(Form PaymentInput () Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''State
|
makeLenses ''State
|
||||||
|
@ -325,6 +334,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
, capCommand "A" "ccounts"
|
, capCommand "A" "ccounts"
|
||||||
, capCommand "V" "iew address"
|
, capCommand "V" "iew address"
|
||||||
, capCommand "S" "end Tx"
|
, capCommand "S" "end Tx"
|
||||||
|
, capCommand2 "Gen " "U" "RI"
|
||||||
, capCommand3 "ba" "L" ("ance (" ++ ( T.unpack (st ^. currencyCode) )++ ")" )
|
, capCommand3 "ba" "L" ("ance (" ++ ( T.unpack (st ^. currencyCode) )++ ")" )
|
||||||
])
|
])
|
||||||
, C.hCenter
|
, C.hCenter
|
||||||
|
@ -403,7 +413,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
else emptyWidget
|
else emptyWidget
|
||||||
where
|
where
|
||||||
keyList =
|
keyList =
|
||||||
map (C.hCenter . str) ["?", "Esc", "w", "a", "v", "s", "b", "d", "k", "l", "q"]
|
map (C.hCenter . str) ["?", "Esc", "w", "a", "v", "s", "u", "b", "d", "k", "l", "q"]
|
||||||
actionList =
|
actionList =
|
||||||
map
|
map
|
||||||
(hLimit 40 . str)
|
(hLimit 40 . str)
|
||||||
|
@ -413,6 +423,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
, "Switch accounts"
|
, "Switch accounts"
|
||||||
, "View address"
|
, "View address"
|
||||||
, "Send Tx"
|
, "Send Tx"
|
||||||
|
, "Gen URI"
|
||||||
, "Address Book"
|
, "Address Book"
|
||||||
, "Shield/De-Shield"
|
, "Shield/De-Shield"
|
||||||
, "Viewing Keys"
|
, "Viewing Keys"
|
||||||
|
@ -463,6 +474,12 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
(renderForm (st ^. txForm) <=>
|
(renderForm (st ^. txForm) <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox [capCommand "↲ " "Send", capCommand "<esc> " "Cancel"]))
|
(hBox [capCommand "↲ " "Send", capCommand "<esc> " "Cancel"]))
|
||||||
|
PaymentURIShow ->
|
||||||
|
D.renderDialog
|
||||||
|
(D.dialog (Just (str " Create Payment URI ")) Nothing 50)
|
||||||
|
(renderForm (st ^. pmtURIForm) <=>
|
||||||
|
C.hCenter
|
||||||
|
(hBox [capCommand "P" "rocess", capCommand3 " " "<esc> " "Cancel"]))
|
||||||
DeshieldForm ->
|
DeshieldForm ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just (str " De-Shield ZEC ")) Nothing 50)
|
(D.dialog (Just (str " De-Shield ZEC ")) Nothing 50)
|
||||||
|
@ -507,7 +524,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just (str " Viewing Keys ")) Nothing 50)
|
(D.dialog (Just (str " Viewing Keys ")) Nothing 50)
|
||||||
(C.hCenter
|
(C.hCenter
|
||||||
(hBox [capCommand "F" "ull", capCommand "I" "ncoming", capCommand "O" "utgoing", capCommand3 "" "E" "xit"])
|
(hBox [capCommand "F" "ull", capCommand "I" "ncoming", capCommand3 "" "E" "xit"])
|
||||||
)
|
)
|
||||||
Blank -> emptyWidget
|
Blank -> emptyWidget
|
||||||
-- Address Book List
|
-- Address Book List
|
||||||
|
@ -781,6 +798,19 @@ mkSendForm bal =
|
||||||
label s w =
|
label s w =
|
||||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||||
|
|
||||||
|
mkPaymentURIForm :: Integer -> PaymentInput -> Form PaymentInput e Name
|
||||||
|
mkPaymentURIForm bal =
|
||||||
|
newForm
|
||||||
|
[ label "Amount: " @@=
|
||||||
|
editShowableFieldWithValidate pmtAmt AmtField (isAmountValid bal)
|
||||||
|
, label "Memo: " @@= editTextField pmtMemo MemoField (Just 1)
|
||||||
|
]
|
||||||
|
where
|
||||||
|
isAmountValid :: Integer -> Scientific -> Bool
|
||||||
|
isAmountValid b i = fromIntegral b >= (i * scientific 1 8)
|
||||||
|
label s w =
|
||||||
|
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||||
|
|
||||||
mkDeshieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
mkDeshieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
||||||
mkDeshieldForm tbal =
|
mkDeshieldForm tbal =
|
||||||
newForm
|
newForm
|
||||||
|
@ -1073,6 +1103,7 @@ appEvent (BT.AppEvent t) = do
|
||||||
ViewingKeyShow -> return ()
|
ViewingKeyShow -> return ()
|
||||||
ViewingKeyMenu -> return ()
|
ViewingKeyMenu -> return ()
|
||||||
ShowFIATBalance -> return()
|
ShowFIATBalance -> return()
|
||||||
|
PaymentURIShow -> return()
|
||||||
Blank -> do
|
Blank -> do
|
||||||
if s ^. timer == 90
|
if s ^. timer == 90
|
||||||
then do
|
then do
|
||||||
|
@ -1695,13 +1726,16 @@ appEvent (BT.VtyEvent e) = do
|
||||||
BT.modify $ set vkName "Incomming"
|
BT.modify $ set vkName "Incomming"
|
||||||
BT.modify $ set vkData "VKIncoming->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
|
BT.modify $ set vkData "VKIncoming->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
|
||||||
BT.modify $ set dialogBox ViewingKeyShow
|
BT.modify $ set dialogBox ViewingKeyShow
|
||||||
V.EvKey (V.KChar 'o') [] -> do
|
|
||||||
BT.modify $ set vkName "Outgoing"
|
|
||||||
BT.modify $ set vkData "VKOutgoing->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
|
|
||||||
BT.modify $ set dialogBox ViewingKeyShow
|
|
||||||
V.EvKey (V.KChar 'e') [] -> BT.modify $ set dialogBox Blank
|
V.EvKey (V.KChar 'e') [] -> BT.modify $ set dialogBox Blank
|
||||||
ev -> return ()
|
ev -> return ()
|
||||||
--
|
--
|
||||||
|
-- Payment URI Form Events
|
||||||
|
--
|
||||||
|
PaymentURIShow -> do
|
||||||
|
case e of
|
||||||
|
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
|
||||||
|
ev -> return ()
|
||||||
|
--
|
||||||
-- Process any other event
|
-- Process any other event
|
||||||
--
|
--
|
||||||
Blank -> do
|
Blank -> do
|
||||||
|
@ -1727,6 +1761,11 @@ appEvent (BT.VtyEvent e) = do
|
||||||
set txForm $
|
set txForm $
|
||||||
mkSendForm (s ^. balance) (SendInput "" 0.0 "" Full)
|
mkSendForm (s ^. balance) (SendInput "" 0.0 "" Full)
|
||||||
BT.modify $ set dialogBox SendTx
|
BT.modify $ set dialogBox SendTx
|
||||||
|
V.EvKey (V.KChar 'u') [] -> do
|
||||||
|
BT.modify $
|
||||||
|
set pmtURIForm $
|
||||||
|
mkPaymentURIForm (s ^. balance) (PaymentInput 0.0 "")
|
||||||
|
BT.modify $ set dialogBox PaymentURIShow
|
||||||
V.EvKey (V.KChar 'b') [] ->
|
V.EvKey (V.KChar 'b') [] ->
|
||||||
BT.modify $ set dialogBox AdrBook
|
BT.modify $ set dialogBox AdrBook
|
||||||
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||||
|
@ -1956,6 +1995,7 @@ runZenithTUI config = do
|
||||||
0
|
0
|
||||||
""
|
""
|
||||||
""
|
""
|
||||||
|
(mkPaymentURIForm 0 $ PaymentInput 0.0 "" )
|
||||||
Left _e -> do
|
Left _e -> do
|
||||||
print $
|
print $
|
||||||
"No Zebra node available on port " <>
|
"No Zebra node available on port " <>
|
||||||
|
|
|
@ -83,7 +83,6 @@ data VkTypeDef
|
||||||
= VkNone
|
= VkNone
|
||||||
| VkFull
|
| VkFull
|
||||||
| VkIncoming
|
| VkIncoming
|
||||||
| VkOutgoing
|
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data AppEvent
|
data AppEvent
|
||||||
|
@ -406,10 +405,6 @@ buildUI wenv model = widgetTree
|
||||||
[alignLeft, onClick $ (ShowViewingKey VkIncoming "VKIncoming->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4")]
|
[alignLeft, onClick $ (ShowViewingKey VkIncoming "VKIncoming->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4")]
|
||||||
(hstack [label "Incoming VK", filler]) `styleBasic`
|
(hstack [label "Incoming VK", filler]) `styleBasic`
|
||||||
[bgColor white, borderB 1 gray, padding 3]
|
[bgColor white, borderB 1 gray, padding 3]
|
||||||
, box_
|
|
||||||
[alignLeft, onClick $ (ShowViewingKey VkOutgoing "VKOutgoing->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4")]
|
|
||||||
(hstack [label "Outgoing VK", filler]) `styleBasic`
|
|
||||||
[bgColor white, borderB 1 gray, padding 3]
|
|
||||||
])
|
])
|
||||||
walletButton =
|
walletButton =
|
||||||
hstack
|
hstack
|
||||||
|
@ -1692,7 +1687,6 @@ handleEvent wenv node model evt =
|
||||||
case vkType of
|
case vkType of
|
||||||
VkFull -> [ Model $ model & vkTypeName .~ "Full" & vkData .~ vkText & viewingKeyDisplay .~ True & menuPopup .~ False]
|
VkFull -> [ Model $ model & vkTypeName .~ "Full" & vkData .~ vkText & viewingKeyDisplay .~ True & menuPopup .~ False]
|
||||||
VkIncoming -> [ Model $ model & vkTypeName .~ "Incoming" & vkData .~ vkText & viewingKeyDisplay .~ True & menuPopup .~ False]
|
VkIncoming -> [ Model $ model & vkTypeName .~ "Incoming" & vkData .~ vkText & viewingKeyDisplay .~ True & menuPopup .~ False]
|
||||||
VkOutgoing -> [ Model $ model & vkTypeName .~ "Outgoing" & vkData .~ vkText & viewingKeyDisplay .~ True & menuPopup .~ False]
|
|
||||||
--
|
--
|
||||||
-- Display PaymentURI Form
|
-- Display PaymentURI Form
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in a new issue