iOS: Implement search / filtering

This commit is contained in:
Jonathan Schleifer 2017-10-15 13:22:32 +02:00
parent 3c8b2d1d7d
commit d916043c03
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3
7 changed files with 103 additions and 47 deletions

View file

@ -85,12 +85,10 @@ showAlert(UIViewController *controller, NSString *title, NSString *message)
return; return;
} }
[self.mainViewController.siteStorage [self.mainViewController.siteStorage setSite: name
setSite: name
length: length length: length
legacy: self.legacySwitch.on]; legacy: self.legacySwitch.on];
[self.mainViewController reset];
[self.mainViewController.tableView reloadData];
[self.navigationController popViewControllerAnimated: YES]; [self.navigationController popViewControllerAnimated: YES];
} }

View file

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BN3-Y7-zvx"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BN3-Y7-zvx">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/> <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
@ -12,7 +15,7 @@
<objects> <objects>
<navigationController id="BN3-Y7-zvx" sceneMemberID="viewController"> <navigationController id="BN3-Y7-zvx" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="K8n-wn-irC"> <navigationBar key="navigationBar" contentMode="scaleToFill" id="K8n-wn-irC">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/> <rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</navigationBar> </navigationBar>
<connections> <connections>
@ -39,9 +42,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="CMc-ZN-RAn"> <searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="CMc-ZN-RAn">
<rect key="frame" x="0.0" y="64" width="375" height="56"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="P19-6i-fpd" id="G7P-7f-gbO"/>
</connections>
</searchBar> </searchBar>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eoq-EJ-t3s"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eoq-EJ-t3s">
<rect key="frame" x="0.0" y="120" width="375" height="547"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections> <connections>
<outlet property="dataSource" destination="P19-6i-fpd" id="1sa-qY-oQx"/> <outlet property="dataSource" destination="P19-6i-fpd" id="1sa-qY-oQx"/>
@ -73,6 +81,7 @@
</barButtonItem> </barButtonItem>
</navigationItem> </navigationItem>
<connections> <connections>
<outlet property="searchBar" destination="CMc-ZN-RAn" id="hDk-Tu-d4M"/>
<outlet property="tableView" destination="eoq-EJ-t3s" id="CE8-oa-Eud"/> <outlet property="tableView" destination="eoq-EJ-t3s" id="CE8-oa-Eud"/>
<segue destination="ayJ-fs-aIU" kind="show" identifier="showDetails" id="Gsx-Js-7aN"/> <segue destination="ayJ-fs-aIU" kind="show" identifier="showDetails" id="Gsx-Js-7aN"/>
</connections> </connections>
@ -94,6 +103,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2xd-QR-99d"> <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2xd-QR-99d">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections> <connections>
<outlet property="delegate" destination="MZ3-iZ-Dsf" id="uKq-6T-ltJ"/> <outlet property="delegate" destination="MZ3-iZ-Dsf" id="uKq-6T-ltJ"/>
@ -129,13 +139,14 @@
<tableViewSection id="Whg-Qc-bTG"> <tableViewSection id="Whg-Qc-bTG">
<cells> <cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="En5-ry-3SM"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="En5-ry-3SM">
<rect key="frame" x="0.0" y="99" width="375" height="44"/> <rect key="frame" x="0.0" y="35" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="En5-ry-3SM" id="fh3-TO-M9D"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="En5-ry-3SM" id="fh3-TO-M9D">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yq7-aM-PNl"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yq7-aM-PNl">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="nTn-vs-RDo"/> <constraint firstAttribute="width" constant="100" id="nTn-vs-RDo"/>
</constraints> </constraints>
@ -144,6 +155,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="apple.com" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="AXY-MA-LhE"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="apple.com" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="AXY-MA-LhE">
<rect key="frame" x="116" y="11.5" width="251" height="21"/>
<nil key="textColor"/> <nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/> <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
@ -159,13 +171,14 @@
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="GI4-iS-21j"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="GI4-iS-21j">
<rect key="frame" x="0.0" y="143" width="375" height="44"/> <rect key="frame" x="0.0" y="79" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GI4-iS-21j" id="zSC-vR-CCb"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GI4-iS-21j" id="zSC-vR-CCb">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Length" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eFJ-jF-rxJ"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Length" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eFJ-jF-rxJ">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="4bi-Kp-8mJ"/> <constraint firstAttribute="width" constant="100" id="4bi-Kp-8mJ"/>
</constraints> </constraints>
@ -174,6 +187,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="16" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="KQA-JL-1zl"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="16" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="KQA-JL-1zl">
<rect key="frame" x="116" y="11.5" width="251" height="21"/>
<nil key="textColor"/> <nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="numberPad" returnKeyType="next"/> <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="numberPad" returnKeyType="next"/>
@ -193,13 +207,14 @@
<tableViewSection id="wRX-mn-ahM"> <tableViewSection id="wRX-mn-ahM">
<cells> <cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="jgd-dy-HQH"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="jgd-dy-HQH">
<rect key="frame" x="0.0" y="223" width="375" height="44"/> <rect key="frame" x="0.0" y="159" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jgd-dy-HQH" id="eqZ-BJ-5O0"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jgd-dy-HQH" id="eqZ-BJ-5O0">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Legacy" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SVA-v8-zP8"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Legacy" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SVA-v8-zP8">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="KzI-6Z-fGE"/> <constraint firstAttribute="width" constant="100" id="KzI-6Z-fGE"/>
</constraints> </constraints>
@ -207,7 +222,9 @@
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="jcs-6K-Sbe"/> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="jcs-6K-Sbe">
<rect key="frame" x="318" y="6.5" width="51" height="31"/>
</switch>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="jcs-6K-Sbe" firstAttribute="trailing" secondItem="eqZ-BJ-5O0" secondAttribute="trailingMargin" id="JvE-mo-ax9"/> <constraint firstItem="jcs-6K-Sbe" firstAttribute="trailing" secondItem="eqZ-BJ-5O0" secondAttribute="trailingMargin" id="JvE-mo-ax9"/>
@ -264,13 +281,14 @@
<tableViewSection id="pum-yC-c7w"> <tableViewSection id="pum-yC-c7w">
<cells> <cells>
<tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="LQ8-yL-l4p"> <tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="LQ8-yL-l4p">
<rect key="frame" x="0.0" y="99" width="375" height="44"/> <rect key="frame" x="0.0" y="35" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="LQ8-yL-l4p" id="Drc-sv-gqn"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="LQ8-yL-l4p" id="Drc-sv-gqn">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SAI-3c-VBt"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SAI-3c-VBt">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="9uC-jX-ZTa"/> <constraint firstAttribute="width" constant="100" id="9uC-jX-ZTa"/>
</constraints> </constraints>
@ -279,6 +297,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="4Le-mO-AdY"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="4Le-mO-AdY">
<rect key="frame" x="116" y="11.5" width="251" height="21"/>
<nil key="textColor"/> <nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits"/>
@ -294,13 +313,14 @@
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="6NO-g9-dsf"> <tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="6NO-g9-dsf">
<rect key="frame" x="0.0" y="143" width="375" height="44"/> <rect key="frame" x="0.0" y="79" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="6NO-g9-dsf" id="UWL-vW-ZHk"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="6NO-g9-dsf" id="UWL-vW-ZHk">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Length" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EKx-FZ-XDX"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Length" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EKx-FZ-XDX">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="ZLB-KT-EH6"/> <constraint firstAttribute="width" constant="100" id="ZLB-KT-EH6"/>
</constraints> </constraints>
@ -309,6 +329,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Lp1-jC-8cn"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Lp1-jC-8cn">
<rect key="frame" x="116" y="11.5" width="251" height="21"/>
<nil key="textColor"/> <nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad"/> <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
@ -328,13 +349,14 @@
<tableViewSection id="52O-Rg-UgA"> <tableViewSection id="52O-Rg-UgA">
<cells> <cells>
<tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="b0f-WS-wGd"> <tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="b0f-WS-wGd">
<rect key="frame" x="0.0" y="223" width="375" height="44"/> <rect key="frame" x="0.0" y="159" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="b0f-WS-wGd" id="Tej-UW-yK7"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="b0f-WS-wGd" id="Tej-UW-yK7">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Legacy" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sLx-Wk-oJm"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Legacy" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sLx-Wk-oJm">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="47g-NW-zSf"/> <constraint firstAttribute="width" constant="100" id="47g-NW-zSf"/>
</constraints> </constraints>
@ -342,7 +364,9 @@
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="qW3-51-hZP"/> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="qW3-51-hZP">
<rect key="frame" x="318" y="6.5" width="51" height="31"/>
</switch>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="sLx-Wk-oJm" firstAttribute="centerY" secondItem="qW3-51-hZP" secondAttribute="centerY" id="D1R-xs-cHg"/> <constraint firstItem="sLx-Wk-oJm" firstAttribute="centerY" secondItem="qW3-51-hZP" secondAttribute="centerY" id="D1R-xs-cHg"/>
@ -357,13 +381,14 @@
<tableViewSection id="pLW-Tc-sKf"> <tableViewSection id="pLW-Tc-sKf">
<cells> <cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="HHm-l0-c0d"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="HHm-l0-c0d">
<rect key="frame" x="0.0" y="303" width="375" height="44"/> <rect key="frame" x="0.0" y="239" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="HHm-l0-c0d" id="4qT-tm-wo7"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="HHm-l0-c0d" id="4qT-tm-wo7">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Passphrase" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fAW-aP-GN9"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Passphrase" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fAW-aP-GN9">
<rect key="frame" x="8" y="11.5" width="100" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="100" id="wRI-ys-67O"/> <constraint firstAttribute="width" constant="100" id="wRI-ys-67O"/>
</constraints> </constraints>
@ -372,6 +397,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" highlighted="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Required" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="DJv-Ey-Hka"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" highlighted="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Required" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="DJv-Ey-Hka">
<rect key="frame" x="116" y="11.5" width="251" height="21"/>
<nil key="textColor"/> <nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" returnKeyType="done" secureTextEntry="YES"/> <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" returnKeyType="done" secureTextEntry="YES"/>
@ -394,13 +420,14 @@
<tableViewSection id="3SB-Gu-7Nb"> <tableViewSection id="3SB-Gu-7Nb">
<cells> <cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="zL5-5B-O5f"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="zL5-5B-O5f">
<rect key="frame" x="0.0" y="383" width="375" height="44"/> <rect key="frame" x="0.0" y="319" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="zL5-5B-O5f" id="WMu-8w-qhO"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="zL5-5B-O5f" id="WMu-8w-qhO">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generate and Copy to Clipboard" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sss-5e-vm2"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generate and Copy to Clipboard" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sss-5e-vm2">
<rect key="frame" x="8" y="8" width="359" height="27.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -415,13 +442,14 @@
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="ojF-JZ-yCg"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="ojF-JZ-yCg">
<rect key="frame" x="0.0" y="427" width="375" height="44"/> <rect key="frame" x="0.0" y="363" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ojF-JZ-yCg" id="bbw-fx-dOK"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ojF-JZ-yCg" id="bbw-fx-dOK">
<frame key="frameInset" width="375" height="43"/> <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generate and Show" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Tib-hU-gDm"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generate and Show" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Tib-hU-gDm">
<rect key="frame" x="8" y="8" width="359" height="27.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -462,10 +490,10 @@
</objects> </objects>
<point key="canvasLocation" x="1993" y="-423"/> <point key="canvasLocation" x="1993" y="-423"/>
</scene> </scene>
<!--View Controller--> <!--Generating-->
<scene sceneID="8JA-Zd-1zR"> <scene sceneID="8JA-Zd-1zR">
<objects> <objects>
<viewController storyboardIdentifier="activityIndicator" id="asG-zz-a8o" sceneMemberID="viewController"> <viewController storyboardIdentifier="activityIndicator" title="Generating" id="asG-zz-a8o" sceneMemberID="viewController">
<layoutGuides> <layoutGuides>
<viewControllerLayoutGuide type="top" id="hu7-uJ-ly6"/> <viewControllerLayoutGuide type="top" id="hu7-uJ-ly6"/>
<viewControllerLayoutGuide type="bottom" id="vvJ-kn-Vjf"/> <viewControllerLayoutGuide type="bottom" id="vvJ-kn-Vjf"/>
@ -474,8 +502,11 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="Qe7-Bk-J1n"/> <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="Qe7-Bk-J1n">
<rect key="frame" x="169" y="315" width="37" height="37"/>
</activityIndicatorView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generating…" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gXF-vs-Gda"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generating…" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gXF-vs-Gda">
<rect key="frame" x="137" y="360" width="101" height="20.5"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="101" id="jwK-5C-D2D"/> <constraint firstAttribute="width" constant="101" id="jwK-5C-D2D"/>
</constraints> </constraints>

View file

@ -24,8 +24,12 @@
#import "SiteStorage.h" #import "SiteStorage.h"
@interface MainViewController: UIViewController <UITableViewDelegate, @interface MainViewController: UIViewController <UISearchBarDelegate,
UITableViewDataSource> UITableViewDelegate, UITableViewDataSource>
@property (retain) OFArray<OFString *> *sites;
@property (retain) SiteStorage *siteStorage; @property (retain) SiteStorage *siteStorage;
@property (nonatomic, retain) IBOutlet UISearchBar *searchBar;
@property (nonatomic, retain) IBOutlet UITableView *tableView; @property (nonatomic, retain) IBOutlet UITableView *tableView;
- (void)reset;
@end @end

View file

@ -31,20 +31,33 @@
- (void)viewDidLoad - (void)viewDidLoad
{ {
_siteStorage = [[SiteStorage alloc] init]; _siteStorage = [[SiteStorage alloc] init];
[self reset];
} }
- (void)dealloc - (void)dealloc
{ {
[_siteStorage release]; [_siteStorage release];
[_tableView release]; [_tableView release];
[_sites release];
[super dealloc]; [super dealloc];
} }
- (void)reset
{
void *pool = objc_autoreleasePoolPush();
_searchBar.text = @"";
self.sites = [_siteStorage sitesWithFilter: nil];
[_tableView reloadData];
objc_autoreleasePoolPop(pool);
}
- (NSInteger)tableView: (UITableView *)tableView - (NSInteger)tableView: (UITableView *)tableView
numberOfRowsInSection: (NSInteger)section numberOfRowsInSection: (NSInteger)section
{ {
return [self.siteStorage sitesCount]; return [self.sites count];
} }
- (UITableViewCell *)tableView: (UITableView *)tableView - (UITableViewCell *)tableView: (UITableView *)tableView
@ -58,11 +71,18 @@
initWithStyle: UITableViewCellStyleDefault initWithStyle: UITableViewCellStyleDefault
reuseIdentifier: @"site"] autorelease]; reuseIdentifier: @"site"] autorelease];
cell.textLabel.text = [self.siteStorage.sites[indexPath.row] NSObject]; cell.textLabel.text = [self.sites[indexPath.row] NSObject];
return cell; return cell;
} }
- (void)searchBar:(UISearchBar *)searchBar
textDidChange:(NSString *)searchText
{
self.sites = [_siteStorage sitesWithFilter: [_searchBar.text OFObject]];
[_tableView reloadData];
}
- (void)tableView: (UITableView *)tableView - (void)tableView: (UITableView *)tableView
didSelectRowAtIndexPath: (NSIndexPath *)indexPath didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{ {

View file

@ -69,7 +69,7 @@ clearNSMutableString(NSMutableString *string)
self.mainViewController.tableView.indexPathForSelectedRow; self.mainViewController.tableView.indexPathForSelectedRow;
[_name release]; [_name release];
_name = [siteStorage.sites[indexPath.row] retain]; _name = [self.mainViewController.sites[indexPath.row] retain];
_length = [siteStorage lengthForSite: _name]; _length = [siteStorage lengthForSite: _name];
_legacy = [siteStorage isSiteLegacy: _name]; _legacy = [siteStorage isSiteLegacy: _name];

View file

@ -30,9 +30,7 @@
OFArray *_sites; OFArray *_sites;
} }
@property (readonly, nonatomic) OFArray<OFString *> *sites; - (OFArray<OFString *> *)sitesWithFilter: (OFString *)filter;
- (size_t)sitesCount;
- (bool)hasSite: (OFString *)name; - (bool)hasSite: (OFString *)name;
- (size_t)lengthForSite: (OFString *)name; - (size_t)lengthForSite: (OFString *)name;
- (bool)isSiteLegacy: (OFString *)name; - (bool)isSiteLegacy: (OFString *)name;

View file

@ -83,21 +83,26 @@ static OFNumber *lengthField, *legacyField;
[super dealloc]; [super dealloc];
} }
- (OFArray<OFString *> *)sites - (OFArray<OFString *> *)sitesWithFilter: (OFString *)filter
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
OFArray *sites = [[_storage allKeys] sortedArray]; /*
* FIXME: We need case folding here, but there is no method for it yet.
*/
filter = [filter lowercaseString];
OFArray *sites = [[[_storage allKeys] sortedArray]
filteredArrayUsingBlock: ^ (id name, size_t index) {
if (filter == nil)
return true;
return [[name lowercaseString] containsString: filter];
}];
[sites retain]; [sites retain];
objc_autoreleasePoolPop(pool); objc_autoreleasePoolPop(pool);
return [sites autorelease]; return [sites autorelease];
} }
- (size_t)sitesCount
{
return [_storage count];
}
- (bool)hasSite: (OFString *)name - (bool)hasSite: (OFString *)name
{ {
return (_storage[name] != nil); return (_storage[name] != nil);