Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UINavigationBar wrappers #34

Merged
merged 9 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem 'cocoapods', '~> 1.3.0'
gem 'cocoapods', '~> 1.7.0'
66 changes: 35 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,72 +1,76 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.5)
activesupport (4.2.9)
CFPropertyList (3.0.0)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
atomos (0.1.3)
claide (1.0.2)
cocoapods (1.3.1)
cocoapods (1.7.0)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.3.1)
cocoapods-deintegrate (>= 1.0.1, < 2.0)
cocoapods-downloader (>= 1.1.3, < 2.0)
cocoapods-core (= 1.7.0)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.2.0, < 2.0)
cocoapods-trunk (>= 1.3.1, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (~> 2.0.1)
fourflusher (>= 2.2.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.5.7)
molinillo (~> 0.6.6)
nap (~> 1.0)
ruby-macho (~> 1.1)
xcodeproj (>= 1.5.1, < 2.0)
cocoapods-core (1.3.1)
ruby-macho (~> 1.4)
xcodeproj (>= 1.8.2, < 2.0)
cocoapods-core (1.7.0)
activesupport (>= 4.0.2, < 6)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.3)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.2.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.3.1)
nap (>= 0.8, < 2.0)
netrc (= 0.7.8)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.1.5)
escape (0.0.4)
fourflusher (2.0.1)
fourflusher (2.2.0)
fuzzy_match (2.0.4)
gh_inspector (1.0.3)
i18n (0.8.6)
minitest (5.10.3)
molinillo (0.5.7)
nanaimo (0.2.3)
gh_inspector (1.1.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
molinillo (0.6.6)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.7.8)
ruby-macho (1.1.0)
netrc (0.11.0)
ruby-macho (1.4.0)
thread_safe (0.3.6)
tzinfo (1.2.3)
tzinfo (1.2.5)
thread_safe (~> 0.1)
xcodeproj (1.5.1)
CFPropertyList (~> 2.3.3)
xcodeproj (1.9.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
nanaimo (~> 0.2.6)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.3.0)
cocoapods (~> 1.7.0)

BUNDLED WITH
1.13.6
1.17.3
4 changes: 3 additions & 1 deletion SwiftyAttributes.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/eddiekaiger/SwiftyAttributes.git", :tag => "v" + s.version.to_s }

s.source_files = "SwiftyAttributes/Sources/common/*.swift"
s.ios.source_files = "SwiftyAttributes/Sources/iOS_tvOS/*.swift"
s.tvos.source_files = "SwiftyAttributes/Sources/iOS_tvOS/*.swift"
s.osx.source_files = "SwiftyAttributes/Sources/macOS/*.swift"

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.11'
s.tvos.deployment_target = '9.0'
Expand Down
18 changes: 17 additions & 1 deletion SwiftyAttributes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
9E0DA889229B2F8600E29BFD /* UIKit+SwiftyAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E0DA888229B2F8600E29BFD /* UIKit+SwiftyAttributes.swift */; };
9E0DA88E229B34D800E29BFD /* UIKit+SwiftyAttributes_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E0DA88D229B34D800E29BFD /* UIKit+SwiftyAttributes_Tests.swift */; };
C027C0C91DEA0A0100953C09 /* SpellingState_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C027C0C81DEA0A0100953C09 /* SpellingState_Tests.swift */; };
C027C0CB1DEA452500953C09 /* Attribute+Sequence_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C027C0CA1DEA452500953C09 /* Attribute+Sequence_Tests.swift */; };
C03658FA1DC859D80051F06D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03658F91DC859D80051F06D /* AppDelegate.swift */; };
Expand Down Expand Up @@ -69,6 +71,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
9E0DA888229B2F8600E29BFD /* UIKit+SwiftyAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIKit+SwiftyAttributes.swift"; sourceTree = "<group>"; };
9E0DA88D229B34D800E29BFD /* UIKit+SwiftyAttributes_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIKit+SwiftyAttributes_Tests.swift"; sourceTree = "<group>"; };
C027C0C81DEA0A0100953C09 /* SpellingState_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpellingState_Tests.swift; sourceTree = "<group>"; };
C027C0CA1DEA452500953C09 /* Attribute+Sequence_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Attribute+Sequence_Tests.swift"; sourceTree = "<group>"; };
C0335B631DC0877C009F9B51 /* WritingDirection_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WritingDirection_Tests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,6 +149,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
9E0DA88A229B33F600E29BFD /* iOS_tvOS */ = {
isa = PBXGroup;
children = (
9E0DA888229B2F8600E29BFD /* UIKit+SwiftyAttributes.swift */,
);
path = iOS_tvOS;
sourceTree = "<group>";
};
C03658F81DC859D80051F06D /* ExampleApp-iOS */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -212,8 +224,9 @@
C0335B651DC087A3009F9B51 /* Operators_Tests.swift */,
C027C0C81DEA0A0100953C09 /* SpellingState_Tests.swift */,
C0D753FA1DC5C77E00BB9754 /* TextEffect_Tests.swift */,
C09633DA1DD8016800059332 /* Info.plist */,
9E0DA88D229B34D800E29BFD /* UIKit+SwiftyAttributes_Tests.swift */,
C0F96A021DEDE1D300D039A4 /* VerticalGlyphForm_Tests.swift */,
C09633DA1DD8016800059332 /* Info.plist */,
);
path = SwiftyAttributesTests;
sourceTree = "<group>";
Expand All @@ -231,6 +244,7 @@
C05082261DFA72F700D39B3B /* TextEffect.swift */,
C05082271DFA72F700D39B3B /* VerticalGlyphForm.swift */,
C05082281DFA72F700D39B3B /* WritingDirection.swift */,
9E0DA88A229B33F600E29BFD /* iOS_tvOS */,
C0F001661DDD8E56009AD8E0 /* macOS */,
);
path = Sources;
Expand Down Expand Up @@ -469,6 +483,7 @@
C0F96A051DEDE23200D039A4 /* String+macOS.swift in Sources */,
C0F001761DDD8EA5009AD8E0 /* SpellingState.swift in Sources */,
C05082291DFA72F700D39B3B /* Attribute+Sequence.swift in Sources */,
9E0DA889229B2F8600E29BFD /* UIKit+SwiftyAttributes.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -483,6 +498,7 @@
C027C0C91DEA0A0100953C09 /* SpellingState_Tests.swift in Sources */,
C0F96A031DEDE1D300D039A4 /* VerticalGlyphForm_Tests.swift in Sources */,
C027C0CB1DEA452500953C09 /* Attribute+Sequence_Tests.swift in Sources */,
9E0DA88E229B34D800E29BFD /* UIKit+SwiftyAttributes_Tests.swift in Sources */,
C0E1C96F1DD31A0D0068E85C /* Operators_Tests.swift in Sources */,
C0E1C96C1DD31A0D0068E85C /* NSAttributedString_Tests.swift in Sources */,
);
Expand Down
9 changes: 9 additions & 0 deletions SwiftyAttributes/Sources/common/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@
public typealias Font = NSFont
public typealias Cursor = NSCursor
public typealias TextAlternatives = NSTextAlternatives
public typealias Point = NSPoint
public typealias Size = NSSize
public typealias Rect = NSRect
public typealias DrawingOptions = NSString.DrawingOptions
#else
import UIKit
public typealias Color = UIColor
public typealias Font = UIFont
public typealias Point = CGPoint
public typealias Size = CGSize
public typealias Rect = CGRect
public typealias DrawingOptions = NSStringDrawingOptions
#endif

public typealias UnderlineStyle = NSUnderlineStyle
public typealias StrikethroughStyle = NSUnderlineStyle
public typealias ParagraphStyle = NSParagraphStyle
public typealias DrawingContext = NSStringDrawingContext
Copy link
Owner

Choose a reason for hiding this comment

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

could we remove all these new typealiases since they're not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could we remove all these new typealiases since they're not used?

I planned to use them for some new functions but then I moved them to another pull request.


#if os(watchOS)
#else
Expand Down
44 changes: 44 additions & 0 deletions SwiftyAttributes/Sources/iOS_tvOS/UIKit+SwiftyAttributes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// UIKit+SwiftyAttributes.swift
// SwiftyAttributes
//
// Created by Roman Podymov on 26/05/19.
// Copyright © 2019 Roman Podymov. All rights reserved.
//

#if os(macOS)
#elseif os(watchOS)
#else
import UIKit
public typealias NavigationBar = UINavigationBar
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we need the typealias since there's no conflicting navigation bar type

#endif

#if os(macOS)
#elseif os(watchOS)
#else
Copy link
Owner

Choose a reason for hiding this comment

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

I think you could just extend the above macros for the entire file so that you don't need to repeat them

extension NavigationBar {

public var swiftyTitleTextAttributes: [Attribute]? {
Copy link
Owner

Choose a reason for hiding this comment

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

could you add some documentation to both of these variables? thanks 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you add some documentation to both of these variables? thanks 🙏

Added description for these new properties, if you want you can add something better.

set {
titleTextAttributes = newValue?.foundationAttributes
}

get {
return titleTextAttributes?.swiftyAttributes
}
}

#if os(iOS)
@available(iOS 11, *)
public var swiftyLargeTitleTextAttributes: [Attribute]? {
set {
largeTitleTextAttributes = newValue?.foundationAttributes
}

get {
return largeTitleTextAttributes?.swiftyAttributes
}
}
#endif
}
#endif
61 changes: 61 additions & 0 deletions SwiftyAttributesTests/UIKit+SwiftyAttributes_Tests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// UIKit+SwiftyAttributes_Tests.swift
// SwiftyAttributes
//
// Created by Roman Podymov on 26/05/19.
// Copyright © 2019 Roman Podymov. All rights reserved.
//

import XCTest
import SwiftyAttributes

#if os(macOS)
#elseif os(watchOS)
#else
class UIKit_SwiftyAttributes_Tests: XCTestCase {

func testTitleTextAttributes() {

let subject = NavigationBar()
subject.swiftyTitleTextAttributes = [
.backgroundColor(.yellow),
.font(.systemFont(ofSize: 19))
]

let exptected = NavigationBar()
exptected.titleTextAttributes = [
NSAttributedString.Key.backgroundColor: UIColor.yellow,
NSAttributedString.Key.font: Font.systemFont(ofSize: 19)
]

XCTAssertNotNil(subject.swiftyTitleTextAttributes?.foundationAttributes)
XCTAssertNotNil(exptected.titleTextAttributes)
XCTAssertEqual(subject.swiftyTitleTextAttributes!.foundationAttributes as NSDictionary, exptected.titleTextAttributes! as NSDictionary)
}

#if os(iOS)
func testLargeTitleTextAttributes() {

guard #available(iOS 11.0, *) else {
return
}

let subject = NavigationBar()
subject.swiftyLargeTitleTextAttributes = [
.backgroundColor(.yellow),
.font(.systemFont(ofSize: 19))
]

let exptected = NavigationBar()
exptected.largeTitleTextAttributes = [
NSAttributedString.Key.backgroundColor: UIColor.yellow,
NSAttributedString.Key.font: Font.systemFont(ofSize: 19)
]

XCTAssertNotNil(subject.swiftyLargeTitleTextAttributes?.foundationAttributes)
XCTAssertNotNil(exptected.largeTitleTextAttributes)
XCTAssertEqual(subject.swiftyLargeTitleTextAttributes!.foundationAttributes as NSDictionary, exptected.largeTitleTextAttributes! as NSDictionary)
}
#endif
}
#endif