Multiplatform Kotlin application of KotlinAcademy
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea Improve libraries structure Jul 16, 2018
android Merge pull request #42 from jmfayard/gradle-kotlin-dsl-libs Oct 9, 2018
art Update Web and Desktop demo Dec 18, 2017
backend Fix tests flaw: dependency on close time Nov 22, 2018
buildSrc Convert two build.gradle files to "implementation Libs.xxx" Oct 3, 2018
common-client-js Fix node plugin Sep 29, 2018
common-client-jvm New native plugin + use common coroutines Aug 11, 2018
common-client-native Fix iOS Aug 15, 2018
common-client Clean-up and test fix Sep 29, 2018
common-js First iOS version using common module as a library. Very messy! Jul 5, 2018
common-jvm First iOS version using common module as a library. Very messy! Jul 5, 2018
common-native New native plugin + use common coroutines Aug 11, 2018
common Web: Add Snippet type Aug 31, 2018
commonImages Bump libraries and add delete icon Apr 19, 2018
desktop Fix Android, Wear, Desktop and Web Jul 21, 2018
gradle/wrapper New native plugin + use common coroutines Aug 11, 2018
ios Fix iOS Aug 15, 2018
web change from kot. to kt. academy Nov 22, 2018
.gitignore Merge remote-tracking branch 'origin/master' into ios Jul 5, 2018
.travis.yml Fix Travis Apr 30, 2018
LICENSE Init Nov 17, 2017
Procfile Clean-up Dec 1, 2017
README.md Clean-up and test fix Sep 29, 2018
build.gradle Add my plugin gradle-kotlin-dsl-libs Oct 3, 2018
dependencies.gradle Bump versions of web libraries, fix puzzler submission Aug 12, 2018
gitcommit.sh Serialization error: Problem with object deserialization Mar 20, 2018
gradle.properties Bump versions Jul 5, 2018
gradlew Init Nov 17, 2017
gradlew.bat Init Nov 17, 2017
imagesShare.gradle Bump libraries and add delete icon Apr 19, 2018
jvmconfig.gradle Clean-up in build configs Jan 26, 2018
privacy_policy.md Add privacy policy Sep 29, 2018
settings.gradle Change name to Kot. Academy Aug 20, 2018
testing Backend: Do not send click_action to Android to open main activity + … Apr 29, 2018
travis_start_emulator.sh Travis: Run desktop Mar 31, 2018

README.md

KotAcademy application

Build Status codebeat badge Analytics Analytics

This is an example how multiplatform development can be used to effectively extract and reuse logic. It contains multiple clients that implement the same logic and single backend. The only common part for all this project is Data Model, so it is placed in common module which is shared among all the platforms. All client applications are based on MVP (Model-View-Presenter). Presenters are common for all of them and they are placed in common-client module. It contains all business logic and is well tested. Views are implemented separately for every platform. Presenters are using Data Model, and communicating with Views from behind the interfaces that are placed in common-client module. On the other side Presenters are communicating with repositories (network API, databases etc.) which are hidden behind an interfaces (for unit-testing purposes) and specified as an expected declarations which have actial declaration in platform modules (common-client-jvm and common-client-js).

Application is composing Kotlin Kotlin Academy and presenting them together. It also allows giving the feedback this article or to Kotlin Academy.

Here is the status of planned clients:

  • Android mobile - DONE (Play)
  • Web - DONE (Demo)
  • Desktop - DONE in TornadoFX
  • Android Wear - DONE
  • iOS - DONE in Swift and Kotlin/Native
  • Firefox plugin - Not yet started
  • Chrome plugin - Not yet started

We will really appreciate help in any of this areas.

Backend

To run desktop application, just excecute in the root folder of the project:

./gradlew :backend:run

Android

Android client is used to display list of article. It uses common-client logic to display loading, refreshing and obtaining list of elements. Here are some screens:

If you open project in Android Studio, it will find both Android mobile and Android watch projects. This way you can easily run the projects.

Backend URL depend on build type. Application run in debug mode will use localhost as base URL so it will not work unless you run backend first. Applicatin run in release mode is production backend as a API base URL.

If you don't have Android SDK and you don't want to work on Android module then you can change gradle.properties property INCLUDE_ANDROID to false. Alternatively you can add -Dorg.gradle.project.INCLUDE_ANDROID=false to your gradle build task.

Web

Web client with the same logic like Android app. It is implemented in React.

Demo is here on Heroku.

To run web, you should use following command:

./gradlew :web:run

Desktop

Desktop TornadoFX client. Designed by Edvin Syse, creator of TornadoFX. Still during designing process.

To run desktop application, just excecute in the root folder of the project:

./gradlew :desktop:run

Warning: It is not working with OpenJDK because it doesn't include JavaFX by default. You need to use Oracle JDK.

Tests

Business logic, especially while it is shared among all the platforms, is unit-tested. Tests can be found on common-client module.

Run them using following commands:

./gradlew :common-client-jvm:test
./gradlew :common-client-js:test

Heroku

To push on Heroku, you need to specify following GRADLE_TASK:

heroku config:set GRADLE_TASK="-Dorg.gradle.project.INCLUDE_ANDROID=false serverPrepare"

Contribution

A lot needs to be done in this project. The mission is to to build solid massive-multiplatform project. See board to check out how you can help us. If you want to chellange yourself and face one of this tasks then join project, assing it to yourself, move to "In progress" and start doing. Don't bother to ask if you are not sude about something. We are here to learn and help learn.

Images sharing

All images are located in commonImages folder. If you want to add image to some platforms, place imege there and add this image to platform include in imagesShare.gradle file. Then use:

./gradlew shareImages

To clean all the previous images (needed when you are deleting some images) use following task:

./gradlew cleanImages

Credits

Special credits to below repositiries which inspired some solutions:

https://github.com/Albert-Gao/kotlin-native-mobile-multiplatform-example/tree/master/platforms/ios

https://bitbucket.org/ivan_vazhnov/mobius_multiplatform/src/9ec77bf4d274?at=master

License

Copyright 2017 Marcin Moskała

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.