Add input form

This commit is contained in:
Rene Vergara 2024-06-17 14:27:00 -05:00
parent c4a3ccadb1
commit 71cc28434a
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
3 changed files with 99 additions and 47 deletions

View file

@ -57,6 +57,8 @@ data AppEvent
| LoadTxs ![Entity UserTx]
| LoadAddrs ![Entity WalletAddress]
| LoadAccs ![Entity ZcashAccount]
| ConfirmCancel
| SaveAddress
deriving (Eq, Show)
data AppModel = AppModel
@ -80,6 +82,11 @@ data AppModel = AppModel
, _walPopup :: !Bool
, _menuPopup :: !Bool
, _newPopup :: !Bool
, _mainInput :: !T.Text
, _confirmTitle :: !(Maybe T.Text)
, _confirmAccept :: !T.Text
, _confirmCancel :: !T.Text
, _confirmEvent :: !AppEvent
} deriving (Eq, Show)
makeLenses ''AppModel
@ -112,7 +119,11 @@ buildUI wenv model = widgetTree
then Nothing
else Just ((model ^. addresses) !! (model ^. selAddr))
widgetTree =
zstack [mainWindow, msgOverlay `nodeVisible` isJust (model ^. msg)]
zstack
[ mainWindow
, confirmOverlay `nodeVisible` isJust (model ^. confirmTitle)
, msgOverlay `nodeVisible` isJust (model ^. msg)
]
mainWindow =
vstack
[ windowHeader
@ -434,6 +445,15 @@ buildUI wenv model = widgetTree
msgOverlay =
alert CloseMsg $
hstack [filler, label $ fromMaybe "" (model ^. msg), filler]
confirmOverlay =
confirm_
(model ^. confirmEvent)
ConfirmCancel
[ titleCaption $ fromMaybe "" $ model ^. confirmTitle
, acceptCaption $ model ^. confirmAccept
, cancelCaption $ model ^. confirmCancel
]
(hstack [label "Name:", filler, textField_ mainInput [maxLength 25]])
generateQRCodes :: Config -> IO ()
generateQRCodes config = do
@ -517,9 +537,17 @@ handleEvent wenv node model evt =
AccountClicked -> [Model $ model & accPopup .~ True]
MenuClicked -> [Model $ model & menuPopup .~ True]
NewClicked -> [Model $ model & newPopup .~ not (model ^. newPopup)]
NewAddress -> [Event $ ShowMsg "You clicked new address"]
NewAddress ->
[ Model $
model & confirmTitle ?~ "New Address" & confirmAccept .~ "Create" &
confirmCancel .~
"Cancel"
]
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]
SetPool p ->
[ Model $ model & selPool .~ p
, Task $
@ -657,6 +685,11 @@ runZenithGUI config = do
False
False
False
""
Nothing
""
""
SaveAddress
startApp model handleEvent buildUI params
Left e -> do
initDb dbFilePath
@ -684,6 +717,11 @@ runZenithGUI config = do
False
False
False
""
Nothing
""
""
SaveAddress
startApp model handleEvent buildUI params
where
params =

View file

@ -4,6 +4,7 @@ module Zenith.GUI.Theme
( zenithTheme
) where
import Data.Default
import Lens.Micro ((&), (+~), (.~), (?~), (^.), at, set)
import Monomer
import Monomer.Core.Themes.BaseTheme
@ -12,49 +13,57 @@ import Monomer.Graphics (rgbHex, transparent)
import Monomer.Graphics.ColorTable
import qualified Monomer.Lens as L
baseTextStyle :: TextStyle
baseTextStyle = def & L.fontSize ?~ FontSize 10 & L.fontColor ?~ black
hiliteTextStyle :: TextStyle
hiliteTextStyle = def & L.fontSize ?~ FontSize 10 & L.fontColor ?~ white
zenithTheme :: Theme
zenithTheme =
baseTheme zgoThemeColors & L.basic . L.labelStyle . L.text ?~
TextStyle
Nothing
(Just . FontSize $ 10)
Nothing
Nothing
(Just black)
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing &
baseTheme zgoThemeColors & L.basic . L.labelStyle . L.text ?~ baseTextStyle &
L.hover .
L.tooltipStyle . L.text ?~
TextStyle
Nothing
(Just . FontSize $ 10)
Nothing
Nothing
(Just black)
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing &
baseTextStyle &
L.hover .
L.labelStyle . L.text ?~
TextStyle
Nothing
(Just . FontSize $ 10)
Nothing
Nothing
(Just black)
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
baseTextStyle &
L.basic .
L.dialogTitleStyle . L.text ?~
(baseTextStyle & L.fontSize ?~ FontSize 12 & L.font ?~ "Bold") &
L.hover .
L.dialogTitleStyle . L.text ?~
(baseTextStyle & L.fontSize ?~ FontSize 12 & L.font ?~ "Bold") &
L.basic .
L.btnStyle . L.text ?~
baseTextStyle &
L.hover .
L.btnStyle . L.text ?~
baseTextStyle &
L.focus .
L.btnStyle . L.text ?~
baseTextStyle &
L.focusHover .
L.btnStyle . L.text ?~
baseTextStyle &
L.active .
L.btnStyle . L.text ?~
baseTextStyle &
L.basic .
L.btnMainStyle . L.text ?~
hiliteTextStyle &
L.hover .
L.btnMainStyle . L.text ?~
hiliteTextStyle &
L.focus .
L.btnMainStyle . L.text ?~
hiliteTextStyle &
L.focusHover .
L.btnMainStyle . L.text ?~
hiliteTextStyle &
L.active .
L.btnMainStyle . L.text ?~
hiliteTextStyle
zenithThemeColors :: BaseThemeColors
zenithThemeColors =
@ -70,10 +79,10 @@ zenithThemeColors =
, btnText = gray02
, btnTextDisabled = gray01
, btnMainFocusBorder = blue08
, btnMainBgBasic = blue05b
, btnMainBgHover = blue06
, btnMainBgFocus = blue05c
, btnMainBgActive = blue05
, btnMainBgBasic = btnColor
, btnMainBgHover = btnHiLite
, btnMainBgFocus = btnColor
, btnMainBgActive = btnHiLite
, btnMainBgDisabled = blue04
, btnMainText = white
, btnMainTextDisabled = gray08
@ -149,10 +158,10 @@ zgoThemeColors =
, btnText = gray02
, btnTextDisabled = gray02
, btnMainFocusBorder = blue09
, btnMainBgBasic = blue05b
, btnMainBgHover = blue06
, btnMainBgFocus = blue05c
, btnMainBgActive = blue05
, btnMainBgBasic = btnColor
, btnMainBgHover = btnHiLite
, btnMainBgFocus = btnColor
, btnMainBgActive = btnHiLite
, btnMainBgDisabled = blue04
, btnMainText = white
, btnMainTextDisabled = white
@ -217,6 +226,10 @@ zgoThemeColors =
--black = rgbHex "#000000"
{-white = rgbHex "#FFFFFF"-}
btnColor = rgbHex "#ff5722" --rgbHex "#1818B2"
btnHiLite = rgbHex "#207DE8"
blue01 = rgbHex "#002159"
blue02 = rgbHex "#01337D"

View file

@ -46,6 +46,7 @@ library
, base64-bytestring
, brick
, bytestring
, data-default
, esqueleto
, resource-pool
, binary