Skip to content

Commit

Permalink
Release 1.2.0 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpeschenkov committed Sep 26, 2019
1 parent bda3330 commit 25e1365
Show file tree
Hide file tree
Showing 49 changed files with 1,322 additions and 570 deletions.
8 changes: 8 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ line_length:
type_body_length:
- 150
- 150

identifier_name:
excluded:
- c
- m
- to
- id

22 changes: 17 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# CHANGELOG

```
### Added for new features.
### Changed for changes in existing functionality.
### Deprecated for once-stable features removed in upcoming releases.
### Removed for deprecated features removed in this release.
### Fixed for any bug fixes.
#### Added for new features.
#### Changed for changes in existing functionality.
#### Deprecated for once-stable features removed in upcoming releases.
#### Removed for deprecated features removed in this release.
#### Fixed for any bug fixes.
```

### 1.2.0

- Implemented builder pattern

#### Changed
- `LAK` prefix renamed to `LK`

### 1.1.9

- Added Xcode 11 support
2 changes: 1 addition & 1 deletion LetterAvatarKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|
spec.name = 'LetterAvatarKit'
spec.platform = :ios, '8.0'
spec.version = '1.1.9'
spec.version = '1.2.0'
spec.license = { :type => 'MIT' }
spec.homepage = 'https://github.com/vpeschenkov/LetterAvatarKit'
spec.authors = { 'Viktor Peschenkov' => 'v.peschenkov@gmail.com' }
Expand Down
16 changes: 14 additions & 2 deletions LetterAvatarKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
351F38A51FAA38D10077F001 /* LetterAvatarSingleLetterTestImage@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 351F38A41FAA38D10077F001 /* LetterAvatarSingleLetterTestImage@2x.png */; };
351F6CEF1FA3F9A8003059D2 /* LetterAvatarOneWordTestImage@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 351F6CED1FA3F9A8003059D2 /* LetterAvatarOneWordTestImage@3x.png */; };
351F6CF01FA3F9A8003059D2 /* LetterAvatarOneWordTestImage@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 351F6CEE1FA3F9A8003059D2 /* LetterAvatarOneWordTestImage@2x.png */; };
3591E079233C233F0041B834 /* LetterAvatarMakerExtendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3591E078233C233F0041B834 /* LetterAvatarMakerExtendable.swift */; };
3591E07B233C24830041B834 /* LetterAvatarMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3591E07A233C24830041B834 /* LetterAvatarMaker.swift */; };
3591E07D233C26A50041B834 /* LetterAvatarMakerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3591E07C233C26A50041B834 /* LetterAvatarMakerTests.swift */; };
35AD1DA81FA8F4FC0059BC9A /* String+LetterAvatarKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35AD1DA71FA8F4FC0059BC9A /* String+LetterAvatarKit.swift */; };
35AD1DAA1FA929720059BC9A /* String+LetterAvatarKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35AD1DA91FA929720059BC9A /* String+LetterAvatarKitTests.swift */; };
EB516B651F8810D200BEA1F2 /* Character+LetterAvatarKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB516B621F8810D200BEA1F2 /* Character+LetterAvatarKit.swift */; };
Expand Down Expand Up @@ -47,6 +50,9 @@
351F38A41FAA38D10077F001 /* LetterAvatarSingleLetterTestImage@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "LetterAvatarSingleLetterTestImage@2x.png"; sourceTree = "<group>"; };
351F6CED1FA3F9A8003059D2 /* LetterAvatarOneWordTestImage@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "LetterAvatarOneWordTestImage@3x.png"; sourceTree = "<group>"; };
351F6CEE1FA3F9A8003059D2 /* LetterAvatarOneWordTestImage@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "LetterAvatarOneWordTestImage@2x.png"; sourceTree = "<group>"; };
3591E078233C233F0041B834 /* LetterAvatarMakerExtendable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LetterAvatarMakerExtendable.swift; sourceTree = "<group>"; };
3591E07A233C24830041B834 /* LetterAvatarMaker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LetterAvatarMaker.swift; sourceTree = "<group>"; };
3591E07C233C26A50041B834 /* LetterAvatarMakerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LetterAvatarMakerTests.swift; sourceTree = "<group>"; };
35AD1DA71FA8F4FC0059BC9A /* String+LetterAvatarKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+LetterAvatarKit.swift"; sourceTree = "<group>"; };
35AD1DA91FA929720059BC9A /* String+LetterAvatarKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+LetterAvatarKitTests.swift"; sourceTree = "<group>"; };
EB516B621F8810D200BEA1F2 /* Character+LetterAvatarKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Character+LetterAvatarKit.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,7 +163,9 @@
EB516B611F8810D200BEA1F2 /* Extensions */,
EB8EC40C1F85929E000B7641 /* LetterAvatarKit.h */,
EB8EC4231F859382000B7641 /* LetterAvatarBuilder.swift */,
3591E078233C233F0041B834 /* LetterAvatarMakerExtendable.swift */,
35089432210272B20024E7CA /* LetterAvatarBuilderConfiguration.swift */,
3591E07A233C24830041B834 /* LetterAvatarMaker.swift */,
EB8EC40D1F85929E000B7641 /* Info.plist */,
);
path = LetterAvatarKit;
Expand All @@ -170,6 +178,7 @@
EB821DF11F98B906009B3775 /* Resources */,
EB516B681F88110A00BEA1F2 /* Extensions */,
EB8EC4171F85929E000B7641 /* LetterAvatarBuilderTests.swift */,
3591E07C233C26A50041B834 /* LetterAvatarMakerTests.swift */,
EB8EC4191F85929E000B7641 /* Info.plist */,
);
path = LetterAvatarKitTests;
Expand Down Expand Up @@ -297,10 +306,12 @@
buildActionMask = 2147483647;
files = (
EB8EC4241F859382000B7641 /* LetterAvatarBuilder.swift in Sources */,
3591E07B233C24830041B834 /* LetterAvatarMaker.swift in Sources */,
35AD1DA81FA8F4FC0059BC9A /* String+LetterAvatarKit.swift in Sources */,
EB516B651F8810D200BEA1F2 /* Character+LetterAvatarKit.swift in Sources */,
35089433210272B20024E7CA /* LetterAvatarBuilderConfiguration.swift in Sources */,
EB516B661F8810D200BEA1F2 /* UIColor+LetterAvatarKit.swift in Sources */,
3591E079233C233F0041B834 /* LetterAvatarMakerExtendable.swift in Sources */,
EB516B671F8810D200BEA1F2 /* UIImage+LetterAvatarKit.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -314,6 +325,7 @@
EB516B6D1F88110A00BEA1F2 /* UIColor+LetterAvatarKitTests.swift in Sources */,
EB516B6C1F88110A00BEA1F2 /* Character+LetterAvatarKitTests.swift in Sources */,
EB821DFC1F98C233009B3775 /* UIImage+TestsUtilities.swift in Sources */,
3591E07D233C26A50041B834 /* LetterAvatarMakerTests.swift in Sources */,
EB516B6E1F88110A00BEA1F2 /* UIImage+LetterAvatarKitTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -465,7 +477,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.1.9;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.peschenkov.LetterAvatarKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -490,7 +502,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.1.9;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.peschenkov.LetterAvatarKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
44 changes: 22 additions & 22 deletions LetterAvatarKit/Extensions/UIColor+LetterAvatarKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import Foundation
/// - Parameters:
/// - hex: HEX code.
/// - Returns: The color by HEX code.
func LAKUIColorByHEX(_ hex: Int) -> UIColor {
return LAKUIColorByRGB(
func LKUIColorByHEX(_ hex: Int) -> UIColor {
return LKUIColorByRGB(
red: CGFloat((hex & 0xFF0000) >> 16),
green: CGFloat((hex & 0x00FF00) >> 8),
blue: CGFloat((hex & 0x0000FF))
Expand All @@ -46,7 +46,7 @@ func LAKUIColorByHEX(_ hex: Int) -> UIColor {
/// - green: A value of the green color component.
/// - blue: A value of the blue color component.
/// - Returns: A UIColor instance.
func LAKUIColorByRGB(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor {
func LKUIColorByRGB(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor {
return UIColor(red: red / 255, green: green / 255, blue: blue / 255, alpha: CGFloat(1.0))
}

Expand Down Expand Up @@ -99,25 +99,25 @@ extension UIColor {
var colors = objc_getAssociatedObject(self, &ColorKey.value)
if colors == nil {
colors = [
LAKUIColorByHEX(HEXColor.turquoiseColor),
LAKUIColorByHEX(HEXColor.emeraldColor),
LAKUIColorByHEX(HEXColor.piterRiverColor),
LAKUIColorByHEX(HEXColor.amethystColor),
LAKUIColorByHEX(HEXColor.wetAsphaltColor),
LAKUIColorByHEX(HEXColor.greenSeaColor),
LAKUIColorByHEX(HEXColor.nephritisColor),
LAKUIColorByHEX(HEXColor.belizeHoldeColor),
LAKUIColorByHEX(HEXColor.wisteriaColor),
LAKUIColorByHEX(HEXColor.midnightBlueColor),
LAKUIColorByHEX(HEXColor.sunflowerColor),
LAKUIColorByHEX(HEXColor.carrotColor),
LAKUIColorByHEX(HEXColor.alizarinColor),
LAKUIColorByHEX(HEXColor.concreteColor),
LAKUIColorByHEX(HEXColor.orangeColor),
LAKUIColorByHEX(HEXColor.pumpkinColor),
LAKUIColorByHEX(HEXColor.pomegranateColor),
LAKUIColorByHEX(HEXColor.silverColor),
LAKUIColorByHEX(HEXColor.asbestosColor)
LKUIColorByHEX(HEXColor.turquoiseColor),
LKUIColorByHEX(HEXColor.emeraldColor),
LKUIColorByHEX(HEXColor.piterRiverColor),
LKUIColorByHEX(HEXColor.amethystColor),
LKUIColorByHEX(HEXColor.wetAsphaltColor),
LKUIColorByHEX(HEXColor.greenSeaColor),
LKUIColorByHEX(HEXColor.nephritisColor),
LKUIColorByHEX(HEXColor.belizeHoldeColor),
LKUIColorByHEX(HEXColor.wisteriaColor),
LKUIColorByHEX(HEXColor.midnightBlueColor),
LKUIColorByHEX(HEXColor.sunflowerColor),
LKUIColorByHEX(HEXColor.carrotColor),
LKUIColorByHEX(HEXColor.alizarinColor),
LKUIColorByHEX(HEXColor.concreteColor),
LKUIColorByHEX(HEXColor.orangeColor),
LKUIColorByHEX(HEXColor.pumpkinColor),
LKUIColorByHEX(HEXColor.pomegranateColor),
LKUIColorByHEX(HEXColor.silverColor),
LKUIColorByHEX(HEXColor.asbestosColor)
]
objc_setAssociatedObject(self, &ColorKey.value, colors, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
return colors as? [ UIColor ] ?? []
Expand Down
6 changes: 3 additions & 3 deletions LetterAvatarKit/Extensions/UIImage+LetterAvatarKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension UIImage {
/// letter-based avatar image.
///
/// - Returns: Returns whether an instance of UIImage or nil.
@objc(lak_makeLetterAvatarWithConfiguration:)
@objc(lk_makeLetterAvatarWithConfiguration:)
static public func makeLetterAvatar(
withConfiguration configuration: LetterAvatarBuilderConfiguration
) -> UIImage? {
Expand All @@ -47,7 +47,7 @@ extension UIImage {
/// letter-based avatar image.
///
/// - Returns: Returns whether an instance of UIImage or nil.
@objc(lak_makeLetterAvatarWithUsername:)
@objc(lk_makeLetterAvatarWithUsername:)
static public func makeLetterAvatar(withUsername username: String?) -> UIImage? {
let configuration = LetterAvatarBuilderConfiguration()
configuration.username = username
Expand All @@ -62,7 +62,7 @@ extension UIImage {
/// - size: The avatar size.
///
/// - Returns: Returns whether an instance of UIImage or nil.
@objc(lak_makeLetterAvatarWithUsername:size:)
@objc(lk_makeLetterAvatarWithUsername:size:)
static public func makeLetterAvatar(withUsername username: String?, size: CGSize) -> UIImage? {
let configuration = LetterAvatarBuilderConfiguration()
configuration.username = username
Expand Down
2 changes: 1 addition & 1 deletion LetterAvatarKit/LetterAvatarBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import UIKit

/// Uses for making letter-based avatar images.
@objc(LAKLetterAvatarBuilder)
@objc(LKLetterAvatarBuilder)
open class LetterAvatarBuilder: NSObject {
/// Makes a letter-based avatar image by using a given configuration.
///
Expand Down
4 changes: 2 additions & 2 deletions LetterAvatarKit/LetterAvatarBuilderConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import Foundation

/// Uses for configurating a LetterAvatarBuilder instance.
@objc(LAKLetterAvatarBuilderConfiguration)
@objc(LKLetterAvatarBuilderConfiguration)
open class LetterAvatarBuilderConfiguration: NSObject {
/// The size of an avatar image.
@objc(size)
Expand All @@ -42,7 +42,7 @@ open class LetterAvatarBuilderConfiguration: NSObject {
open var lettersFont: UIFont?
/// The letters colors.
@objc(lettersColor)
open var lettersColor: UIColor = LAKUIColorByRGB(red: 236, green: 240, blue: 241)
open var lettersColor: UIColor = LKUIColorByRGB(red: 236, green: 240, blue: 241)
/// The background colors of a letter-based avatar.
@objc(backgroundColors)
open var backgroundColors: [UIColor] = UIColor.colors
Expand Down
85 changes: 85 additions & 0 deletions LetterAvatarKit/LetterAvatarMaker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// LetterAvatarMaker.swift
// LetterAvatarKit
//
// Copyright 2017 Victor Peschenkov
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// o this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

open class LetterAvatarMaker: NSObject {
fileprivate var configuration = LetterAvatarBuilderConfiguration()
}

extension LetterAvatarMaker: LetterAvatarMakerExtendable {
@discardableResult
public func setSize(_ size: CGSize) -> LetterAvatarMakerExtendable {
configuration.size = size
return self
}

@discardableResult
public func setUsername(_ username: String) -> LetterAvatarMakerExtendable {
configuration.username = username
return self
}

@discardableResult
public func setSingleLetter(_ singleLetter: Bool) -> LetterAvatarMakerExtendable {
configuration.singleLetter = singleLetter
return self
}

@discardableResult
public func setLettersFont(_ lettersFont: UIFont?) -> LetterAvatarMakerExtendable {
configuration.lettersFont = lettersFont
return self
}

@discardableResult
public func setLettersColor(_ lettersColor: UIColor) -> LetterAvatarMakerExtendable {
configuration.lettersColor = lettersColor
return self
}

@discardableResult
public func setBackgroundColors(_ backgroundColors: [UIColor]) -> LetterAvatarMakerExtendable {
configuration.backgroundColors = backgroundColors
return self
}

@discardableResult
public func setLettersFontAttributes(
_ lettersFontAttributes: [NSAttributedString.Key: Any]?
) -> LetterAvatarMakerExtendable {
configuration.lettersFontAttributes = lettersFontAttributes
return self
}

public func build(maker: (LetterAvatarBuilderConfiguration) -> Void) -> UIImage? {
maker(configuration)
return UIImage.makeLetterAvatar(withConfiguration: configuration)
}

public func build() -> UIImage? {
return UIImage.makeLetterAvatar(withConfiguration: configuration)
}
}
40 changes: 40 additions & 0 deletions LetterAvatarKit/LetterAvatarMakerExtendable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// LetterAvatarMakerExtendable.swift
// LetterAvatarKit
//
// Copyright 2017 Victor Peschenkov
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// o this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

public protocol LetterAvatarMakerExtendable: NSObjectProtocol {
func setSize(_ size: CGSize) -> LetterAvatarMakerExtendable
func setUsername(_ username: String) -> LetterAvatarMakerExtendable
func setSingleLetter(_ singleLetter: Bool) -> LetterAvatarMakerExtendable
func setLettersFont(_ lettersFont: UIFont?) -> LetterAvatarMakerExtendable
func setLettersColor(_ lettersColor: UIColor) -> LetterAvatarMakerExtendable
func setBackgroundColors(_ backgroundColors: [UIColor]) -> LetterAvatarMakerExtendable
func setLettersFontAttributes(
_ lettersFontAttributes: [NSAttributedString.Key: Any]?
) -> LetterAvatarMakerExtendable
func build(maker: (LetterAvatarBuilderConfiguration) -> Void) -> UIImage?
func build() -> UIImage?
}

0 comments on commit 25e1365

Please sign in to comment.