2021-09-14 17:06:34 +02:00
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
|
2021-09-17 17:36:58 +02:00
|
|
|
{-|
|
|
|
|
Module : AppTypes
|
|
|
|
Description : Contains the types related to our Brick application
|
|
|
|
-}
|
|
|
|
|
2021-09-14 17:06:34 +02:00
|
|
|
module AppTypes where
|
|
|
|
|
|
|
|
import JSONTypes
|
|
|
|
import Lens.Micro.TH
|
2021-09-20 13:21:48 +02:00
|
|
|
import Brick.Widgets.Edit (Editor(..))
|
|
|
|
import qualified Data.Text as T
|
2021-09-14 17:06:34 +02:00
|
|
|
|
2021-09-17 17:36:58 +02:00
|
|
|
-- | Contains the different elements which we
|
|
|
|
-- might want brick to be able to identify
|
2021-09-14 17:06:34 +02:00
|
|
|
data Ident = Listing | Input | ListItem Int
|
|
|
|
deriving (Eq, Ord, Show)
|
|
|
|
|
2021-09-17 17:36:58 +02:00
|
|
|
-- | Used to distiguish what set of
|
|
|
|
-- widgets should currently be rendered.
|
|
|
|
data Mode = Search | Browse | Message
|
2021-09-14 17:06:34 +02:00
|
|
|
deriving (Eq, Ord, Show)
|
|
|
|
|
2021-09-17 17:36:58 +02:00
|
|
|
-- | Used for scrolling
|
2021-09-14 17:06:34 +02:00
|
|
|
data ScrollDirection = Up | Down
|
|
|
|
deriving (Eq, Show)
|
|
|
|
|
2021-09-17 17:36:58 +02:00
|
|
|
-- | The state of our app
|
2021-09-14 17:06:34 +02:00
|
|
|
data AppS = AppS
|
2021-09-20 13:21:48 +02:00
|
|
|
{ _appMode :: Mode -- ^ The current mode of the app
|
|
|
|
, _appCursor :: Int -- ^ The selected into the listing
|
|
|
|
, _appExpanded :: Bool -- ^ If the currently selected listing is expanded
|
|
|
|
, _appPage :: Int -- ^ The page currently being viewed
|
|
|
|
, _appListing :: JSONListMovies -- ^ The movies being browsed
|
|
|
|
, _appDetails :: Maybe JSONMovie -- ^ The movie being focused
|
|
|
|
, _appMessage :: Maybe String -- ^ The message to be shown in message mode
|
|
|
|
, _appContinue :: Bool -- ^ If to continue after showing message
|
|
|
|
, _appEditor :: Editor T.Text Ident -- ^ The state for the editor widget
|
2021-09-14 17:06:34 +02:00
|
|
|
} deriving (Show)
|
|
|
|
|
|
|
|
makeLenses ''AppS
|