├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ │ ├── ic_add.xml │ │ │ │ ├── ic_remove.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ ├── layout │ │ │ │ ├── item_todo.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── content_main.xml │ │ │ │ └── fragment_new_todo.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── cotel │ │ │ │ └── comonadic_ui │ │ │ │ ├── ServiceLocator.kt │ │ │ │ ├── datatypes │ │ │ │ ├── Component.kt │ │ │ │ ├── Moore.kt │ │ │ │ └── Store.kt │ │ │ │ ├── Model.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── TodosAdapter.kt │ │ │ │ ├── NewTodoFragment.kt │ │ │ │ └── TodosListFragment.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── cotel │ │ │ └── comonadic_ui │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── cotel │ │ └── comonadic_ui │ │ ├── matchers.kt │ │ ├── TodosListFragmentTest.kt │ │ └── NewTodoRecordedTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── .travis.yml ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/java/cotel/comonadic_ui/ServiceLocator.kt: -------------------------------------------------------------------------------- 1 | package cotel.comonadic_ui 2 | 3 | object ServiceLocator { 4 | 5 | var todosState = TodosState(emptyList()) 6 | 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea/ 4 | /local.properties 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Oct 12 16:48:04 CEST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Comonadic-Ui 3 | Settings 4 | 5 | 6 | Hello blank fragment 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/cotel/comonadic_ui/datatypes/Component.kt: -------------------------------------------------------------------------------- 1 | package cotel.comonadic_ui.datatypes 2 | 3 | import arrow.data.State 4 | 5 | data class Component(val model: T, val render: (T) -> State) { 6 | fun extract(): State = render(model) 7 | 8 | fun move(newModel: T): Component = Component(newModel, render) 9 | } -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_remove.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/cotel/comonadic_ui/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package cotel.comonadic_ui 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/cotel/comonadic_ui/datatypes/Moore.kt: -------------------------------------------------------------------------------- 1 | package cotel.comonadic_ui.datatypes 2 | 3 | class Moore(val state: S, val handle: (E) -> Moore) { 4 | 5 | fun extract(): S = state 6 | 7 | fun extend(f: (Moore) -> A): Moore = 8 | Moore(f(Moore(state, handle))) { update -> 9 | handle(update).extend(f) 10 | } 11 | 12 | fun map(f: (S) -> A): Moore = 13 | Moore(f(state)) { update -> handle(update).map(f) } 14 | 15 | fun duplicate(): Moore> = extend { it } 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/java/cotel/comonadic_ui/datatypes/Store.kt: -------------------------------------------------------------------------------- 1 | package cotel.comonadic_ui.datatypes 2 | 3 | class Store(val state: S, val render: (S) -> V) { 4 | 5 | fun extract(): V = render(state) 6 | 7 | fun extend(f: (Store) -> A): Store = 8 | Store(state) { next -> f(Store(next, render)) } 9 | 10 | fun map(f: (V) -> A): Store = 11 | Store(state) { next -> f(render(next)) } 12 | 13 | fun duplicate(): Store> = extend { it } 14 | 15 | fun move(newState: S): Store = Store(newState, render) 16 | 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /app/src/main/java/cotel/comonadic_ui/Model.kt: -------------------------------------------------------------------------------- 1 | package cotel.comonadic_ui 2 | 3 | import java.util.* 4 | 5 | data class Todo( 6 | val title: String, 7 | val id: UUID = UUID.randomUUID(), 8 | val isCompleted: Boolean = false 9 | ) 10 | 11 | data class TodosState(val todos: List) { 12 | fun addTodo(todo: Todo): TodosState = copy(todos = todos + todo) 13 | 14 | fun updateTodo(todo: Todo): TodosState = copy(todos = todos.map { 15 | if (todo.id == it.id) todo else it 16 | }) 17 | 18 | fun removeTodo(todo: Todo): TodosState = copy(todos = todos.filterNot { it.id == todo.id }) 19 | } 20 | 21 | sealed class TodoInputs 22 | class AddTodo(val todo: Todo) : TodoInputs() 23 | class UpdateTodo(val todo: Todo) : TodoInputs() 24 | class RemoveTodo(val todo: Todo) : TodoInputs() 25 | 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - tools 5 | - platform-tools 6 | - build-tools-28.0.3 7 | - android-22 8 | - android-27 9 | - android-28 10 | - extra-android-support 11 | - extra-google-m2repository 12 | - extra-android-m2repository 13 | - sys-img-armeabi-v7a-android-22 14 | 15 | before_script: 16 | - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a 17 | - emulator -avd test -no-audio -no-window & 18 | - android-wait-for-emulator 19 | - adb shell settings put global window_animation_scale 0 & 20 | - adb shell settings put global transition_animation_scale 0 & 21 | - adb shell settings put global animator_duration_scale 0 & 22 | - adb shell input keyevent 82 & 23 | 24 | script: ./gradlew connectedAndroidTest 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 17 | 18 |