{-# 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 Image' -> [Image'] -> [Image']
forall a. a -> [a] -> [a]
:
[ Attr -> Text -> Image'
text' Attr
defAttr (Text -> Text
cleanText (Identifier -> Text
idText Identifier
mask)) | Identifier
mask <- HashSet Identifier -> [Identifier]
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
| HashSet Identifier -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null HashSet Identifier
ignores = Attr -> Text -> Image'
text' (Getting Attr Palette Attr -> Palette -> Attr
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting Attr Palette Attr
Lens' Palette Attr
palError Palette
pal) Text
"Ignore list empty"
| Bool
otherwise = Attr -> Text -> Image'
text' (Getting Attr Palette Attr -> Palette -> Attr
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting Attr Palette Attr
Lens' Palette Attr
palLabel Palette
pal) Text
"Ignore entries: "
Image' -> Image' -> Image'
forall a. Semigroup a => a -> a -> a
<> Attr -> String -> Image'
string Attr
defAttr (Int -> String
forall a. Show a => a -> String
show (HashSet Identifier -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length HashSet Identifier
ignores))