Giter Site home page Giter Site logo

pseudoankit / coachmark Goto Github PK

View Code? Open in Web Editor NEW
110.0 1.0 8.0 331 KB

A lighweight compose multiplatform libray to create better onboarding experience for users.

License: Apache License 2.0

Kotlin 100.00%
coach-mark-android coachmarks jetpack-compose onboarding-tool tooltip-library android-library coach-marks tutorial user-onboarding walkthrough

coachmark's Introduction

Compose Multiplatform Coachmark/Onboarding Library

Maven Central License

A lightweight Compose multiplatform library dedicated to creating seamless onboarding experiences.

android iOS
android ios
Feature Description
Custom Coachmarks Easily create and customize coachmarks to guide users through your app.
Flexible and Extensible Customize coachmarks to match your app's design and extend functionality as needed.
Cross-Platform Compatibility Compatible with Android and iOS, ideal for multiplatform projects.
Jetpack Compose Integration Seamlessly integrate coachmarks with Jetpack Compose UI components.
Dynamic Tooltip Views Display tooltip views for each key when coachmarks are active, enhancing user guidance.
Comprehensive Documentation Access detailed documentation and support for easy implementation.

Installation

Android Project


In your module's gradle

dependencies {
    implementation("io.github.pseudoankit:coachmark:<latest_version🔝>")
}
Compose Multiplatform Project


In your shared module gradle

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("io.github.pseudoankit:coachmark:<latest_version🔝>")
            }
        }
    }
}

Usage

Complete Demo Code

Define key for all composables that needs to be higlighted.

enum class Keys { Text1, Text2 }

At the root level, ensure that your code is wrapped with UnifyCoachmark.

UnifyCoachmark(
    tooltip = { /* Declare Tooltip Source code below ⏬ */ Tooltip(it) },
    overlayEffect = DimOverlayEffect(Color.Black.copy(alpha = .5f)),
    onOverlayClicked = { OverlayClickEvent.GoNext }
) { this : CoachmarkScope
    Content()     // Source code below ⏬
}

Call the enableCoachMark method in all the composables that need to be highlighted.
This method can be invoked within the CoachmarkScope.
If you are not in the CoachmarkScope, you can access it by calling 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,    // unique key that we declared above
                    toolTipPlacement = ToolTipPlacement.Top,
                    highlightedViewConfig = HighlightedViewConfig(
                        shape = HighlightedViewConfig.Shape.Rect(12.dp),
                        padding = PaddingValues(8.dp)
                    )
                )
        )
    }
}

Define a tooltip view for each key to be displayed when any coachmark is active or highlighted.

@Composable
private fun Tooltip(key: CoachMarkKey) {
    when (key) {
        Keys.Text1 -> {
            Balloon(arrow = Arrow.Start()) {
                Text(text = "Highlighting Text1", color = Color.White)
            }
        }
    
        Keys.Text2 -> {
            Balloon(arrow = Arrow.Start()) {
                Text(text = "Highlighting Text2", color = Color.White)
            }
        }
    }
}

Overlay Logic referred from reveal library

License

Copyright 2024 pseudoankit (Ankit)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

coachmark's People

Contributors

aiyu-ayaan avatar pseudoankit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

coachmark's Issues

Support specifying a gap between highlight and tooltip

I use tooltips without arrows, so I like to display a small gap between the highlight and the tooltip. I currently realize this gap via padding around the tooltip composable, in all four directions. But this approach will be wasteful in cases where the tooltip is sized not to run off the left or right side of the screen. I could switch on position to put the padding only on the side that needs it (adjacent to the highlight), but a centralized solution might be better, in case other users need the same thing.

The gap could be specified on UnifyCoachmark, and defaulted to 0.dp for backward compatibility.

old coach mark briefly visible when displaying unrelated coach mark sequence

Recreate:

  1. Add this button to the demo:
            Button(onClick = { show(Keys.TextBottom, Keys.TextTop) }) {
                Text(text = "Highlight Some")
            }
  1. Run the demo.
  2. Tap the new button and tap through the displayed coach marks.
  3. Tap "Highlight 1".

Expected behavior: Nothing is visible from the previous coach mark sequence.
Actual behavior: A "ghost" (fade-out animation?) of the first coach mark (highlight and tooltip) from the previous sequence is briefly visible. (at 0:05 in the video below)

ghost1.webm

Observations:

  • This doesn't seem to happen (or isn't noticeable) when the two coach mark sequences start with the same coach mark.

I haven't investigated the cause.

min distance from screen not configurable for each tooltip

current this value can be passed in Overlay Layout, so it's can't be configured for each individual item
as shown in below video, I can't specify the value for any specific tooltip

The idea is to move this to ToolTipConfig

Screen_recording_20231205_092016.webm

fix tooltip flicker

Tooltips flicker, or jump out of position very briefly, in two cases that I've seen:

  1. First displayed tooltip. This seems to go away when tooltips are displayed again.
  2. Unpredictably on tooltips other than the first, especially when a new tooltip requires recomposition. Unlike the first case, this doesn't go away when tooltips are displayed again.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

  • Update kotlin 1.8.0 to v1.9.23 (org.jetbrains.kotlin:kotlin-stdlib-jdk8, org.jetbrains.kotlin:kotlin-stdlib-jdk7, org.jetbrains.kotlin.multiplatform, org.jetbrains.kotlin.android)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

  • Update all dependencies (actions/checkout, actions/setup-java, gradle, androidx.compose:compose-bom, org.jetbrains.compose, io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin, com.android.library, com.android.application)

Detected dependencies

github-actions
.github/workflows/publish.yml
  • actions/checkout v2
  • actions/setup-java v1
.github/workflows/verify.yml
  • actions/checkout v2
  • actions/setup-java v1
  • actions/checkout v2
  • actions/setup-java v1
gradle
gradle.properties
settings.gradle.kts
build.gradle.kts
coachmark/build.gradle.kts
convention-plugins/settings.gradle.kts
convention-plugins/build.gradle.kts
convention-plugins/src/main/kotlin/publication.module.gradle.kts
convention-plugins/src/main/kotlin/publication.root.gradle.kts
demo/android/build.gradle
  • org.jetbrains.kotlin:kotlin-stdlib-jdk7 1.8.0
  • org.jetbrains.kotlin:kotlin-stdlib-jdk8 1.8.0
  • androidx.activity:activity-compose 1.8.2
  • androidx.compose:compose-bom 2022.10.00
demo/shared/build.gradle.kts
gradle/libs.versions.toml
  • io.github.pseudoankit:coachmark 1.8.0
  • com.slack.lint.compose:compose-lint-checks 1.3.1
  • io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin 2.0.0-rc-1
  • com.android.application 8.2.2
  • com.android.library 8.2.2
  • org.jetbrains.kotlin.android 1.9.22
  • org.jetbrains.kotlin.multiplatform 1.9.22
  • org.jetbrains.compose 1.6.0-rc02
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.2

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.