{-|
Module: IHP.Controller.Layout
Copyright: (c) digitally induced GmbH, 2020
-}
module IHP.Controller.Layout
( setLayout
, getLayout
, ViewLayout (..)
) where

import IHP.Prelude
import IHP.ViewSupport
import IHP.Controller.Context

newtype ViewLayout = ViewLayout ((?context :: ControllerContext) => Layout)

setLayout :: (?context :: ControllerContext) => ((?context :: ControllerContext) => Layout) -> IO ()
setLayout :: (?context::ControllerContext) =>
((?context::ControllerContext) => Layout) -> IO ()
setLayout (?context::ControllerContext) => Layout
layout = do
    ViewLayout -> IO ()
forall value.
(?context::ControllerContext, Typeable value) =>
value -> IO ()
putContext (((?context::ControllerContext) => Layout) -> ViewLayout
ViewLayout (?context::ControllerContext) => Layout
Layout
layout)
{-# INLINE setLayout #-}

getLayout :: (?context :: ControllerContext) => IO Layout
getLayout :: (?context::ControllerContext) => IO Layout
getLayout = do
    (ViewLayout (?context::ControllerContext) => Layout
layout) <- IO ViewLayout
forall value.
(?context::ControllerContext, Typeable value) =>
IO value
fromContext
    Layout -> IO Layout
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (?context::ControllerContext) => Layout
Layout
layout