Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Aztec/Classes/Extensions/NSRange+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ extension Sequence where Iterator.Element == NSRange {
}
}

extension NSRange: Equatable {
public static func ==(lhs: NSRange, rhs: NSRange) -> Bool{
return lhs.location == rhs.location && lhs.length == rhs.length
#if swift(>=3.2)
// No Op
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to specify with a comment though, it's self evident!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's okay with you, let's leave it! love the way NO-OP reads, reminds me of the good old ASM days.

#else
extension NSRange: Equatable {
public static func ==(lhs: NSRange, rhs: NSRange) -> Bool{
return lhs.location == rhs.location && lhs.length == rhs.length
}
}
}
#endif

23 changes: 0 additions & 23 deletions Aztec/Classes/Extensions/String+RangeConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ public extension String {
return start ..< end
}

func range(from unicodeNSRange: Range<String.UnicodeScalarView.Index>) -> Range<String.Index>? {
guard let lowerBound = unicodeNSRange.lowerBound.samePosition(in: self),
let upperBound = unicodeNSRange.upperBound.samePosition(in: self) else {
return nil
}

return lowerBound ..< upperBound
}

func nsRange(of string: String) -> NSRange? {
guard let range = self.range(of: string) else {
return nil
Expand Down Expand Up @@ -131,20 +122,6 @@ public extension String {
return NSRange(location: location, length: length)
}

/// Converts a `Range<String.UnicodeScalarView.Index>` into an Unicod Scalar `NSRange`.
///
/// - Parameters:
/// - range: the range to convert.
///
/// - Returns: the requested `NSRange`.
///
func nsRange(from range: Range<String.UnicodeScalarView.Index>) -> NSRange {
let location = unicodeScalars.distance(from: unicodeScalars.startIndex, to: range.lowerBound)
let length = unicodeScalars.distance(from: range.lowerBound, to: range.upperBound)

return NSRange(location: location, length: length)
}

/// Returns a NSRange with a starting location at the very end of the string
///
func endOfStringNSRange() -> NSRange {
Expand Down
4 changes: 2 additions & 2 deletions Aztec/Classes/TextKit/HTMLStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private extension HTMLStorage {
///
struct Styles {
static let defaultCommentColor = UIColor.lightGray
static let defaultTagColor = UIColor(colorLiteralRed: 0x00/255.0, green: 0x75/255.0, blue: 0xB6/255.0, alpha: 0xFF/255.0)
static let defaultQuotedColor = UIColor(colorLiteralRed: 0x6E/255.0, green: 0x96/255.0, blue: 0xB1/255.0, alpha: 0xFF/255.0)
static let defaultTagColor = UIColor(red: 0x00/255.0, green: 0x75/255.0, blue: 0xB6/255.0, alpha: 0xFF/255.0)
static let defaultQuotedColor = UIColor(red: 0x6E/255.0, green: 0x96/255.0, blue: 0xB1/255.0, alpha: 0xFF/255.0)
}
}
4 changes: 2 additions & 2 deletions AztecTests/Extensions/UIColorHexParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UIColorHexParserTests: XCTestCase {

color = UIColor(hexString: "#FFFFFF")

XCTAssertEqual(color, UIColor.init(colorLiteralRed: 1, green: 1, blue: 1, alpha: 1))
XCTAssertEqual(color, UIColor(red: 1, green: 1, blue: 1, alpha: 1))
}

func testParseOf32bitsHexColors() {
Expand All @@ -46,7 +46,7 @@ class UIColorHexParserTests: XCTestCase {

color = UIColor(hexString: "#FFFFFFFF")

XCTAssertEqual(color, UIColor.init(colorLiteralRed: 1, green: 1, blue: 1, alpha: 1))
XCTAssertEqual(color, UIColor(red: 1, green: 1, blue: 1, alpha: 1))
}

func testFailingColor() {
Expand Down
2 changes: 1 addition & 1 deletion AztecTests/TextKit/TextViewStubAttachmentDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UIKit

class TextViewStubAttachmentDelegate: TextViewAttachmentDelegate, TextViewAttachmentImageProvider {

func textView(_ textView: TextView, attachment: NSTextAttachment, imageAt url: URL, onSuccess success: @escaping (UIImage) -> Void, onFailure failure: @escaping (Void) -> Void) {
func textView(_ textView: TextView, attachment: NSTextAttachment, imageAt url: URL, onSuccess success: @escaping (UIImage) -> Void, onFailure failure: @escaping () -> Void) {
// NO OP!
}

Expand Down
1 change: 1 addition & 0 deletions AztecTests/TextKit/TextViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TextViewTests: XCTestCase {
func createTextView(withHTML html: String) -> TextView {
let richTextView = Aztec.TextView(defaultFont: UIFont.systemFont(ofSize: 14), defaultMissingImage: UIImage())
richTextView.textAttachmentDelegate = attachmentDelegate
richTextView.registerAttachmentImageProvider(attachmentDelegate)
richTextView.setHTML(html)

return richTextView
Expand Down