content: {-# LANGUAGE OverloadedStrings #-}
  {-# LANGUAGE TemplateHaskell #-}
  
  module Main where
  
  import Control.Lens
  import Monomer
  import TextShow
  
  newtype AppModel = AppModel {
    _clickCount :: Int
  } deriving (Eq, Show)
  
  data AppEvent
    = AppInit
    | AppIncrease
    deriving (Eq, Show)
  
  makeLenses 'AppModel
  
  buildUI
    :: WidgetEnv AppModel AppEvent
    -> AppModel
    -> WidgetNode AppModel AppEvent
  buildUI wenv model = widgetTree where
    widgetTree = vstack [
        label "Hello world",
        spacer,
        hstack [
          label $ "Click count: " <> showt (model ^. clickCount),
          spacer,
          button "Increase count" AppIncrease
        ]
      ] `styleBasic` [padding 10]
  
  handleEvent
    :: WidgetEnv AppModel AppEvent
    -> WidgetNode AppModel AppEvent
    -> AppModel
    -> AppEvent
    -> [AppEventResponse AppModel AppEvent]
  handleEvent wenv node model evt = case evt of
    AppInit -> []
    AppIncrease -> [Model (model & clickCount +~ 1)]
  
  main :: IO ()
  main = do
    startApp model handleEvent buildUI config
    where
      config = [
        appWindowTitle "Dev test app",
        appWindowIcon "./assets/images/icon.png",
        appTheme darkTheme,
        appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
        appInitEvent AppInit,
        appModelFingerprint show
        ]
      model = AppModel 0
  