render the master password form

This commit is contained in:
Jonathan Lamothe 2024-09-07 18:30:25 -04:00
parent 2b427789d2
commit ffce0d6a1c
3 changed files with 51 additions and 8 deletions

View File

@ -4,7 +4,7 @@ cabal-version: 2.2
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
-- --
-- hash: d742af1f90e36896cfb5979f267f1ef87b81fb7e603c8c72ccc0c8e7a382a408 -- hash: 1fb75b25a67b68f60aa6fa054876daeef931fac289d7f62c2b455533ab282fba
name: passman name: passman
version: 0.3.1.1 version: 0.3.1.1
@ -27,6 +27,7 @@ library
exposed-modules: exposed-modules:
Password Password
Password.App Password.App
Password.App.Draw
Password.App.Types Password.App.Types
other-modules: other-modules:
Paths_passman Paths_passman

View File

@ -28,29 +28,25 @@ import Brick
( App (..) ( App (..)
, BrickEvent , BrickEvent
, EventM , EventM
, Widget
, attrMap , attrMap
, emptyWidget
, halt , halt
, neverShowCursor , showFirstCursor
, style , style
) )
import Password.App.Draw
import Password.App.Types import Password.App.Types
-- | The main application -- | The main application
passmanApp :: App AppState () ResName passmanApp :: App AppState () ResName
passmanApp = App passmanApp = App
{ appDraw = drawFunc { appDraw = drawFunc
, appChooseCursor = neverShowCursor , appChooseCursor = showFirstCursor
, appHandleEvent = eventHandler , appHandleEvent = eventHandler
, appStartEvent = return () , appStartEvent = return ()
, appAttrMap = const $ attrMap (style 0) [] , appAttrMap = const $ attrMap (style 0) []
} }
drawFunc :: AppState -> [Widget ResName]
drawFunc = const [emptyWidget]
eventHandler :: BrickEvent ResName () -> EventM ResName AppState () eventHandler :: BrickEvent ResName () -> EventM ResName AppState ()
eventHandler = const halt eventHandler = const halt

46
src/Password/App/Draw.hs Normal file
View File

@ -0,0 +1,46 @@
{-|
Module: Password.App.Draw
Description: widget drawing functions
Copyright: (C) Jonathan Lamothe
License: LGPLv3 (or later)
Maintainer: jonathan@jlamothe.net
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<https://www.gnu.org/licenses/>.
-}
module Password.App.Draw (drawFunc) where
import Brick (Widget, txt, vBox)
import Brick.Forms (renderForm)
import Lens.Micro ((^.))
import Password.App.Types
-- | Renders the application view
drawFunc :: AppState -> [Widget ResName]
drawFunc s = case s^.appMode of
InitMode is -> drawPassForm is
drawPassForm :: InitState -> [Widget ResName]
drawPassForm is =
[ vBox
[ renderForm $ is^.setPassForm
, txt $ is^.spfError
]
]
--jl