Skip to content

Commit 02b16b1

Browse files
authored
docs(README): add installation instructions and update example
1 parent ea9af87 commit 02b16b1

File tree

1 file changed

+72
-14
lines changed

1 file changed

+72
-14
lines changed

README.md

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,86 @@
11
# TopToast
2-
Simple toast library for Jetpack Compose
3-
- ⚠️ 0.0.11 and higher use Material 3
4-
- 👀 You can try TopToast by downloading demo application from [releases](https://github.com/aliernfrog/top-toast-compose/releases)
2+
[![GitHub Packages](https://img.shields.io/github/v/tag/aliernfrog/top-toast-compose?label=GitHub)](https://github.com/aliernfrog/top-toast-compose/packages)
3+
[![JitPack](https://jitpack.io/v/aliernfrog/top-toast-compose.svg)](https://jitpack.io/#aliernfrog/top-toast-compose)
54

6-
## [📁 JitPack](https://jitpack.io/#aliernfrog/top-toast-compose)
7-
[![](https://jitpack.io/v/aliernfrog/top-toast-compose.svg)](https://jitpack.io/#aliernfrog/top-toast-compose)
5+
Toast library for Jetpack Compose
6+
7+
## 👀 Try it out
8+
You can try TopToast by downloading demo application from [releases](https://github.com/aliernfrog/top-toast-compose/releases)
9+
10+
## 📥 Installation
11+
You can get the library from GitHub Packages or JitPack
12+
### GitHub Packages
13+
- Create a GitHub PAT with `read:packages` scope
14+
- Put the PAT and your GitHub username in global/project `gradle.properties`:
15+
```
16+
gpr.user=MyUserName
17+
gpr.key=MyPAT
18+
```
19+
or supply `GITHUB_ACTOR` (username) and `GITHUB_TOKEN` (PAT) in environment variables
20+
- Add maven repository: (Kotlin)
21+
```kts
22+
maven(url = "https://maven.pkg.github.com/aliernfrog/top-toast-compose") {
23+
credentials {
24+
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR")
25+
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
26+
}
27+
}
28+
```
29+
- Add dependency: (Kotlin)
30+
```kts
31+
implementation("aliernfrog:top-toast-compose:<VERSION>")
32+
```
33+
34+
### JitPack
35+
> [!WARNING]
36+
> As JitPack now fails to build with no reason, latest versions available on JitPack are `1.3.4` and `1.3.5-alpha01`.
37+
> It may or may not be updated in the future.
38+
- Add maven repository: (Kotlin)
39+
```kts
40+
maven(url = "https://jitpack.io")
41+
```
42+
- Add dependency: (Kotlin)
43+
```kts
44+
implementation("com.github.aliernfrog:top-toast-compose:<VERSION>")
45+
```
846

947
## 🍞 Example usage
1048
```kotlin
1149
val topToastState = remember {
12-
TopToastState(window.decorView)
50+
TopToastState(
51+
// Required for Android type toasts, you can set it to null and set it later using `setComposeView()`
52+
composeView = window.decorView,
53+
// Used in Android type toasts, you can set it to null and set it later using `setAppTheme()`
54+
appTheme = { toastContent ->
55+
MyAppTheme(toastContent)
56+
}
57+
)
1358
}
1459

1560
Box(
1661
modifier = Modifier.background(MaterialTheme.colorScheme.surface)
1762
) {
18-
Button(
19-
content = {
20-
Text("Click me")
21-
},
22-
onClick = {
23-
topToastState.showToast("This is a toast")
24-
}
25-
)
63+
Column {
64+
Button(
65+
content = {
66+
Text("Click me")
67+
},
68+
onClick = {
69+
// Shows an interactive toast in TopToastHost
70+
topToastState.showToast("This is a toast")
71+
}
72+
)
73+
Button(
74+
content = {
75+
Text("Android toast")
76+
},
77+
onClick = {
78+
// Shows a toast using Android Toast APIs, visible on top of modals and dialogs
79+
// Cannot be interacted with
80+
topToastState.showToast("This is a toast")
81+
}
82+
)
83+
}
2684
TopToastHost(topToastState)
2785
}
2886
```

0 commit comments

Comments
 (0)