fix examples

This commit is contained in:
pdlla 2021-04-11 17:08:26 -07:00
parent 533265e7d7
commit 2c9156e8d7
4 changed files with 18 additions and 5 deletions

View File

@ -100,7 +100,7 @@ cpuStats
, HasLayout t m
, HasFocus t m
, HasInput t m
, HasFocusReader t m
, HasFocusReader t m, HasTheme t m
)
=> m ()
cpuStats = do
@ -122,7 +122,7 @@ chart
, HasImageWriter t m
, HasInput t m
, HasDisplayRegion t m
, HasFocusReader t m
, HasFocusReader t m, HasTheme t m
)
=> Dynamic t (Ratio Word64) -> m ()
chart pct = do

View File

@ -23,7 +23,7 @@ type VtyExample t m =
, HasImageWriter t m
, HasDisplayRegion t m
, HasFocus t m
, HasFocusReader t m
, HasFocusReader t m, HasTheme t m
)
type Manager t m =
@ -46,12 +46,20 @@ withCtrlC f = do
V.EvKey (V.KChar 'c') [V.MCtrl] -> Just ()
_ -> Nothing
darkTheme :: V.Attr
darkTheme = V.Attr {
V.attrStyle = V.SetTo V.standout
, V.attrForeColor = V.SetTo V.black
, V.attrBackColor = V.Default
, V.attrURL = V.Default
}
main :: IO ()
main = mainWidget $ withCtrlC $ do
initManager_ $ do
tabNavigation
let gf = grout . fixed
t = tile flex
t = tile flex
buttons = col $ do
gf 3 $ col $ do
gf 1 $ text "Select an example."
@ -77,7 +85,7 @@ main = mainWidget $ withCtrlC $ do
_ -> Nothing
rec out <- networkHold buttons $ ffor (switch (current out)) $ \case
Left Example_Todo -> escapable taskList
Left Example_TextEditor -> escapable testBoxes
Left Example_TextEditor -> escapable $ localTheme (const (constant darkTheme)) testBoxes
Left Example_ScrollableTextDisplay -> escapable scrolling
Left Example_ClickButtonsGetEmojis -> escapable easyExample
Left Example_CPUStat -> escapable cpuStats

View File

@ -116,6 +116,7 @@ checkboxStyleTick = CheckboxStyle
-- | Configuration options for a checkbox
data CheckboxConfig t = CheckboxConfig
{ _checkboxConfig_checkboxStyle :: Behavior t CheckboxStyle
-- TODO DELETE and use HasTheme instead
, _checkboxConfig_attributes :: Behavior t V.Attr
, _checkboxConfig_setValue :: Event t Bool
}

View File

@ -133,6 +133,8 @@ instance (HasImageWriter t m, MonadFix m) => HasImageWriter t (Focus t m) where
instance (HasFocusReader t m, Monad m) => HasFocusReader t (Focus t m)
instance (HasTheme t m, Monad m) => HasTheme t (Focus t m)
instance (Reflex t, MonadFix m, MonadNodeId m) => HasFocus t (Focus t m) where
makeFocus = do
fid <- FocusId <$> lift getNextNodeId
@ -430,6 +432,8 @@ instance (HasDisplayRegion t m, HasImageWriter t m, MonadFix m) => HasImageWrite
instance (HasFocusReader t m, Monad m) => HasFocusReader t (Layout t m)
instance (HasTheme t m, Monad m) => HasTheme t (Layout t m)
instance (Monad m, MonadNodeId m, Reflex t, MonadFix m) => HasLayout t (Layout t m) where
axis o c (Layout x) = Layout $ do
nodeId <- getNextNodeId