Skip to content

Commit

Permalink
Merge pull request #19305 from ipalm0423/fix/19244-19246-fix-oversize…
Browse files Browse the repository at this point in the history
…-label-on-NoResultVC-for-iPad

Fix oversize label in no result side menu on iPad
  • Loading branch information
twstokes authored Sep 30, 2022
2 parents 5e75d09 + a3ba7ee commit ef7dad3
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 9 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [*] [Jetpack-only] Weekly roundup: Adds support for weekly roundup notifications to the Jetpack app. [#19364]
* [*] Fixed an issue where the push notifications prompt button would overlap on iPad. [#19304]
* [*] Story Post: Fixed an issue where deleting one image in a story draft would cause the following image not to load. [#16966]
* [*] Fixed an issue where the no result label on the side menu is oversize on iPad. [#19305]

20.8
-----
Expand Down
19 changes: 10 additions & 9 deletions WordPress/Classes/ViewRelated/Views/NoResults.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -20,7 +20,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="Mkl-mm-wtH">
<rect key="frame" x="67.5" y="108.5" width="240.5" height="450"/>
<rect key="frame" x="67.5" y="105.5" width="240.5" height="456.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="3Mp-LB-oOz" userLabel="Accessory Stack View">
<rect key="frame" x="0.5" y="0.0" width="239" height="234"/>
Expand All @@ -39,33 +39,33 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="gjj-bC-32w" userLabel="Label Button Stack View">
<rect key="frame" x="0.0" y="254" width="240.5" height="196"/>
<rect key="frame" x="0.0" y="254" width="240.5" height="202.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="v7c-T9-kZq" userLabel="Label Stack View">
<rect key="frame" x="38" y="0.0" width="164.5" height="68"/>
<rect key="frame" x="27" y="0.0" width="186.5" height="74.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This is the title text." textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8BN-gx-7TL">
<rect key="frame" x="0.0" y="0.0" width="164.5" height="23"/>
<rect key="frame" x="1.5" y="0.0" width="183" height="26.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle2"/>
<color key="textColor" red="0.40000000000000002" green="0.55686274509803924" blue="0.66666666666666663" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="This is the subtitle text." textAlignment="center" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pAg-XC-9IM" userLabel="Subtitle Text View">
<rect key="frame" x="2" y="33" width="160.5" height="35"/>
<rect key="frame" x="0.0" y="36.5" width="186.5" height="38"/>
<color key="textColor" red="0.1803921568627451" green="0.26666666666666666" blue="0.32549019607843138" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
</stackView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3N8-XV-xJk" userLabel="Subtitle Image View">
<rect key="frame" x="0.0" y="88" width="240.5" height="44"/>
<rect key="frame" x="0.0" y="94.5" width="240.5" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="GdA-7V-dg9"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="749" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageSizeForAccessibilityContentSizeCategory="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CPl-cH-d7b" customClass="FancyButton" customModule="WordPressUI">
<rect key="frame" x="84" y="152" width="72" height="44"/>
<rect key="frame" x="78" y="158.5" width="84" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="ALu-HJ-Bk4"/>
</constraints>
Expand All @@ -92,6 +92,7 @@
<constraints>
<constraint firstItem="Mkl-mm-wtH" firstAttribute="centerX" secondItem="0Ae-eX-ae9" secondAttribute="centerX" id="NmZ-mA-W4r"/>
<constraint firstItem="Mkl-mm-wtH" firstAttribute="centerY" secondItem="0Ae-eX-ae9" secondAttribute="centerY" id="awy-Qw-qAb"/>
<constraint firstItem="Mkl-mm-wtH" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="0Ae-eX-ae9" secondAttribute="leading" constant="20" id="htC-A3-u00"/>
</constraints>
</view>
</subviews>
Expand Down
12 changes: 12 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,7 @@
AB2211D225ED68E300BF72FC /* CommentServiceRemoteFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB2211D125ED68E300BF72FC /* CommentServiceRemoteFactory.swift */; };
AB2211F425ED6E7A00BF72FC /* CommentServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB2211F325ED6E7A00BF72FC /* CommentServiceTests.swift */; };
AB758D9E25EFDF9C00961C0B /* LikesListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB758D9D25EFDF9C00961C0B /* LikesListController.swift */; };
ACACE3AE28D729FA000992F9 /* NoResultsViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACACE3AD28D729FA000992F9 /* NoResultsViewControllerTests.swift */; };
ACBAB5FE0E121C7300F38795 /* PostSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ACBAB5FD0E121C7300F38795 /* PostSettingsViewController.m */; };
ADF544C2195A0F620092213D /* CustomHighlightButton.m in Sources */ = {isa = PBXBuildFile; fileRef = ADF544C1195A0F620092213D /* CustomHighlightButton.m */; };
AE2F3125270B6DA000B2A9C2 /* Scanner+QuotedText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2F3124270B6DA000B2A9C2 /* Scanner+QuotedText.swift */; };
Expand Down Expand Up @@ -7029,6 +7030,7 @@
AB2211F325ED6E7A00BF72FC /* CommentServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentServiceTests.swift; sourceTree = "<group>"; };
AB390AA9C94F16E78184E9D1 /* Pods_WordPressScreenshotGeneration.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressScreenshotGeneration.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AB758D9D25EFDF9C00961C0B /* LikesListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikesListController.swift; sourceTree = "<group>"; };
ACACE3AD28D729FA000992F9 /* NoResultsViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoResultsViewControllerTests.swift; sourceTree = "<group>"; };
ACBAB5FC0E121C7300F38795 /* PostSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PostSettingsViewController.h; sourceTree = "<group>"; usesTabs = 0; };
ACBAB5FD0E121C7300F38795 /* PostSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PostSettingsViewController.m; sourceTree = "<group>"; usesTabs = 0; };
ADE06D6829F9044164BBA5AB /* Pods-WordPressIntents.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressIntents.release.xcconfig"; path = "../Pods/Target Support Files/Pods-WordPressIntents/Pods-WordPressIntents.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11155,6 +11157,7 @@
732A4738218786F30015DA74 /* Views */ = {
isa = PBXGroup;
children = (
ACACE3AF28D76A62000992F9 /* Controllers */,
732A473B218787500015DA74 /* WPRichText */,
);
name = Views;
Expand Down Expand Up @@ -13310,6 +13313,14 @@
path = Blog;
sourceTree = "<group>";
};
ACACE3AF28D76A62000992F9 /* Controllers */ = {
isa = PBXGroup;
children = (
ACACE3AD28D729FA000992F9 /* NoResultsViewControllerTests.swift */,
);
path = Controllers;
sourceTree = "<group>";
};
B0088A8F283D68B1008C9676 /* Stats Revamp v2 */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -20702,6 +20713,7 @@
DC06DFF927BD52BE00969974 /* WeeklyRoundupBackgroundTaskTests.swift in Sources */,
24C69A8B2612421900312D9A /* UserSettingsTests.swift in Sources */,
8B6BD55024293FBE00DB8F28 /* PrepublishingNudgesViewControllerTests.swift in Sources */,
ACACE3AE28D729FA000992F9 /* NoResultsViewControllerTests.swift in Sources */,
8BFE36FF230F1C850061EBA8 /* AbstractPost+fixLocalMediaURLsTests.swift in Sources */,
08A2AD791CCED2A800E84454 /* PostTagServiceTests.m in Sources */,
F543AF5723A84E4D0022F595 /* PublishSettingsControllerTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import XCTest
@testable import WordPress

class NoResultsViewControllerTests: XCTestCase {

private enum Constants {
static let shortText = "This is a text"
static let longText = """
This is a long Text. This is a long Text. This is a long Text. This is a long Text. This is a long Text.
This is a long Text. This is a long Text. This is a long Text. This is a long Text. This is a long Text.
This is a long Text. This is a long Text. This is a long Text. This is a long Text. This is a long Text.
"""
static let iPhoneSeSize = CGSize(width: 320, height: 568)
static let iPadProSize = CGSize(width: 1024, height: 1366)
static let resultViewMaxWidth: CGFloat = 360
static let resultViewHorizontalMargin: CGFloat = 20
}

private var resultViewController: NoResultsViewController!
private var parentViewController: UIViewController!

override func setUpWithError() throws {
self.resultViewController = NoResultsViewController.controller()
self.parentViewController = UIViewController()
}

override func tearDownWithError() throws {
self.resultViewController = nil
self.parentViewController = nil
}

func testTitleLabelWidthForLongTextInSmallScreen() {
// Given
let parentViewSize = Constants.iPhoneSeSize
let title = Constants.longText

// When
parentViewController.view.frame = CGRect(origin: .zero, size: parentViewSize)
resultViewController.configure(title: title)
addResultViewControllerToParent()

// Then
XCTAssertEqual(resultViewController.titleLabel.text, title)
XCTAssertTrue(resultViewController.titleLabel.frame.width + Constants.resultViewHorizontalMargin * 2 <= parentViewSize.width)
}

func testTitleLabelWidthForLongTextInLargeScreen() {
// Given
let parentViewSize = Constants.iPadProSize
let title = Constants.longText

// When
parentViewController.view.frame = CGRect(origin: .zero, size: parentViewSize)
resultViewController.configure(title: title)
addResultViewControllerToParent()

// Then
XCTAssertEqual(resultViewController.titleLabel.text, title)
XCTAssertTrue(resultViewController.titleLabel.frame.width <= parentViewSize.width)
XCTAssertTrue(resultViewController.titleLabel.frame.width <= Constants.resultViewMaxWidth)
}

func testSubtitleLabelWidthForLongTextInSmallScreen() {
// Given
let parentViewSize = Constants.iPhoneSeSize
let subtitle = Constants.longText

// When
parentViewController.view.frame = CGRect(origin: .zero, size: parentViewSize)
resultViewController.configure(title: Constants.shortText, subtitle: subtitle)
addResultViewControllerToParent()

// Then
XCTAssertEqual(resultViewController.subtitleTextView.text, subtitle)
XCTAssertTrue(resultViewController.subtitleTextView.frame.width + Constants.resultViewHorizontalMargin * 2 <= parentViewSize.width)
}

func testSubtitleLabelWidthForLongTextInLargeScreen() {
// Given
let parentViewSize = Constants.iPadProSize
let subtitle = Constants.longText

// When
parentViewController.view.frame = CGRect(origin: .zero, size: parentViewSize)
resultViewController.configure(title: Constants.shortText, subtitle: subtitle)
addResultViewControllerToParent()

// Then
XCTAssertEqual(resultViewController.subtitleTextView.text, subtitle)
XCTAssertTrue(resultViewController.subtitleTextView.frame.width <= parentViewSize.width)
XCTAssertTrue(resultViewController.subtitleTextView.frame.width <= Constants.resultViewMaxWidth)
}

}

private extension NoResultsViewControllerTests {
func addResultViewControllerToParent() {
parentViewController.view.addSubview(resultViewController.view)
resultViewController.view.frame = parentViewController.view.bounds
resultViewController.didMove(toParent: parentViewController)
}
}

0 comments on commit ef7dad3

Please sign in to comment.