{-# Language OverloadedStrings #-}
module Client.View.IgnoreList
( ignoreListLines
) where
import Client.Image.PackedImage
import Client.Image.Palette
import Client.Image.Message
import Graphics.Vty.Attributes
import Irc.Identifier
import Data.HashSet (HashSet)
import Data.Foldable
import Control.Lens
ignoreListLines ::
HashSet Identifier ->
Palette ->
[Image']
ignoreListLines :: HashSet Identifier -> Palette -> [Image']
ignoreListLines HashSet Identifier
ignores Palette
pal =
HashSet Identifier -> Palette -> Image'
summaryLine HashSet Identifier
ignores Palette
pal forall a. a -> [a] -> [a]
:
[ Attr -> Text -> Image'
text' Attr
defAttr (Text -> Text
cleanText (Identifier -> Text
idText Identifier
mask)) | Identifier
mask <- forall (t :: * -> *) a. Foldable t => t a -> [a]
toList HashSet Identifier
ignores ]
summaryLine ::
HashSet Identifier ->
Palette ->
Image'
summaryLine :: HashSet Identifier -> Palette -> Image'
summaryLine HashSet Identifier
ignores Palette
pal
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null HashSet Identifier
ignores = Attr -> Text -> Image'
text' (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Lens' Palette Attr
palError Palette
pal) Text
"Ignore list empty"
| Bool
otherwise = Attr -> Text -> Image'
text' (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Lens' Palette Attr
palLabel Palette
pal) Text
"Ignore entries: "
forall a. Semigroup a => a -> a -> a
<> Attr -> String -> Image'
string Attr
defAttr (forall a. Show a => a -> String
show (forall (t :: * -> *) a. Foldable t => t a -> Int
length HashSet Identifier
ignores))