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

StringDescriptor Formatter #395

Merged
merged 20 commits into from
Nov 2, 2018
Merged

StringDescriptor Formatter #395

merged 20 commits into from
Nov 2, 2018

Conversation

jleandroperez
Copy link
Collaborator

@jleandroperez jleandroperez commented Nov 1, 2018

Details:

This PR implements a new tool, to be used in the Notifications List / Details, to be known as StringFormatter.

Given a String, a collection of Range Descriptors, and Styles (Bold, Italics, etc), this tool will produce a NSAttributedString instance with its metadata stylized.

Testing:

  • Verify the unit tests are green!
  • Make sure the code makes sense

Notes:

StringStyles.swift contains a (temporary) private structure, called NukeMe. This will be removed, as soon as we do have a way to visually test how this class works, and get to fine-tune the colors.

(Subtask added in the main ticket).

cc @bummytime thanks in advance!!

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 1, 2018

1 Warning
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

SwiftLint found issues

Warnings

File Line Reason
StringDescriptor.swift 14 Opening braces should be preceded by a single space and on the same line as the declaration.
StringFormatter.swift 54 Opening braces should be preceded by a single space and on the same line as the declaration.

Generated by 🚫 Danger

@jleandroperez jleandroperez changed the title [WIP] StringDescriptor Formatter StringDescriptor Formatter Nov 1, 2018
@jleandroperez jleandroperez added feature: notifications Related to notifications or notifs. and removed [Status] Not Ready for Review labels Nov 1, 2018
@astralbodies astralbodies mentioned this pull request Nov 1, 2018
39 tasks
/// Returns the receiver *Bold* version.
///
var bold: UIFont {
guard let italicDescriptor = fontDescriptor.withSymbolicTraits(.traitBold) else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you mean boldDescriptor instead of italicDescriptor here

return self
}

return UIFont(descriptor: italicDescriptor, size: pointSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

.replacingOccurrences(of: " \t", with: String.space + String.hairSpace) // tabs after a space
.replacingOccurrences(of: "\t@", with: String.hairSpace + "@") // tabs before @mentions
.replacingOccurrences(of: "\t.", with: String.hairSpace + ".") // tabs before a space
.replacingOccurrences(of: "\t,", with: String.hairSpace + ",") // tabs cefore a comman
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicky: comment tabs before a comma

}()


/// Styles: Notification Defailts / Badge Blocks
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicky - Defaults instead of Defailts

Copy link
Member

@bummytime bummytime left a comment

Choose a reason for hiding this comment

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

@jleandroperez I poured over the code and did not find any issues (beyond what @mindgraffiti noted) — StringFormatter looks straight-forward in terms of usage. Can't wait to give this a try in the UI!

:shipit: !

@@ -4,8 +4,16 @@ import UIKit
// MARK: - Style defines the basic API of a Woo Skin.
//
protocol Style {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for organizing this! ❤️

@jleandroperez
Copy link
Collaborator Author

Thank you both!! ❤️

@jleandroperez jleandroperez merged commit cc01cfc into develop Nov 2, 2018
@jleandroperez jleandroperez deleted the issue/19-block-formatter branch November 2, 2018 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: notifications Related to notifications or notifs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants