diff --git a/assets/1F616_color.png b/assets/1F616_color.png new file mode 100644 index 0000000..ac48165 Binary files /dev/null and b/assets/1F616_color.png differ diff --git a/src/Zenith/GUI.hs b/src/Zenith/GUI.hs index 8dd01ab..b1db955 100644 --- a/src/Zenith/GUI.hs +++ b/src/Zenith/GUI.hs @@ -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 = diff --git a/src/Zenith/GUI/Theme.hs b/src/Zenith/GUI/Theme.hs index 2b422a0..7322522 100644 --- a/src/Zenith/GUI/Theme.hs +++ b/src/Zenith/GUI/Theme.hs @@ -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 =