### Basic Reveal Effect Setup in Compose Source: https://context7.com/svenjacobs/reveal/llms.txt Integrate Reveal by initializing RevealCanvas at the top of your composition hierarchy and a Reveal composable on each screen. Elements intended for highlighting are marked with the revealable() modifier and controlled programmatically using RevealState. This setup allows for basic reveal effects triggered by state changes. ```kotlin @Composable fun App() { val revealCanvasState = rememberRevealCanvasState() // Single RevealCanvas at the top level RevealCanvas( modifier = Modifier.fillMaxSize(), revealCanvasState = revealCanvasState, ) { MainScreen(revealCanvasState = revealCanvasState) } } @Composable fun MainScreen(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() val scope = rememberCoroutineScope() // One Reveal per screen Reveal( revealCanvasState = revealCanvasState, revealState = revealState, onRevealableClick = { key -> scope.launch { revealState.hide() } }, onOverlayClick = { key -> scope.launch { revealState.hide() } }, ) { Column { Text( modifier = Modifier.revealable( key = "hello_world", state = revealState, ), text = "Hello World" ) Button( modifier = Modifier.revealable( key = "action_button", state = revealState, ), onClick = { /* action */ } ) { Text("Click Me") } } } // Trigger reveal effect LaunchedEffect(Unit) { delay(1000) revealState.reveal("hello_world") } } ``` -------------------------------- ### Basic Reveal Canvas and Reveal Setup in Compose Source: https://github.com/svenjacobs/reveal/blob/main/README.md Demonstrates the fundamental structure for using `RevealCanvas` and `Reveal` composables. `RevealCanvas` should be a single, top-level instance to render the effect, while `Reveal` instances manage individual revealable items within screens. ```kotlin import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.github.forntoh.kotlin.compose.reveal.* @Composable fun App() { val revealCanvasState = rememberRevealCanvasState() // Single instance that should be at the top of the Compose hierarchy RevealCanvas( modifier = Modifier.fillMaxSize(), revealCanvasState = revealCanvasState, ) { MainScreen(revealCanvasState = revealCanvasState) } } @Composable fun MainScreen(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() // Usually one instance per screen Reveal( revealCanvasState = revealCanvasState, revealState = revealState, onRevealableClick = {}, onOverlayClick = {}, ) { // Contents } } ``` -------------------------------- ### Register Single Composable with Multiple Reveal Keys (Kotlin) Source: https://context7.com/svenjacobs/reveal/llms.txt This example shows how to associate a single UI element with multiple reveal keys, enabling reuse across different contexts. It demonstrates using both a `List` of keys and the varargs syntax for the `revealable` modifier. The snippet also includes an example of how to trigger the reveal of different elements using their associated keys. ```kotlin import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Star import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.arjun.reveal.RevealState import com.arjun.reveal.revealable import com.arjun.reveal.RevealShape import kotlinx.coroutines.launch import kotlinx.coroutines.delay @Composable fun MultipleKeysExample(revealState: RevealState) { val scope = rememberCoroutineScope() Column { // Single element with multiple keys Button( modifier = Modifier.revealable( keys = listOf("intro_button", "tutorial_step_5", "feature_showcase"), state = revealState, shape = RevealShape.RoundRect(8.dp), ), onClick = { } // Internal onClick is not needed when using revealable onClick ) { Text("Multi-purpose Button") } // Vararg syntax for multiple keys Icon( modifier = Modifier.revealable( "icon_intro", "icon_tutorial", "icon_highlight", state = revealState, ), imageVector = Icons.Default.Star, contentDescription = null ) // Reveal any of the keys Button(onClick = { scope.launch { revealState.reveal("intro_button") // Shows first button delay(2000) revealState.reveal("icon_tutorial") // Shows icon } }) { Text("Start Tutorial") } } } ``` -------------------------------- ### Android View Compatibility Example using Reveal Effect in Kotlin Source: https://context7.com/svenjacobs/reveal/llms.txt This Kotlin code demonstrates how to use `FullscreenRevealOverlayInserter` to enable the reveal effect in a mixed Android View and Compose application. It shows how to integrate a Compose UI and a legacy Android Button within the `RevealCanvas`. The `revealableOffset` might need adjustment based on your app's layout. ```kotlin import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import com.revealcrypt.reveal.core.RevealCanvas import com.revealcrypt.reveal.core.RevealCanvasState import com.revealcrypt.reveal.core.RevealShape import com.revealcrypt.reveal.core.RevealState import com.revealcrypt.reveal.core.composable.Reveal import com.revealcrypt.reveal.core.composable.Revealable import com.revealcrypt.reveal.core.composable.Revealable.Layout import com.revealcrypt.reveal.core.composable.modifier.revealable import com.revealcrypt.reveal.core.composable.overlayinserter.FullscreenRevealOverlayInserter import com.revealcrypt.reveal.core.util.rememberRevealCanvasState import com.revealcrypt.reveal.core.util.rememberRevealState @Composable fun AndroidCompatibilityExample() { val revealCanvasState = rememberRevealCanvasState() // Use FullscreenRevealOverlayInserter for mixed View/Compose apps RevealCanvas( revealCanvasState = revealCanvasState, overlayInserter = FullscreenRevealOverlayInserter( // Adjust offset if reveal effect is misplaced revealableOffset = DpOffset(x = 0.dp, y = (-56).dp) ), ) { // App content MainScreen(revealCanvasState = revealCanvasState) } } @Composable fun MainScreen(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() Reveal( revealCanvasState = revealCanvasState, revealState = revealState, ) { // Compose content Column { Text( modifier = Modifier.revealable(key = "text", state = revealState), text = "Hello from Compose" ) } } // Manually add Android View as revealable AndroidView( factory = { android.widget.Button(it).apply { text = "Legacy Button" setOnClickListener { /* handle click */ } } }, update = { // Manually register view coordinates with RevealState it.post { val location = IntArray(2) it.getLocationInWindow(location) revealState.addRevealable( Revealable( key = "legacy_button", shape = RevealShape.RoundRect(4.dp), padding = PaddingValues(8.dp), layout = Layout( offset = Offset(location[0].toFloat(), location[1].toFloat()), size = Size( it.width.toFloat(), it.height.toFloat() ), ), ) ) } } ) } ``` -------------------------------- ### Kotlin: Apply Custom Shapes and Borders to Reveal Areas Source: https://context7.com/svenjacobs/reveal/llms.txt This Kotlin code snippet demonstrates how to apply various custom shapes and visual styling to reveal areas using the `revealable` modifier. It includes examples for rounded rectangles, circles, rectangles, and custom paths, with options for padding and border strokes. This functionality is useful for creating visually distinct reveal effects. ```kotlin import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Star import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Path import androidx.compose.ui.unit.dp import com.pranav.reveal.RevealShape import com.pranav.reveal.RevealState import com.pranav.reveal.revealable @Composable fun StyledRevealExample(revealState: RevealState) { Column { // Rounded rectangle reveal area Button( modifier = Modifier.revealable( key = "rounded_button", state = revealState, shape = RevealShape.RoundRect(16.dp), padding = PaddingValues(12.dp), borderStroke = BorderStroke(2.dp, Color.Blue), ), onClick = { } // TODO: Implement click handling ) { Text("Rounded Button") } // Circular reveal area Icon( modifier = Modifier.revealable( key = "circle_icon", state = revealState, shape = RevealShape.Circle, padding = PaddingValues(16.dp), borderStroke = BorderStroke(3.dp, Color.Green), ), imageVector = Icons.Default.Star, contentDescription = null ) // Rectangular reveal area Card( modifier = Modifier.revealable( key = "rect_card", state = revealState, shape = RevealShape.Rect, padding = PaddingValues(horizontal = 8.dp, vertical = 4.dp), ) ) { Text("Card Content") } // Custom shape with negative padding Text( modifier = Modifier.revealable( key = "tight_text", state = revealState, shape = RevealShape.RoundRect(4.dp), padding = PaddingValues(horizontal = 4.dp, vertical = 2.dp), borderStroke = BorderStroke(1.dp, Color.Red), ), text = "Tight Fit" ) // Custom path shape Box( modifier = Modifier.revealable( key = "custom_shape", state = revealState, shape = RevealShape.Custom { size, density, layoutDirection -> Path().apply { // Create custom path for reveal area moveTo(size.width / 2, 0f) lineTo(size.width, size.height / 2) lineTo(size.width / 2, size.height) lineTo(0f, size.height / 2) close() } }, ) ) { Text("Custom Shape") } } } ``` -------------------------------- ### Jetpack Compose Onboarding Tutorial with Sequential Reveals Source: https://context7.com/svenjacobs/reveal/llms.txt Implements a multi-step onboarding tutorial using Jetpack Compose and the Reveal library. It displays sequential reveal overlays with informative balloons for each step. The tutorial advances automatically or upon user interaction. ```kotlin import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Search import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.imanolcalderon.reveal.Reveal import com.imanolcalderon.reveal.RevealCanvasState import com.imanolcalderon.reveal.RevealOverlayArrangement import com.imanolcalderon.reveal.RevealState import com.imanolcalderon.reveal.revealable import com.imanolcalderon.reveal.Balloon import com.imanolcalderon.reveal.Arrow import kotlinx.coroutines.delay import kotlinx.coroutines.launch @Composable fun OnboardingTutorial(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() val scope = rememberCoroutineScope() var tutorialStep by remember { mutableStateOf(0) } val tutorialSteps = listOf("home", "search", "profile", "settings", "menu") Reveal( revealCanvasState = revealCanvasState, revealState = revealState, overlayContent = { key -> val stepIndex = tutorialSteps.indexOf(key) Balloon( modifier = Modifier .align(verticalArrangement = RevealOverlayArrangement.Bottom) .padding(16.dp), arrow = Arrow.top(), backgroundColor = MaterialTheme.colorScheme.primaryContainer, ) { Column(modifier = Modifier.padding(16.dp)) { Text( text = when (key) { "home" -> "Welcome! This is your home screen" "search" -> "Use search to find content quickly" "profile" -> "Access your profile and settings" "settings" -> "Customize your preferences" "menu" -> "Explore more features in the menu" else -> "" }, style = MaterialTheme.typography.bodyLarge, ) Row( modifier = Modifier.padding(top = 8.dp), horizontalArrangement = Arrangement.SpaceBetween, ) { Text("Step ${stepIndex + 1} of ${tutorialSteps.size}") TextButton( onClick = { scope.launch { if (stepIndex < tutorialSteps.size - 1) { tutorialStep++ revealState.reveal(tutorialSteps[tutorialStep]) } else { revealState.hide() } } } ) { Text(if (stepIndex == tutorialSteps.size - 1) "Finish" else "Next") } } } } }, onRevealableClick = { key -> // Advance to next step on click scope.launch { val currentIndex = tutorialSteps.indexOf(key) if (currentIndex < tutorialSteps.size - 1) { tutorialStep++ revealState.reveal(tutorialSteps[tutorialStep]) } else { revealState.hide() } } }, onOverlayClick = { /* Prevent dismissing on overlay click */ }, ) { Scaffold( topBar = { TopAppBar( title = { Text( modifier = Modifier.revealable(key = "home", state = revealState), text = "Home" ) }, actions = { IconButton( modifier = Modifier.revealable(key = "search", state = revealState), onClick = { } // Do nothing ) { Icon(Icons.Default.Search, contentDescription = null) } IconButton( modifier = Modifier.revealable(key = "profile", state = revealState), onClick = { } // Do nothing ) { Icon(Icons.Default.Person, contentDescription = null) } } ) } ) { padding -> Column(modifier = Modifier.padding(padding)) { Button( modifier = Modifier.revealable(key = "settings", state = revealState), onClick = { } // Do nothing ) { Text("Settings") } Button( modifier = Modifier.revealable(key = "menu", state = revealState), onClick = { } // Do nothing ) { Text("Menu") } } } } // Start tutorial automatically LaunchedEffect(Unit) { delay(500) revealState.reveal(tutorialSteps[0]) } } ``` -------------------------------- ### Compose Explanatory Overlay with Kotlin Source: https://context7.com/svenjacobs/reveal/llms.txt Demonstrates how to implement an explanatory overlay using Jetpack Compose in Kotlin. It utilizes the `Reveal` composable and associates different overlay contents with unique keys for elements like FABs, settings icons, and profile buttons. This requires the `reveal` library and standard Compose UI dependencies. ```kotlin import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Settings import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.example.reveal.Reveal import com.example.reveal.RevealOverlayArrangement import com.example.reveal.RevealCanvasState import com.example.reveal.revealable import com.example.reveal.rememberRevealState @Composable fun RevealWithExplanations(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() val scope = rememberCoroutineScope() Reveal( revealCanvasState = revealCanvasState, revealState = revealState, overlayContent = { key -> when (key) { "fab" -> { Surface( modifier = Modifier .align(horizontalArrangement = RevealOverlayArrangement.Start) .padding(16.dp), shape = RoundedCornerShape(8.dp), color = Color.White, shadowElevation = 4.dp, ) { Text( modifier = Modifier.padding(16.dp), text = "Tap here to add a new item", style = MaterialTheme.typography.bodyLarge, ) } } "settings" -> { Surface( modifier = Modifier .align(verticalArrangement = RevealOverlayArrangement.Bottom) .padding(16.dp), shape = RoundedCornerShape(8.dp), color = MaterialTheme.colorScheme.primaryContainer, ) { Column(modifier = Modifier.padding(16.dp)) { Text( text = "Access settings here", style = MaterialTheme.typography.titleMedium, ) Text( text = "Customize your experience", style = MaterialTheme.typography.bodySmall, ) } } } "profile" -> { Surface( modifier = Modifier .align(horizontalArrangement = RevealOverlayArrangement.End) .align(verticalArrangement = RevealOverlayArrangement.Top) .padding(16.dp), shape = RoundedCornerShape(8.dp), color = Color(0xFFFFEB3B), ) { Text( modifier = Modifier.padding(12.dp), text = "View your profile", ) } } } }, ) { Scaffold( floatingActionButton = { FloatingActionButton( modifier = Modifier.revealable(key = "fab", state = revealState), onClick = { } ) { Icon(Icons.Default.Add, contentDescription = null) } } ) { Column(modifier = Modifier.padding(it)) { IconButton( modifier = Modifier.revealable(key = "settings", state = revealState), onClick = { } ) { Icon(Icons.Default.Settings, contentDescription = null) } } } } } ``` -------------------------------- ### Add Reveal Dependency to Gradle Project Source: https://context7.com/svenjacobs/reveal/llms.txt Include the Reveal core library and optional modules for additional shapes or Android compatibility in your project's Gradle build file. These dependencies enable the reveal effect functionality and its extensions. ```kotlin dependencies { implementation("com.svenjacobs.reveal:reveal-core:3.0.0") // Optional: Additional shapes for explanatory items implementation("com.svenjacobs.reveal:reveal-shapes:3.0.0") // Optional: Android View/Compose compatibility utilities implementation("com.svenjacobs.reveal:reveal-compat-android:3.0.0") } ``` -------------------------------- ### Programmatic Reveal Control with RevealState Source: https://context7.com/svenjacobs/reveal/llms.txt Manage reveal effects programmatically using RevealState's methods like reveal(), tryReveal(), hide(), containsRevealable(), and by accessing current/previous revealable keys. This snippet demonstrates sequential reveals, error handling for non-existent revealables, and safe reveal attempts. ```kotlin @Composable fun TutorialScreen() { val revealCanvasState = rememberRevealCanvasState() val revealState = rememberRevealState() val scope = rememberCoroutineScope() Reveal( revealCanvasState = revealCanvasState, revealState = revealState, ) { Column { Text( modifier = Modifier.revealable(key = "step1", state = revealState), text = "First step" ) Text( modifier = Modifier.revealable(key = "step2", state = revealState), text = "Second step" ) Text( modifier = Modifier.revealable(key = "step3", state = revealState), text = "Third step" ) } } // Reveal with error handling LaunchedEffect(Unit) { try { revealState.reveal("step1") delay(2000) revealState.reveal("step2") delay(2000) revealState.reveal("step3") } catch (e: IllegalArgumentException) { // Handle case where revealable is not found println("Revealable not found: ${e.message}") } } // Safe reveal without exception fun revealNextStep(key: String) { scope.launch { val success = revealState.tryReveal(key) if (!success) { println("Could not reveal $key - item not visible") } } } // Check if revealable exists val canRevealStep2 = revealState.containsRevealable("step2") // Get current and previous keys val currentKey = revealState.currentRevealableKey val previousKey = revealState.previousRevealableKey // Hide effect Button(onClick = { scope.launch { revealState.hide() } }) { Text("Skip Tutorial") } } ``` -------------------------------- ### Create Balloon Overlays with Arrows in Kotlin Source: https://context7.com/svenjacobs/reveal/llms.txt Demonstrates creating speech-bubble style explanatory overlays using the reveal-shapes module in Kotlin. This function utilizes composable functions to define balloon overlays with various arrow orientations, background customizations, and text content, triggered by interactions with revealable elements. ```kotlin import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.dokar.reveal.Reveal import com.dokar.reveal.RevealCanvasState import com.dokar.reveal.RevealOverlayArrangement import com.dokar.reveal.RevealState import com.dokar.reveal.anim.rememberRevealState import com.dokar.reveal.revealable import com.dokar.reveal.shapes.Arrow import com.dokar.reveal.shapes.Balloon import kotlinx.coroutines.launch @Composable fun BalloonOverlayExample(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() val scope = rememberCoroutineScope() Reveal( revealCanvasState = revealCanvasState, revealState = revealState, overlayContent = { key -> when (key) { "fab" -> { Balloon( modifier = Modifier .align(horizontalArrangement = RevealOverlayArrangement.Start) .padding(8.dp), arrow = Arrow.end(), // Arrow pointing to the right backgroundColor = MaterialTheme.colorScheme.secondaryContainer, cornerRadius = 12.dp, elevation = 4.dp, ) { Text( modifier = Modifier.padding(12.dp), text = "Click button to get started", style = MaterialTheme.typography.labelLarge, textAlign = TextAlign.Center, ) } } "explanation" -> { Balloon( modifier = Modifier .align(verticalArrangement = RevealOverlayArrangement.Bottom) .padding(8.dp), arrow = Arrow.top( width = 16.dp, height = 10.dp, horizontalAlignment = Alignment.CenterHorizontally, ), backgroundColor = Color.White, cornerRadius = 8.dp, elevation = 2.dp, ) { Text( modifier = Modifier.padding(16.dp), text = "This is an example of the reveal effect", style = MaterialTheme.typography.bodyMedium, ) } } "menu" -> { Balloon( modifier = Modifier .align(horizontalArrangement = RevealOverlayArrangement.End) .padding(8.dp), arrow = Arrow.start( width = 8.dp, height = 12.dp, verticalAlignment = Alignment.Top, ), backgroundBrush = Brush.verticalGradient( colors = listOf(Color(0xFF6200EE), Color(0xFF3700B3)) ), backgroundAlpha = 0.9f, ) { Text( modifier = Modifier.padding(12.dp), text = "Open menu", color = Color.White, ) } } "footer" -> { Balloon( modifier = Modifier .align(verticalArrangement = RevealOverlayArrangement.Top) .padding(8.dp), arrow = Arrow.bottom(), // Arrow pointing down backgroundColor = MaterialTheme.colorScheme.tertiaryContainer, ) { Text( modifier = Modifier.padding(8.dp), text = "More info below", ) } } } }, onRevealableClick = { key -> scope.launch { revealState.hide() } }, ) { // Screen content FloatingActionButton( modifier = Modifier.revealable(key = "fab", state = revealState), onClick = { } // Replace with your actual click logic ) { Icon(Icons.Default.Add, contentDescription = null) } } } ``` -------------------------------- ### Configure Custom Click Handling for Reveal Items (Kotlin) Source: https://context7.com/svenjacobs/reveal/llms.txt This snippet demonstrates how to configure individual click behaviors for revealable items using the `revealable` modifier. It shows how to define custom `onClick` listeners for specific keys, use `OnClick.Listener` for custom actions, and `OnClick.Passthrough` to allow underlying composable clicks. It also explains the default `onRevealableClick` and `onOverlayClick` behaviors of the `Reveal` composable. ```kotlin import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button import androidx.compose.material3.Checkbox import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import com.arjun.reveal.Reveal import com.arjun.reveal.RevealCanvasState import com.arjun.reveal.RevealState import com.arjun.reveal.revealable import com.arjun.reveal.OnClick import kotlinx.coroutines.launch import kotlinx.coroutines.delay @Composable fun CustomClickExample(revealCanvasState: RevealCanvasState) { val revealState = rememberRevealState() val scope = rememberCoroutineScope() Reveal( revealCanvasState = revealCanvasState, revealState = revealState, // Default click handler for revealables without custom onClick onRevealableClick = { key -> scope.launch { revealState.hide() } }, // Called when overlay (grey area) is clicked onOverlayClick = { key -> scope.launch { revealState.hide() } }, ) { Column { // Custom click listener - advance to next step Button( modifier = Modifier.revealable( key = "step1", state = revealState, onClick = OnClick.Listener { key -> scope.launch { revealState.reveal("step2") } }, ), onClick = { } // Internal onClick is not needed when using revealable onClick ) { Text("Step 1: Click to continue") } // Another custom listener - different action Text( modifier = Modifier.revealable( key = "step2", state = revealState, onClick = OnClick.Listener { key -> scope.launch { revealState.reveal("step3") } }, ), text = "Step 2: Tap to proceed" ) // Passthrough - clicks go to underlying composable Checkbox( modifier = Modifier.revealable( key = "interactive_checkbox", state = revealState, onClick = OnClick.Passthrough, // Allow checkbox to be toggled during reveal ), checked = true, onCheckedChange = { /* handle change */ } ) // No custom onClick - uses Reveal's onRevealableClick Text( modifier = Modifier.revealable( key = "step3", state = revealState, ), text = "Step 3: Click to finish" ) } } } ``` -------------------------------- ### Displaying Overlay Content for Revealable Items Source: https://github.com/svenjacobs/reveal/blob/main/README.md Illustrates how to provide explanatory content that appears when a revealable item is activated. The `overlayContent` lambda within the `Reveal` composable allows conditional rendering of UI elements based on the revealed item's key, with alignment options available. ```kotlin import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.github.forntoh.kotlin.compose.reveal.Reveal import com.github.forntoh.kotlin.compose.reveal.RevealOverlayArrangement @Composable fun ExampleRevealWithOverlay(revealCanvasState: RevealCanvasState, revealState: RevealState) { Reveal( revealCanvasState = revealCanvasState, revealState = revealState, overlayContent = { key -> when (key) { Keys.HelloWorld -> { Surface( modifier = Modifier .align(horizontalArrangement = RevealOverlayArrangement.Horizontal.Start) .padding(8.dp), shape = RoundedCornerShape(4.dp), color = Color.White, ) { Text("This is an explanation") } } } } ) { // Contents } } ``` -------------------------------- ### Add Reveal Core Dependency to Kotlin Project Source: https://github.com/svenjacobs/reveal/blob/main/README.md Integrates the core reveal effect functionality into your Kotlin project. Ensure your Jetpack Compose version is compatible with the Compose Multiplatform version used by Reveal. This dependency is available on Maven Central. ```kotlin dependencies { implementation("com.svenjacobs.reveal:reveal-core:$REVEAL_VERSION") } ``` -------------------------------- ### Defining Revealable Items with Modifiers Source: https://github.com/svenjacobs/reveal/blob/main/README.md Shows how to mark `Text` composables as revealable items using the `revealable` modifier. Each revealable item is associated with a unique key, allowing for specific targeting. ```kotlin import androidx.compose.foundation.layout.Column import androidx.compose.material.Text import androidx.compose.ui.Modifier import com.github.forntoh.kotlin.compose.reveal.revealable enum class Keys { HelloWorld } Column { Text( modifier = Modifier.revealable(key = Keys.HelloWorld), text = "Hello world", ) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.