Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoankit authored Jan 27, 2024
1 parent f84bb40 commit 45c7629
Showing 1 changed file with 26 additions and 56 deletions.
82 changes: 26 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Jetpack Compose Coachmark/Onboarding Library

[![](https://jitpack.io/v/pseudoankit/coachmark.svg)](https://jitpack.io/#pseudoankit/coachmark)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.pseudoankit/coachmark/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.pseudoankit/coachmark)
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="License" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/></a>


Expand All @@ -21,88 +21,57 @@ Now provide seamless onboarding experience to end users with just few lines of c

## Getting Started

In your settings.gradle

```
dependencyResolutionManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

In your module's build.gradle

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.pseudoankit/coachmark/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.pseudoankit/coachmark)
```
dependencies {
implementation 'com.github.pseudoankit:coachmark:<version>'
implementation 'io.github.pseudoankit:coachmark:<latest_version🔝>'
}
```

## Usage

Define Keys for all coachmarks
```
enum class Keys { Text1, Text2 }
```
public enum class Keys { Text1, Text2 }

At root level make sure to wrap with UnifyCoachmark
```
UnifyCoachmark(
tooltip = { Tooltip(it) },
tooltip = { /* Declare Tooltip Source code below ⏬ */ Tooltip(it) },
overlayEffect = DimOverlayEffect(Color.Black.copy(alpha = .5f)),
onOverlayClicked = { OverlayClickEvent.GoNext }
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Content() // Source code below ⏬
}
```

Enable coachmark for the required views with `enableCoachMark`, To access `enableCoachMark` you need to be inside `CoachmarkScope`
If you are not in `CoachmarkScope` then get access to it via LocalCoachMarkScope.current
```
@Composable
private fun Content() {
with(LocalCoachMarkScope.current) { // not needed if you are already in `CoachmarkScope`
Text(
text = "Will show tooltip 1",
modifier = Modifier
.enableCoachMark(
key = Keys.Text1,
toolTipPlacement = ToolTipPlacement.End,
highlightedViewConfig = HighlightedViewConfig(
shape = HighlightedViewConfig.Shape.Rect(12.dp),
padding = PaddingValues(8.dp)
)
)
.padding(16.dp),
color = Color.Black
)
Text(
text = "Will show tooltip 2",
modifier = Modifier
.enableCoachMark(
key = Keys.Text2,
toolTipPlacement = ToolTipPlacement.End,
key = Keys.Text1, // unique that we declared above
toolTipPlacement = placement,
highlightedViewConfig = HighlightedViewConfig(
shape = HighlightedViewConfig.Shape.Rect(12.dp),
padding = PaddingValues(8.dp)
)
)
.padding(16.dp),
color = Color.Black
)
Button(
onClick = {
show(Keys.Text1)
},
modifier = Modifier.align(Alignment.CenterHorizontally)
) {
Text(text = "Highlight1")
}
Button(
onClick = {
show(Keys.Text1, Keys.Text2)
},
modifier = Modifier.align(Alignment.CenterHorizontally)
) {
Text(text = "Highlight 1 & 2")
}
}
}
```

Define tooltip view (Tootip is showing when view is highlighted currently)
```
@Composable
private fun Tooltip(key: CoachMarkKey) {
when (key) {
Expand All @@ -111,7 +80,7 @@ private fun Tooltip(key: CoachMarkKey) {
Text(text = "Highlighting Text1", color = Color.White)
}
}
Keys.Text2 -> {
Balloon(arrow = Arrow.Start()) {
Text(text = "Highlighting Text2", color = Color.White)
Expand All @@ -121,6 +90,7 @@ private fun Tooltip(key: CoachMarkKey) {
}
```


Inspired from <a href = "https://github.com/svenjacobs/reveal">reveal</a> library

# License
Expand Down

0 comments on commit 45c7629

Please sign in to comment.