rvv041 #82

Merged
pitmutt merged 30 commits from rvv041 into milestone2 2024-06-07 20:03:06 +00:00
Showing only changes of commit e946df43f8 - Show all commits

View file

@ -40,6 +40,8 @@ import Brick.Widgets.Core
, joinBorders , joinBorders
, padAll , padAll
, padBottom , padBottom
, padTop
, setAvailableSize
, str , str
, strWrap , strWrap
, strWrapWith , strWrapWith
@ -48,6 +50,7 @@ import Brick.Widgets.Core
, txtWrapWith , txtWrapWith
, updateAttrMap , updateAttrMap
, vBox , vBox
, viewport
, vLimit , vLimit
, withAttr , withAttr
, withBorderStyle , withBorderStyle
@ -108,6 +111,7 @@ data Name
| RecField | RecField
| AmtField | AmtField
| MemoField | MemoField
| ABViewport
deriving (Eq, Show, Ord) deriving (Eq, Show, Ord)
data DialogInput = DialogInput data DialogInput = DialogInput
@ -132,6 +136,7 @@ data DialogType
| ASelect | ASelect
| SendTx | SendTx
| Blank | Blank
| AdrBook
pitmutt marked this conversation as resolved
Review

The name of the field should be _abDescrip so the there are no conflict with the lens.

The name of the field should be `_abDescrip` so the there are no conflict with the lens.
Review

@reneve It's better to use more specific name fields to avoid conflicts.

@reneve It's better to use more specific name fields to avoid conflicts.
pitmutt marked this conversation as resolved
Review

The name of the field should be _abAddress so no conflicts with existing fields are found.

The name of the field should be `_abAddress` so no conflicts with existing fields are found.
data DisplayType data DisplayType
= AddrDisplay = AddrDisplay
@ -341,6 +346,45 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
C.hCenter C.hCenter
(hBox [capCommand "" "Send", capCommand "<esc> " "Cancel"])) (hBox [capCommand "" "Send", capCommand "<esc> " "Cancel"]))
Blank -> emptyWidget Blank -> emptyWidget
AdrBook ->
-- D.renderDialog
-- (D.dialog (Just (str "Select Wallet")) Nothing 50)
-- (selectListBox "Wallets" (st ^. wallets) listDrawWallet <=>
-- C.hCenter
-- (hBox
-- [ capCommand "↑↓ " "move"
-- , capCommand "↲ " "select"
-- , capCommand "N" "ew"
-- , capCommand "S" "how phrase"
-- , xCommand
-- ]))
D.renderDialog
(D.dialog (Just $ str " Address Book ") Nothing 60)
(withAttr abDefAttr $
setAvailableSize (50,20) $
viewport ABViewport BT.Vertical $
vLimit 20 $
hLimit 50 $
vBox $ [vLimit 16 $
hLimit 50 $
vBox $ --[ L.renderList listDrawAB True (s^.abaddresses) ],
[str "Addresses 1.................",
str "Addresses 2.....",
str "Addresses 3",
str "Addresses 4"],
padTop Max $
vLimit 4 $
hLimit 50 $
withAttr abMBarAttr $
vBox $ [C.hCenter $
(capCommand "N" "ew Address" <+>
capCommand "E" "dit Address" <+>
capCommand3 "" "C" "opy Address"),
C.hCenter $
(capCommand "D" "elete Address" <+>
capCommand "S" "end Zcash" <+>
capCommand3 "E" "x" "it")]])
splashDialog :: State -> Widget Name splashDialog :: State -> Widget Name
splashDialog st = splashDialog st =
if st ^. splashBox if st ^. splashBox
@ -586,6 +630,15 @@ barDoneAttr = A.attrName "done"
barToDoAttr :: A.AttrName barToDoAttr :: A.AttrName
barToDoAttr = A.attrName "remaining" barToDoAttr = A.attrName "remaining"
abDefAttr :: A.AttrName
abDefAttr = A.attrName "abdefault"
abSelAttr :: A.AttrName
abSelAttr = A.attrName "abselected"
abMBarAttr :: A.AttrName
abMBarAttr = A.attrName "menubar"
validBarValue :: Float -> Float validBarValue :: Float -> Float
validBarValue = clamp 0 1 validBarValue = clamp 0 1
@ -694,6 +747,7 @@ appEvent (BT.AppEvent t) = do
WSelect -> return () WSelect -> return ()
ASelect -> return () ASelect -> return ()
SendTx -> return () SendTx -> return ()
AdrBook -> return ()
Blank -> do Blank -> do
if s ^. timer == 90 if s ^. timer == 90
then do then do
@ -931,6 +985,23 @@ appEvent (BT.VtyEvent e) = do
setFieldValid setFieldValid
(isRecipientValid (fs ^. sendTo)) (isRecipientValid (fs ^. sendTo))
RecField RecField
AdrBook -> do
case e of
V.EvKey (V.KChar 'x') [] ->
BT.modify $ set dialogBox Blank
V.EvKey V.KEnter [] -> do
ns <- liftIO $ refreshWallet s
BT.put ns
BT.modify $ set dialogBox Blank
V.EvKey (V.KChar 'n') [] -> do
BT.modify $
set inputForm $
updateFormState (DialogInput "New Wallet") $
s ^. inputForm
BT.modify $ set dialogBox WName
V.EvKey (V.KChar 's') [] ->
BT.modify $ set displayBox PhraseDisplay
ev -> BT.zoom wallets $ L.handleListEvent ev
Blank -> do Blank -> do
case e of case e of
V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext
@ -955,7 +1026,7 @@ appEvent (BT.VtyEvent e) = do
mkSendForm (s ^. balance) (SendInput "" 0.0 "") mkSendForm (s ^. balance) (SendInput "" 0.0 "")
BT.modify $ set dialogBox SendTx BT.modify $ set dialogBox SendTx
V.EvKey (V.KChar 'b') [] -> V.EvKey (V.KChar 'b') [] ->
BT.modify $ set dialogBox ASelect BT.modify $ set dialogBox AdrBook
ev -> ev ->
case r of case r of
Just AList -> Just AList ->
@ -986,6 +1057,9 @@ theMap =
, (baseAttr, bg V.brightBlack) , (baseAttr, bg V.brightBlack)
, (barDoneAttr, V.white `on` V.blue) , (barDoneAttr, V.white `on` V.blue)
, (barToDoAttr, V.white `on` V.black) , (barToDoAttr, V.white `on` V.black)
, (abDefAttr, V.white `on` V.blue)
, (abSelAttr, V.blue `on` V.white)
, (abMBarAttr, V.white `on` V.black)
] ]
pitmutt marked this conversation as resolved Outdated

It is not necessary to show the address, it is too long for the message window. We should only use the name in the message.

It is not necessary to show the address, it is too long for the message window. We should only use the name in the message.
theApp :: M.App State Tick Name theApp :: M.App State Tick Name