Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 8a53966

Browse files
authored
Merge pull request #277 from wordpress-mobile/release/1.12.0
Release/1.12.0
2 parents 93e7c66 + a357b0a commit 8a53966

File tree

5 files changed

+93
-5
lines changed

5 files changed

+93
-5
lines changed

WordPressShared.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressShared"
3-
s.version = "1.10.0-beta.2"
3+
s.version = "1.12.0"
44
s.summary = "Shared components used in building the WordPress iOS apps and other library components."
55

66
s.description = <<-DESC

WordPressShared.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
B5A7881F202B3A92007874FB /* WPTextFieldTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
8383
B5A78820202B3A92007874FB /* WPTextFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7881C202B3A92007874FB /* WPTextFieldTableViewCell.m */; };
8484
B5A78821202B3A92007874FB /* WPTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881D202B3A92007874FB /* WPTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
85+
CE1CB30424DCAFCB00DBAD9C /* CollectionType+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1CB30324DCAFCB00DBAD9C /* CollectionType+Helpers.swift */; };
8586
E157E126239527700051AE41 /* Secret.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E125239527700051AE41 /* Secret.swift */; };
8687
E157E128239527AD0051AE41 /* SecretTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E127239527AD0051AE41 /* SecretTests.swift */; };
8788
E18EABEA1F0E2C6800BFCB0B /* TestAnalyticsTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */; };
@@ -202,6 +203,7 @@
202203
B5A7881D202B3A92007874FB /* WPTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WPTableViewCell.h; sourceTree = "<group>"; };
203204
B5A78823202B3B3C007874FB /* WordPressUIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WordPressUIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
204205
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 = "<group>"; };
206+
CE1CB30324DCAFCB00DBAD9C /* CollectionType+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CollectionType+Helpers.swift"; sourceTree = "<group>"; };
205207
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 = "<group>"; };
206208
E157E125239527700051AE41 /* Secret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secret.swift; sourceTree = "<group>"; };
207209
E157E127239527AD0051AE41 /* SecretTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretTests.swift; sourceTree = "<group>"; };
@@ -297,6 +299,7 @@
297299
82706FE01ECA32D400155CBF /* Utility */ = {
298300
isa = PBXGroup;
299301
children = (
302+
CE1CB30324DCAFCB00DBAD9C /* CollectionType+Helpers.swift */,
300303
74FA25F21F1FD9640044BC54 /* DateUtils.h */,
301304
74FA25F31F1FD9640044BC54 /* DateUtils.m */,
302305
F1134A262270C15E00B8F75F /* Debouncer.swift */,
@@ -571,11 +574,11 @@
571574
};
572575
buildConfigurationList = 829DD1381EC9EED200AB8C12 /* Build configuration list for PBXProject "WordPressShared" */;
573576
compatibilityVersion = "Xcode 3.2";
574-
developmentRegion = English;
577+
developmentRegion = en;
575578
hasScannedForEncodings = 0;
576579
knownRegions = (
577-
English,
578580
en,
581+
Base,
579582
);
580583
mainGroup = 829DD1341EC9EED200AB8C12;
581584
productRefGroup = 829DD13F1EC9EED200AB8C12 /* Products */;
@@ -712,6 +715,7 @@
712715
F193585624CA3F4E00942507 /* AnalyticsEvent.swift in Sources */,
713716
F1134A272270C15E00B8F75F /* Debouncer.swift in Sources */,
714717
B5393FD8206D608F007BF9D4 /* EmailFormatValidator.swift in Sources */,
718+
CE1CB30424DCAFCB00DBAD9C /* CollectionType+Helpers.swift in Sources */,
715719
F106FA62226FA82E00706DE4 /* String+URLValidation.swift in Sources */,
716720
F10A569023E1FC1300B184F4 /* String+StripShortcodes.swift in Sources */,
717721
32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
3+
4+
// MARK: - Collection Type Helpers
5+
//
6+
extension BidirectionalCollection {
7+
public func lastIndex(where predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.Index? {
8+
if let idx = try reversed().firstIndex(where: predicate) {
9+
return self.index(before: idx.base)
10+
}
11+
return nil
12+
}
13+
}
14+
15+
extension Collection {
16+
/// Returns the element at the specified index if it is within bounds, otherwise nil.
17+
///
18+
public subscript (safe index: Index) -> Element? {
19+
return indices.contains(index) ? self[index] : nil
20+
}
21+
}

WordPressShared/Core/Views/WPStyleGuide+DynamicType.swift

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,28 @@ extension WPStyleGuide {
189189
return UIFont(descriptor: descriptorWithTraits, size: size)
190190
}
191191

192+
/// Creates a NotoSerif UIFont at the specified size.
193+
///
194+
/// - Parameters:
195+
/// - size: The desired size.
196+
///
197+
/// - Returns: The created font.
198+
///
199+
@objc public class func fixedNotoFontWithSize(_ size: CGFloat) -> UIFont {
200+
return fixedCustomNotoFontNamed("NotoSerif", withSize: size)
201+
}
202+
203+
/// Creates a bold NotoSerif UIFont at the specified size.
204+
///
205+
/// - Parameters:
206+
/// - size: The desired size.
207+
///
208+
/// - Returns: The created font.
209+
///
210+
@objc public class func fixedBoldNotoFontWithSize(_ size: CGFloat) -> UIFont {
211+
return fixedCustomNotoFontNamed("NotoSerif-Bold", withSize: size)
212+
}
213+
192214
/// Creates a NotoSerif UIFont for the user current text size settings.
193215
///
194216
/// - Parameters:
@@ -239,7 +261,7 @@ extension WPStyleGuide {
239261
/// - fontName: the Noto font name (NotoSerif, NotoSerif-Bold, NotoSerif-Italic, NotoSerif-BoldItalic)
240262
/// - style: The desired UIFontTextStyle.
241263
///
242-
/// - Returns: The created font point size.
264+
/// - Returns: The created font.
243265
///
244266
private class func customNotoFontNamed(_ fontName: String, forTextStyle style: UIFont.TextStyle, maximumPointSize: CGFloat = maxFontSize) -> UIFont {
245267
WPFontManager.loadNotoFontFamily()
@@ -251,4 +273,25 @@ extension WPStyleGuide {
251273
}
252274
return font
253275
}
276+
277+
/// Creates a Noto UIFont at the specified size.
278+
///
279+
/// - Parameters:
280+
/// - fontName: the Noto font name (NotoSerif, NotoSerif-Bold, NotoSerif-Italic, NotoSerif-BoldItalic)
281+
/// - size: The desired point size.
282+
///
283+
/// - Returns: The created font.
284+
///
285+
private class func fixedCustomNotoFontNamed(_ fontName: String, withSize size: CGFloat) -> UIFont {
286+
WPFontManager.loadNotoFontFamily()
287+
guard let font = UIFont(name: fontName, size: size) else {
288+
// If we can't get the Noto font for some reason we will default to the system font
289+
if fontName.contains("Bold") {
290+
return UIFont.systemFont(ofSize: size, weight: .bold)
291+
} else {
292+
return UIFont.systemFont(ofSize: size)
293+
}
294+
}
295+
return font
296+
}
254297
}

WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,27 @@ extension WPStyleGuide {
1515
return UIFontMetrics.default.scaledFont(for: UIFont(descriptor: fontDescriptor, size: 0.0))
1616
}
1717

18-
18+
// 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
19+
@objc public class func fixedSerifFontForTextStyle(_ style: UIFont.TextStyle,
20+
fontWeight weight: UIFont.Weight = .regular) -> UIFont {
21+
22+
let defaultContentSizeCategory = UITraitCollection(preferredContentSizeCategory: .large) // .large is the default
23+
let fontSize = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style, compatibleWith: defaultContentSizeCategory).pointSize
24+
25+
guard #available(iOS 13, *),
26+
let fontDescriptor = UIFont.systemFont(ofSize: fontSize, weight: weight).fontDescriptor.withDesign(.serif) else {
27+
switch weight {
28+
case .bold, .semibold, .heavy, .black:
29+
return WPStyleGuide.fixedBoldNotoFontWithSize(fontSize)
30+
default:
31+
return WPStyleGuide.fixedNotoFontWithSize(fontSize)
32+
}
33+
}
34+
35+
// Uses size from original font, so we don't want to override it here.
36+
return UIFont(descriptor: fontDescriptor, size: 0.0)
37+
}
38+
1939
private class func notoFontForTextStyle(_ style: UIFont.TextStyle,
2040
fontWeight weight: UIFont.Weight = .regular) -> UIFont {
2141
var font: UIFont

0 commit comments

Comments
 (0)