Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1260 Detecting and Cleaning Galleries #8119

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions WordPress/Classes/Extensions/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ extension Array {
}
}
}

/// Safely returns an index from an array.
///
subscript(safe index: Int) -> Element? {
return index >= 0 && index < count ? self[index] : nil
}
}
39 changes: 24 additions & 15 deletions WordPress/Classes/ViewRelated/Reader/Reader.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -18,11 +19,11 @@
<viewControllerLayoutGuide type="bottom" id="icf-FG-h6u"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="nFH-eq-cvg">
<rect key="frame" x="0.0" y="64" width="375" height="495"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="483"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="n2H-rP-0mh">
<rect key="frame" x="0.0" y="0.0" width="375" height="495"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="483"/>
<connections>
<segue destination="ojY-lw-Nq8" kind="embed" id="HkI-vX-JZt"/>
</connections>
Expand Down Expand Up @@ -55,7 +56,7 @@
<viewControllerLayoutGuide type="bottom" id="zkd-Io-waS"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" id="dbo-c9-92a">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Ix7-KK-iap" customClass="WPRichContentView" customModule="WordPress" customModuleProvider="target">
Expand Down Expand Up @@ -232,14 +233,14 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" text="Attribution" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I5s-ci-UB0">
<rect key="frame" x="28" y="0.0" width="81" height="20.5"/>
<rect key="frame" x="28" y="0.0" width="0.0" height="20.5"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view alpha="0.0" contentMode="scaleToFill" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="1" verticalCompressionResistancePriority="1" translatesAutoresizingMaskIntoConstraints="NO" id="YBQ-xA-5CN" userLabel="View (spacer)">
<rect key="frame" x="117" y="0.0" width="228" height="0.0"/>
<rect key="frame" x="-14" y="0.0" width="0.0" height="0.0"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
Expand Down Expand Up @@ -393,14 +394,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="B6J-Lg-PdX">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="56"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" returnKeyType="done" enablesReturnKeyAutomatically="YES"/>
<connections>
<outlet property="delegate" destination="e0f-8T-Sz8" id="8aD-d4-C9q"/>
</connections>
</searchBar>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="49S-3J-OMN">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="76" width="375" height="591"/>
<connections>
<segue destination="FBk-BW-Oyk" kind="embed" id="BIm-m7-JCp"/>
</connections>
Expand Down Expand Up @@ -442,12 +443,20 @@
</objects>
<point key="canvasLocation" x="687" y="1811"/>
</scene>
<!--Gallery Page View Controller-->
<scene sceneID="zqw-de-bzF">
<objects>
<pageViewController storyboardIdentifier="GalleryPageViewController" autoresizesArchivedViewToFullSize="NO" modalTransitionStyle="crossDissolve" transitionStyle="scroll" navigationOrientation="horizontal" spineLocation="none" id="M0F-5q-ILH" customClass="WPGalleryPageViewController" customModule="WordPress" customModuleProvider="target" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="XvH-cK-eCg" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="678" y="2520"/>
</scene>
<!--Table View Controller-->
<scene sceneID="Xc2-1X-rOR">
<objects>
<tableViewController id="ojY-lw-Nq8" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="8GD-qV-397">
<rect key="frame" x="0.0" y="0.0" width="375" height="495"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="483"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
Expand All @@ -473,24 +482,24 @@
<viewControllerLayoutGuide type="bottom" id="4Hq-9j-ssQ"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="3Jv-hf-pib">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="UQY-Uf-csX">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="56"/>
<textInputTraits key="textInputTraits" returnKeyType="search" enablesReturnKeyAutomatically="YES"/>
<connections>
<outlet property="delegate" destination="sKI-JH-RAG" id="fsR-5r-2Md"/>
</connections>
</searchBar>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PuG-YC-OIC">
<rect key="frame" x="0.0" y="44" width="375" height="559"/>
<rect key="frame" x="0.0" y="56" width="375" height="547"/>
<connections>
<segue destination="His-O5-Cy6" kind="embed" id="xfh-l2-pdU"/>
</connections>
</containerView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="What would you like to find?" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="afc-5c-5tF">
<rect key="frame" x="16" y="246" width="343" height="27"/>
<rect key="frame" x="16" y="252" width="343" height="27"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -596,7 +605,7 @@
<objects>
<tableViewController id="FBk-BW-Oyk" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="54" sectionHeaderHeight="18" sectionFooterHeight="18" id="q5P-P8-r6d">
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="591"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,16 @@ extension ReaderDetailViewController: WPRichContentViewDelegate {

present(controller, animated: true, completion: nil)
}

func richContentView(_ richContentView: WPRichContentView, didReceiveGalleryAction image: [WPTextAttachment], indexTapped index: Int) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second parameter name here feels slightly confusing, I think. didReceiveGalleryAction doesn't really explain what the parameter contains, and the inner name is image but it looks like it contains an array of images (plural)? How about didReceiveGalleryActionWithImages images: [WPTextAttachment]?


let galleryVC = WPGalleryPageViewController.controllerWithImages(with: image, selectedIndex: index)

galleryVC.modalTransitionStyle = .crossDissolve
galleryVC.modalPresentationStyle = .fullScreen

present(galleryVC, animated: true, completion: nil)
}
}


Expand Down
8 changes: 8 additions & 0 deletions WordPress/Classes/ViewRelated/Reader/ReaderGalleryCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import UIKit

class ReaderGalleryCell: UICollectionViewCell {

@IBOutlet weak var galleryImageView: UIImageView!
@IBOutlet weak var loadingIndicator: UIActivityIndicatorView!

}
47 changes: 47 additions & 0 deletions WordPress/Classes/ViewRelated/Reader/ReaderGalleryCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="ReaderGalleryCell" customModule="WordPress" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="251" height="211"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="251" height="211"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ajo-bT-AZE">
<rect key="frame" x="0.0" y="0.0" width="251" height="211"/>
</imageView>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="cAa-GN-Pga">
<rect key="frame" x="115" y="95" width="20" height="20"/>
</activityIndicatorView>
</subviews>
</view>
<constraints>
<constraint firstItem="Ajo-bT-AZE" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="1UW-mN-bJP"/>
<constraint firstItem="cAa-GN-Pga" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="78G-L0-ECS"/>
<constraint firstAttribute="bottom" secondItem="Ajo-bT-AZE" secondAttribute="bottom" id="B4f-2v-67f"/>
<constraint firstItem="Ajo-bT-AZE" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="UPS-xN-kZ3"/>
<constraint firstItem="cAa-GN-Pga" firstAttribute="centerY" secondItem="gTV-IL-0wX" secondAttribute="centerY" id="qBz-yF-5zI"/>
<constraint firstAttribute="trailing" secondItem="Ajo-bT-AZE" secondAttribute="trailing" id="sJw-gb-Bah"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<size key="customSize" width="251" height="211"/>
<connections>
<outlet property="galleryImageView" destination="Ajo-bT-AZE" id="COb-J9-HCW"/>
<outlet property="loadingIndicator" destination="cAa-GN-Pga" id="urp-z1-VwJ"/>
</connections>
<point key="canvasLocation" x="31" y="-8"/>
</collectionViewCell>
</objects>
</document>
Loading