From e06f73f60f77d02de62685014c82afce6ec76922 Mon Sep 17 00:00:00 2001 From: Haik Aslanyan Date: Mon, 13 Apr 2020 18:40:02 +0400 Subject: [PATCH] added readme --- README.md | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 307ca26..7a24660 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,147 @@ -# RoundCode +# RoundCode for iOS -A description of this package. +[![License](http://img.shields.io/badge/License-MIT-green.svg?style=flat)](https://github.com/aslanyanhaik/Quick-Chat/blob/master/LICENSE) +[![Swift 5](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)](https://swift.org) +[![Twitter: @aslanyanhaik](https://img.shields.io/badge/Contact-Twitter-blue.svg?style=flat)](https://twitter.com/aslanyanhaik) + + + +RoundCode is a Facebook messenger like custom barcode with lots of customization. + +In addition to encoder the RoundCode also includes convenient camera scanner and decoder. + +

+Screenshot of RoundCode for iOS +

+ +## Installation + +### Cocoapods: + +```curl +pod 'RoundCode' +``` + +### Swift Package Manager: + +File > Swift Packages > Add Package Dependency + +```swift +https://github.com/aslanyanhaik/RoundCode +``` + +## Usage example + +import framework + +```swift +import RoundCode +``` + +### Encoding +create coder and encode + +```swift +let image = RCImage(message: "Hello World") +let coder = RCCoder() +do { + imageView.image = try coder.encode(image) +} catch { + //handle errors +} +``` + +You can also validate the messsage before encoding + +```swift +let coder = RCCoder() +let isValidText = coder.validate("Hello world") +``` + +### Decoding + +Create instane of RCCameraViewController and handle the delegate + +```swift +class ViewController: UIViewController, RCCameraViewControllerDelegate { + + func scan() { + let cameraController = RCCameraViewController() + cameraController.delegate = self + present(cameraController, animated: true) + } + + func cameraViewController(didFinishPickingScanning message: String) { + messageLabel.text = message + } +} +``` + +You can also decode a UIImage like this + +```swift +let coder = RCCoder() + do { + messageLabel.text = try coder.decode(UIImage(named: code)!) + } catch { + //handle errors + } +``` + +### Appearance + +You can change the appearance like this + +```swift +var image = RCImage(message: "Hello world") +image.contentInsets = UIEdgeInsets(top: 8, left: 10, bottom: 4, right: 10) +image.attachmentImage = UIImage(named: "Profile") +image.size = 300 +image.gradientType = .linear(angle: CGFloat.pi) +image.tintColors = [.red, .black] +``` + +

+Different styles of RoundCode for iOS +

+ +⚠️ When choosing colors or transparent background you should keep in mind that decoder will detect the code on light background with dark colors ⚠️ + +### Advanced + +You can provide custom coding configuration in order to encode long text by reducing number of characters + +```swift +let configuration = RCCoderConfiguration.shortConfiguration +let coder = RCCoder(configuration: configuration) +``` + +```swift +let configuration = RCCoderConfiguration(characters: " -abcdefghijklmnopqrstuvwxyz0123456789") +let coder = RCCoder(configuration: configuration) +``` + +⚠️ If you are encoding with custom configuration, then you should change the RCCameraViewController configuration ⚠️ + +```swift +let configuration = RCCoderConfiguration(characters: " -abcdefghijklmnopqrstuvwxyz0123456789") +let coder = RCCoder(configuration: configuration) +let camera = RCCameraViewController() +camera.coder = coder +``` + +## Compatibility + +Written in Swift 5 and requires Xcode 11.0 + +RoundCode is compatible with iOS 13.0+. + +## Author + +* [Haik Aslanyan](https://twitter.com/aslanyanhaik) + +## License + +Copyright 2020 Haik Aslanyan. + +Licensed under MIT License: https://opensource.org/licenses/MIT \ No newline at end of file