Parametrize input form

This commit is contained in:
Rene Vergara 2024-06-17 15:47:56 -05:00
parent 71cc28434a
commit eae4bfc949
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
3 changed files with 75 additions and 7 deletions

BIN
assets/1F616_color.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -40,6 +40,7 @@ import Zenith.Utils (displayAmount, showAddress)
data AppEvent
= AppInit
| ShowMsg !T.Text
| ShowError !T.Text
| CloseMsg
| WalletClicked
| AccountClicked
@ -59,6 +60,8 @@ data AppEvent
| LoadAccs ![Entity ZcashAccount]
| ConfirmCancel
| SaveAddress
| SaveAccount
| SaveWallet
deriving (Eq, Show)
data AppModel = AppModel
@ -87,6 +90,7 @@ data AppModel = AppModel
, _confirmAccept :: !T.Text
, _confirmCancel :: !T.Text
, _confirmEvent :: !AppEvent
, _inError :: !Bool
} deriving (Eq, Show)
makeLenses ''AppModel
@ -444,7 +448,14 @@ buildUI wenv model = widgetTree
]
msgOverlay =
alert CloseMsg $
hstack [filler, label $ fromMaybe "" (model ^. msg), filler]
hstack
[ filler
, image_ "./assets/1F616_color.png" [fitHeight] `styleBasic`
[height 44, width 44] `nodeVisible`
(model ^. inError)
, label $ fromMaybe "" (model ^. msg)
, filler
]
confirmOverlay =
confirm_
(model ^. confirmEvent)
@ -533,6 +544,8 @@ handleEvent wenv node model evt =
case evt of
AppInit -> []
ShowMsg t -> [Model $ model & msg ?~ t & menuPopup .~ False]
ShowError t ->
[Model $ model & msg ?~ t & menuPopup .~ False & inError .~ True]
WalletClicked -> [Model $ model & walPopup .~ True]
AccountClicked -> [Model $ model & accPopup .~ True]
MenuClicked -> [Model $ model & menuPopup .~ True]
@ -541,13 +554,51 @@ handleEvent wenv node model evt =
[ Model $
model & confirmTitle ?~ "New Address" & confirmAccept .~ "Create" &
confirmCancel .~
"Cancel"
"Cancel" &
confirmEvent .~
SaveAddress &
menuPopup .~
False
]
NewAccount ->
[ Model $
model & confirmTitle ?~ "New Account" & confirmAccept .~ "Create" &
confirmCancel .~
"Cancel" &
confirmEvent .~
SaveAccount &
menuPopup .~
False
]
NewWallet ->
[ Model $
model & confirmTitle ?~ "New Wallet" & confirmAccept .~ "Create" &
confirmCancel .~
"Cancel" &
confirmEvent .~
SaveWallet &
menuPopup .~
False
]
NewAccount -> [Event $ ShowMsg "You clicked new account"]
NewWallet -> [Event $ ShowMsg "You clicked new wallet"]
ConfirmCancel -> [Model $ model & confirmTitle .~ Nothing & mainInput .~ ""]
SaveAddress ->
[Event $ ShowMsg $ "You saved address: " <> model ^. mainInput]
[ if T.length (model ^. mainInput) > 1
then Event $ ShowMsg $ "You saved address: " <> model ^. mainInput
else Event $ ShowError "Invalid input"
, Event ConfirmCancel
]
SaveAccount ->
[ if T.length (model ^. mainInput) > 1
then Event $ ShowMsg $ "You saved account: " <> model ^. mainInput
else Event $ ShowError "Invalid input"
, Event ConfirmCancel
]
SaveWallet ->
[ if T.length (model ^. mainInput) > 1
then Event $ ShowMsg $ "You saved wallet: " <> model ^. mainInput
else Event $ ShowError "Invalid input"
, Event ConfirmCancel
]
SetPool p ->
[ Model $ model & selPool .~ p
, Task $
@ -606,7 +657,7 @@ handleEvent wenv node model evt =
LoadTxs t -> [Model $ model & transactions .~ t]
LoadAddrs a -> [Model $ model & addresses .~ a, Event $ SetPool Orchard]
LoadAccs a -> [Model $ model & accounts .~ a, Event $ SwitchAcc 0]
CloseMsg -> [Model $ model & msg .~ Nothing]
CloseMsg -> [Model $ model & msg .~ Nothing & inError .~ False]
where
currentWallet =
if null (model ^. wallets)
@ -690,6 +741,7 @@ runZenithGUI config = do
""
""
SaveAddress
False
startApp model handleEvent buildUI params
Left e -> do
initDb dbFilePath
@ -722,6 +774,7 @@ runZenithGUI config = do
""
""
SaveAddress
False
startApp model handleEvent buildUI params
where
params =

View file

@ -63,7 +63,22 @@ zenithTheme =
hiliteTextStyle &
L.active .
L.btnMainStyle . L.text ?~
hiliteTextStyle
hiliteTextStyle &
L.basic .
L.textFieldStyle . L.text ?~
baseTextStyle &
L.hover .
L.textFieldStyle . L.text ?~
baseTextStyle &
L.focus .
L.textFieldStyle . L.text ?~
baseTextStyle &
L.active .
L.textFieldStyle . L.text ?~
baseTextStyle &
L.focusHover .
L.textFieldStyle . L.text ?~
baseTextStyle
zenithThemeColors :: BaseThemeColors
zenithThemeColors =