Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved existed topics and added new. Also added github link and changed structure #50

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Modo
# [Modo](https://ikarenkov.github.io/Modo) - state-based Jetpack Compose navigation

[![Maven Central](https://img.shields.io/maven-central/v/com.github.terrakok/modo-compose)](https://repo1.maven.org/maven2/com/github/terrakok)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -30,6 +30,10 @@ Modo is a simple and convenient state-base navigation library for Jetpack Compos
</tr>
</table>

# [Project website](https://ikarenkov.github.io/Modo)

Check out our website to get the most up-to-date information about the library.

## The Main idea

* `NavigationState` defines UI
Expand Down
12 changes: 10 additions & 2 deletions Writerside/cfg/buildprofiles.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<buildprofiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd">

<build-profile instance="modo-docs">
<variables>
<noindex-content>false</noindex-content>
<product-web-url>https://github.com/ikarenkov/Modo</product-web-url>

<enable-browser-edits>true</enable-browser-edits>
<browser-edits-url>https://github.com/ikarenkov/Modo/blob/dev/Writerside/</browser-edits-url>

<showDownloadButton>true</showDownloadButton>
<download-title>GitHub</download-title>
<download-page>%github_url%</download-page>
</variables>
</build-profile>

Expand Down
3 changes: 1 addition & 2 deletions Writerside/cfg/glossary.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE terms SYSTEM "https://resources.jetbrains.com/writerside/1.0/glossary.dtd">
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE terms SYSTEM "https://resources.jetbrains.com/writerside/1.0/glossary.dtd">
<terms>
<term name="parcelize">The kotlin-parcelize plugin provides a Parcelable implementation generator. When you annotate a class with @Parcelize, a
Parcelable implementation is automatically generated.
Expand Down
13 changes: 13 additions & 0 deletions Writerside/codeSnippets/OverviewSampleScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@Parcelize
class SampleScreen(
override val screenKey: ScreenKey = generateScreenKey()
) : Screen {

@Composable
override fun Content(modifier: Modifier) {
Text(
text = "Hello, Modo! Screen №$screenIndex",
modifier = modifier
)
}
}
Binary file added Writerside/images/coreConcepts/sample_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions Writerside/modo-docs.tree
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

<instance-profile name="Modo docs" id="modo-docs" start-page="ModoOverview.md">

<toc-element topic="ModoOverview.md" />
<toc-element topic="QuickStartGuide.md" />
<toc-element topic="Core-concepts.md" />
<toc-element topic="Modo-and-DI.md" />
<toc-element topic="How-to-integrate-modo-to-your-app.md" />
<toc-element topic="ModoOverview.md" >
<toc-element topic="QuickStartGuide.md" />
<toc-element topic="Core-concepts.md" />
<toc-element topic="How-to-integrate-modo-to-your-app.md" />
</toc-element>
<toc-element topic="Features.md" >
<toc-element topic="StackScreen.md" />
<toc-element topic="Modo-and-DI.md" />
<toc-element topic="Screen-effects.md" />
</toc-element>
<toc-element topic="Screen-model-and-view-model.md" />
<toc-element topic="Community-and-contribution.md" />
</instance-profile>
39 changes: 38 additions & 1 deletion Writerside/topics/Community-and-contribution.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# Community and contribution

[//]: # (TBD)
Modo is a community-driven project, and we welcome your contributions! Currently it is developing primary by
me ([Igor Karenkov](https://github.com/ikarenkov)). We
believe in the power of collaboration and are excited to see how you can
help us make Modo even better.

> Modo was started as a POC of state-driven navigation for Fragments by [Konstantin Tskhovrebov](https://github.com/terrakok). Then the support of
> Jetpack Compose was added by [Alexey Ershov](https://github.com/alaershov) and finalized by [Igor Karenkov](%ikarenkov_github_url%) (me). I've been
> developing Modo for a while and used it in my personal and work projects, so we with [Konstantin Tskhovrebov](https://github.com/terrakok) decided
> to
> transfer this project to my personal GitHub. Currently, I'm the main maintainer of Modo.

{ style="note" }

## Join the Conversation:

- [Telegram Group (RU)](https://t.me/Cicerone_RUS): Connect with other Modo users, ask questions, share your experiences, and discuss new features.
This is a great place to get help, share your ideas, and stay up-to-date with the latest developments.
- If you are seeking for english-speaking community, please [write to me](https://t.me/karenkovigor) and emphasize that need. We are ready to create a
new group for you.

## Contribute to Modo:

[GitHub](%github_url%): We encourage you to contribute to Modo by:

- Reporting issues: If you encounter any bugs or have suggestions for improvements, please [open an issue](%github_url%issues) on GitHub.
- Submitting pull requests: If you have code contributions, such as bug fixes, new features, or documentation improvements, feel free to submit a pull
request.
- Improving documentation: Help us make Modo easier to use by contributing to the documentation. Each page has an "Edit page" link on top of it. You
can improve existing documentation or write new guides and tutorials.

## Why Contribute?

- Enhance the library: Your contributions directly improve Modo for everyone.
- Learn and grow: Contributing to an open-source project is a great way to learn new skills and gain experience.
- Be part of a community: Join a vibrant community of developers who are passionate about Jetpack Compose and navigation.

**We appreciate all contributions, no matter how big or small!**
**Let's build a better Modo together!**
32 changes: 31 additions & 1 deletion Writerside/topics/Core-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@
Modo is a state-based navigation library for jetpack compose. It represents UI as a structure of `Screen`s and `ContainerScreen`s (which is an
implementation of `Screen`).

![diagram_1.png](diagram_1.png){ height = 400 }
<include from="snippets.topic" element-id="under_develop_note"/>

<include from="snippets.topic" element-id="navigation_is_a_graph"/>

## Screen

`Screen` is a basic unit of UI. It displays content defined in overridden `fun Content(modifier: Modifier)`

```kotlin
```

{ src="SampleScreen.kt" include-lines="1-20"}

### Screen key

Each screen is identified by `ScreenKey` - a unique key that represents the screen.
This key is widely used in internal implementation. It is required to be unique per a screen, even after process death. For this you must use
build-in `generateScreenKey` function.

### Arguments

To pass arguments - use parcelable constructor parameters.

### Saving and restoring

Each screen is `Parcelable`, that helps to save and restore it during lifecycle changes. Use <tooltip term="parcelize">
parcelable</tooltip> [gradle plugin](https://developer.android.com/kotlin/parcelize) and `@Parcelable` annotation to generate `Parcelable`
implementation on the fly.

It's vital to use build-in function like `rememberRootScreen` to integrate Modo with your application. Read [](How-to-integrate-modo-to-your-app.md)
for details.

## Container Screen

Expand Down
20 changes: 20 additions & 0 deletions Writerside/topics/Features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Features

The list of available features in Modo:

<include from="snippets.topic" element-id="under_develop_note"/>

<table>
<tr><td>Feature</td><td>Status</td><td>Source/Docs</td><td>Sample</td></tr>
<tr><td><a href="StackScreen.md">Stack navigation</a></td><td>✅</td><td><a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/stack/StackScreen.kt">StackScreen</a>, <a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/stack/StackActions.kt">build-in commands</a></td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/containers/SampleStack.kt">SampleStack</a>, <a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/stack/StackActionsScreen.kt">sample</a> of navigation actions</td></tr>
<tr><td>Multi screen navigation</td><td>✅</td><td><a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/multiscreen/MultiScreen.kt">MultiScreen</a>, <a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/multiscreen/MultiScreenActions.kt">build-in commands</a></td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/containers/SampleMultiScreen.kt">SampleMultiscreen</a></td></tr>
<tr><td>Dialogs</td><td>✅</td><td><a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/DialogScreen.kt">DialogScreen</a></td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/dialogs/DialogsPlayground.kt">Dialogs playground</a></td></tr>
<tr><td>Arguments</td><td>✅</td><td>Arguments can be passed as constructor parameter of Screen.</td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/MainScreen.kt">MainScreen</a></td></tr>
<tr><td>Animation</td><td>✅</td><td><a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/animation/ScreenTransitions.kt">ScreenTransition</a>, <a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/animation/StackTransitionType.kt">helpers for stack screen transition</a></td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/containers/SampleStack.kt">SampleStack</a></td></tr>
<tr><td>Android lifecycle support</td><td>✅</td><td><a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/android/ModoScreenAndroidAdapter.kt">ModoScreenAndroidAdapter</a> connect Modo with android-related features. You can safely use LocalLifecycleOwner and other fun inside Screen's. To correctly observe screen lifecycle it's recommender to use <code>LifecycleScreenEffect</code></td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/MainScreen.kt">MainScreen</a></td></tr>
<tr><td>Android ViewModel support</td><td>✅</td><td><a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/android/ModoScreenAndroidAdapter.kt">ModoScreenAndroidAdapter</a> connect Modo with android-related features. You can safely use <code>viewModel</code> and other fun inside Screen's.</td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/viewmodel/AndroidViewModelSampleScreen.kt">AndroidViewModelSampleScreen.kt</a></td></tr>
<tr><td>Activity and fragment integration</td><td>✅</td><td>Use <code>rememberRootScreen</code> inside <code>Fragment</code> or <code>Activity</code>. These functions are declared in <a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/Modo.kt">Modo</a> and automatically handle saving and restoring during <code>Activity</code> lifecycle and process death.</td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/ModoSampleActivity.kt">ModoSampleActivity</a>, <a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/fragment/ModoFragment.kt">ModoFragment.kt</a>, <a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/ModoLegacyIntegrationActivity.kt">ModoLegacyIntegrationActivity.kt</a></td></tr>
<tr><td>Activity and process death handling</td><td>✅</td><td>Automatically provided by <code>Fragment</code> and <code>Activity</code> Modo integration. For more details take a look to</td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/ModoSampleActivity.kt">ModoSampleActivity</a>, <a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/fragment/ModoFragment.kt">ModoFragment.kt</a></td></tr>
<tr><td>Screen effects</td><td>✅</td><td>You can use <code>LaunchedScreenEffect</code> and <code>DisposableScreenEffect</code> analogies for <code>Screen</code>, it's linked to life time of a <code>Screen</code>. There is also <code>LifecycleScreenEffect</code> for easy observing lifecycle. See <a href="%github_code_url%modo-compose/src/main/java/com/github/terrakok/modo/lifecycle/ScreenEffects.kt">ScreenEffects</a> for details.</td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/ScreenEffectsSampleScreen.kt">ScreenEffectsSampleScreen.kt</a></td></tr>
<tr><td>Pager and LazyList integration</td><td>✅</td><td>You can create custom <code>ContainerScreen</code> and use internal <code>Screen</code> inside <code>Vertical/HorizontalPager</code> and <code>LazyRow/Column</code>. It's vital to define <code>key = {}</code> lambda with <code>InternalContent</code> for correct intagration. For more details take a look to the samples. <a href="%github_code_url%modo-compose%2Fsrc%2Fmain%2Fjava%2Fcom%2Fgithub%2Fterrakok%2Fmodo%2Flazylist%2FLazyListUtils.kt">LazyListUtils</a></td><td><a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/containers/StackInLazyColumnScreen.kt">StackInLazyColumnScreen.kt</a>, <a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/containers/HorizontalPagerScreen.kt">HorizontalPagerScreen.kt</a>, <a href="%github_code_url%sample/src/main/java/com/github/terrakok/modo/sample/screens/containers/custom/RemovableItemContainerScreen.kt">RemovableItemContainerScreen.kt</a></td></tr>
</table>
12 changes: 7 additions & 5 deletions Writerside/topics/How-to-integrate-modo-to-your-app.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# How to integrate modo into your app

<link-summary>This topic provides guide for available app integrations. It also describes explains some details of the implementation.</link-summary>

To provide correctness of navigation, Modo requires usage of build-in functions for integration.
To intagrate Modo to your app you have 2 approaches:
To integrate Modo to your app you have 2 approaches:

* `rememberRootScreen` - convinient intagration to `Activity` or `Fragment`. You call it inside `setContent` function.
* `rememberRootScreen` - convenient integration to `Activity` or `Fragment`. You call it inside `setContent` function.
* `Modo.getOrCreateRootScreen`, `Modo.save` and `Modo.onRootScreenFinished` - for manual integration.

> `rememberRootScreen` and `Modo.getOrCreateRootScreen` return the same instance of `RootScreen` in the same process, so you can safelly inject it
> `rememberRootScreen` and `Modo.getOrCreateRootScreen` return the same instance of `RootScreen` in the same process, so you can safely inject it
> into your DI
> container.

{ style="note" }

## Convenient integration to Activity and Fragment

`rememberRootScreen` is a convinient way to integrate Modo to your `Activity` or `Fragment`. It automatically handles saving and restoring
`rememberRootScreen` is a convenient way to integrate Modo to your `Activity` or `Fragment`. It automatically handles saving and restoring
of `RootScreen` during `Activity` lifecycle and process death.

To use modo inside your Activity or Fragment you need:
Expand Down Expand Up @@ -49,7 +51,7 @@ the [ModoLegacyIntegrationActivity](%github_code_url%sample/src/main/java/com/gi
sample project for an example.

- `Modo.getOrCreateRootScreen` - initializes `RootScreen` with provided screen's or returns the existing instance.
- `Modo.save` - saves the current state of `RootScreen` and othe internal data (like `screenCounterKey`) to the bundle for further restore
- `Modo.save` - saves the current state of `RootScreen` and other internal data (like `screenCounterKey`) to the bundle for further restore
in `Modo.getOrCreateRootScreen`.
- `Modo.onRootScreenFinished` - should be called when `RootScreen` is no longer needed, f.e. at the finish of the Activity or the Fragment. It removes
the instance of `RootScreen` from the
Expand Down
6 changes: 4 additions & 2 deletions Writerside/topics/Modo-and-DI.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Modo and DI

You can safelly inject `Screen` into your DI container, but it must be removed from DI as soon as `Screen` is removed from hierarchy. You can use
build-in screen effects for this purpose.
You can safely inject `Screen` into your DI container, but it must be removed from DI as soon as `Screen` is removed from hierarchy. You can use
build-in screen effects for this purpose.

<include from="snippets.topic" element-id="under_develop_note"/>
Loading