Skip to content

Commit

Permalink
Merge changes from 24.6.0.1 (#22961)
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano authored Apr 4, 2024
2 parents b21049b + e5127db commit 8c67180
Show file tree
Hide file tree
Showing 89 changed files with 1,772 additions and 617 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension ReaderTopicService {

@objc func fetchAllFollowedSites(success: @escaping () -> Void, failure: @escaping (Error?) -> Void) {
let service = ReaderTopicServiceRemote(wordPressComRestApi: apiRequest())
let pageSize: UInt = 100
let pageSize: UInt = 25

service.fetchFollowedSites(forPage: 1, number: pageSize) { totalSites, sites in
guard let totalSites, let sites else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable {

private var isLikeButtonAnimating: Bool = false

/// Styling configuration based on `ReaderDisplaySetting`. The parameter is optional so that the styling approach
/// can be scoped by using the "legacy" style when the passed parameter is nil.
private var style: CellStyle = .init(displaySetting: nil)

var displaySetting: ReaderDisplaySetting? = nil {
didSet {
style = CellStyle(displaySetting: displaySetting)
resetRenderedContents()
applyStyles()
}
}

// MARK: Visibility Control

private var isCommentReplyEnabled: Bool = false {
Expand Down Expand Up @@ -235,6 +247,8 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable {
isCommentReplyEnabled = false
isAccessoryButtonEnabled = false

shouldHideSeparator = true

containerStackLeadingConstraint.constant = 0
containerStackTrailingConstraint.constant = 0
}
Expand Down Expand Up @@ -266,6 +280,53 @@ extension CommentContentTableViewCell: CommentContentRendererDelegate {
}
}

// MARK: - Cell Style

private extension CommentContentTableViewCell {
/// A structure to override the cell styling based on `ReaderDisplaySetting`.
/// This doesn't cover all aspects of the cell, and iks currently scoped only for Reader Detail.
struct CellStyle {
let displaySetting: ReaderDisplaySetting?

/// NOTE: Remove when the `readerCustomization` flag is removed.
var customizationEnabled: Bool {
ReaderDisplaySetting.customizationEnabled
}

// Name Label

var nameFont: UIFont {
guard let displaySetting, customizationEnabled else {
return Style.nameFont
}
return displaySetting.font(with: .subheadline, weight: .semibold)
}

var nameTextColor: UIColor {
guard let displaySetting, customizationEnabled else {
return Style.nameTextColor
}
return displaySetting.color.foreground
}

// Date Label

var dateFont: UIFont {
guard let displaySetting, customizationEnabled else {
return Style.dateFont
}
return displaySetting.font(with: .footnote)
}

var dateTextColor: UIColor {
guard let displaySetting, customizationEnabled else {
return Style.dateTextColor
}
return displaySetting.color.secondaryForeground
}
}
}

// MARK: - Helpers

private extension CommentContentTableViewCell {
Expand Down Expand Up @@ -300,17 +361,17 @@ private extension CommentContentTableViewCell {

selectionStyle = .none

nameLabel?.font = Style.nameFont
nameLabel?.textColor = Style.nameTextColor
nameLabel?.font = style.nameFont
nameLabel?.textColor = style.nameTextColor

badgeLabel?.font = Style.badgeFont
badgeLabel?.textColor = Style.badgeTextColor
badgeLabel?.backgroundColor = Style.badgeColor
badgeLabel?.adjustsFontForContentSizeCategory = true
badgeLabel?.adjustsFontSizeToFitWidth = true

dateLabel?.font = Style.dateFont
dateLabel?.textColor = Style.dateTextColor
dateLabel?.font = style.dateFont
dateLabel?.textColor = style.dateTextColor

accessoryButton?.tintColor = Style.buttonTintColor
accessoryButton?.setImage(accessoryButtonImage, for: .normal)
Expand Down Expand Up @@ -342,6 +403,19 @@ private extension CommentContentTableViewCell {
updateLikeButton(liked: false, numberOfLikes: 0)
likeButton?.sizeToFit()
likeButton?.accessibilityIdentifier = .likeButtonAccessibilityId

separatorView.layoutMargins = .init(top: 0, left: 20, bottom: 0, right: 0).flippedForRightToLeft

applyStyles()
}

/// Applies the `ReaderDisplaySetting` styles
private func applyStyles() {
nameLabel?.font = style.nameFont
nameLabel?.textColor = style.nameTextColor

dateLabel?.font = style.dateFont
dateLabel?.textColor = style.dateTextColor
}

private func adjustImageAndTitleEdgeInsets(for button: UIButton) {
Expand Down Expand Up @@ -471,7 +545,7 @@ private extension CommentContentTableViewCell {
var renderer: CommentContentRenderer = {
switch renderMethod {
case .web:
return WebCommentContentRenderer(comment: comment)
return WebCommentContentRenderer(comment: comment, displaySetting: displaySetting ?? .standard)
case .richContent(let attributedText):
let renderer = RichCommentContentRenderer(comment: comment)
renderer.richContentDelegate = self.richContentDelegate
Expand Down
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.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
Expand All @@ -28,7 +28,7 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="hcN-S7-sLG" userLabel="Container Stack View">
<rect key="frame" x="16" y="0.0" width="288" height="309"/>
<rect key="frame" x="16" y="0.0" width="288" height="330"/>
<subviews>
<view contentMode="scaleToFill" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="f2E-yC-BJS" userLabel="Header View">
<rect key="frame" x="0.0" y="0.0" width="288" height="119"/>
Expand All @@ -41,18 +41,18 @@
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="CzL-pe-Tnr" userLabel="Name Stack View">
<rect key="frame" x="48" y="18" width="208" height="31"/>
<rect key="frame" x="48" y="18" width="208" height="36"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="po6-3F-ppN" userLabel="Name Container View">
<rect key="frame" x="0.0" y="0.0" width="208" height="14.5"/>
<rect key="frame" x="0.0" y="0.0" width="208" height="18"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="761" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HpE-B7-6wr" userLabel="Name Label">
<rect key="frame" x="0.0" y="0.0" width="169.5" height="14.5"/>
<rect key="frame" x="0.0" y="0.0" width="169.5" height="18"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
<nil key="highlightedColor"/>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" text="Badge" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hDo-cU-sWp" userLabel="Badge Label" customClass="BadgeLabel" customModule="WordPress" customModuleProvider="target">
<rect key="frame" x="174.5" y="-2" width="33.5" height="13.5"/>
<rect key="frame" x="174.5" y="1" width="33.5" height="13.5"/>
<color key="backgroundColor" name="Blue50"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
<color key="textColor" name="White"/>
Expand Down Expand Up @@ -82,7 +82,7 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ghT-Xy-q8c" userLabel="Date Label">
<rect key="frame" x="0.0" y="16.5" width="208" height="14.5"/>
<rect key="frame" x="0.0" y="20" width="208" height="16"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -127,10 +127,10 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="QT8-DO-J30" userLabel="Reaction Stack View">
<rect key="frame" x="0.0" y="119" width="288" height="190"/>
<rect key="frame" x="0.0" y="119" width="288" height="210"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="761" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VoI-YI-Qgc" userLabel="Reply Button">
<rect key="frame" x="0.0" y="75" width="184.5" height="40"/>
<rect key="frame" x="0.0" y="83.5" width="175.5" height="43"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<inset key="contentEdgeInsets" minX="0.0" minY="10" maxX="15" maxY="15"/>
Expand All @@ -144,7 +144,7 @@
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="762" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="X2J-8b-R5F" userLabel="Like Button">
<rect key="frame" x="184.5" y="74.5" width="53.5" height="41"/>
<rect key="frame" x="175.5" y="83.5" width="62.5" height="43.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
<color key="tintColor" systemColor="secondaryLabelColor"/>
<inset key="contentEdgeInsets" minX="0.0" minY="10" maxX="15" maxY="15"/>
Expand All @@ -158,34 +158,31 @@
</state>
</button>
<view contentMode="scaleToFill" horizontalHuggingPriority="1" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="8GH-U7-J7H" userLabel="Spacer View">
<rect key="frame" x="238" y="70" width="50" height="50"/>
<rect key="frame" x="238" y="80" width="50" height="50"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="width" constant="50" placeholder="YES" id="4wt-Z8-Xp5"/>
</constraints>
</view>
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qId-Th-B9r">
<rect key="frame" x="0.0" y="329" width="288" height="1"/>
<color key="backgroundColor" systemColor="systemGray5Color"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="HnG-UL-I2f"/>
</constraints>
</view>
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qId-Th-B9r">
<rect key="frame" x="20" y="329" width="300" height="1"/>
<color key="backgroundColor" systemColor="systemGray5Color"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="HnG-UL-I2f"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="hcN-S7-sLG" secondAttribute="trailing" constant="16" id="2zy-oR-X5O"/>
<constraint firstAttribute="trailing" secondItem="qId-Th-B9r" secondAttribute="trailing" id="3d4-sp-Uyb"/>
<constraint firstItem="qId-Th-B9r" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" id="I4L-Vv-SIn"/>
<constraint firstAttribute="bottom" secondItem="hcN-S7-sLG" secondAttribute="bottom" constant="10" id="FxL-ee-fbZ"/>
<constraint firstItem="mNJ-fg-sKO" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="II8-F0-CBs"/>
<constraint firstItem="mNJ-fg-sKO" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="eId-Od-5wj"/>
<constraint firstItem="hcN-S7-sLG" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="esQ-oB-yxJ"/>
<constraint firstAttribute="bottom" secondItem="mNJ-fg-sKO" secondAttribute="bottom" id="izD-cW-YFx"/>
<constraint firstItem="qId-Th-B9r" firstAttribute="top" secondItem="hcN-S7-sLG" secondAttribute="bottom" constant="20" id="pdj-JT-7h5"/>
<constraint firstAttribute="bottom" secondItem="qId-Th-B9r" secondAttribute="bottom" constant="10" id="qZq-8s-UAU"/>
<constraint firstItem="hcN-S7-sLG" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="uFL-PF-ffo"/>
</constraints>
</tableViewCellContentView>
Expand All @@ -212,7 +209,7 @@
<resources>
<image name="gravatar" width="85" height="85"/>
<image name="icon-reader-comment-reply" width="13" height="12"/>
<image name="square.and.arrow.up" catalog="system" width="115" height="128"/>
<image name="square.and.arrow.up" catalog="system" width="108" height="128"/>
<image name="star" catalog="system" width="128" height="116"/>
<namedColor name="Blue50">
<color red="0.023529411764705882" green="0.45882352941176469" blue="0.7686274509803922" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
Loading

0 comments on commit 8c67180

Please sign in to comment.