Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/raheemadamboev/pin-lock-compose

🔐 Light library that is beautiful Pin Lock screen for Jetpack Compose
https://github.com/raheemadamboev/pin-lock-compose

android android-library compose-pin-lock jetpack-compose jetpack-compose-library library lock-compose pin-compose pin-lock pin-lock-compose

Last synced: 3 months ago
JSON representation

🔐 Light library that is beautiful Pin Lock screen for Jetpack Compose

Lists

README

        

Pin Lock


Android
Version
License
API


🔐 Light library that is beautiful Pin Lock screen for Jetpack Compose. The library handles saving pin in Encrypted file. Integration is very easy and fast.

# Setup

Add it in your root **build.gradle** at the end of repositories:
```groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

Include below dependency in build.gradle of application and sync it:
```groovy
implementation 'com.github.raheemadamboev:pin-lock-compose:1.0.1'
```
# Implementation

Firstly, initialize the library on your `onCreate` of Application class:
```kotlin
PinManager.initialize(this)
```

---

To add Pin Lock screen, add the `PinLock` composable to your compose area:
```kotlin
PinLock(
title = { pinExists ->
Text(text = if (pinExists) "Enter your pin" else "Create pin")
},
color = MaterialTheme.colorScheme.primary,
onPinCorrect = {
// pin is correct, navigate or hide pin lock
},
onPinIncorrect = {
// pin is incorrect, show error
},
onPinCreated = {
// pin created for the first time, navigate or hide pin lock
}
)
```

If there is no saved pin yet, it promtps the user to create pin. If there is saved pin, it promts the user to enter its pin:




---

It is also possible to change pin. Just add `ChangePinLock` composable to your compose area:
```kotlin
ChangePinLock(
title = { authenticated ->
Text(text = if (authenticated) "Enter new pin" else "Enter your pin")
},
color = MaterialTheme.colorScheme.primary,
onPinIncorrect = {
// pin is incorrect, show error
},
onPinChanged = {
// pin changed, navigate or hide pin lock
}
)
```
Use this only if there is already saved pin. If there is no saved pin, use simple `PinLock` instead for creating pin for the first time. When using `ChangePinLock`, firstly it prompts the user to enter original pin. After user succesfully authenticates using his original pin, it prompts the user to creat a new pin:



---

To check if saved pin exists:
```kotlin
val pinExists = PinManager.pinExists()
```

To clear saved pin so user can create brand new pin:
```kotlin
PinManager.clearPin()
```

# Features

- pin lock screen very easily
- handles encryption and saving pin internally
- change pin lock screen
- customizable background color
- robust to configuration changes
- backspace to remove last entered pin number
- incorrect indicator animation

# Demo

You can install and try demo app. All the features are implemented in the demo from creating pin to changing pin.

Download demo




# Projects using this library

**Notepad**: 40 000+ downloads.

Google Play Store

Github

# Licence

```xml
Designed and developed by raheemadamboev (Raheem) 2023.

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.
```