diff options
author | Tim <contact@bytim.eu> | 2025-02-08 11:28:57 +0100 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-02-08 11:28:57 +0100 |
commit | d69bc395e6cc9ed5e1da6a31835874142fe6800e (patch) | |
tree | 324cf18c710721c286890d78310ebe0075499ea4 /src/distractionless/core.cljd | |
download | distractionless-d69bc395e6cc9ed5e1da6a31835874142fe6800e.tar.xz distractionless-d69bc395e6cc9ed5e1da6a31835874142fe6800e.zip |
Initial commit
Diffstat (limited to 'src/distractionless/core.cljd')
-rw-r--r-- | src/distractionless/core.cljd | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/distractionless/core.cljd b/src/distractionless/core.cljd new file mode 100644 index 0000000..2036da6 --- /dev/null +++ b/src/distractionless/core.cljd @@ -0,0 +1,53 @@ +(ns distractionless.core + (:require ["package:flutter/material.dart" :as m] + [cljd.flutter :as f] + ["package:path_provider/path_provider.dart" :as path-provider] + [distractionless.config :as dconfig] + ["dart:io" :as io] + + [distractionless.ui.constants :as duconstants] + [distractionless.ui.apps :as duapps])) + +(defn ^dynamic main [] + (f/run + (m/MaterialApp + .theme (m/ThemeData .primarySwatch m.Colors/pink)) + .home + (m/Scaffold .backgroundColor duconstants/background-color) + .body + :context ctx + :watch [apps (atom '()) :as *apps + query (atom "") :as *query + data-dir (await (path-provider/getApplicationDocumentsDirectory)) + _ (atom 0) :as reloader] + :managed [_ (duapps/load-installed-apps! *apps) ; loads apps on app startup + config-file (io/File. (str (.-path data-dir) "/config.edn")) + _ (dconfig/init-config! config-file nil) ; Init config on app startup + _ (m/AppLifecycleListener .onShow #(do (dconfig/init-config! config-file nil) + (duapps/load-installed-apps! *apps))) + page-controller (m/PageController.)] + :let [root-container-padding (m/EdgeInsets.only + .top 50)] + (m/PageView. + .controller page-controller + .children [(let [favourites (get (dconfig/read-from-file config-file) "favourites")] + (m/Container + .padding root-container-padding + .child (m/Column + .children [(m/Expanded + .child (duapps/apps-list (filter #(.contains favourites (.-packageName %)) apps) nil config-file ctx reloader)) + (m/Text "Wische nach links, um alle Apps anzuzeigen" + .style duconstants/text-style)]))) + (m/Container + .padding root-container-padding + .child (m/Column + .children [(m/Text "Alle Apps" + .style duconstants/title-style) + (m/SearchBar + .onChanged (fn [new-val] + (reset! *query new-val) + nil) + .hintText "Suche" + .backgroundColor (#/(.resolveWith m/Color?) m/MaterialStateProperty (fn [^Set _states] duconstants/search-bar-color))) + (m/Expanded + .child (duapps/apps-list apps query config-file ctx reloader))]))]))) |