Browse Source

UI improvements

master
Denis Tereshkin 6 years ago
parent
commit
f0040bf339
  1. 12
      src/Main.hs

12
src/Main.hs

@ -13,6 +13,7 @@ import Control.Exception
import Control.Monad import Control.Monad
import Data.Aeson import Data.Aeson
import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy as B
import qualified Data.List as L
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import qualified Graphics.Vty as Vty import qualified Graphics.Vty as Vty
import Lens.Micro.Platform import Lens.Micro.Platform
@ -67,13 +68,10 @@ main = do
where where
initialState = AppState M.empty initialState = AppState M.empty
draw :: AppState -> [Widget Name] draw :: AppState -> [Widget Name]
draw s = [hBox [vBox (txt <$> tickers s), draw s = [hBox . L.intersperse vBorder $ hLimit 15 . padLeftRight 3 <$> [vBox ([str "Ticker", hBorder] ++ (txt <$> tickers s)),
vBorder, vBox ([str "Last", hBorder] ++ (str <$> fmap (printEntry s qteLastPrice) (tickers s))),
vBox (str <$> fmap (printEntry s qteLastPrice) (tickers s)), vBox ([str "Bid", hBorder] ++ (str <$> fmap (printEntry s qteBid) (tickers s))),
vBorder, vBox ([str "Ask", hBorder] ++ (str <$> fmap (printEntry s qteAsk) (tickers s)))] ]
vBox (str <$> fmap (printEntry s qteBid) (tickers s)),
vBorder,
vBox (str <$> fmap (printEntry s qteAsk) (tickers s))] ]
printEntry s l tickerId = case s ^. quotes . at tickerId of printEntry s l tickerId = case s ^. quotes . at tickerId of
Just qte -> show $ qte ^. l Just qte -> show $ qte ^. l
Nothing -> "-" Nothing -> "-"

Loading…
Cancel
Save