rvv001 - Start URI payment form

This commit is contained in:
Rene V. Vergara 2025-01-08 14:27:09 -05:00
parent e4b6b36a7d
commit 9aaf712bad

View file

@ -196,6 +196,11 @@ data PaymentInput = PaymentInput
, _pmtMemo :: !T.Text
} deriving (Show)
newtype URIText = URIText
{
_uriString :: !Text
} deriving (Show)
makeLenses ''PaymentInput
data DialogType
@ -216,6 +221,7 @@ data DialogType
| ViewingKeyMenu
| ViewingKeyShow
| PaymentURIShow
| ProcessURIMenu
data DisplayType
= AddrDisplay
@ -272,6 +278,7 @@ data State = State
, _vkName :: !T.Text
, _vkData :: !T.Text
, _pmtURIForm :: !(Form PaymentInput () Name)
, _payUsingURIForm :: !(Form PaymentInput () Name)
}
makeLenses ''State
@ -344,11 +351,8 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
, capCommand "A" "ccounts"
, capCommand "V" "iew address"
, capCommand "S" "end Tx"
, capCommand2 "Gen " "U" "RI"
, capCommand3
"ba"
"L"
("ance (" ++ (T.unpack (st ^. currencyCode)) ++ ")")
, capCommand "U" "RI Support"
, capCommand3 "ba" "L" ("ance (" ++ (T.unpack (st ^. currencyCode)) ++ ")")
])
, C.hCenter
(hBox
@ -438,7 +442,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
, "Switch accounts"
, "View address"
, "Send Tx"
, "Gen URI"
, "URI Menu"
, "Address Book"
, "Shield/De-Shield"
, "Viewing Keys"
@ -489,6 +493,10 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
(renderForm (st ^. txForm) <=>
C.hCenter
(hBox [capCommand "" "Send", capCommand "<esc> " "Cancel"]))
--
-- URI Support
--
-- | Create a New payment URI
PaymentURIShow ->
D.renderDialog
(D.dialog (Just (str " Create Payment URI ")) Nothing 50)
@ -496,6 +504,16 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
C.hCenter
(hBox
[capCommand "P" "rocess", capCommand3 " " "<esc> " "Cancel"]))
--
-- | Pay usin a URI
PayUsingURIShow ->
D.renderDialog
(D.dialog (Just (str " Pay Using URI ")) Nothing 50)
(renderForm (st ^. payUsingURIForm) <=>
C.hCenter
(hBox
[capCommand "P" "rocess", capCommand3 " " "<esc> " "Cancel"]))
--
DeshieldForm ->
D.renderDialog
(D.dialog (Just (str " De-Shield ZEC ")) Nothing 50)
@ -546,6 +564,15 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
, capCommand "I" "ncoming"
, capCommand3 "" "E" "xit"
]))
ProcessURIMenu ->
D.renderDialog
(D.dialog (Just (str " URI Support ")) Nothing 50)
(C.hCenter
(hBox
[ capCommand "C" "reate Payment URI"
, capCommand "P" "ay using an URI"
, capCommand3 "" "E" "xit"
]))
Blank -> emptyWidget
-- Address Book List
AdrBook ->
@ -846,6 +873,15 @@ mkPaymentURIForm bal =
label s w =
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
payUsingURIForm :: URIText -> Form URIText e Name
payUsingURIForm =
newForm
[ label "URI: " @@= editTextField uriString MemoField (Just 1)
]
where
label s w =
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
mkDeshieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
mkDeshieldForm tbal =
newForm
@ -1149,6 +1185,7 @@ appEvent (BT.AppEvent t) = do
ShieldForm -> return ()
ViewingKeyShow -> return ()
ViewingKeyMenu -> return ()
ProcessURIMenu -> return ()
ShowFIATBalance -> return ()
PaymentURIShow -> return ()
Blank -> do
@ -1728,7 +1765,9 @@ appEvent (BT.VtyEvent e) = do
ev ->
BT.zoom deshieldForm $ do
handleFormEvent (BT.VtyEvent ev)
-- Process ShowFIATBalance events
--
-- Process ShowFIATBalance events
--
ShowFIATBalance -> do
case e of
V.EvKey (V.KChar 'x') [] ->
@ -1819,6 +1858,19 @@ appEvent (BT.VtyEvent e) = do
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
ev -> return ()
--
-- Open URI process form
--
ProcessURIMenu -> do
case e of
V.EvKey (V.KChar 'c') [] -> do
BT.modify $
set pmtURIForm $
mkPaymentURIForm (s ^. balance) (PaymentInput 0.0 "")
BT.modify $ set dialogBox PaymentURIShow
V.EvKey (V.KChar 'e') [] ->
BT.modify $ set dialogBox Blank
ev -> return ()
--
-- Process any other event
--
Blank -> do
@ -1844,11 +1896,8 @@ appEvent (BT.VtyEvent e) = do
set txForm $
mkSendForm (s ^. balance) (SendInput "" 0.0 "" Full)
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 'u') [] ->
BT.modify $ set dialogBox ProcessURIMenu
V.EvKey (V.KChar 'b') [] ->
BT.modify $ set dialogBox AdrBook
V.EvKey (V.KChar 'l') [] -> do
@ -1925,6 +1974,11 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set displayBox MsgDisplay
V.EvKey (V.KChar 'k') [] -> do
BT.modify $ set dialogBox ViewingKeyMenu
V.EvKey (V.KChar 'u') [] -> do
BT.modify $ set dialogBox ViewingKeyMenu
-- set pmtURIForm $
-- mkPaymentURIForm (s ^. balance) (PaymentInput 0.0 "")
-- BT.modify $ set dialogBox PaymentURIShow
ev ->
case r of
Just AList ->