From e6c6701a513798b9053249b452a0efd03b05c4dc Mon Sep 17 00:00:00 2001 From: "Thuy.Copeland" Date: Thu, 6 Aug 2020 16:37:15 -0500 Subject: [PATCH 01/10] Bump the podspec version to 1.10.0-beta.3 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index bf46f8f..4cf3962 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.10.0-beta.2" + s.version = "1.10.0-beta.3" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From 9d2a8c33ccc1ef2f5270b7473bf8249dfd78a2de Mon Sep 17 00:00:00 2001 From: "Thuy.Copeland" Date: Thu, 6 Aug 2020 16:37:36 -0500 Subject: [PATCH 02/10] Update and migrate internationalization to recommended Xcode settings --- WordPressShared.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPressShared.xcodeproj/project.pbxproj b/WordPressShared.xcodeproj/project.pbxproj index a4398e7..ecec6e3 100644 --- a/WordPressShared.xcodeproj/project.pbxproj +++ b/WordPressShared.xcodeproj/project.pbxproj @@ -571,11 +571,11 @@ }; buildConfigurationList = 829DD1381EC9EED200AB8C12 /* Build configuration list for PBXProject "WordPressShared" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, + Base, ); mainGroup = 829DD1341EC9EED200AB8C12; productRefGroup = 829DD13F1EC9EED200AB8C12 /* Products */; From 1d6d6ae0d6ae4baff22d49cc8104b93178e3cecf Mon Sep 17 00:00:00 2001 From: "Thuy.Copeland" Date: Thu, 6 Aug 2020 16:39:15 -0500 Subject: [PATCH 03/10] Add the CollectionType extension file to the project --- WordPressShared.xcodeproj/project.pbxproj | 4 ++++ .../Core/Utility/CollectionType+Helpers.swift | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 WordPressShared/Core/Utility/CollectionType+Helpers.swift diff --git a/WordPressShared.xcodeproj/project.pbxproj b/WordPressShared.xcodeproj/project.pbxproj index ecec6e3..c79adf5 100644 --- a/WordPressShared.xcodeproj/project.pbxproj +++ b/WordPressShared.xcodeproj/project.pbxproj @@ -82,6 +82,7 @@ B5A7881F202B3A92007874FB /* WPTextFieldTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; B5A78820202B3A92007874FB /* WPTextFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7881C202B3A92007874FB /* WPTextFieldTableViewCell.m */; }; B5A78821202B3A92007874FB /* WPTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881D202B3A92007874FB /* WPTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE1CB30424DCAFCB00DBAD9C /* CollectionType+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1CB30324DCAFCB00DBAD9C /* CollectionType+Helpers.swift */; }; E157E126239527700051AE41 /* Secret.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E125239527700051AE41 /* Secret.swift */; }; E157E128239527AD0051AE41 /* SecretTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E127239527AD0051AE41 /* SecretTests.swift */; }; E18EABEA1F0E2C6800BFCB0B /* TestAnalyticsTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */; }; @@ -202,6 +203,7 @@ B5A7881D202B3A92007874FB /* WPTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WPTableViewCell.h; sourceTree = ""; }; B5A78823202B3B3C007874FB /* WordPressUIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WordPressUIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BAD47F9FCABF8C12D6352A20 /* Pods-WordPressSharedTests.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.release-internal.xcconfig"; sourceTree = ""; }; + CE1CB30324DCAFCB00DBAD9C /* CollectionType+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CollectionType+Helpers.swift"; sourceTree = ""; }; D62D565031D4683172615BAC /* Pods-WordPressSharedTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.release.xcconfig"; sourceTree = ""; }; E157E125239527700051AE41 /* Secret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secret.swift; sourceTree = ""; }; E157E127239527AD0051AE41 /* SecretTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretTests.swift; sourceTree = ""; }; @@ -297,6 +299,7 @@ 82706FE01ECA32D400155CBF /* Utility */ = { isa = PBXGroup; children = ( + CE1CB30324DCAFCB00DBAD9C /* CollectionType+Helpers.swift */, 74FA25F21F1FD9640044BC54 /* DateUtils.h */, 74FA25F31F1FD9640044BC54 /* DateUtils.m */, F1134A262270C15E00B8F75F /* Debouncer.swift */, @@ -712,6 +715,7 @@ F193585624CA3F4E00942507 /* AnalyticsEvent.swift in Sources */, F1134A272270C15E00B8F75F /* Debouncer.swift in Sources */, B5393FD8206D608F007BF9D4 /* EmailFormatValidator.swift in Sources */, + CE1CB30424DCAFCB00DBAD9C /* CollectionType+Helpers.swift in Sources */, F106FA62226FA82E00706DE4 /* String+URLValidation.swift in Sources */, F10A569023E1FC1300B184F4 /* String+StripShortcodes.swift in Sources */, 32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */, diff --git a/WordPressShared/Core/Utility/CollectionType+Helpers.swift b/WordPressShared/Core/Utility/CollectionType+Helpers.swift new file mode 100644 index 0000000..997d774 --- /dev/null +++ b/WordPressShared/Core/Utility/CollectionType+Helpers.swift @@ -0,0 +1,18 @@ +import Foundation + +extension BidirectionalCollection { + public func lastIndex(where predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Index? { + if let idx = try reversed().firstIndex(where: predicate) { + return self.index(before: idx.base) + } + return nil + } +} + +extension Collection { + + /// Returns the element at the specified index if it is within bounds, otherwise nil. + subscript (safe index: Index) -> Element? { + return indices.contains(index) ? self[index] : nil + } +} From ec212d0072ac1908c3465cb67d1a83118ae1b1fb Mon Sep 17 00:00:00 2001 From: "Thuy.Copeland" Date: Fri, 7 Aug 2020 11:37:16 -0500 Subject: [PATCH 04/10] Expose the subscript function to be public --- WordPressShared/Core/Utility/CollectionType+Helpers.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared/Core/Utility/CollectionType+Helpers.swift b/WordPressShared/Core/Utility/CollectionType+Helpers.swift index 997d774..a7afed9 100644 --- a/WordPressShared/Core/Utility/CollectionType+Helpers.swift +++ b/WordPressShared/Core/Utility/CollectionType+Helpers.swift @@ -12,7 +12,7 @@ extension BidirectionalCollection { extension Collection { /// Returns the element at the specified index if it is within bounds, otherwise nil. - subscript (safe index: Index) -> Element? { + public subscript (safe index: Index) -> Element? { return indices.contains(index) ? self[index] : nil } } From b5d973d8086498c4871073c26c37970864dcc024 Mon Sep 17 00:00:00 2001 From: "Thuy.Copeland" Date: Mon, 10 Aug 2020 12:09:41 -0500 Subject: [PATCH 05/10] Bump the podspec to 1.11.0-beta.1 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index 4cf3962..a5e0473 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.10.0-beta.3" + s.version = "1.11.0-beta.1" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From c6caeb07e37ed48edb73b352043725d24b0949b4 Mon Sep 17 00:00:00 2001 From: "Thuy.Copeland" Date: Mon, 10 Aug 2020 12:11:03 -0500 Subject: [PATCH 06/10] Conform to code standards by adding (some) documentation --- WordPressShared/Core/Utility/CollectionType+Helpers.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WordPressShared/Core/Utility/CollectionType+Helpers.swift b/WordPressShared/Core/Utility/CollectionType+Helpers.swift index a7afed9..c0d76cc 100644 --- a/WordPressShared/Core/Utility/CollectionType+Helpers.swift +++ b/WordPressShared/Core/Utility/CollectionType+Helpers.swift @@ -1,5 +1,8 @@ import Foundation + +// MARK: - Collection Type Helpers +// extension BidirectionalCollection { public func lastIndex(where predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Index? { if let idx = try reversed().firstIndex(where: predicate) { @@ -10,8 +13,8 @@ extension BidirectionalCollection { } extension Collection { - /// Returns the element at the specified index if it is within bounds, otherwise nil. + /// public subscript (safe index: Index) -> Element? { return indices.contains(index) ? self[index] : nil } From d1853db9ebb4259e8b1e0d871be981737ec322d2 Mon Sep 17 00:00:00 2001 From: Jeremy Massel Date: Mon, 10 Aug 2020 20:01:42 -0600 Subject: [PATCH 07/10] Tag 1.11.0 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index a5e0473..163b68c 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.11.0-beta.1" + s.version = "1.11.0" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From 35741b509fa7fb2e5f52f9d16ea20fdf87e29bf8 Mon Sep 17 00:00:00 2001 From: James Frost Date: Mon, 31 Aug 2020 12:16:21 +0100 Subject: [PATCH 08/10] Adds loading system serif or noto font at default size for style --- .../Core/Views/WPStyleGuide+DynamicType.swift | 45 ++++++++++++++++++- .../Core/Views/WPStyleGuide+SerifFonts.swift | 22 ++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/WordPressShared/Core/Views/WPStyleGuide+DynamicType.swift b/WordPressShared/Core/Views/WPStyleGuide+DynamicType.swift index 804a71d..64ef5bf 100644 --- a/WordPressShared/Core/Views/WPStyleGuide+DynamicType.swift +++ b/WordPressShared/Core/Views/WPStyleGuide+DynamicType.swift @@ -189,6 +189,28 @@ extension WPStyleGuide { return UIFont(descriptor: descriptorWithTraits, size: size) } + /// Creates a NotoSerif UIFont at the specified size. + /// + /// - Parameters: + /// - size: The desired size. + /// + /// - Returns: The created font. + /// + @objc public class func fixedNotoFontWithSize(_ size: CGFloat) -> UIFont { + return fixedCustomNotoFontNamed("NotoSerif", withSize: size) + } + + /// Creates a bold NotoSerif UIFont at the specified size. + /// + /// - Parameters: + /// - size: The desired size. + /// + /// - Returns: The created font. + /// + @objc public class func fixedBoldNotoFontWithSize(_ size: CGFloat) -> UIFont { + return fixedCustomNotoFontNamed("NotoSerif-Bold", withSize: size) + } + /// Creates a NotoSerif UIFont for the user current text size settings. /// /// - Parameters: @@ -239,7 +261,7 @@ extension WPStyleGuide { /// - fontName: the Noto font name (NotoSerif, NotoSerif-Bold, NotoSerif-Italic, NotoSerif-BoldItalic) /// - style: The desired UIFontTextStyle. /// - /// - Returns: The created font point size. + /// - Returns: The created font. /// private class func customNotoFontNamed(_ fontName: String, forTextStyle style: UIFont.TextStyle, maximumPointSize: CGFloat = maxFontSize) -> UIFont { WPFontManager.loadNotoFontFamily() @@ -251,4 +273,25 @@ extension WPStyleGuide { } return font } + + /// Creates a Noto UIFont at the specified size. + /// + /// - Parameters: + /// - fontName: the Noto font name (NotoSerif, NotoSerif-Bold, NotoSerif-Italic, NotoSerif-BoldItalic) + /// - size: The desired point size. + /// + /// - Returns: The created font. + /// + private class func fixedCustomNotoFontNamed(_ fontName: String, withSize size: CGFloat) -> UIFont { + WPFontManager.loadNotoFontFamily() + guard let font = UIFont(name: fontName, size: size) else { + // If we can't get the Noto font for some reason we will default to the system font + if fontName.contains("Bold") { + return UIFont.systemFont(ofSize: size, weight: .bold) + } else { + return UIFont.systemFont(ofSize: size) + } + } + return font + } } diff --git a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift index 5d35647..fdda3b3 100644 --- a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift +++ b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift @@ -15,7 +15,27 @@ extension WPStyleGuide { return UIFontMetrics.default.scaledFont(for: UIFont(descriptor: fontDescriptor, size: 0.0)) } - + // Returns the system serif font (New York) for iOS 13+ but defaults to noto for older os's, at the default size for the specified style + @objc public class func fixedSerifFontForTextStyle(_ style: UIFont.TextStyle, + fontWeight weight: UIFont.Weight = .regular) -> UIFont { + + let defaultContentSizeCategory = UITraitCollection(preferredContentSizeCategory: .large) // .large is the default + let fontSize = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style, compatibleWith: defaultContentSizeCategory).pointSize + + guard #available(iOS 13, *), + let fontDescriptor = UIFont.systemFont(ofSize: fontSize, weight: weight).fontDescriptor.withDesign(.serif) else { + switch weight { + case .bold, .semibold, .heavy, .black: + return WPStyleGuide.fixedBoldNotoFontWithSize(fontSize) + default: + return WPStyleGuide.fixedNotoFontWithSize(fontSize) + } + } + + // Uses size from original font, so we don't want to override it here. + return UIFont(descriptor: fontDescriptor, size: 0.0) + } + private class func notoFontForTextStyle(_ style: UIFont.TextStyle, fontWeight weight: UIFont.Weight = .regular) -> UIFont { var font: UIFont From 19018f8937701834dad00a60b57eb80cd5ca0f61 Mon Sep 17 00:00:00 2001 From: James Frost Date: Tue, 1 Sep 2020 08:42:58 +0100 Subject: [PATCH 09/10] Updated podspec version --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index 163b68c..6cef489 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.11.0" + s.version = "1.12.0-beta.1" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From a357b0a20f47ff14b362325d0e22624c8fddc294 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Mon, 7 Sep 2020 12:03:16 +0200 Subject: [PATCH 10/10] Bump version to 1.12.0 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index 6cef489..2898202 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.12.0-beta.1" + s.version = "1.12.0" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC