{"id":13605304,"url":"https://github.com/Chaintech-Network/QRKitComposeMultiplatform","last_synced_at":"2025-04-12T05:32:40.459Z","repository":{"id":232523941,"uuid":"783713756","full_name":"Chaintech-Network/QRKitComposeMultiplatform","owner":"Chaintech-Network","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-17T11:20:11.000Z","size":14510,"stargazers_count":155,"open_issues_count":3,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T15:10:55.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chaintech-Network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-08T12:33:38.000Z","updated_at":"2024-10-19T07:05:38.000Z","dependencies_parsed_at":"2024-04-12T10:27:01.854Z","dependency_job_id":"e5faca4d-2c0b-44a0-9526-13a4d6f56d1e","html_url":"https://github.com/Chaintech-Network/QRKitComposeMultiplatform","commit_stats":null,"previous_names":["chaintechnetwork/qrkitcomposemultiplatform","chaintech-network/qrkitcomposemultiplatform"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chaintech-Network%2FQRKitComposeMultiplatform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chaintech-Network%2FQRKitComposeMultiplatform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chaintech-Network%2FQRKitComposeMultiplatform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chaintech-Network%2FQRKitComposeMultiplatform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chaintech-Network","download_url":"https://codeload.github.com/Chaintech-Network/QRKitComposeMultiplatform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223497740,"owners_count":17155199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:00:57.220Z","updated_at":"2025-04-12T05:32:40.438Z","avatar_url":"https://github.com/Chaintech-Network.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/network.chaintech/qr-kit.svg)](https://central.sonatype.com/artifact/network.chaintech/qr-kit)\n[![Kotlin](https://img.shields.io/badge/kotlin-v2.0.20-blue.svg?logo=kotlin)](http://kotlinlang.org)\n[![Compose Multiplatform](https://img.shields.io/badge/Compose%20Multiplatform-v1.7.0-blue)](https://github.com/JetBrains/compose-multiplatform)\n[![License](https://img.shields.io/github/license/Chaintech-Network/CMPCharts)](http://www.apache.org/licenses/LICENSE-2.0)\n\n![badge-android](http://img.shields.io/badge/platform-android-3DDC84.svg?style=flat)\n![badge-ios](http://img.shields.io/badge/platform-ios-FF375F.svg?style=flat)\n![badge-desktop](http://img.shields.io/badge/platform-desktop-FF9500.svg?style=flat)\n\n# QRKit - Compose Multiplatform\nQRKit is a Compose Multiplatform library designed for seamless QR code scanning \u0026 QR code Generating across Android, iOS, and Desktop applications.\n\n\u003cimg width=\"960\" alt=\"QR-code-generator-scanner\" src=\"/assets/CMP_QRKit_scanner_genrator_banner.png\"\u003e\n\n## 📦 Installation\n\nTo use QRKit in your Compose Multiplatform project, add the following dependency to your `build.gradle.kts` file\n\n```kotlin\ncommonMain.dependencies {\n    implementation(\"network.chaintech:qr-kit:3.0.6\")\n}\n```   \n\u003cbr\u003e\n\n## 🚀 Usage\n\n### 🔒 Add Permissions in Android and iOS\n\n- **Android**: Include this at the root level in your `AndroidManifest.xml`:\n\n    ```xml\n    \u003cuses-feature android:name=\"android.hardware.camera\"/\u003e\n    \u003cuses-feature android:name=\"android.hardware.camera.autofocus\"/\u003e\n    \u003cuses-permission android:name=\"android.permission.CAMERA\"/\u003e\n    \u003cuses-permission android:name=\"android.permission.FLASHLIGHT\"/\u003e\n    ```\n\n- **iOS**: Add the following keys to the `Info.plist` in your Xcode project:\n\n    ```xml\n    \u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\u003cstring\u003e$(PRODUCT_NAME) camera description.\u003c/string\u003e\n    \u003ckey\u003eNSPhotoLibraryUsageDescription\u003c/key\u003e\u003cstring\u003e$(PRODUCT_NAME) photos description.\u003c/string\u003e\n    ```\n\n### 📷 QR Code Scanner\n\n\u003cimg width=\"960\" alt=\"QR-code-generator-scanner\" src=\"/assets/CMP_QRKit_scanner.gif\"\u003e\n\n```kotlin\nQrScanner(\n    modifier: Modifier,\n    flashlightOn: Boolean,\n    cameraLens: CameraLens,\n    openImagePicker: Boolean,\n    onCompletion: (String) -\u003e Unit,\n    imagePickerHandler: (Boolean) -\u003e Unit,\n    onFailure: (String) -\u003e Unit,\n    overlayShape = OverlayShape.Square,\n    overlayColor = Color(0x88000000),\n    overlayBorderColor = Color.White,\n    customOverlay: (ContentDrawScope.() -\u003e Unit)? = null,\n    permissionDeniedView: @Composable (() -\u003e Unit?)? = null\n)\n```\n\n* `modifier`: Modifier for modifying the layout of the QR scanner.\n* `flashlightOn`: Boolean indicating whether the flashlight is turned on.\n* `cameraLens`: This parameter allows users to switch between the front and back cameras.\n* `openImagePicker`: Boolean indicating whether to launch the picker for selecting images.\n* `imagePickerHandler`: Callback invoked to indicate the status of the gallery, whether it's open or closed.\n* `onFailure`: Callback invoked when there's a failure during QR code scanning.\u003cbr\u003e\n* `overlayShape`: Defines the shape of the overlay that appears over the camera view. Square and Rectangle\u003cbr\u003e\n* `overlayColor`: The color of the overlay that dims the area around the scanning region. The default is a semi-transparent black color.\u003cbr\u003e\n* `overlayBorderColor`: The color of the border around the scanning region. The default is white.\u003cbr\u003e\n* `customOverlay`: Allows the user to provide a custom overlay design. If no custom overlay is provided, a default one is applied.\u003cbr\u003e\n* `permissionDeniedView`: Allows the user to provide a custom view when camera permission is denied. If no custom view is provided, a default one is shown.\u003cbr\u003e\n\n🔗 For more details, follow the implementation in [QrScannerScreen.kt](https://github.com/Chaintech-Network/QRKitComposeMultiplatform_org/blob/qrkit/composeApp/src/commonMain/kotlin/org/qrcodedemo/app/ui/QrScannerScreen.kt)\n\n\u003cbr\u003e\n\n### 🖼️ QR Code Generator\n\n\u003cimg width=\"960\" alt=\"QRCodeGenerator\" src=\"/assets/CMP_QRKit_QR_Generator.png\"\u003e\n\u003cimg width=\"960\" alt=\"QRCodeCustomization\" src=\"/assets/CMP_QRKit_QR_Customisation.png\"\u003e\n\n- ### Basic QR Code Generation\n  Generating a basic QR code is as simple as using the rememberQrKitPainter function:\n\n    ```kotlin\n    val painter = rememberQrKitPainter(data = inputText)\n    \n    Image(\n        painter = painter, \n        contentDescription = null, \n        modifier = Modifier.size(100.dp)\n    )\n    ```\n\n- ### Designed QR Code Generation\n  To create a more customized QR code, you can use rememberQrKitPainter function with additional options:\n\n    ```kotlin\n    val centerLogo = painterResource(Res.drawable.ic_youtube)\n  \n    val painter = rememberQrKitPainter(inputText) {\n        shapes = QrKitShapes(\n            ballShape = getSelectedQrBall(QrBallType.SquareQrBall()),\n            darkPixelShape = getSelectedPixel(QrPixelType.SquarePixel()),\n            frameShape = getSelectedFrameShape(QrFrameType.SquareFrame()),\n            codeShape = getSelectedPattern(PatternType.SquarePattern),\n        )\n        colors = QrKitColors(\n            darkBrush = QrKitBrush.customBrush {\n                Brush.linearGradient(\n                    0f to color[0],\n                    1f to color[1],\n                    end = Offset(it, it)\n                )\n            }\n        )\n        logo = QrKitLogo(centerLogo)\n    }\n    ```\n\n  ### 📖 Step by Step Implementation\n\n  #### 1. Creating a QR Code Painter\n    - Use the `rememberQrKitPainter` function to create a QR code painter with the specified input text.\n\n       ```kotlin\n       val painter = rememberQrKitPainter(inputText)\n       ```\n\n  #### 2. Setting the Center Logo\n    - Set the center logo of the QR code using the `QrKitLogo` function.\n\n       ```kotlin\n       QrKitLogo(centerLogo)\n       ```\n\n  #### 3. Configuring Colors\n    - Use the `qrColors` function to configure the colors of the QR code.\n\n       ```kotlin\n       qrColors {\n            // configure colors here\n           darkBrush = QrKitBrush.customBrush {\n               Brush.linearGradient(\n                   0f to Color.White,\n                   1f to Color.White,\n                   end = Offset(it, it)\n               )\n           }\n           frameBrush = QrKitBrush.solidBrush(Color.Blue)\n       }\n       ```\n\n  #### 4. Configuring Shapes\n    - Use the `qrShapes` function to configure the shapes used in the QR code.\n\n       ```kotlin\n       qrShapes {\n           // configure shapes here\n       }\n       ```\n\n      Within the `qrShapes` block, you can configure the following properties:\n\n      | Property            | Description                                 | Example Code                                                      |\n      |---------------------|---------------------------------------------|-------------------------------------------------------------------|\n      | **ballShape**       | Sets the ball shape to a square QR ball.   | `ballShape = getSelectedQrBall(QrBallType.SquareQrBall())`      |\n      | **darkPixelShape**  | Sets the dark pixel shape to a square pixel.| `darkPixelShape = getSelectedPixel(PixelType.SquarePixel())`     |\n      | **frameShape**      | Sets the frame shape to a square QR frame. | `frameShape = getSelectedQrFrame(QrFrameType.SquareQrFrame())`   |\n      | **codeShape**   | Sets the QR code pattern to a square pattern.| `codeShape = getSelectedPattern(PatternType.SquarePattern)`   |\n\n\u003cbr\u003e\n\n- ### Supported Data Types for QR Codes\n  The QR code generator supports a wide range of data types, allowing you to encode various forms of information effortlessly.\n\n\n    | Data Type | Description                                 |\n    |-----------|---------------------------------------------|\n    | **Text**  | Simple text data type.                      |\n    | **Phone** | Telephone number data type.                 |\n    | **Email** | Email address data type.                    |\n    | **SMS**   | Short message service data.                 |\n    | **Wi-Fi** | Wireless network configuration data.        |\n    | **Event** | Calendar event data type.                   |\n    | **Location** | Geographic location data type.            |\n    \n    Below is an example of how to create a QR code for an email address:\n    \n    ```kotlin\n    val email: String = email(\"developer@gmail.com\", \"addeveloper@gmail.com\", \"Lorem ipsum\", \"Lorem ipsum\")\n    \n    val painter = rememberQrKitPainter(data = email)\n    \n    Image(\n        painter = painter, contentDescription = null, modifier = Modifier.size(100.dp)\n    )\n    ```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## 🏷️ Barcode Generator\n\u003cimg width=\"960\" alt=\"QRCodeGenerator\" src=\"/assets/CMP_QRKit_Barcode_Generator.png\"\u003e\n\nYou can easily generate and display barcodes using the `rememberBarcodePainter` function in your Compose application.\n\n```kotlin\nval barCodePainter = rememberBarcodePainter(\n    content = data, \n    format = type, \n    brush = SolidColor(Color.White), \n    onError = { throwable -\u003e\n        scope.launch {\n            snackbarHostState.showSnackbar(\"Error occurred: ${throwable.message}\")\n        }\n        // Return a fallback painter, for example, an empty painter\n        EmptyPainter()\n    }\n)\n\nImage(\n    painter = barCodePainter,\n    contentDescription = null,\n    modifier = Modifier\n        .fillMaxWidth()\n        .height(100.sdp)\n)\n```\n\n\u003cbr\u003e🔗 For more details, follow the implementation in [BarCodeGeneratorScreen.kt](https://github.com/Chaintech-Network/QRKitComposeMultiplatform_org/blob/qrkit/composeApp/src/commonMain/kotlin/org/qrcodedemo/app/ui/BarCodeGeneratorScreen.kt)\n\n\u003cbr\u003eThe following table explains the parameters used in the `rememberBarcodePainter` function.\n\n| Parameter       | Description                                                                                                       |\n|-----------------|-------------------------------------------------------------------------------------------------------------------|\n| `content`       | The string data to be encoded into the barcode.                                                                   |\n| `format`        | The format of the barcode to be generated (e.g., `BarcodeFormat.QR_CODE`, `CODE_128`, etc.).                      |\n| `brush`         | The `Brush` used to paint the barcode. By default, it uses `SolidColor(Color.Black)`.                             |\n| `onError`       | A callback function that handles errors during barcode generation. It returns a `Painter` to display in case of failure.|\n| `pathGenerator` | Function that generates the path for the barcode. It defines how the barcode lines or patterns are drawn. The default is `::defaultBarcodePathGenerator`. |\n| `factory`       | A `PainterFactory` used to create the `Painter` for rendering the barcode. The default is `DefaultPainterFactory()`.|\n\n\u003cbr\u003e\n\n### 🧩 Barcode Formats\n\n| Barcode Format | Description | Limitations |\n|----------------|-------------|-------------|\n| `Codabar`      | **Codabar** is a simple barcode used for libraries, blood banks, and airbills. | Can encode numbers and a few special characters (A, B, C, D, +, -, $, /, :). Limited character set. |\n| `Code39`       | **Code 39** is widely used in industrial applications. It can encode alphanumeric characters and a few special symbols. | Lower data density compared to other formats. |\n| `Code93`       | **Code 93** is an enhanced version of Code 39, offering higher density and encoding of additional characters. | Limited to alphanumeric data, but can encode more characters than Code 39. |\n| `Code128`      | **Code 128** is a high-density barcode used for logistics and shipping. It can encode all 128 ASCII characters. | More complex and longer compared to simpler formats like Code 39. |\n| `EAN8`         | **EAN-8** is a shorter version of EAN-13, used on smaller products where space is limited. | Can encode only 8 digits, limiting the amount of information. |\n| `EAN13`        | **EAN-13** is the standard barcode for products, mainly used in retail. | Can encode only numeric digits, no letters or symbols. |\n| `ITF`          | **ITF (Interleaved 2 of 5)** is used in packaging and logistics. | Can encode only numeric digits and may be prone to misreading without proper scanning equipment. |\n| `UPCA`         | **UPC-A** is a barcode format used for retail products in the US, encoding 12 digits. | Can encode only numeric digits and space is limited to 12 characters. |\n| `UPCE`         | **UPC-E** is a compressed version of UPC-A, used on smaller packages. | Limited to encoding fewer digits (6–8) and primarily used in specific retail scenarios. |\n\n\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n## 📖 Detailed Explanation\n\n✨ **See the QR Code Generator in Action!**\n- Check out the full implementation in [QrGeneratorScreen.kt](https://github.com/Chaintech-Network/QRKitComposeMultiplatform_org/blob/qrkit/composeApp/src/commonMain/kotlin/org/qrcodedemo/app/ui/QrGeneratorScreen.kt) to witness the magic of generating QR codes in real-time! 🚀\n\n💡 **Need to Pick and Crop Images?**\n- We’ve integrated the powerful **CMP Pick n Crop Library** for seamless image handling. Head over to [App.kt](https://github.com/Chaintech-Network/QRKitComposeMultiplatform/blob/main/composeApp/src/commonMain/kotlin/org/qrcodedemo/app/App.kt) for all the details! 📸\n\n📖 **Want to Learn More?**  \nExplore our detailed Medium articles for a deeper dive:\n\n- [**QRCodeGenerator**](https://medium.com/mobile-innovation-network/qrkit-2-0-scan-genrate-customize-716d870c3eae) 🛠️ — Everything you need to know about generating QR codes!\n- [**QRCodeScanner**](https://medium.com/mobile-innovation-network/qrkit-barcode-scanning-in-compose-multiplatform-for-android-and-ios-77cf5d84f719) 🔍 — Learn how to implement QR code scanning across platforms!\n  \u003cbr\u003e\u003cbr\u003e\n\n## 🌐 Stay Connected with Us\nStay connected and keep up with our latest innovations! 💼 Let's innovate together!\u003cbr\u003e\u003cbr\u003e\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/showcase/mobile-innovation-network)\n[![Medium](https://img.shields.io/badge/Medium-12100E?style=for-the-badge\u0026logo=medium\u0026logoColor=white)](https://medium.com/mobile-innovation-network)   \n\u003cbr\u003e\n\n## 📄 License\n```\nCopyright 2023 Mobile Innovation Network\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChaintech-Network%2FQRKitComposeMultiplatform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChaintech-Network%2FQRKitComposeMultiplatform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChaintech-Network%2FQRKitComposeMultiplatform/lists"}