{"id":13537350,"url":"https://github.com/dmdevgo/Premo","last_synced_at":"2025-04-02T04:30:33.953Z","repository":{"id":40439958,"uuid":"264552757","full_name":"dmdevgo/Premo","owner":"dmdevgo","description":"Premo helps to implement the presentation layer and share it on Android, iOS, Desktop and Web.","archived":false,"fork":false,"pushed_at":"2024-05-01T19:37:19.000Z","size":7157,"stargazers_count":205,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T15:20:04.033Z","etag":null,"topics":["android","architecture","compose-multiplatform","desktop","ios","jetpack-compose","kotlin","kotlin-multiplatform","mvvm","navigation","pm","presentation-model","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmdevgo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-17T00:19:10.000Z","updated_at":"2025-03-17T10:01:50.000Z","dependencies_parsed_at":"2022-09-17T01:04:07.338Z","dependency_job_id":"2f162bec-cb56-4855-8ed0-2206943652f5","html_url":"https://github.com/dmdevgo/Premo","commit_stats":{"total_commits":353,"total_committers":3,"mean_commits":"117.66666666666667","dds":0.005665722379603388,"last_synced_commit":"b87910649c01abfc0573d2c477e4a54d6d10c6fc"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmdevgo%2FPremo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmdevgo%2FPremo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmdevgo%2FPremo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmdevgo%2FPremo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmdevgo","download_url":"https://codeload.github.com/dmdevgo/Premo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246756827,"owners_count":20828774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","architecture","compose-multiplatform","desktop","ios","jetpack-compose","kotlin","kotlin-multiplatform","mvvm","navigation","pm","presentation-model","swiftui"],"created_at":"2024-08-01T09:00:57.937Z","updated_at":"2025-04-02T04:30:33.931Z","avatar_url":"https://github.com/dmdevgo.png","language":"Kotlin","readme":"# Premo\n\n[![Maven Central](https://img.shields.io/maven-central/v/me.dmdev.premo/premo)](https://search.maven.org/artifact/me.dmdev.premo/premo)\n[![License: MIT](https://img.shields.io/github/license/dmdevgo/premo?color=informational)](https://github.com/dmdevgo/Premo/blob/master/LICENSE)\n![platform-android](https://img.shields.io/badge/platform-android-green)\n![platform-ios](https://img.shields.io/badge/platform-ios-lightgray)\n![platform-jvm](https://img.shields.io/badge/platform-jvm-orange)\n![platform-js](https://img.shields.io/badge/platform-js-yellow)\n![platform-wasm](https://img.shields.io/badge/platform-wasm-red)\n\nPremo 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.\n\nHere are some key features:\n- **State holding** — PresentationModel is a multiplatform version of the ViewModel.\n- **Lifecycle** — PresentationModel is lifecycle aware.\n- **Navigation** — navigate between PresentationModels instead of switching views.\n- **Persistence** — saving and restoring state after recreating a process.\n- **Communication** — send messages from children towards the root PresentationModel.\n\nAt the same time, the library does not depend on:\n- **Architecture** — MVVM, PM, MVI or other.\n- **UI** — Compose, SwiftUI, UIKit, React and other.\n\nNavigation module implements the following commonly used navigators:\n- [`StackNavigator`](/premo-navigation/src/commonMain/kotlin/me/dmdev/premo/navigation/StackNavigator.kt) — organizes child presentation models in a stack and navigate between them.\n- [`SetNavigator`](/premo-navigation/src/commonMain/kotlin/me/dmdev/premo/navigation/SetNavigator.kt) — can be used for tabs, bottom navigation, navigation drawer.\n- [`MasterDetailNavigator`](/premo-navigation/src/commonMain/kotlin/me/dmdev/premo/navigation/MasterDetailNavigator.kt) — allows to implement an adaptive layout to show one pane or two panes side-by-side.\n- [`DialogNavigator`](/premo-navigation/src/commonMain/kotlin/me/dmdev/premo/navigation/DialogNavigator.kt) — helps to show a dialog and wait for the result from it\n\n## Overview\n\nThe library is based on the ideas of the [Presentation Model](https://martinfowler.com/eaaDev/PresentationModel.html) pattern described by Martin Fowler. The Presentation Model stores the state for presentation and coordinates with the domain model layer. \n\nIn 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.\n\nSuch a tree composition is well suited for a hierarchical view as well as for a composition of functions from declarative UI frameworks.\n\n\u003cimg src=\"/docs/images/premo_diagram.jpg\" width=\"500px\"\u003e\n\nOne 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.\n\n\u003cimg src=\"/docs/images/premo_messaging.jpg\" width=\"500px\"\u003e\n\nNavigation 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.\n\nThis way of navigation has several advantages:\n- Relieves the Child PM from the responsibility of what transition to make and allow the parents to decide.\n- Simplifies nested navigation when an event occurs deep in the hierarchy.\n\n## Installation\n\nAdd to the root gradle script:\n```Kotlin\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\nAdd dependencies to the shared multiplatform module:\n```Kotlin\nkotlin {\n    sourceSets {\n        commonMain {\n            dependencies {\n                api(\"me.dmdev.premo:premo:\u003clatest_version\u003e\")\n                api(\"me.dmdev.premo:premo-navigation:\u003clatest_version\u003e\")\n                api(\"me.dmdev.premo:premo-saver-json:\u003clatest_version\u003e\")\n            }\n        }\n\n        commonTest {\n            dependencies {\n                implementation(\"me.dmdev.premo:premo-test:\u003clatest_version\u003e\")\n            }\n        }\n    }\n}\n```\n\n\u003e 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.\n\n## Sample\n\n[Sample](https://github.com/dmdevgo/Premo/tree/master/sample) demonstrates:\n- Sharing presentation logic between Android, iOS, Desktop and Web.\n- Sharing Compose UI between Android, iOS, Desktop and Web.\n- UI on Compose Multiplatform, SwiftUI, React, Compose for Html.\n- Simple Counter.\n- Stack navigation.\n- Bottom navigation with multistack.\n- Master-Detail navigation.\n- Dialog navigation.\n- Saving and restoring the state after killing the process.\n\n\u003cimg src=\"/docs/images/desktop_demo.gif\" width=\"600px\"\u003e\n\u003cimg src=\"/docs/images/android_and_ios_demo.gif\" width=\"600px\"\u003e\n\u003cimg src=\"/docs/images/web_demo.gif\" width=\"600px\"\u003e\n\n## License\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2020-2024 Dmitriy Gorbunov (dmitriy.goto@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":["Libraries","Uncategorized"],"sub_categories":["Architecture","🏗 Architecture","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmdevgo%2FPremo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmdevgo%2FPremo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmdevgo%2FPremo/lists"}