diff options
author | Joris | 2021-01-03 13:40:40 +0100 |
---|---|---|
committer | Joris | 2021-01-03 13:54:20 +0100 |
commit | 11052951b74b9ad4b6a9412ae490086235f9154b (patch) | |
tree | 64526ac926c1bf470ea113f6cac8a33158684e8d /client/src/View/App.hs | |
parent | 371449b0e312a03162b78797b83dee9d81706669 (diff) |
Rewrite in Rust
Diffstat (limited to 'client/src/View/App.hs')
-rw-r--r-- | client/src/View/App.hs | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/client/src/View/App.hs b/client/src/View/App.hs deleted file mode 100644 index 71f0234..0000000 --- a/client/src/View/App.hs +++ /dev/null @@ -1,108 +0,0 @@ -module View.App - ( widget - ) where - -import qualified Data.Text as T -import Prelude hiding (error, init) -import Reflex.Dom (Dynamic, Event, MonadWidget) -import qualified Reflex.Dom as R - -import Common.Model (Currency, Init (..), UserId) -import qualified Common.Msg as Msg - -import Model.Route (Route (..)) -import qualified Util.Reflex as ReflexUtil -import qualified Util.Router as Router -import qualified View.Category.Category as Category -import qualified View.Header as Header -import qualified View.Income.Income as Income -import qualified View.NotFound as NotFound -import qualified View.Payment.Payment as Payment -import qualified View.SignIn as SignIn -import qualified View.Statistics.Statistics as Statistics - -widget :: Maybe Init -> IO () -widget init = - R.mainWidget $ R.divClass "app" $ do - - route <- getRoute - - rec - header <- Header.view $ Header.In - { Header._in_init = initState - , Header._in_route = route - } - - initState <- - R.foldDyn - const - init - (R.leftmost $ - [ initEvent - , Nothing <$ (Header._out_signOut header) - ]) - - initEvent <- - (R.dyn . R.ffor initState $ \case - Nothing -> do - signIn <- SignIn.view - return (Just <$> SignIn._out_success signIn) - - Just i -> do - signedWidget i route - return R.never) >>= ReflexUtil.flatten - - return () - -signedWidget :: forall t m. MonadWidget t m => Init -> Dynamic t Route -> m () -signedWidget init route = do - R.dyn . R.ffor route $ \case - RootRoute -> - Payment.view $ Payment.In - { Payment._in_currentUser = _init_currentUser init - , Payment._in_currency = _init_currency init - , Payment._in_users = _init_users init - } - - IncomeRoute -> - Income.view $ Income.In - { Income._in_currentUser = _init_currentUser init - , Income._in_currency = _init_currency init - , Income._in_users = _init_users init - } - - CategoryRoute -> - Category.view $ Category.In - { Category._in_currentUser = _init_currentUser init - , Category._in_currency = _init_currency init - , Category._in_users = _init_users init - } - - StatisticsRoute -> - Statistics.view $ Statistics.In - { Statistics._in_currency = _init_currency init - } - - NotFoundRoute -> - NotFound.view - - return () - -getRoute :: forall t m. MonadWidget t m => m (Dynamic t Route) -getRoute = do - r <- Router.partialPathRoute "" . R.switchPromptlyDyn =<< R.holdDyn R.never R.never - return . R.ffor r $ \case - [""] -> - RootRoute - - ["income"] -> - IncomeRoute - - ["category"] -> - CategoryRoute - - ["statistics"] -> - StatisticsRoute - - _ -> - NotFoundRoute |