-
Notifications
You must be signed in to change notification settings - Fork 83
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
Changes from 8 commits
6e36ce8
50f2509
a8da890
4480f79
d7597a1
c31f4ce
c4b2e96
cceb197
af6f7b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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' |
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 |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you add some documentation to both of these variables? thanks 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I planned to use them for some new functions but then I moved them to another pull request.