From 63aa5e59843ad1ff6c5c4ed39df49134f61a4332 Mon Sep 17 00:00:00 2001 From: "Rene V. Vergara" Date: Thu, 26 Dec 2024 13:53:26 -0500 Subject: [PATCH] rvv001 - Issue 084 Form to capture input from the user implemented The inputs are : One numeric field for amount of ZEC One text field for memo (optional) --- src/Zenith/GUI.hs | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/Zenith/GUI.hs b/src/Zenith/GUI.hs index 5d465d1..bc12801 100644 --- a/src/Zenith/GUI.hs +++ b/src/Zenith/GUI.hs @@ -163,6 +163,8 @@ data AppEvent | ShowViewingKey !VkTypeDef !T.Text | CopyViewingKey !T.Text !T.Text | CloseShowVK + | DisplayPaymentURI + | ClosePaymentURI deriving (Eq, Show) data AppModel = AppModel @@ -229,6 +231,7 @@ data AppModel = AppModel , _viewingKeyDisplay :: !Bool , _vkTypeName :: !T.Text , _vkData :: !T.Text + , _paymentURIDisplay :: !Bool } deriving (Eq, Show) makeLenses ''AppModel @@ -280,6 +283,7 @@ buildUI wenv model = widgetTree model ^. updateABAddress , showVKOverlay `nodeVisible` model ^. viewingKeyDisplay + , paymentURIOverlay `nodeVisible` model ^. paymentURIDisplay , shieldOverlay `nodeVisible` model ^. shieldZec , deShieldOverlay `nodeVisible` model ^. deShieldZec , msgAdrBookOverlay `nodeVisible` isJust (model ^. msgAB) @@ -369,6 +373,8 @@ buildUI wenv model = widgetTree [bgColor white, borderB 1 gray, padding 3] , box_ [alignLeft, onClick ShowFIATBalance] ( label ("Balance in " <> T.toUpper (c_currencyCode (model ^. configuration) ) ) ) `styleBasic` [bgColor white, borderB 1 gray, padding 3] + , box_ [alignLeft, onClick DisplayPaymentURI] (label "Create URI") `styleBasic` + [bgColor white, borderB 1 gray, padding 3] ]) `styleBasic` [bgColor btnColor, padding 3] newBox = @@ -1196,6 +1202,64 @@ buildUI wenv model = widgetTree , filler ]) `styleBasic` [bgColor (white & L.a .~ 0.5)] + paymentURIOverlay = + box + (vstack + [ filler + , hstack + [ filler + , box_ + [] + (vstack + [ box_ + [alignMiddle] + (label "Create URI" `styleBasic` + [textColor white, textFont "Bold", textSize 12]) `styleBasic` [bgColor btnColor] + , separatorLine `styleBasic` [fgColor btnColor] + , spacer + , hstack + [ label "Amount:" `styleBasic` + [width 50, textFont "Bold"] + , spacer + , numericField_ + sendAmount + [ decimals 8 + , minValue 0.0 + , maxValue + (fromIntegral (model ^. balance) / 100000000.0) + , validInput amountValid + , onChange CheckAmount + ] `styleBasic` + [ width 150 + , styleIf + (not $ model ^. amountValid) + (textColor red) + ] + ] + , hstack + [ label "Memo:" `styleBasic` + [width 50, textFont "Bold"] + , spacer + , textArea sendMemo `styleBasic` + [width 150, height 40] + ] + , spacer + , box_ + [alignMiddle] + (hstack + [ spacer + , mainButton "Create URI" NotImplemented `nodeEnabled` True + , spacer + , button "Cancel" ClosePaymentURI + , spacer + ]) + ]) `styleBasic` + [radius 4, border 2 btnColor, bgColor white, padding 4] + , filler + ] + , filler + ]) `styleBasic` + [bgColor (white & L.a .~ 0.5)] notImplemented = NotImplemented @@ -1630,6 +1694,11 @@ handleEvent wenv node model evt = 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 + -- + DisplayPaymentURI -> [ Model $ model & paymentURIDisplay .~ True & menuPopup .~ False] + ClosePaymentURI -> [Model $ model & paymentURIDisplay .~ False] + -- -- ShowShield -> if model ^. tBalance > 0 @@ -2163,6 +2232,7 @@ runZenithGUI config = do False "" "" + False startApp model handleEvent buildUI (params hD) Left _e -> print "Zebra not available" where