Swiftpack.co - Package - IrelDev/TelegramColorPicker

TelegramColorPicker

Simple telegram style color picker built with Swift & UIKit

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To integrate TelegramColorPicker into your project using CocoaPods, specify it in your Podfile:

pod 'TelegramColorPicker'

After that use pod install command in your terminal.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate TelegramColorPicker into your Xcode project using Carthage, specify it in your Cartfile:

github "IrelDev/TelegramColorPicker"

After that use carthage update command in your terminal.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. To integrate TelegramColorPicker into your Xcode project using Swift Package Manager, specify it in you Package:

dependencies: [
    .package(url: "https://github.com/IrelDev/TelegramColorPicker.git", .upToNextMinor(from: "1.3.0"))
]

Manually

If you prefer not to use any dependency managers, you can integrate TelegramColorPicker into your project manually by downloading the desired release and copying the Sources directory.


Warning

Sources downloaded directly from the master branch may be unstable, please download sources from releases page.


Usage

Programmatically

Create TelegramColorPicker instance then add it as a subview.

let frame = CGRect(x: .zero, y: .zero, width: 400, height: 250)
let colorPicker = TelegramColorPicker(frame: frame)
view.addSubview(colorPicker)

Storyboard

Drag UIView object from the object library and set TelegramColorPicker as a custom class in identity inspector. Create and connect @IBOutlet with TelegramColorPicker type.

SwiftUI

Create struct that conforms to UIViewRepresentable protocol:

struct TelegramColorPickerRepresentable: UIViewRepresentable {
    func makeUIView(context: Context) -> TelegramColorPicker {
        TelegramColorPicker()
    }
    func updateUIView(_ uiView: TelegramColorPicker, context: Context) { }
}

use it in your View:

var body: some View {
        TelegramColorPickerRepresentable()
        .frame(width: 400, height: 250, alignment: .center)
}

Get color update

Use getColorUpdate function with your custom closure and don't forget to use [weak self] to avoid strong reference cycle.

getColorUpdate { [weak self] (_, color) in
           guard let newColor = color.newValue, let hexadecimalColor = newColor.toHex() else { return }
           self?.textLabel.text = hexadecimalColor
}

Example

This repository contains example where you can see how TelegramColorPicker can be used for QRCode foreground color changing.

License

TelegramColorPicker is available under the MIT license, see the LICENSE file for more information.

Github

link
Stars: 6

Dependencies

Used By

Total: 0

Releases

v1.3.1 - 2020-08-11 15:42:33

Release v1.3.1

interactions:

  • The Brightness Slider can now be tapped anywhere to change its value

Testing:

  • New shouldRespondTo X & Y tests added

v1.3.0 - 2020-08-09 12:36:58

Release v1.3.0

Dependency managers:

  • SwiftPM is now available

Other:

  • Added Unit Tests

v1.2 - 2020-07-31 02:38:30

Release v1.2

Performance improvement:

  • Constraints that are not based on view bounds are removed from layoutSubviews
  • View render became faster

v1.1.3 - 2020-06-29 03:56:27

Release v1.1.3

What's new:

  • Added Carthage support
  • Delegates are now public for custom color picker creation.

v1.1.2 - 2020-06-19 06:41:23

Release v1.1.2

User Interface:

  • The circle size & circle line width has been changed to a more appropriate size.

Bug fixes:

  • Fixed a bug when the circle goes over ColorPickerView bounds

v1.1.1 - 2020-06-10 11:56:12

Release v1.1.1

What's new:

  • Now TelegramColorPicker can be used with SwiftUI using UIViewRepresentable

Bug fixes:

  • Fixed TelegramColorPicker render preview in Storyboard
  • Fixed an issue that prevented TelegramColorPicker usage with SwiftUI

v1.1.0 - 2020-06-07 06:24:26

Release 1.1.0

Bug fixes:

  • Fixed hue & saturation issues. Added circle movement limitation in ColorPickerView

v1.0.1 - 2020-06-04 07:19:22

Release 1.0.1

Bug fixes:

  • Fixed TelegramColorPicker UIView creation, made init public

v1.0.0 - 2020-06-04 07:09:17

Initial Release