Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Aug 4, 2020
2 parents 4e623dd + fcfef1e commit 93e7c66
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion WordPressShared.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressShared"
s.version = "1.9.0"
s.version = "1.10.0-beta.2"
s.summary = "Shared components used in building the WordPress iOS apps and other library components."

s.description = <<-DESC
Expand Down
8 changes: 8 additions & 0 deletions WordPressShared.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
1A4094D52270A75E009AA86D /* NSBundle+WordPressShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A4094D42270A75E009AA86D /* NSBundle+WordPressShared.swift */; };
1A4095102271AA9E009AA86D /* WPShared-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A40950D2271AA9E009AA86D /* WPShared-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; };
2EB9C57E3BFEDA1676FE857C /* Pods_WordPressShared.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE15A6EE80D7766A21B83BF5 /* Pods_WordPressShared.framework */; };
32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */; };
740B23CC1F17F1FF00067A2A /* DisplayableImageHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 740B23CA1F17F1FF00067A2A /* DisplayableImageHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
740B23CD1F17F1FF00067A2A /* DisplayableImageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CB1F17F1FF00067A2A /* DisplayableImageHelper.m */; };
740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CE1F17F28E00067A2A /* DisplayableImageHelperTest.m */; };
Expand Down Expand Up @@ -93,6 +94,7 @@
F10A569223E1FE7700B184F4 /* NSString+Summary.swift in Sources */ = {isa = PBXBuildFile; fileRef = F10A569123E1FE7700B184F4 /* NSString+Summary.swift */; };
F1134A272270C15E00B8F75F /* Debouncer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1134A262270C15E00B8F75F /* Debouncer.swift */; };
F1134A292270C19200B8F75F /* DebouncerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1134A282270C19200B8F75F /* DebouncerTests.swift */; };
F193585624CA3F4E00942507 /* AnalyticsEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = F193585524CA3F4E00942507 /* AnalyticsEvent.swift */; };
F1C83C0C23E205D900A8CCF1 /* NSStringSummaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C83C0B23E205D900A8CCF1 /* NSStringSummaryTests.swift */; };
F1C83C0E23E20D9400A8CCF1 /* String+StripGutenbergContentForExcerpt.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C83C0D23E20D9400A8CCF1 /* String+StripGutenbergContentForExcerpt.swift */; };
F1C83C1023E20EF200A8CCF1 /* String+RemovingMatches.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C83C0F23E20EF200A8CCF1 /* String+RemovingMatches.swift */; };
Expand All @@ -114,6 +116,7 @@
/* Begin PBXFileReference section */
1A4094D42270A75E009AA86D /* NSBundle+WordPressShared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+WordPressShared.swift"; sourceTree = "<group>"; };
1A40950D2271AA9E009AA86D /* WPShared-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPShared-Swift.h"; sourceTree = "<group>"; };
32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WPStyleGuide+SerifFonts.swift"; sourceTree = "<group>"; };
405129D7901B7D4AD3B46442 /* Pods-WordPressShared.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release-internal.xcconfig"; sourceTree = "<group>"; };
47629DF6D2C813279CBF93C4 /* Pods_WordPressSharedTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressSharedTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5AC1280B7CDCD44A2F3A20AC /* Pods-WordPressShared.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release-alpha.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -212,6 +215,7 @@
F10A569123E1FE7700B184F4 /* NSString+Summary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSString+Summary.swift"; sourceTree = "<group>"; };
F1134A262270C15E00B8F75F /* Debouncer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Debouncer.swift; sourceTree = "<group>"; };
F1134A282270C19200B8F75F /* DebouncerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebouncerTests.swift; sourceTree = "<group>"; };
F193585524CA3F4E00942507 /* AnalyticsEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsEvent.swift; sourceTree = "<group>"; };
F19847DB226F92420004A8BC /* String+URLValidation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+URLValidation.swift"; sourceTree = "<group>"; };
F19847DD226F92EA0004A8BC /* StringURLValidationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringURLValidationTests.swift; sourceTree = "<group>"; };
F1C83C0B23E205D900A8CCF1 /* NSStringSummaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStringSummaryTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -452,6 +456,7 @@
B5A7880E202B3A55007874FB /* WPNUXUtility.h */,
B5A78811202B3A55007874FB /* WPNUXUtility.m */,
B5A7880F202B3A55007874FB /* WPStyleGuide+DynamicType.swift */,
32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */,
B5A7881D202B3A92007874FB /* WPTableViewCell.h */,
B5A7881A202B3A92007874FB /* WPTableViewCell.m */,
B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */,
Expand All @@ -463,6 +468,7 @@
E1A444251F063CAB00F6AA8A /* Analytics */ = {
isa = PBXGroup;
children = (
F193585524CA3F4E00942507 /* AnalyticsEvent.swift */,
E1A444261F063CAB00F6AA8A /* WPAnalytics.h */,
E1A444271F063CAB00F6AA8A /* WPAnalytics.m */,
);
Expand Down Expand Up @@ -703,10 +709,12 @@
827070061ECA43AA00155CBF /* NSString+XMLExtensions.m in Sources */,
F1C83C0E23E20D9400A8CCF1 /* String+StripGutenbergContentForExcerpt.swift in Sources */,
82706FF31ECA438500155CBF /* WPSharedLogging.m in Sources */,
F193585624CA3F4E00942507 /* AnalyticsEvent.swift in Sources */,
F1134A272270C15E00B8F75F /* Debouncer.swift in Sources */,
B5393FD8206D608F007BF9D4 /* EmailFormatValidator.swift in Sources */,
F106FA62226FA82E00706DE4 /* String+URLValidation.swift in Sources */,
F10A569023E1FC1300B184F4 /* String+StripShortcodes.swift in Sources */,
32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */,
93C882AD1EEB1E2F00227A59 /* NSDate+Helpers.swift in Sources */,
74650F801F0EA4BD00188EDB /* NSMutableData+Helpers.swift in Sources */,
7414BD621F13D084005759F8 /* UIDevice+Helpers.m in Sources */,
Expand Down
55 changes: 55 additions & 0 deletions WordPressShared/Core/Analytics/AnalyticsEvent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Foundation

/// This struct represents an analytics event.
/// Declaring this class as final is a design choice to promote a simpler usage and implement events
/// through parametrization of the `name` and `properties` properties.
///
/// An example of a static event definition (in the client App or Pod):
///
/// ~~~
/// extension AnalyticsEvent {
/// static let loginStart = AnalyticsEvent(name: "login", properties: ["step": "start"])
/// }
/// ~~~
///
/// An example of a dynamic / parametrized event definition (in the client App or Pod):
///
/// ~~~
/// extension AnalyticsEvent {
/// enum LoginStep: String {
/// case start
/// case success
/// }
///
/// static func login(step: LoginStep) -> AnalyticsEvent {
/// let properties = [
/// "step": step.rawValue
/// ]
///
/// return AnalyticsEvent(name: "login", properties: properties)
/// }
/// }
/// ~~~
///
/// Examples of tracking calls (in the client App or Pod):
///
/// ~~~
/// WPAnalytics.track(.login(step: .start))
/// WPAnalytics.track(.loginStart)
/// ~~~
///
public final class AnalyticsEvent {
public let name: String
public let properties: [String: String]

public init(name: String, properties: [String: String]) {
self.name = name
self.properties = properties
}
}

extension WPAnalytics {
public static func track(_ event: AnalyticsEvent) {
WPAnalytics.trackString(event.name, withProperties: event.properties)
}
}
3 changes: 0 additions & 3 deletions WordPressShared/Core/Analytics/WPAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) {
WPAnalyticsStatMenusSavedMenu,
WPAnalyticsStatMeTabAccessed,
WPAnalyticsStatMySitesTabAccessed,
WPAnalyticsStatNewsCardViewed,
WPAnalyticsStatNewsCardDismissed,
WPAnalyticsStatNewsCardRequestedExtendedInfo,
WPAnalyticsStatNotificationsCommentApproved,
WPAnalyticsStatNotificationsCommentFlaggedAsSpam,
WPAnalyticsStatNotificationsCommentLiked,
Expand Down
33 changes: 33 additions & 0 deletions WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Foundation

/// WPStyleGuide Extension to use serif fonts.
///
extension WPStyleGuide {
/// Returns the system serif font (New York) for iOS 13+ but defaults to noto for older os's
@objc public class func serifFontForTextStyle(_ style: UIFont.TextStyle,
fontWeight weight: UIFont.Weight = .regular) -> UIFont {
guard #available(iOS 13, *),
let fontDescriptor = WPStyleGuide.fontForTextStyle(style, fontWeight: weight).fontDescriptor.withDesign(.serif)
else {
return WPStyleGuide.notoFontForTextStyle(style, fontWeight: weight)
}

return UIFontMetrics.default.scaledFont(for: UIFont(descriptor: fontDescriptor, size: 0.0))
}


private class func notoFontForTextStyle(_ style: UIFont.TextStyle,
fontWeight weight: UIFont.Weight = .regular) -> UIFont {
var font: UIFont

switch weight {
// Map all the bold weights to the bold font
case .bold, .semibold, .heavy, .black:
font = WPStyleGuide.notoBoldFontForTextStyle(style)
default:
font = WPStyleGuide.notoFontForTextStyle(style)
}

return font
}
}

0 comments on commit 93e7c66

Please sign in to comment.