packages feed

monomer-flatpak-example (empty) → 0.0.1.0

raw patch · 3 files changed

+125/−0 lines, 3 filesdep +basedep +containersdep +directory

Dependencies added: base, containers, directory, monomer, monomer-hagrid, text

Files

+ LICENSE view
@@ -0,0 +1,7 @@+Copyright 2022 Gareth Daniel Smith++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ app/Main.hs view
@@ -0,0 +1,73 @@+module Main (main) where++import Data.Sequence (Seq)+import qualified Data.Sequence as Seq+import Data.Text (Text, pack, unpack, unwords)+import Monomer+import Monomer.Hagrid+import System.Directory (getCurrentDirectory, getHomeDirectory, listDirectory)+import Prelude hiding (unwords)++data AppModel = AppModel+  { environmentInfos :: Seq EnvironmentInfo+  }+  deriving (Eq, Show)++data EnvironmentInfo = EnvironmentInfo+  { key :: Text,+    value :: Text+  }+  deriving (Eq, Show)++data AppEvent+  = AppInit+  | AppInitFinish (Seq EnvironmentInfo)++main :: IO ()+main = do+  startApp initialModel handleEvent buildUI config+  where+    initialModel = AppModel {environmentInfos = mempty}+    config =+      [ appTheme darkTheme,+        appWindowTitle "Monomer Flatpak Example",+        appFontDef "Regular" "./assets/fonts/Cantarell/Cantarell-Regular.ttf",+        appFontDef "Bold" "./assets/fonts/Cantarell/Cantarell-Bold.ttf",+        appDisableAutoScale True,+        appInitEvent AppInit+      ]++buildUI :: UIBuilder AppModel AppEvent+buildUI _wenv model =+  vstack+    [ label "This is a demo of the monomer framework running inside the Flatpak sandbox."+        `styleBasic` [padding 10],+      hagrid+        [ (textColumn "Environment Property" (.key)) {initialWidth = 200},+          (textColumn "Value" (.value)) {initialWidth = 600}+        ]+        model.environmentInfos+    ]++handleEvent :: EventHandler AppModel AppEvent sp ep+handleEvent _wenv _node model = \case+  AppInit ->+    [ Task $ do+        curDir <- pack <$> getCurrentDirectory+        homeDir <- pack <$> getHomeDirectory+        lsRoot <- unwords . fmap pack <$> listDirectory "/"+        lsCurDir <- unwords . fmap pack <$> listDirectory (unpack curDir)+        lsHomeDir <- unwords . fmap pack <$> listDirectory (unpack homeDir)+        pure $+          AppInitFinish+            ( Seq.fromList+                [ EnvironmentInfo "Current Directory" curDir,+                  EnvironmentInfo "Home Directory" homeDir,+                  EnvironmentInfo "ls /" lsRoot,+                  EnvironmentInfo ("ls " <> curDir) lsCurDir,+                  EnvironmentInfo ("ls " <> homeDir) lsHomeDir+                ]+            )+    ]+  AppInitFinish environmentInfos ->+    [Model model {environmentInfos}]
+ monomer-flatpak-example.cabal view
@@ -0,0 +1,45 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.35.1.+--+-- see: https://github.com/sol/hpack++name:           monomer-flatpak-example+version:        0.0.1.0+synopsis:       Monomer Flatpak Example Application.+description:    An example of how to package Monomer apps with Flatpak.+category:       GUI+homepage:       https://github.com/Dretch/monomer-flatpak-example#readme+bug-reports:    https://github.com/Dretch/monomer-flatpak-example/issues+maintainer:     garethdanielsmith@gmail.com+license:        MIT+license-file:   LICENSE+build-type:     Simple++source-repository head+  type: git+  location: https://github.com/Dretch/monomer-flatpak-example++executable monomer-flatpak-example+  main-is: Main.hs+  other-modules:+      Paths_monomer_flatpak_example+  hs-source-dirs:+      app+  default-extensions:+      DisambiguateRecordFields+      DuplicateRecordFields+      FlexibleContexts+      LambdaCase+      NamedFieldPuns+      OverloadedRecordDot+      OverloadedStrings+  ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+  build-depends:+      base >=4.7 && <5+    , containers+    , directory+    , monomer+    , monomer-hagrid+    , text+  default-language: Haskell2010