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

Posts & Pages: Native search #21738

Merged
Merged
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
71 changes: 12 additions & 59 deletions WordPress/Classes/ViewRelated/Pages/PageListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,16 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
return BlockEditorSettingsService(blog: blog, coreDataStack: ContextManager.shared)
}()

// MARK: - GUI

@IBOutlet weak var filterTabBarTopConstraint: NSLayoutConstraint!
@IBOutlet weak var filterTabBariOS10TopConstraint: NSLayoutConstraint!
@IBOutlet weak var filterTabBarBottomConstraint: NSLayoutConstraint!
@IBOutlet weak var tableViewTopConstraint: NSLayoutConstraint!

// MARK: - Convenience constructors

@objc class func controllerWithBlog(_ blog: Blog) -> PageListViewController {

let storyBoard = UIStoryboard(name: "Pages", bundle: Bundle.main)
let controller = storyBoard.instantiateViewController(withIdentifier: "PageListViewController") as! PageListViewController

controller.blog = blog
controller.restorationClass = self

let vc = PageListViewController()
vc.blog = blog
vc.restorationClass = self
if QuickStartTourGuide.shared.isCurrentElement(.pages) {
controller.filterSettings.setFilterWithPostStatus(BasePost.Status.publish)
vc.filterSettings.setFilterWithPostStatus(BasePost.Status.publish)
}

return controller
return vc
}

static func showForBlog(_ blog: Blog, from sourceController: UIViewController) {
Expand Down Expand Up @@ -135,13 +123,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe

// MARK: - UIViewController

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.refreshNoResultsViewController = { [weak self] noResultsViewController in
self?.handleRefreshNoResultsViewController(noResultsViewController)
}
super.tableViewController = (segue.destination as! UITableViewController)
}

override func viewDidLoad() {
super.viewDidLoad()

Expand All @@ -153,9 +134,11 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe

title = NSLocalizedString("Pages", comment: "Title of the screen showing the list of pages for a blog.")

configureFilterBarTopConstraint()

createButtonCoordinator.add(to: view, trailingAnchor: view.safeAreaLayoutGuide.trailingAnchor, bottomAnchor: view.safeAreaLayoutGuide.bottomAnchor)

refreshNoResultsViewController = { [weak self] in
self?.handleRefreshNoResultsViewController($0)
}
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -189,10 +172,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe

// MARK: - Configuration

private func configureFilterBarTopConstraint() {
filterTabBariOS10TopConstraint.isActive = false
}

override func configureTableView() {
tableView.accessibilityIdentifier = "PagesTable"
tableView.estimatedRowHeight = Constant.Size.pageCellEstimatedRowHeight
Expand All @@ -208,16 +187,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
tableView.register(restorePageCellNib, forCellReuseIdentifier: Constant.Identifiers.restorePageCellIdentifier)

tableView.register(TemplatePageTableViewCell.self, forCellReuseIdentifier: Constant.Identifiers.templatePageCellIdentifier)

WPStyleGuide.configureColors(view: view, tableView: tableView)
}

override func configureSearchController() {
super.configureSearchController()

tableView.tableHeaderView = searchController.searchBar

tableView.verticalScrollIndicatorInsets.top = searchController.searchBar.bounds.height
}

override func configureAuthorFilter() {
Expand All @@ -230,10 +199,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
}

fileprivate func beginRefreshingManually() {
guard let refreshControl = refreshControl else {
return
}

refreshControl.beginRefreshing()
tableView.setContentOffset(CGPoint(x: 0, y: tableView.contentOffset.y - refreshControl.frame.size.height), animated: true)
}
Expand Down Expand Up @@ -955,7 +920,7 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
self?.refreshAndReload()
self?.handleHomepageSettingsSuccess()
}, failure: { error in
self?.refreshControl?.endRefreshing()
self?.refreshControl.endRefreshing()
self?.handleHomepageSettingsFailure()
})
}
Expand Down Expand Up @@ -988,7 +953,7 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
self?.refreshAndReload()
self?.handleHomepagePostsPageSettingsSuccess()
}, failure: { error in
self?.refreshControl?.endRefreshing()
self?.refreshControl.endRefreshing()
self?.handleHomepageSettingsFailure()
})
}
Expand Down Expand Up @@ -1043,14 +1008,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe

// MARK: - UISearchControllerDelegate

override func willPresentSearchController(_ searchController: UISearchController) {
super.willPresentSearchController(searchController)

filterTabBar.alpha = WPAlphaZero

tableView.contentInset.top = -searchController.searchBar.bounds.height
}

override func updateSearchResults(for searchController: UISearchController) {
super.updateSearchResults(for: searchController)
}
Expand All @@ -1066,11 +1023,7 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
}

func didDismissSearchController(_ searchController: UISearchController) {
UIView.animate(withDuration: Animations.searchDismissDuration, delay: 0, options: .curveLinear, animations: {
self.filterTabBar.alpha = WPAlphaFull
}) { _ in
self.hideNoResultsView()
}
self.hideNoResultsView()
}

enum Animations {
Expand Down
102 changes: 9 additions & 93 deletions WordPress/Classes/ViewRelated/Pages/Pages.storyboard
Original file line number Diff line number Diff line change
@@ -1,101 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Pages-->
<scene sceneID="7fg-lR-xvd">
<objects>
<viewController storyboardIdentifier="PageListViewController" extendedLayoutIncludesOpaqueBars="YES" useStoryboardIdentifierAsRestorationIdentifier="YES" id="RgW-to-XfM" customClass="PageListViewController" customModule="WordPress" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="zEU-W1-HEN"/>
<viewControllerLayoutGuide type="bottom" id="njG-x9-YTM"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="MiP-YM-poS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LM5-dj-tFF">
<rect key="frame" x="0.0" y="110" width="375" height="557"/>
<connections>
<segue destination="54R-UA-mAH" kind="embed" id="f4C-M8-QGj"/>
</connections>
</containerView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kb7-5Y-cyY" customClass="FilterTabBar" customModule="WordPress" customModuleProvider="target">
<rect key="frame" x="0.0" y="64" width="375" height="46"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="46" placeholder="YES" id="k7G-Mg-MRE"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="LM5-dj-tFF" firstAttribute="leading" secondItem="MiP-YM-poS" secondAttribute="leading" id="5cl-1d-1tg"/>
<constraint firstAttribute="trailing" secondItem="LM5-dj-tFF" secondAttribute="trailing" id="AVm-wb-6M1"/>
<constraint firstAttribute="bottomMargin" secondItem="LM5-dj-tFF" secondAttribute="bottom" id="Icj-Cf-hTM"/>
<constraint firstItem="kb7-5Y-cyY" firstAttribute="top" secondItem="MiP-YM-poS" secondAttribute="topMargin" id="Iu4-wT-NJl"/>
<constraint firstItem="kb7-5Y-cyY" firstAttribute="top" secondItem="zEU-W1-HEN" secondAttribute="bottom" priority="999" id="N3R-GK-VXe"/>
<constraint firstItem="LM5-dj-tFF" firstAttribute="top" secondItem="kb7-5Y-cyY" secondAttribute="bottom" id="VTs-hm-pCI"/>
<constraint firstAttribute="trailing" secondItem="kb7-5Y-cyY" secondAttribute="trailing" id="bVD-D5-qun"/>
<constraint firstItem="LM5-dj-tFF" firstAttribute="top" secondItem="MiP-YM-poS" secondAttribute="topMargin" id="hqa-P7-bPN"/>
<constraint firstItem="kb7-5Y-cyY" firstAttribute="leading" secondItem="MiP-YM-poS" secondAttribute="leading" id="vh1-Zx-orQ"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="hqa-P7-bPN"/>
</mask>
</variation>
</view>
<extendedEdge key="edgesForExtendedLayout" top="YES"/>
<toolbarItems/>
<navigationItem key="navigationItem" title="Pages" id="pX7-HW-iFF"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
<nil key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="filterTabBar" destination="kb7-5Y-cyY" id="yfM-1V-Kgn"/>
<outlet property="filterTabBarBottomConstraint" destination="VTs-hm-pCI" id="8xw-da-7bY"/>
<outlet property="filterTabBarTopConstraint" destination="Iu4-wT-NJl" id="ncb-1g-VsV"/>
<outlet property="filterTabBariOS10TopConstraint" destination="N3R-GK-VXe" id="qgA-sx-Yrb"/>
<outlet property="tableViewTopConstraint" destination="hqa-P7-bPN" id="Mas-aT-2OZ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="qQg-Lr-ANj" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="517.60000000000002" y="317.99100449775113"/>
</scene>
<!--Table View Controller-->
<scene sceneID="nof-o6-aRy">
<objects>
<tableViewController id="54R-UA-mAH" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="47" sectionHeaderHeight="24" sectionFooterHeight="1" id="y3a-Ok-AN1">
<rect key="frame" x="0.0" y="0.0" width="375" height="557"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<sections/>
<connections>
<outlet property="dataSource" destination="54R-UA-mAH" id="mDP-Tv-HsW"/>
<outlet property="delegate" destination="54R-UA-mAH" id="aOd-Bh-W9d"/>
</connections>
</tableView>
<extendedEdge key="edgesForExtendedLayout"/>
<refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="GUI-3V-x2m">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</refreshControl>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SeM-Uk-MdX" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1202" y="318"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="sxx-aJ-IGT">
<objects>
Expand Down Expand Up @@ -126,7 +37,7 @@
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="rFc-KI-K05">
<rect key="frame" x="0.0" y="120" width="375" height="547"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
</tableView>
<searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="DaX-Id-Nby">
<rect key="frame" x="0.0" y="64" width="375" height="56"/>
Expand Down Expand Up @@ -168,4 +79,9 @@
<point key="canvasLocation" x="1240.8" y="1047.5262368815593"/>
</scene>
</scenes>
<resources>
<systemColor name="groupTableViewBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Loading