From d69bc395e6cc9ed5e1da6a31835874142fe6800e Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 8 Feb 2025 11:28:57 +0100 Subject: Initial commit --- .gitattributes | 6 + .gitignore | 54 ++++ .metadata | 45 +++ LICENSE | 21 ++ README.md | 11 + analysis_options.yaml | 28 ++ android/.gitignore | 13 + android/app/build.gradle | 44 +++ android/app/src/debug/AndroidManifest.xml | 7 + android/app/src/main/AndroidManifest.xml | 48 ++++ .../example/cljd_distractionless/MainActivity.kt | 5 + .../main/res/drawable-v21/launch_background.xml | 12 + .../src/main/res/drawable/launch_background.xml | 12 + .../app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes android/app/src/main/res/values-night/styles.xml | 18 ++ android/app/src/main/res/values/styles.xml | 18 ++ android/app/src/profile/AndroidManifest.xml | 7 + android/build.gradle | 18 ++ android/gradle.properties | 3 + android/gradle/wrapper/gradle-wrapper.properties | 5 + android/settings.gradle | 25 ++ deps.edn | 7 + lib/main.dart | 1 + pubspec.lock | 301 +++++++++++++++++++++ pubspec.yaml | 91 +++++++ src/distractionless/config.cljd | 29 ++ src/distractionless/core.cljd | 53 ++++ src/distractionless/ui/apps.cljd | 26 ++ src/distractionless/ui/apps/settings.cljd | 42 +++ src/distractionless/ui/constants.cljd | 15 + 34 files changed, 965 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .metadata create mode 100644 LICENSE create mode 100644 README.md create mode 100644 analysis_options.yaml create mode 100644 android/.gitignore create mode 100644 android/app/build.gradle create mode 100644 android/app/src/debug/AndroidManifest.xml create mode 100644 android/app/src/main/AndroidManifest.xml create mode 100644 android/app/src/main/kotlin/com/example/cljd_distractionless/MainActivity.kt create mode 100644 android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 android/app/src/main/res/drawable/launch_background.xml create mode 100644 android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 android/app/src/main/res/values-night/styles.xml create mode 100644 android/app/src/main/res/values/styles.xml create mode 100644 android/app/src/profile/AndroidManifest.xml create mode 100644 android/build.gradle create mode 100644 android/gradle.properties create mode 100644 android/gradle/wrapper/gradle-wrapper.properties create mode 100644 android/settings.gradle create mode 100644 deps.edn create mode 100644 lib/main.dart create mode 100644 pubspec.lock create mode 100644 pubspec.yaml create mode 100644 src/distractionless/config.cljd create mode 100644 src/distractionless/core.cljd create mode 100644 src/distractionless/ui/apps.cljd create mode 100644 src/distractionless/ui/apps/settings.cljd create mode 100644 src/distractionless/ui/constants.cljd diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0523f84 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ + +# Syntax highlighting for ClojureDart files +*.cljd linguist-language=Clojure + +# Syntax highlighting for ClojureDart files +*.cljd linguist-language=Clojure diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dae98d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +# ClojureDart +.cpcache/ +.clojuredart/ +lib/cljd-out/ +test/cljd-out/ + +.clj-kondo/ +.lsp/ diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..b02a7e4 --- /dev/null +++ b/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "17025dd88227cd9532c33fa78f5250d548d87e9a" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + - platform: android + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + - platform: ios + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + - platform: linux + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + - platform: macos + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + - platform: web + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + - platform: windows + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..edf6717 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Tim R. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd6817e --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# distractionless + +*WIP Alternative Homescreen aiming to minimalize distractions.* + +This project is currently under heavy development. + +# Installation +Run the following commands in the root of the project: +1. `clj -M:cljd compile` +2. `flutter build apk` +3. `flutter install -d ` diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..55afd91 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..f71bfcf --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,44 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + +android { + namespace = "com.example.cljd_distractionless" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.cljd_distractionless" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.debug + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8c235aa --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/example/cljd_distractionless/MainActivity.kt b/android/app/src/main/kotlin/com/example/cljd_distractionless/MainActivity.kt new file mode 100644 index 0000000..cda77c0 --- /dev/null +++ b/android/app/src/main/kotlin/com/example/cljd_distractionless/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.cljd_distractionless + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..d2ffbff --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,18 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = "../build" +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..2597170 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7bb2df6 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..a42444d --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,25 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.2.1" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} + +include ":app" diff --git a/deps.edn b/deps.edn new file mode 100644 index 0000000..7eb6e23 --- /dev/null +++ b/deps.edn @@ -0,0 +1,7 @@ +{:paths ["src"] ; where your cljd files are + :deps {tensegritics/clojuredart + {:git/url "https://github.com/tensegritics/ClojureDart.git" + :sha "6127d8ef23156f2be5b10e97a0932868d175e585"}} + :aliases {:cljd {:main-opts ["-m" "cljd.build"]}} + :cljd/opts {:kind :flutter + :main distractionless.core}} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..8ff8454 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1 @@ +export "cljd-out/distractionless/core.dart" show main; diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..7108ce5 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,301 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + url: "https://pub.dev" + source: hosted + version: "1.19.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + installed_apps: + dependency: "direct main" + description: + name: installed_apps + sha256: "34d001c74632fe4f10aa460a143d73050ea666f8f83d05a2bc84b2a0a91cf897" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + url: "https://pub.dev" + source: hosted + version: "10.0.7" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + url: "https://pub.dev" + source: hosted + version: "3.0.8" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + url: "https://pub.dev" + source: hosted + version: "1.15.0" + path: + dependency: transitive + description: + name: path + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" + source: hosted + version: "1.9.0" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2" + url: "https://pub.dev" + source: hosted + version: "2.2.15" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + url: "https://pub.dev" + source: hosted + version: "1.12.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + url: "https://pub.dev" + source: hosted + version: "0.7.3" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + url: "https://pub.dev" + source: hosted + version: "14.3.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" +sdks: + dart: ">=3.6.0 <4.0.0" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..2fd58f1 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,91 @@ +name: distractionless +description: "distractionless home screen" +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 0.0.1 + +environment: + sdk: ^3.6.0 + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 + installed_apps: ^1.5.2 + path_provider: ^2.1.5 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^5.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/src/distractionless/config.cljd b/src/distractionless/config.cljd new file mode 100644 index 0000000..07d86b8 --- /dev/null +++ b/src/distractionless/config.cljd @@ -0,0 +1,29 @@ +(ns distractionless.config + (:require ["dart:io" :as io] + [cljd.reader :as cljdreader])) + +(defn read-from-file [^io/File file] + (->> (.readAsStringSync file) + cljdreader/read-string)) + +(defn write-to-file! [^io/File file content reloader] + (->> content + pr-str + (.writeAsStringSync file)) + (when (some? reloader) + (reset! reloader (when (= @reloader 0) + 1 + 0)))) + +(defn update-config! [^io/File file func reloader] + (let [new-content (-> (read-from-file file) + func)] + (write-to-file! file new-content reloader) + new-content)) + +(defn init-config! [^io/File file reloader] + (when-not (.existsSync file) + (.createSync file) + (write-to-file! file {} reloader)) + (when-not (contains? (read-from-file file) "favourites") + (prn (update-config! file #(assoc % "favourites" #{}) reloader)))) 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))]))]))) diff --git a/src/distractionless/ui/apps.cljd b/src/distractionless/ui/apps.cljd new file mode 100644 index 0000000..7fd620c --- /dev/null +++ b/src/distractionless/ui/apps.cljd @@ -0,0 +1,26 @@ +(ns distractionless.ui.apps + (:require ["package:flutter/material.dart" :as m] + [clojure.string :as cstr] + ["package:installed_apps/installed_apps.dart" :as apps] + [distractionless.ui.constants :as duconstants] + [distractionless.ui.apps.settings :as duasettings])) + +(defn load-installed-apps! [a] + (reset! a (await (apps/InstalledApps.getInstalledApps)))) + +(defn- render-app [app config-file ctx reloader] + (m/ListTile + .title (m/Text (.-name app) + .style duconstants/text-style) + .onTap #(do (await (apps/InstalledApps.startApp (.-packageName app))) nil) + .onLongPress #(duasettings/open app config-file ctx reloader))) + +(defn apps-list [apps query config-file ctx reloader] + (m/ListView + .children (for [app (if (cstr/blank? query) + apps + (filter #(cstr/includes? + (cstr/lower-case (.-name %)) + (cstr/lower-case query)) + apps))] + (render-app app config-file ctx reloader)))) diff --git a/src/distractionless/ui/apps/settings.cljd b/src/distractionless/ui/apps/settings.cljd new file mode 100644 index 0000000..1b4de0a --- /dev/null +++ b/src/distractionless/ui/apps/settings.cljd @@ -0,0 +1,42 @@ +(ns distractionless.ui.apps.settings + (:require ["package:flutter/material.dart" :as m] + [cljd.flutter :as f] + [distractionless.ui.constants :as duconstants] + [distractionless.config :as dconfig])) + +(defn- header [app ctx] + (m/Row + .mainAxisAlignment m/MainAxisAlignment.spaceBetween + .children [(m/Text (.-name app) + .style duconstants/title-style) + (m/IconButton .icon (m/Icon m/Icons.clear_rounded) + .color duconstants/text-color + .onPressed #(m/Navigator.pop ctx) + .iconSize 30.0)])) + +(defn- favourite-setting [app config-file reloader] + (m/Row + .children [(m/Checkbox + .value (contains? (get (dconfig/read-from-file config-file) "favourites") + (.-packageName app)) + .onChanged (fn [new-val] + (if new-val + (dconfig/update-config! config-file + #(update % "favourites" conj (.-packageName app)) + reloader) + (dconfig/update-config! config-file + (fn [config] + (update config "favourites" disj (.-packageName app))) + reloader))) + .activeColor duconstants/checkbox-active-color) + (m/Text "Favorit")])) + +(defn open [app config-file ctx reloader] + (m/showDialog + .context ctx + .builder (f/build :watch [_ reloader] + (m/Dialog.fullscreen + .backgroundColor duconstants/background-color + .child (m/Column + .children (list (header app ctx) + (favourite-setting app config-file reloader))))))) diff --git a/src/distractionless/ui/constants.cljd b/src/distractionless/ui/constants.cljd new file mode 100644 index 0000000..505778f --- /dev/null +++ b/src/distractionless/ui/constants.cljd @@ -0,0 +1,15 @@ +(ns distractionless.ui.constants + (:require ["package:flutter/material.dart" :as m])) + +(def background-color (m/Color.fromARGB 255 157 166 159)) +(def search-bar-color (m/Color.fromARGB 255 138 150 141)) +(def text-color (m/Color.fromARGB 255 0 0 0)) + +(def checkbox-active-color (m/Color.fromARGB 255 86 93 86)) +(def checkbox-fill-color (m/Color.fromARGB 255 197 205 199)) + +(def text-style (m/TextStyle + .color text-color)) +(def title-style (m/TextStyle + .color text-color + .fontSize 30.0)) -- cgit v1.2.3