started work on sorting mode
This commit is contained in:
parent
860f079ae6
commit
879fd536d6
|
@ -98,14 +98,25 @@ instance FromJSON JSONTorrent where
|
|||
|
||||
-- | Contains the different elements which we
|
||||
-- might want brick to be able to identify
|
||||
data Ident = Listing | Input | ListItem Int
|
||||
data Ident = Listing | Input
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
-- | Used to distinguish what set of
|
||||
-- | Distinguishes what set of
|
||||
-- widgets should currently be rendered.
|
||||
data Mode = Search | Browse | Message
|
||||
data Mode = Search | Browse | Message | Sort
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
-- | Used to choose what to sort listings by
|
||||
data SortOrder
|
||||
= Title
|
||||
| Year
|
||||
| Rating
|
||||
| Seeds
|
||||
| Downloads
|
||||
| Likes
|
||||
| UploadDate
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | Used for scrolling
|
||||
data ScrollDirection = Up | Down
|
||||
deriving (Eq, Show)
|
||||
|
@ -122,6 +133,7 @@ data AppS = AppS
|
|||
, _appContinue :: Bool -- ^ If to continue after showing message
|
||||
, _appEditor :: Editor T.Text Ident -- ^ The state for the editor widget
|
||||
, _appReqOpts :: WR.Options -- ^ The options to use to make our requests
|
||||
, _appSort :: SortOrder -- ^ The order to display the listings in
|
||||
} deriving (Show)
|
||||
|
||||
makeLenses ''AppS
|
||||
|
|
|
@ -117,6 +117,16 @@ eventHandler s (VtyEvent e@(EvKey k _)) =
|
|||
& appMessage .~ Nothing)
|
||||
else halt s
|
||||
|
||||
Sort -> case k of
|
||||
(KChar 't') -> undefined
|
||||
(KChar 'y') -> undefined
|
||||
(KChar 'r') -> undefined
|
||||
(KChar 's') -> undefined
|
||||
(KChar 'd') -> undefined
|
||||
(KChar 'l') -> undefined
|
||||
(KChar 'u') -> undefined
|
||||
_ -> undefined
|
||||
|
||||
Search -> case k of
|
||||
(KEnter) -> do
|
||||
let queryText = T.unlines (getEditContents (s ^. appEditor))
|
||||
|
|
|
@ -26,10 +26,10 @@ import Kino.Torrent
|
|||
select :: Widget Ident -> Widget Ident
|
||||
select = withAttr (attrName "selected")
|
||||
|
||||
-- | Given a movie and a tuple of widgets and state, append the
|
||||
-- movie to the widgets. Used by movieWidgets
|
||||
widgetCons :: JSONMovie -> (Widget Ident, AppS) -> (Widget Ident, AppS)
|
||||
widgetCons m (w, s) =
|
||||
-- | Given a state, a movie and a second widget, append the
|
||||
-- movie to the widget second widget. Used by movieWidgets
|
||||
widgetCons :: AppS -> JSONMovie -> Widget Ident -> Widget Ident
|
||||
widgetCons s m w =
|
||||
embed $ if Just m == (s ^. appDetails)
|
||||
then select . visible $
|
||||
if s ^. appExpanded
|
||||
|
@ -37,12 +37,11 @@ widgetCons m (w, s) =
|
|||
else movieWidget m
|
||||
else movieWidget m
|
||||
where
|
||||
embed x = (x <=> w, s)
|
||||
embed = (<=> w)
|
||||
|
||||
-- | Returns a big list of all movies
|
||||
movieWidgets :: AppS -> Widget Ident
|
||||
movieWidgets s = let (items, _) = foldr widgetCons (emptyWidget, s) (moviesMovies (s ^. appListing))
|
||||
in items
|
||||
movieWidgets s = foldr (widgetCons s) emptyWidget (moviesMovies (s ^. appListing))
|
||||
|
||||
-- | Returns a single movie listing
|
||||
movieWidget :: JSONMovie -> Widget Ident
|
||||
|
|
Loading…
Reference in New Issue
Block a user