
Facilitates implementation of the Presentation Layer, focusing on state management, lifecycle awareness, navigation, and state persistence. Supports hierarchical view composition and messaging between components.
Premo is a Kotlin Multiplatform library that helps to implement the Presentation Layer and share it on Android, iOS, Desktop and Web. Focus on writing logic instead of solving common and boring UI related issues.
Here are some key features:
At the same time, the library does not depend on:
Navigation module implements the following commonly used navigators:
StackNavigator — organizes child presentation models in a stack and navigate between them.SetNavigator — can be used for tabs, bottom navigation, navigation drawer.MasterDetailNavigator — allows to implement an adaptive layout to show one pane or two panes side-by-side.DialogNavigator — helps to show a dialog and wait for the result from itThe library is based on the ideas of the Presentation Model pattern described by Martin Fowler. The Presentation Model stores the state for presentation and coordinates with the domain model layer.
In practice, you will have not only one Presentation Model, but a composition of child Presentation Models. At the base, there will be a root Presentation Model, from which a tree of children will grow. Children can be pushed into the Stack Navigator, thus organizing the navigation stack.
Such a tree composition is well suited for a hierarchical view as well as for a composition of functions from declarative UI frameworks.
One interesting feature of the tree is that the child keeps a reference to the parent. This allows for messaging between Presentation Models. For example, when some event occurs in a child that requires a reaction from the parent. In this case, the child can send a message towards the root for one of the parents to handle it.
Navigation commands can be the such event. A Child PM sends a message and then its Parent PM can intercept this message and push the next Child PM into the Stack Navigator.
This way of navigation has several advantages:
Add to the root gradle script:
allprojects {
repositories {
mavenCentral()
}
}Add dependencies to the shared multiplatform module:
kotlin {
sourceSets {
commonMain {
dependencies {
api("me.dmdev.premo:premo:<latest_version>")
api("me.dmdev.premo:premo-navigation:<latest_version>")
api("me.dmdev.premo:premo-saver-json:<latest_version>")
}
}
commonTest {
dependencies {
implementation("me.dmdev.premo:premo-test:<latest_version>")
}
}
}
}Attention! The library is in the pre-release alpha version. Stable work and backward compatibility are not guaranteed. API may be changed in the future.
Sample demonstrates:
The MIT License (MIT)
Copyright (c) 2020-2024 Dmitriy Gorbunov (dmitriy.goto@gmail.com)
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.
Premo is a Kotlin Multiplatform library that helps to implement the Presentation Layer and share it on Android, iOS, Desktop and Web. Focus on writing logic instead of solving common and boring UI related issues.
Here are some key features:
At the same time, the library does not depend on:
Navigation module implements the following commonly used navigators:
StackNavigator — organizes child presentation models in a stack and navigate between them.SetNavigator — can be used for tabs, bottom navigation, navigation drawer.MasterDetailNavigator — allows to implement an adaptive layout to show one pane or two panes side-by-side.DialogNavigator — helps to show a dialog and wait for the result from itThe library is based on the ideas of the Presentation Model pattern described by Martin Fowler. The Presentation Model stores the state for presentation and coordinates with the domain model layer.
In practice, you will have not only one Presentation Model, but a composition of child Presentation Models. At the base, there will be a root Presentation Model, from which a tree of children will grow. Children can be pushed into the Stack Navigator, thus organizing the navigation stack.
Such a tree composition is well suited for a hierarchical view as well as for a composition of functions from declarative UI frameworks.
One interesting feature of the tree is that the child keeps a reference to the parent. This allows for messaging between Presentation Models. For example, when some event occurs in a child that requires a reaction from the parent. In this case, the child can send a message towards the root for one of the parents to handle it.
Navigation commands can be the such event. A Child PM sends a message and then its Parent PM can intercept this message and push the next Child PM into the Stack Navigator.
This way of navigation has several advantages:
Add to the root gradle script:
allprojects {
repositories {
mavenCentral()
}
}Add dependencies to the shared multiplatform module:
kotlin {
sourceSets {
commonMain {
dependencies {
api("me.dmdev.premo:premo:<latest_version>")
api("me.dmdev.premo:premo-navigation:<latest_version>")
api("me.dmdev.premo:premo-saver-json:<latest_version>")
}
}
commonTest {
dependencies {
implementation("me.dmdev.premo:premo-test:<latest_version>")
}
}
}
}Attention! The library is in the pre-release alpha version. Stable work and backward compatibility are not guaranteed. API may be changed in the future.
Sample demonstrates:
The MIT License (MIT)
Copyright (c) 2020-2024 Dmitriy Gorbunov (dmitriy.goto@gmail.com)
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.