Skip to content

Commit 8030596

Browse files
kradicalDiego Ernst
authored andcommitted
inherit from fieldcell and make nicer appearance in a list of cells (#8)
* inherit from fieldcell and make nicer appearance in a list of cells * add outlets for leading and trailing constraints on cell content
1 parent ad08804 commit 8030596

3 files changed

Lines changed: 34 additions & 17 deletions

File tree

Resources/GenericPasswordCell.xib

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
47
<deployment version="2048" identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
69
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
711
</dependencies>
812
<objects>
913
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
@@ -12,53 +16,59 @@
1216
<rect key="frame" x="0.0" y="0.0" width="393" height="199"/>
1317
<autoresizingMask key="autoresizingMask"/>
1418
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="laY-Xe-HBQ" id="m16-zs-DcU">
15-
<rect key="frame" x="0.0" y="0.0" width="393" height="198"/>
19+
<rect key="frame" x="0.0" y="0.0" width="393" height="198.5"/>
1620
<autoresizingMask key="autoresizingMask"/>
1721
<subviews>
1822
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tyh-Vt-DFb">
1923
<rect key="frame" x="0.0" y="0.0" width="393" height="198"/>
2024
<subviews>
2125
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" verticalHuggingPriority="253" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Create password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Zy9-qp-gBx">
22-
<rect key="frame" x="10" y="12" width="341" height="17"/>
26+
<rect key="frame" x="16" y="12" width="329" height="17"/>
2327
<fontDescription key="fontDescription" type="system" pointSize="14"/>
2428
<textInputTraits key="textInputTraits"/>
2529
</textField>
2630
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lnm-KM-o1x">
27-
<rect key="frame" x="361" y="10" width="22" height="22"/>
31+
<rect key="frame" x="355" y="10" width="22" height="22"/>
2832
<constraints>
2933
<constraint firstAttribute="width" secondItem="lnm-KM-o1x" secondAttribute="height" id="cMs-S1-GBE"/>
3034
<constraint firstAttribute="width" constant="22" id="gaV-V2-qNo"/>
3135
</constraints>
3236
<state key="normal" image="visibility.png"/>
3337
</button>
3438
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8m2-Ek-2uQ" customClass="DefaultPasswordStrengthView" customModule="GenericPasswordRow" customModuleProvider="target">
35-
<rect key="frame" x="10" y="35" width="373" height="5"/>
36-
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
39+
<rect key="frame" x="16" y="35" width="361" height="5"/>
40+
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
3741
<constraints>
3842
<constraint firstAttribute="height" constant="5" id="8df-ch-q1A"/>
3943
</constraints>
4044
</view>
4145
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="afsda" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wOo-IE-4vB">
4246
<rect key="frame" x="183" y="43" width="27" height="152"/>
4347
<fontDescription key="fontDescription" type="system" pointSize="10"/>
44-
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
48+
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4549
<nil key="highlightedColor"/>
4650
</label>
4751
</subviews>
48-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
52+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4953
<constraints>
5054
<constraint firstItem="lnm-KM-o1x" firstAttribute="leading" secondItem="Zy9-qp-gBx" secondAttribute="trailing" constant="10" id="5nR-b8-58B"/>
51-
<constraint firstAttribute="trailing" secondItem="lnm-KM-o1x" secondAttribute="trailing" constant="10" id="AUP-Wp-2yc"/>
55+
<constraint firstItem="lnm-KM-o1x" firstAttribute="trailing" secondItem="8m2-Ek-2uQ" secondAttribute="trailing" id="83O-Mt-PJ2"/>
56+
<constraint firstAttribute="trailing" secondItem="lnm-KM-o1x" secondAttribute="trailing" constant="16" id="AUP-Wp-2yc"/>
5257
<constraint firstItem="wOo-IE-4vB" firstAttribute="centerX" secondItem="Tyh-Vt-DFb" secondAttribute="centerX" id="EAz-sa-xiM"/>
5358
<constraint firstItem="lnm-KM-o1x" firstAttribute="centerY" secondItem="Zy9-qp-gBx" secondAttribute="centerY" id="Zgx-dV-oPo"/>
5459
<constraint firstItem="8m2-Ek-2uQ" firstAttribute="top" secondItem="Zy9-qp-gBx" secondAttribute="bottom" constant="6" id="fom-uj-88T"/>
55-
<constraint firstItem="Zy9-qp-gBx" firstAttribute="leading" secondItem="Tyh-Vt-DFb" secondAttribute="leading" constant="10" id="lRa-nV-O9c"/>
56-
<constraint firstAttribute="trailing" secondItem="8m2-Ek-2uQ" secondAttribute="trailing" constant="10" id="t2D-BY-nFh"/>
60+
<constraint firstItem="Zy9-qp-gBx" firstAttribute="leading" secondItem="Tyh-Vt-DFb" secondAttribute="leading" constant="16" id="lRa-nV-O9c"/>
5761
<constraint firstItem="Zy9-qp-gBx" firstAttribute="top" secondItem="Tyh-Vt-DFb" secondAttribute="top" constant="12" id="uBJ-pR-RE7"/>
5862
<constraint firstItem="8m2-Ek-2uQ" firstAttribute="leading" secondItem="Zy9-qp-gBx" secondAttribute="leading" id="uQo-kZ-xY5"/>
5963
<constraint firstAttribute="bottom" secondItem="wOo-IE-4vB" secondAttribute="bottom" constant="3" id="v13-h7-ubq"/>
64+
<constraint firstItem="8m2-Ek-2uQ" firstAttribute="leading" secondItem="Zy9-qp-gBx" secondAttribute="leading" id="vho-ft-Nyl"/>
6065
<constraint firstItem="wOo-IE-4vB" firstAttribute="top" secondItem="8m2-Ek-2uQ" secondAttribute="bottom" constant="3" id="wcD-wv-hwb"/>
6166
</constraints>
67+
<variation key="default">
68+
<mask key="constraints">
69+
<exclude reference="uQo-kZ-xY5"/>
70+
</mask>
71+
</variation>
6272
</view>
6373
</subviews>
6474
<constraints>
@@ -70,8 +80,10 @@
7080
</tableViewCellContentView>
7181
<connections>
7282
<outlet property="hintLabel" destination="wOo-IE-4vB" id="T1I-It-Pxo"/>
83+
<outlet property="leading" destination="lRa-nV-O9c" id="bL6-Nc-e7S"/>
7384
<outlet property="passwordStrengthView" destination="8m2-Ek-2uQ" id="QiY-2S-FbF"/>
7485
<outlet property="textField" destination="Zy9-qp-gBx" id="okX-a5-G3H"/>
86+
<outlet property="trailing" destination="AUP-Wp-2yc" id="EyW-oa-GGd"/>
7587
<outlet property="visibilityButton" destination="lnm-KM-o1x" id="Sex-mW-T4T"/>
7688
</connections>
7789
<point key="canvasLocation" x="-425.5" y="405.5"/>

Sources/GenericPasswordCell.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
import Foundation
1010
import Eureka
1111

12-
open class GenericPasswordCell: Cell<String>, CellType {
12+
open class GenericPasswordCell: _FieldCell<String>, CellType {
1313

14-
@IBOutlet public weak var textField: UITextField!
1514
@IBOutlet weak var visibilityButton: UIButton?
1615
@IBOutlet weak var passwordStrengthView: PasswordStrengthView?
1716
@IBOutlet public weak var hintLabel: UILabel?
1817

18+
@IBOutlet public weak var leading: NSLayoutConstraint!
19+
@IBOutlet public weak var trailing: NSLayoutConstraint!
20+
1921
var genericPasswordRow: _GenericPasswordRow! {
2022
return row as? _GenericPasswordRow
2123
}
@@ -81,7 +83,7 @@ open class GenericPasswordCell: Cell<String>, CellType {
8183
visibilityButton?.setImage(textField.isSecureTextEntry ? visibilityImage.on : visibilityImage.off, for: .normal)
8284
}
8385

84-
open func textFieldDidChange(_ textField: UITextField) {
86+
open override func textFieldDidChange(_ textField: UITextField) {
8587
genericPasswordRow.value = textField.text
8688
updatePasswordStrengthIfNeeded()
8789

Sources/GenericPasswordRow.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import Foundation
1010
import Eureka
1111

12-
open class _GenericPasswordRow: Row<GenericPasswordCell> {
12+
open class _GenericPasswordRow: Row<GenericPasswordCell>, KeyboardReturnHandler {
13+
14+
/// Configuration for the keyboardReturnType of this row
15+
open var keyboardReturnType: KeyboardReturnTypeConfiguration?
1316

1417
open var passwordValidator: PasswordValidator = DefaultPasswordValidator()
1518
open var placeholder: String? = "Password"

0 commit comments

Comments
 (0)