/compose-lock

jetpack compose pattern lock library

Primary LanguageKotlinApache License 2.0Apache-2.0

Compose Lock

compose lock is a pattern lock library based on jetpack compose framework

Features

  • custom dimension
  • custom sensitivity
  • custom colors
  • custom animation duration
  • supporting any size

Installation

Add the JitPack repository to your build.gradle file

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

Add Compose Lock to the dependency

dependencies {
    implementation 'implementation 'com.github.AbyssSpecter:ComposeLock:1.0.0'
}

Setup

use ComposeLock fuction in composeable scope

ComposeLock(
    modifier = Modifier.fillMaxWidth(),
    dimension = 4,
    sensitivity = 100f,
    dotsColor = Color.Black,
    dotsSize = 20f,
    linesColor = Color.Black,
    linesStroke = 30f,
    animationDuration = 200,
    animationDelay = 100,
    callback = object :ComposeLockCallback {
        override fun onStart(dot: Dot) {
            Toast.makeText(context, "start on dot with id : ${dot.id}", Toast.LENGTH_SHORT).show()
        }

        override fun onDotConnected(dot: Dot) {
            Toast.makeText(context, "dot connected with id : ${dot.id}", Toast.LENGTH_SHORT).show()
        }

        override fun onResult(result: List<Dot>) {
            var connectedDots = ""
            for (dot in result) connectedDots += "${dot.id }  "
            Toast.makeText(context, "result : $connectedDots", Toast.LENGTH_SHORT).show()
        }
    }
)

Preview