Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 52938ae

Browse files
authored
Create README.md
1 parent 5d07c1b commit 52938ae

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# karavel
2+
Lightweight navigation library for Compose for Desktop
3+
4+
## Install
5+
6+
1. Add it in your root build.gradle at the end of repositories:
7+
```gradle
8+
allprojects {
9+
repositories {
10+
// ...
11+
maven { url 'https://jitpack.io' }
12+
}
13+
}
14+
```
15+
16+
2. Add the dependency
17+
```
18+
dependencies {
19+
implementation 'com.github.User:Repo:Tag'
20+
}
21+
```
22+
23+
## Usage
24+
```kotlin
25+
import androidx.compose.runtime.Composable
26+
import io.appoutlet.karavel.Page
27+
28+
// 1. Extends the Page class
29+
class MainPage : Page() {
30+
31+
// 2. Override the content() method and annotate it with composable
32+
@Composable
33+
override fun content() {
34+
// ...Page content...
35+
}
36+
}
37+
```
38+
39+
```kotlin
40+
import androidx.compose.desktop.Window
41+
import androidx.compose.material.MaterialTheme
42+
import io.appoutlet.karavel.Karavel
43+
import io.appoutlet.ui.page.MainPage
44+
45+
fun main() = Window {
46+
47+
// 3. Create karavel instance passing the main page as argument
48+
val karavel = Karavel(MainPage())
49+
50+
MaterialTheme {
51+
// 4. Get the current page content
52+
karavel.currentPage().content()
53+
}
54+
}
55+
```
56+
57+
```kotlin
58+
@Composable
59+
override fun content() {
60+
Button(onClick = {
61+
// 5. use the karavel object to navigate
62+
karavel?.navigate(SettingsPage())
63+
}) {
64+
Text("Go to settings page")
65+
}
66+
67+
Button(onClick = {
68+
// 6. use the karavel object to back to the previous screen
69+
karavel?.back()
70+
}) {
71+
Text("Back to previous screen")
72+
}
73+
}
74+
```

0 commit comments

Comments
 (0)