module Matterhorn.Draw.ChannelSelectPrompt
  ( drawChannelSelectPrompt
  )
where

import Prelude ()
import Matterhorn.Prelude

import           Brick
import           Brick.Widgets.Edit ( renderEditor )
import qualified Data.Text as T
import           Network.Mattermost.Types ( TeamId)

import           Matterhorn.Types
import           Matterhorn.Themes


drawChannelSelectPrompt :: ChatState -> TeamId -> Widget Name
drawChannelSelectPrompt :: ChatState -> TeamId -> Widget Name
drawChannelSelectPrompt ChatState
st TeamId
tId =
    forall n. Size -> Size -> RenderM n (Result n) -> Widget n
Widget Size
Greedy Size
Greedy forall a b. (a -> b) -> a -> b
$ do
       Context Name
ctx <- forall n. RenderM n (Context n)
getContext
       let rowOffset :: Int
rowOffset = Context Name
ctxforall s a. s -> Getting a s a -> a
^.forall n. Lens' (Context n) Int
availHeightL forall a. Num a => a -> a -> a
- Int
1
           e :: Editor Text Name
e = ChatState
stforall s a. s -> Getting a s a -> a
^.TeamId -> Lens' ChatState TeamState
csTeam(TeamId
tId)forall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' TeamState ChannelSelectState
tsChannelSelectStateforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' ChannelSelectState (Editor Text Name)
channelSelectInput
       forall n. Widget n -> RenderM n (Result n)
render forall a b. (a -> b) -> a -> b
$ forall n. Location -> Widget n -> Widget n
translateBy ((Int, Int) -> Location
Location (Int
0, Int
rowOffset)) forall a b. (a -> b) -> a -> b
$
                forall n. AttrName -> Widget n -> Widget n
withDefAttr AttrName
channelSelectPromptAttr forall a b. (a -> b) -> a -> b
$
                (forall n. Text -> Widget n
txt Text
"Switch to channel [use ^ and $ to anchor]: ") forall n. Widget n -> Widget n -> Widget n
<+>
                (forall n t.
(Ord n, Show n, Monoid t, TextWidth t, GenericTextZipper t) =>
([t] -> Widget n) -> Bool -> Editor t n -> Widget n
renderEditor (forall n. Text -> Widget n
txt forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat) Bool
True Editor Text Name
e)