rvv001 - Start URI payment form
This commit is contained in:
parent
e4b6b36a7d
commit
9aaf712bad
1 changed files with 66 additions and 12 deletions
|
@ -196,6 +196,11 @@ data PaymentInput = PaymentInput
|
||||||
, _pmtMemo :: !T.Text
|
, _pmtMemo :: !T.Text
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
|
newtype URIText = URIText
|
||||||
|
{
|
||||||
|
_uriString :: !Text
|
||||||
|
} deriving (Show)
|
||||||
|
|
||||||
makeLenses ''PaymentInput
|
makeLenses ''PaymentInput
|
||||||
|
|
||||||
data DialogType
|
data DialogType
|
||||||
|
@ -216,6 +221,7 @@ data DialogType
|
||||||
| ViewingKeyMenu
|
| ViewingKeyMenu
|
||||||
| ViewingKeyShow
|
| ViewingKeyShow
|
||||||
| PaymentURIShow
|
| PaymentURIShow
|
||||||
|
| ProcessURIMenu
|
||||||
|
|
||||||
data DisplayType
|
data DisplayType
|
||||||
= AddrDisplay
|
= AddrDisplay
|
||||||
|
@ -272,6 +278,7 @@ data State = State
|
||||||
, _vkName :: !T.Text
|
, _vkName :: !T.Text
|
||||||
, _vkData :: !T.Text
|
, _vkData :: !T.Text
|
||||||
, _pmtURIForm :: !(Form PaymentInput () Name)
|
, _pmtURIForm :: !(Form PaymentInput () Name)
|
||||||
|
, _payUsingURIForm :: !(Form PaymentInput () Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''State
|
makeLenses ''State
|
||||||
|
@ -344,11 +351,8 @@ 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"
|
, capCommand "U" "RI Support"
|
||||||
, capCommand3
|
, capCommand3 "ba" "L" ("ance (" ++ (T.unpack (st ^. currencyCode)) ++ ")")
|
||||||
"ba"
|
|
||||||
"L"
|
|
||||||
("ance (" ++ (T.unpack (st ^. currencyCode)) ++ ")")
|
|
||||||
])
|
])
|
||||||
, C.hCenter
|
, C.hCenter
|
||||||
(hBox
|
(hBox
|
||||||
|
@ -438,7 +442,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"
|
, "URI Menu"
|
||||||
, "Address Book"
|
, "Address Book"
|
||||||
, "Shield/De-Shield"
|
, "Shield/De-Shield"
|
||||||
, "Viewing Keys"
|
, "Viewing Keys"
|
||||||
|
@ -489,6 +493,10 @@ 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"]))
|
||||||
|
--
|
||||||
|
-- URI Support
|
||||||
|
--
|
||||||
|
-- | Create a New payment URI
|
||||||
PaymentURIShow ->
|
PaymentURIShow ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just (str " Create Payment URI ")) Nothing 50)
|
(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
|
C.hCenter
|
||||||
(hBox
|
(hBox
|
||||||
[capCommand "P" "rocess", capCommand3 " " "<esc> " "Cancel"]))
|
[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 ->
|
DeshieldForm ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just (str " De-Shield ZEC ")) Nothing 50)
|
(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"
|
, capCommand "I" "ncoming"
|
||||||
, capCommand3 "" "E" "xit"
|
, 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
|
Blank -> emptyWidget
|
||||||
-- Address Book List
|
-- Address Book List
|
||||||
AdrBook ->
|
AdrBook ->
|
||||||
|
@ -846,6 +873,15 @@ mkPaymentURIForm 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
|
||||||
|
|
||||||
|
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 :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
||||||
mkDeshieldForm tbal =
|
mkDeshieldForm tbal =
|
||||||
newForm
|
newForm
|
||||||
|
@ -1149,6 +1185,7 @@ appEvent (BT.AppEvent t) = do
|
||||||
ShieldForm -> return ()
|
ShieldForm -> return ()
|
||||||
ViewingKeyShow -> return ()
|
ViewingKeyShow -> return ()
|
||||||
ViewingKeyMenu -> return ()
|
ViewingKeyMenu -> return ()
|
||||||
|
ProcessURIMenu -> return ()
|
||||||
ShowFIATBalance -> return ()
|
ShowFIATBalance -> return ()
|
||||||
PaymentURIShow -> return ()
|
PaymentURIShow -> return ()
|
||||||
Blank -> do
|
Blank -> do
|
||||||
|
@ -1728,7 +1765,9 @@ appEvent (BT.VtyEvent e) = do
|
||||||
ev ->
|
ev ->
|
||||||
BT.zoom deshieldForm $ do
|
BT.zoom deshieldForm $ do
|
||||||
handleFormEvent (BT.VtyEvent ev)
|
handleFormEvent (BT.VtyEvent ev)
|
||||||
-- Process ShowFIATBalance events
|
--
|
||||||
|
-- Process ShowFIATBalance events
|
||||||
|
--
|
||||||
ShowFIATBalance -> do
|
ShowFIATBalance -> do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey (V.KChar 'x') [] ->
|
V.EvKey (V.KChar 'x') [] ->
|
||||||
|
@ -1819,6 +1858,19 @@ appEvent (BT.VtyEvent e) = do
|
||||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
|
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
|
||||||
ev -> return ()
|
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
|
-- Process any other event
|
||||||
--
|
--
|
||||||
Blank -> do
|
Blank -> do
|
||||||
|
@ -1844,11 +1896,8 @@ 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
|
V.EvKey (V.KChar 'u') [] ->
|
||||||
BT.modify $
|
BT.modify $ set dialogBox ProcessURIMenu
|
||||||
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
|
||||||
V.EvKey (V.KChar 'l') [] -> do
|
V.EvKey (V.KChar 'l') [] -> do
|
||||||
|
@ -1925,6 +1974,11 @@ appEvent (BT.VtyEvent e) = do
|
||||||
BT.modify $ set displayBox MsgDisplay
|
BT.modify $ set displayBox MsgDisplay
|
||||||
V.EvKey (V.KChar 'k') [] -> do
|
V.EvKey (V.KChar 'k') [] -> do
|
||||||
BT.modify $ set dialogBox ViewingKeyMenu
|
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 ->
|
ev ->
|
||||||
case r of
|
case r of
|
||||||
Just AList ->
|
Just AList ->
|
||||||
|
|
Loading…
Reference in a new issue