Update fill password UI
- Click the setting icon to show or hide the slider. - Clicking on other sections does not work now (remove gesture)
This commit is contained in:
parent
820c4eca04
commit
abce9d7be5
4 changed files with 50 additions and 52 deletions
|
|
@ -56,11 +56,6 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
tableView.estimatedRowHeight = 48
|
tableView.estimatedRowHeight = 48
|
||||||
self.tableView.sectionFooterHeight = UITableViewAutomaticDimension;
|
self.tableView.sectionFooterHeight = UITableViewAutomaticDimension;
|
||||||
self.tableView.estimatedSectionFooterHeight = 0;
|
self.tableView.estimatedSectionFooterHeight = 0;
|
||||||
|
|
||||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tableTapped))
|
|
||||||
tapGesture.delegate = self
|
|
||||||
tapGesture.cancelsTouchesInView = false
|
|
||||||
tableView.addGestureRecognizer(tapGesture)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
|
@ -166,35 +161,8 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
fillPasswordCell?.setContent(content: plainPassword)
|
fillPasswordCell?.setContent(content: plainPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableTapped(recognizer: UITapGestureRecognizer) {
|
func showHidePasswordSettings() {
|
||||||
if recognizer.state == UIGestureRecognizerState.ended {
|
hidePasswordSettings = !hidePasswordSettings
|
||||||
let tapLocation = recognizer.location(in: self.tableView)
|
|
||||||
let tapIndexPath = self.tableView.indexPathForRow(at: tapLocation)
|
|
||||||
|
|
||||||
// do nothing, if delete is tapped (a temporary solution)
|
|
||||||
if tapIndexPath != nil, deletePasswordCell != nil,
|
|
||||||
tableView.cellForRow(at: tapIndexPath!) == deletePasswordCell {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide password settings (e.g., the length slider)
|
|
||||||
if tapIndexPath?.section != passwordSection, hidePasswordSettings == false {
|
|
||||||
hidePasswordSettings = true
|
|
||||||
tableView.reloadSections([passwordSection], with: .fade)
|
tableView.reloadSections([passwordSection], with: .fade)
|
||||||
// select the row at tapIndexPath manually
|
|
||||||
if tapIndexPath != nil {
|
|
||||||
self.tableView(self.tableView, didSelectRowAt: tapIndexPath!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
|
||||||
if gestureRecognizer is UITapGestureRecognizer {
|
|
||||||
// so that the tap gesture could be passed by
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import UIKit
|
||||||
|
|
||||||
protocol FillPasswordTableViewCellDelegate {
|
protocol FillPasswordTableViewCellDelegate {
|
||||||
func generateAndCopyPassword()
|
func generateAndCopyPassword()
|
||||||
|
func showHidePasswordSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
class FillPasswordTableViewCell: ContentTableViewCell {
|
class FillPasswordTableViewCell: ContentTableViewCell {
|
||||||
|
|
@ -17,10 +18,17 @@ class FillPasswordTableViewCell: ContentTableViewCell {
|
||||||
@IBOutlet weak var contentTextField: UITextField!
|
@IBOutlet weak var contentTextField: UITextField!
|
||||||
var delegate: FillPasswordTableViewCellDelegate?
|
var delegate: FillPasswordTableViewCellDelegate?
|
||||||
|
|
||||||
|
@IBOutlet weak var settingButton: UIButton!
|
||||||
|
@IBOutlet weak var generateButton: UIButton!
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
// Initialization code
|
// Initialization code
|
||||||
contentTextField.font = UIFont(name: Globals.passwordFonts, size: (contentTextField.font?.pointSize)!)
|
contentTextField.font = UIFont(name: Globals.passwordFonts, size: (contentTextField.font?.pointSize)!)
|
||||||
|
|
||||||
|
// Force aspect ratio of button images
|
||||||
|
settingButton.imageView?.contentMode = .scaleAspectFit
|
||||||
|
generateButton.imageView?.contentMode = .scaleAspectFit
|
||||||
}
|
}
|
||||||
|
|
||||||
override func setSelected(_ selected: Bool, animated: Bool) {
|
override func setSelected(_ selected: Bool, animated: Bool) {
|
||||||
|
|
@ -33,6 +41,10 @@ class FillPasswordTableViewCell: ContentTableViewCell {
|
||||||
self.delegate?.generateAndCopyPassword()
|
self.delegate?.generateAndCopyPassword()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func showHidePasswordSettings() {
|
||||||
|
self.delegate?.showHidePasswordSettings()
|
||||||
|
}
|
||||||
|
|
||||||
// re-color
|
// re-color
|
||||||
@IBAction func textFieldDidChange(_ sender: UITextField) {
|
@IBAction func textFieldDidChange(_ sender: UITextField) {
|
||||||
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
|
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@
|
||||||
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
|
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="320" height="89"/>
|
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="password" textAlignment="natural" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="k0U-2N-YaX">
|
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="password" textAlignment="natural" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="k0U-2N-YaX" userLabel="Password">
|
||||||
<rect key="frame" x="15" y="8" width="220" height="74"/>
|
<rect key="frame" x="15" y="8" width="78" height="73.5"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="qVX-ui-dIn"/>
|
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="9gX-VT-F9P"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<nil key="textColor"/>
|
<nil key="textColor"/>
|
||||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||||
|
|
@ -31,31 +31,49 @@
|
||||||
<action selector="textFieldDidChange:" destination="KGk-i7-Jjw" eventType="editingChanged" id="U0t-2B-JxY"/>
|
<action selector="textFieldDidChange:" destination="KGk-i7-Jjw" eventType="editingChanged" id="U0t-2B-JxY"/>
|
||||||
</connections>
|
</connections>
|
||||||
</textField>
|
</textField>
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hTh-ek-Xam">
|
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SZJ-aY-45Y" userLabel="Setting">
|
||||||
<rect key="frame" x="243" y="-0.5" width="64" height="89.5"/>
|
<rect key="frame" x="285" y="8" width="20" height="73.5"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="width" constant="64" id="X1A-kc-qJy"/>
|
<constraint firstAttribute="width" constant="20" id="D9D-FC-ANz"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<state key="normal" title="Generate"/>
|
<state key="normal" image="HorizontalSettings"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="showHidePasswordSettings" destination="KGk-i7-Jjw" eventType="touchUpInside" id="3I8-S0-qlo"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hTh-ek-Xam" userLabel="Generate">
|
||||||
|
<rect key="frame" x="255" y="8" width="20" height="73.5"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="width" constant="20" id="l0l-7B-Tws"/>
|
||||||
|
</constraints>
|
||||||
|
<state key="normal" image="Refresh"/>
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="generatePassword:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="M61-hs-PCP"/>
|
<action selector="generatePassword:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="M61-hs-PCP"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="trailingMargin" secondItem="k0U-2N-YaX" secondAttribute="trailing" constant="77" id="3S1-gj-XVP" userLabel="trailingMargin = Content Text Field.trailing + 71"/>
|
<constraint firstItem="SZJ-aY-45Y" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="5XP-xZ-YWY"/>
|
||||||
<constraint firstItem="hTh-ek-Xam" firstAttribute="centerY" secondItem="k0U-2N-YaX" secondAttribute="centerY" id="Fls-do-khd"/>
|
<constraint firstAttribute="trailingMargin" secondItem="SZJ-aY-45Y" secondAttribute="trailing" constant="7" id="5bp-bm-9vv"/>
|
||||||
<constraint firstItem="hTh-ek-Xam" firstAttribute="height" secondItem="H2p-sc-9uM" secondAttribute="height" id="Gok-dX-tQ5"/>
|
<constraint firstAttribute="bottomMargin" secondItem="SZJ-aY-45Y" secondAttribute="bottom" id="CMF-1f-MdG"/>
|
||||||
<constraint firstItem="hTh-ek-Xam" firstAttribute="leading" secondItem="k0U-2N-YaX" secondAttribute="trailing" constant="8" id="hsy-gb-ero" userLabel="Generate.leading = Content Text Field.trailing"/>
|
<constraint firstItem="hTh-ek-Xam" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="OjQ-mD-CWV"/>
|
||||||
<constraint firstItem="k0U-2N-YaX" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="jKd-Xa-tr5"/>
|
<constraint firstItem="SZJ-aY-45Y" firstAttribute="leading" secondItem="hTh-ek-Xam" secondAttribute="trailing" constant="10" id="UlR-NB-9So"/>
|
||||||
<constraint firstItem="k0U-2N-YaX" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="7" id="lAm-D6-pir"/>
|
<constraint firstAttribute="bottomMargin" secondItem="hTh-ek-Xam" secondAttribute="bottom" id="bvu-Q0-QAG"/>
|
||||||
<constraint firstAttribute="bottomMargin" secondItem="k0U-2N-YaX" secondAttribute="bottom" constant="-1" id="pLC-H7-JTU" userLabel="bottomMargin = Content Text Field.bottom"/>
|
<constraint firstAttribute="bottomMargin" secondItem="k0U-2N-YaX" secondAttribute="bottom" id="lRv-MC-Cru"/>
|
||||||
|
<constraint firstItem="k0U-2N-YaX" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="sUk-sk-JLT"/>
|
||||||
|
<constraint firstItem="k0U-2N-YaX" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="7" id="zGn-an-SlK"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</tableViewCellContentView>
|
</tableViewCellContentView>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="contentTextField" destination="k0U-2N-YaX" id="kQO-tR-Epp"/>
|
<outlet property="contentTextField" destination="k0U-2N-YaX" id="kQO-tR-Epp"/>
|
||||||
|
<outlet property="generateButton" destination="hTh-ek-Xam" id="MUa-qs-uw4"/>
|
||||||
|
<outlet property="settingButton" destination="SZJ-aY-45Y" id="G4T-04-NBD"/>
|
||||||
</connections>
|
</connections>
|
||||||
<point key="canvasLocation" x="34" y="77"/>
|
<point key="canvasLocation" x="34" y="77"/>
|
||||||
</tableViewCell>
|
</tableViewCell>
|
||||||
</objects>
|
</objects>
|
||||||
|
<resources>
|
||||||
|
<image name="HorizontalSettings" width="25" height="25"/>
|
||||||
|
<image name="Refresh" width="32" height="32"/>
|
||||||
|
</resources>
|
||||||
</document>
|
</document>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
<rect key="frame" x="0.0" y="0.0" width="320" height="74"/>
|
<rect key="frame" x="0.0" y="0.0" width="320" height="74"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="320" height="73.5"/>
|
<rect key="frame" x="0.0" y="0.0" width="320" height="73"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="MwT-Jl-hhE">
|
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="MwT-Jl-hhE">
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
<nil key="textColor"/>
|
<nil key="textColor"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="t7T-HC-hUd" userLabel="Title">
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="t7T-HC-hUd" userLabel="Title">
|
||||||
<rect key="frame" x="15" y="8" width="30" height="57.5"/>
|
<rect key="frame" x="15" y="8" width="30" height="57.5"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="8Tz-Qo-Mkg"/>
|
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="8Tz-Qo-Mkg"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue