From c9675ec31a799273ea0069f0004232f1721d2191 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 7 Nov 2023 14:14:40 +0600 Subject: [PATCH] partially done navigation/getting-started --- docs/navigation/getting-started.md | 32 ++++++++++++++++++++++++------ docs/navigation/index.md | 2 ++ mkdocs.yml | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/navigation/getting-started.md b/docs/navigation/getting-started.md index b47cca8..a2b2424 100644 --- a/docs/navigation/getting-started.md +++ b/docs/navigation/getting-started.md @@ -1,4 +1,4 @@ -# Getting started +# Getting started (TBD) [![Maven Central](https://img.shields.io/maven-central/v/dev.inmo/navigation.core?label=navigation&style=flat-square)](https://github.com/InsanusMokrassar/navigation) @@ -12,11 +12,9 @@ Traditionally, you need to add dependency to your project. Currently, there are | `Core` | Only necessary tools for your projects | `implementation "dev.inmo:navigation.core:$navigation_version"` | | `MVVM` | Model-View-ViewModel architecture tools + `Core` components | `implementation "dev.inmo:navigation.mvvm:$navigation_version"` | -# Initialization +# Get started -After you have added your dependency, you should initialize navigation. - -There are several important things: +After you have added your dependency, you should initialize navigation. There are several important things: 1. `Config` - it is an instance of any class which extending the `NavigationNodeDefaultConfig` in common case 2. `Factory` - usually object which may create a node or some required part for node @@ -32,6 +30,17 @@ data class MainConfig( ) : NavigationNodeDefaultConfig ``` +Both `JS` and `Android` platforms require `ViewModel` for their `MVVM` node variants, but it can be common as well as +`MainConfig`: + +```kotlin +class MainViewModel( + node: NavigationNode +) : ViewModel( + node +) +``` + ### JS part ```kotlin @@ -50,7 +59,7 @@ class MainNode( class MainNodeView( config: MainConfig, chain: NavigationChain, -) : View( +) : View( config, chain ) { @@ -75,6 +84,10 @@ object MainNodeFactory : NavigationNodeFactory { } ``` +--- + +Data below is under TBD + ### Android In Android there is one important note: you will not directly work with nodes. In fact it will be required to create @@ -86,8 +99,15 @@ class MainFragment : NodeFragment() { // Your code // Here will be available: node with type `AndroidFragmentNode`, config: `MainConfig` } +// MVVM Variant +class MainViewFragment : ViewFragment() { + // Will be available also `viewModel` via koin `lazyInject` + override val viewModelClass + get() = MainViewModel::class +} ``` + Initialization is different on the platforms, so, lets take a look at each one. ## JS diff --git a/docs/navigation/index.md b/docs/navigation/index.md index ff0bb2d..c858a5f 100644 --- a/docs/navigation/index.md +++ b/docs/navigation/index.md @@ -1,5 +1,7 @@ # Navigation +**This library uses koin as preferred DI in MVVM part** + Navigation is a library for simple management for your app views (or some other logics). In this library there are several important terms: diff --git a/mkdocs.yml b/mkdocs.yml index 82f63f7..0cc278d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -47,6 +47,7 @@ nav: - 'kslog/logging.md' - 'Navigation': - 'navigation/index.md' + - 'navigation/getting-started.md' use_directory_urls: false