Skip to content

Commit

Permalink
Version 1.1.0 is here
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor-blue committed Oct 4, 2021
1 parent cbeb899 commit 2bd5b05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ allprojects {
}
dependencies {
implementation 'com.github.doctor-blue:compose-navigation:1.0.0'
implementation 'com.github.doctor-blue:compose-navigation:1.1.0'
}
```

Expand Down Expand Up @@ -44,6 +44,8 @@ data class Screen2Argument(val number: Int = -1) : Argument
```
### Step 3: Setup your navigation
- Same as using navigation component, but at the composable function you can give ComposeScreen and Argument object, let me help you with the rest.
- Support get argument from Bundle or SavedStateHandle. If Bundle or SavedStateHandle object doen't contains key argument will be default of Argument object

```kotlin
package com.devcomentry.composenavigation

Expand All @@ -56,7 +58,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import com.devcomentry.composenavigation.ui.screen.*
import com.devcomentry.lib.composable
import com.devcomentry.lib.getParamFromArg
import com.devcomentry.lib.from

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -83,9 +85,10 @@ class MainActivity : AppCompatActivity() {

composable(Screen.Screen2, Screen2Argument()) {
// get data from arguments
Screen2(
it.arguments?.getParamFromArg(Screen2Argument()) as Screen2Argument
)
it.arguments?.let { bundle->
val argument = Screen2Argument().from(bundle)
Screen2(argument)
}
}

}
Expand Down Expand Up @@ -116,12 +119,15 @@ class MainActivity : AppCompatActivity() {


### Note
- You can get Argument object from arguments (Instance of Bundle) like example above. Or get data from SavedStateHandle like this

- You can get Argument object from arguments (Instance of Bundle) like example above.
```kotlin
(savedStateHandle.get(Screen2Argument()) as Screen2Argument).let { arg ->

}
val argument = Screen2Argument().from(bundle)
// use your argument
```
- Or get data from SavedStateHandle like this
```kotlin
val argument = Screen2Argument().from(savedStateHandle)
// use your argument
```
## Want more an example?
- See [Note app](https://github.com/doctor-blue/clean-architecture-jetpack-compose-note-app-android)
Expand Down
4 changes: 2 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0.0"
versionName "1.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -76,7 +76,7 @@ afterEvaluate {
// You can then customize attributes of the publication as shown below.
groupId = 'com.devcomentry.composenavigation'
artifactId = 'final'
version = '1.0.0'
version = '1.1.0'
}
}
}
Expand Down

0 comments on commit 2bd5b05

Please sign in to comment.