Archived
1
Fork 0

Pressing return on iOS devices now adds the tag

This commit is contained in:
redstrate 2020-03-16 13:23:21 -04:00
parent edc9b3a76b
commit 83d10e5a28
3 changed files with 46 additions and 51 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Q6f-oJ-eRP">
<device id="mac" appearance="light"/>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Q6f-oJ-eRP">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="collection view cell content view" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -13,7 +13,7 @@
<objects>
<navigationController id="Q6f-oJ-eRP" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="bva-S3-Kph">
<rect key="frame" x="0.0" y="0.0" width="800" height="50"/>
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
@ -29,11 +29,11 @@
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="nHo-hC-uT9" customClass="PostCollectionView" customModule="Gallery" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="800" height="550"/>
<rect key="frame" x="0.0" y="88" width="414" height="770"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="N2K-Me-YT7">
<size key="itemSize" width="50" height="50"/>
@ -97,11 +97,11 @@
<objects>
<viewController storyboardIdentifier="PostViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="jQf-RA-c2I" customClass="PostViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8Jm-eh-tzq">
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="7Hd-Ax-kkQ">
<rect key="frame" x="0.0" y="50" width="800" height="550"/>
<rect key="frame" x="0.0" y="88" width="414" height="774"/>
<gestureRecognizers/>
<connections>
<outletCollection property="gestureRecognizers" destination="uQa-Iu-LrE" appends="YES" id="Qec-Ks-5Aj"/>
@ -160,22 +160,22 @@
<objects>
<viewController storyboardIdentifier="EditTagsViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="3TL-qD-pbO" customClass="EditTagsViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="FH2-sj-H4t">
<rect key="frame" x="0.0" y="0.0" width="333" height="480"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="bb4-UL-VAQ">
<rect key="frame" x="29" y="111" width="288" height="353"/>
<rect key="frame" x="16" y="110" width="382" height="682"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="tagCell" id="c7T-0r-L5w" customClass="TagViewCell" customModule="Gallery" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="288" height="44.5"/>
<rect key="frame" x="0.0" y="28" width="382" height="47.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="c7T-0r-L5w" id="WjD-Nb-tif">
<rect key="frame" x="0.0" y="0.0" width="288" height="44.5"/>
<rect key="frame" x="0.0" y="0.0" width="382" height="47.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Cei-95-iOR">
<rect key="frame" x="15" y="12" width="258" height="21"/>
<rect key="frame" x="20" y="13" width="342" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -200,28 +200,21 @@
</connections>
</tableView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tags" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Avc-oj-cgH">
<rect key="frame" x="148" y="21" width="38" height="20"/>
<rect key="frame" x="189" y="21" width="36.5" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vru-rx-keE">
<rect key="frame" x="280" y="15" width="38" height="31"/>
<state key="normal" title="Done"/>
<connections>
<action selector="doneAction:" destination="3TL-qD-pbO" eventType="touchDown" id="qAw-6K-ZZF"/>
</connections>
</button>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter new tag..." textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="2po-UQ-V0K">
<rect key="frame" x="29" y="61" width="288" height="34"/>
<rect key="frame" x="16" y="60" width="382" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<textInputTraits key="textInputTraits" returnKeyType="done"/>
<connections>
<action selector="editingFinished:" destination="3TL-qD-pbO" eventType="editingDidEnd" id="MGp-b4-ufV"/>
<outlet property="delegate" destination="3TL-qD-pbO" id="c7V-JT-hDp"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iWK-vF-Vze">
<rect key="frame" x="29" y="15" width="30" height="31"/>
<rect key="frame" x="16" y="15" width="30" height="30"/>
<state key="normal" title="Edit"/>
<connections>
<action selector="editAction:" destination="3TL-qD-pbO" eventType="touchDown" id="5er-HM-8S2"/>
@ -234,10 +227,8 @@
<constraint firstItem="iWK-vF-Vze" firstAttribute="top" secondItem="QZA-mC-Y5U" secondAttribute="top" constant="15" id="1GH-Ph-jLQ"/>
<constraint firstItem="2po-UQ-V0K" firstAttribute="top" secondItem="iWK-vF-Vze" secondAttribute="bottom" constant="15" id="Tfw-tD-NIh"/>
<constraint firstItem="bb4-UL-VAQ" firstAttribute="top" secondItem="2po-UQ-V0K" secondAttribute="bottom" constant="16" id="Tza-Yu-GJy"/>
<constraint firstItem="vru-rx-keE" firstAttribute="top" secondItem="QZA-mC-Y5U" secondAttribute="top" constant="15" id="Vie-or-57j"/>
<constraint firstItem="QZA-mC-Y5U" firstAttribute="trailing" secondItem="bb4-UL-VAQ" secondAttribute="trailing" constant="16" id="Y0t-Xb-GeO"/>
<constraint firstItem="bb4-UL-VAQ" firstAttribute="leading" secondItem="QZA-mC-Y5U" secondAttribute="leading" constant="16" id="dU7-AM-rdu"/>
<constraint firstItem="QZA-mC-Y5U" firstAttribute="trailing" secondItem="vru-rx-keE" secondAttribute="trailing" constant="15" id="fQA-zb-Ggk"/>
<constraint firstItem="2po-UQ-V0K" firstAttribute="leading" secondItem="QZA-mC-Y5U" secondAttribute="leading" constant="16" id="h3a-gQ-AeR"/>
<constraint firstItem="iWK-vF-Vze" firstAttribute="leading" secondItem="QZA-mC-Y5U" secondAttribute="leading" constant="16" id="hJB-8r-k89"/>
<constraint firstItem="QZA-mC-Y5U" firstAttribute="trailing" secondItem="2po-UQ-V0K" secondAttribute="trailing" constant="16" id="mcC-aj-xcR"/>
@ -247,6 +238,7 @@
<viewLayoutGuide key="safeArea" id="QZA-mC-Y5U"/>
</view>
<connections>
<outlet property="editButton" destination="iWK-vF-Vze" id="uzO-ey-3MZ"/>
<outlet property="tableView" destination="bb4-UL-VAQ" id="Vq5-Vb-i3L"/>
<outlet property="tagField" destination="2po-UQ-V0K" id="Mrv-6H-7QS"/>
</connections>
@ -260,18 +252,18 @@
<objects>
<viewController storyboardIdentifier="InfoViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="MaR-nc-wxI" customClass="InfoViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="VFL-0t-HSi">
<rect key="frame" x="0.0" y="0.0" width="333" height="480"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yPq-yv-LyM">
<rect key="frame" x="279" y="15" width="38" height="30"/>
<rect key="frame" x="361" y="15" width="37" height="30"/>
<state key="normal" title="Done"/>
<connections>
<action selector="exitAction:" destination="MaR-nc-wxI" eventType="touchDown" id="VYZ-ym-Qcz"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDx-zx-hmw">
<rect key="frame" x="33" y="57" width="280" height="423"/>
<rect key="frame" x="20" y="57" width="374" height="751"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -302,11 +294,11 @@
<objects>
<viewController storyboardIdentifier="ReverseImageViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="VhH-X2-v6b" customClass="ReverseImageViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="TNu-lY-cd3">
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uq3-56-0hX">
<rect key="frame" x="0.0" y="59" width="800" height="541"/>
<rect key="frame" x="0.0" y="102" width="414" height="760"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
@ -314,14 +306,14 @@
</wkWebViewConfiguration>
</wkWebView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rUi-3B-MYc">
<rect key="frame" x="20" y="20" width="49" height="31"/>
<rect key="frame" x="20" y="64" width="48" height="30"/>
<state key="normal" title="Cancel"/>
<connections>
<action selector="cancelAction:" destination="VhH-X2-v6b" eventType="touchDown" id="ggg-rw-euW"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dtc-GD-q7J">
<rect key="frame" x="734" y="20" width="46" height="31"/>
<rect key="frame" x="348" y="64" width="46" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="46" id="jzo-YK-PFI"/>
</constraints>
@ -354,11 +346,11 @@
<objects>
<viewController id="E6A-NM-9w9" customClass="SearchViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ZwQ-d4-u0T">
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Bba-zG-RTo" customClass="PostCollectionView" customModule="Gallery" customModuleProvider="target">
<rect key="frame" x="0.0" y="102" width="800" height="498"/>
<rect key="frame" x="0.0" y="140" width="414" height="722"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="aRU-y0-ffy">
<size key="itemSize" width="50" height="50"/>
@ -388,7 +380,7 @@
</cells>
</collectionView>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Search..." textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="hMR-QW-233">
<rect key="frame" x="20" y="60" width="760" height="34"/>
<rect key="frame" x="20" y="98" width="374" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
@ -423,11 +415,11 @@
<objects>
<viewController id="1Lq-DE-RSc" customClass="TagViewController" customModule="Gallery" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="YEa-YJ-CTQ">
<rect key="frame" x="0.0" y="0.0" width="720" height="560"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="5op-NT-lmm" customClass="PostCollectionView" customModule="Gallery" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="720" height="560"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="808"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="d7Y-hv-w27">
<size key="itemSize" width="50" height="50"/>

View file

@ -1,11 +1,10 @@
import UIKit
import CoreData
class EditTagsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
class EditTagsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {
var post: Post?
var onDismiss: (() -> Void)? = nil
@IBOutlet weak var editButton: UIButton!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var tagField: UITextField!
@ -29,7 +28,7 @@ class EditTagsViewController: UIViewController, UITableViewDelegate, UITableView
}
}
@IBAction func editingFinished(_ sender: Any) {
func textFieldDidEndEditing(_ textField: UITextField) {
guard let appDelegate =
UIApplication.shared.delegate as? AppDelegate else {
return
@ -46,15 +45,20 @@ class EditTagsViewController: UIViewController, UITableViewDelegate, UITableView
tagField.text?.removeAll()
}
@IBAction func editAction(_ sender: Any) {
tableView.setEditing(true, animated: true)
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textFieldDidEndEditing(textField)
return false
}
@IBAction func doneAction(_ sender: Any) {
dismiss(animated: true, completion: nil)
@IBAction func editAction(_ sender: Any) {
isEditing = !isEditing
if onDismiss != nil {
onDismiss!()
tableView.setEditing(isEditing, animated: true)
if isEditing {
editButton.setTitle("Done", for: UIControl.State.normal)
} else {
editButton.setTitle("Edit", for: UIControl.State.normal)
}
}

View file

@ -86,7 +86,6 @@ class PostViewController: UIViewController, UIPopoverPresentationControllerDeleg
return
}
newViewController.onDismiss = updateWindowTitle
newViewController.post = self.post as? Post
segue.destination.popoverPresentationController?.delegate = self