-
Notifications
You must be signed in to change notification settings - Fork 84
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6e36ce8
extension NSString for macOS
RomanPodymov 50f2509
UIKit + SwiftyAttributes
RomanPodymov a8da890
tests for public var swiftyLargeTitleTextAttributes
RomanPodymov 4480f79
fixed build error on tvOS
RomanPodymov d7597a1
fixed for tvOS again
RomanPodymov c31f4ce
moved NSString+SwiftyAttributes
RomanPodymov c4b2e96
fixed macOS build error
RomanPodymov cceb197
less functions
RomanPodymov af6f7b5
removed unused typealiases. less #if os. added documentation for new …
RomanPodymov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
SwiftyAttributes/Sources/iOS_tvOS/UIKit+SwiftyAttributes.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// 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 | ||
extension UINavigationBar { | ||
|
||
/// A swifty wrapper for UINavigationBar.titleTextAttributes. Use it if you prefer [Attribute] to [NSAttributedString.Key:Any]. | ||
public var swiftyTitleTextAttributes: [Attribute]? { | ||
set { | ||
titleTextAttributes = newValue?.foundationAttributes | ||
} | ||
|
||
get { | ||
return titleTextAttributes?.swiftyAttributes | ||
} | ||
} | ||
|
||
/// A swifty wrapper for UINavigationBar.largeTitleTextAttributes. Use it if you prefer [Attribute] to [NSAttributedString.Key:Any]. | ||
#if os(iOS) | ||
@available(iOS 11, *) | ||
public var swiftyLargeTitleTextAttributes: [Attribute]? { | ||
set { | ||
largeTitleTextAttributes = newValue?.foundationAttributes | ||
} | ||
|
||
get { | ||
return largeTitleTextAttributes?.swiftyAttributes | ||
} | ||
} | ||
#endif | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = UINavigationBar() | ||
subject.swiftyTitleTextAttributes = [ | ||
.backgroundColor(.yellow), | ||
.font(.systemFont(ofSize: 19)) | ||
] | ||
|
||
let exptected = UINavigationBar() | ||
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 = UINavigationBar() | ||
subject.swiftyLargeTitleTextAttributes = [ | ||
.backgroundColor(.yellow), | ||
.font(.systemFont(ofSize: 19)) | ||
] | ||
|
||
let exptected = UINavigationBar() | ||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 you add some documentation to both of these variables? thanks 🙏
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.
Added description for these new properties, if you want you can add something better.