Skip to content

Commit f28c285

Browse files
committed
v0.1.2
1 parent 231d616 commit f28c285

2 files changed

Lines changed: 50 additions & 17 deletions

File tree

README.md

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
<img src="docs/assets/demo_1_2.gif" alt="GuideKit demo showing alternate styling and circular highlights" width="320" />
4242
</p>
4343

44-
<p align="center">
45-
Both demos showcase the same core idea: GuideKit renders polished tours above your real Compose UI while your app provides measured targets and callbacks.
46-
</p>
47-
4844
---
4945

5046
## Installation
@@ -70,32 +66,69 @@ kotlin {
7066

7167
## Quick Start
7268

73-
Measure a target, describe a step, and let GuideKit render the overlay.
69+
Add GuideKit to the **main composable that occupies the full screen**. It does not matter whether your screen uses a `Scaffold`, a `Box`, or another layout. The guide should be placed at the screen's top level so it can draw above all of its content.
70+
71+
### 1. Keep the external values in the parent screen
72+
73+
Store the measured bounds of the composable you want to highlight. This minimal example uses `rememberSaveable` for guide visibility, but you can use any persistence approach you prefer, such as a ViewModel backed by DataStore or a database, to prevent completed guides from appearing again.
7474

7575
```kotlin
76-
@Composable
77-
fun ProductScreen() {
78-
val targets = remember { mutableStateMapOf<String, Rect>() }
79-
var showTour by remember { mutableStateOf(true) }
76+
var targetBounds by remember { mutableStateOf<Rect?>(null) }
77+
var showGuide by rememberSaveable { mutableStateOf(true) }
78+
```
8079

81-
Box(Modifier.fillMaxSize()) {
82-
PrimaryButton(
80+
### 2. Measure the UI you want to highlight
81+
82+
Pass a bounds callback into the child composable that contains the target. Attach `onGloballyPositioned` to the target itself and send its measured bounds back through that callback.
83+
84+
```kotlin
85+
@Composable
86+
fun MainScreenContent(
87+
onTargetBoundsChanged: (Rect?) -> Unit,
88+
modifier: Modifier = Modifier,
89+
) {
90+
Column(modifier) {
91+
Button(
92+
onClick = { /* Your action */ },
8393
modifier = Modifier.onGloballyPositioned { coordinates ->
84-
targets["primary"] = coordinates.boundsInRoot()
94+
onTargetBoundsChanged(coordinates.boundsInRoot())
8595
},
96+
) {
97+
Text("Create item")
98+
}
99+
}
100+
}
101+
```
102+
103+
### 3. Place GuideKit at the full-screen parent level
104+
105+
Place `GuideKit` in the full-size parent composable, after the screen content. The parent owns `targetBounds` and passes its update callback into `MainScreenContent`. This lets a target inside any nested composable send its bounds to the parent without moving the target itself.
106+
107+
```kotlin
108+
@Composable
109+
fun MainScreen() {
110+
var targetBounds by remember { mutableStateOf<Rect?>(null) }
111+
var showGuide by rememberSaveable { mutableStateOf(true) }
112+
113+
Box(Modifier.fillMaxSize()) {
114+
MainScreenContent(
115+
onTargetBoundsChanged = { bounds -> targetBounds = bounds },
116+
modifier = Modifier.fillMaxSize(),
86117
)
87118

88-
if (showTour) {
119+
if (showGuide) {
89120
GuideKit(
90121
steps = listOf(
91122
GuideKitStep(
92-
targetBounds = targets["primary"],
123+
targetBounds = targetBounds,
93124
title = "Create your first item",
94125
description = "Tap here to start a new workflow.",
95126
),
96127
),
97-
onSkipped = { showTour = false },
98-
onFinished = { showTour = false },
128+
// Replace with your persistence update if needed.
129+
onSkipped = { showGuide = false },
130+
onFinished = { showGuide = false },
131+
modifier = Modifier.fillMaxSize(),
99132
)
100133
}
101134
}

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = "io.github.tharukack"
12-
version = "0.1.1"
12+
version = "0.1.2"
1313

1414
kotlin {
1515
androidTarget {

0 commit comments

Comments
 (0)