Show category info after an password entry when show password folder is off

This commit is contained in:
Bob Sun 2017-03-10 23:07:56 -08:00
parent ff947f8e17
commit 3964ca64ed
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
4 changed files with 120 additions and 17 deletions

View file

@ -162,6 +162,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
tableView.insertSubview(refreshControl, at: 0)
SVProgressHUD.setDefaultMaskType(.black)
updateRefreshControlTitle()
tableView.register(UINib(nibName: "PasswordWithFolderTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordWithFolderTableViewCell")
}
override func viewWillAppear(_ animated: Bool) {
@ -186,26 +187,41 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
let entry = getPasswordEntry(by: indexPath)
if !entry.isDir {
if entry.passwordEntity!.synced {
cell.textLabel?.text = entry.title
} else {
cell.textLabel?.text = "\(entry.title)"
}
let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction(_:)))
longPressGestureRecognizer.minimumPressDuration = 0.6
if Defaults[.isShowFolderOn] {
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction(_:)))
longPressGestureRecognizer.minimumPressDuration = 0.6
cell.addGestureRecognizer(longPressGestureRecognizer)
cell.accessoryType = .none
cell.detailTextLabel?.text = ""
let entry = getPasswordEntry(by: indexPath)
if !entry.isDir {
if entry.passwordEntity!.synced {
cell.textLabel?.text = entry.title
} else {
cell.textLabel?.text = "\(entry.title)"
}
cell.addGestureRecognizer(longPressGestureRecognizer)
cell.accessoryType = .none
cell.detailTextLabel?.text = ""
} else {
cell.textLabel?.text = "\(entry.title)"
cell.accessoryType = .disclosureIndicator
cell.detailTextLabel?.text = "\(entry.passwordEntity?.children?.count ?? 0)"
}
return cell
} else {
cell.textLabel?.text = "\(entry.title)"
cell.accessoryType = .disclosureIndicator
cell.detailTextLabel?.text = "\(entry.passwordEntity?.children?.count ?? 0)"
let passwordWithFolderCell = tableView.dequeueReusableCell(withIdentifier: "passwordWithFolderTableViewCell", for: indexPath) as! PasswordWithFolderTableViewCell
let entry = getPasswordEntry(by: indexPath)
if entry.passwordEntity!.synced {
passwordWithFolderCell.passwordLabel?.text = entry.title
} else {
passwordWithFolderCell.passwordLabel?.text = "\(entry.title)"
}
passwordWithFolderCell.folderLabel.text = entry.passwordEntity?.getCategoryText()
passwordWithFolderCell.addGestureRecognizer(longPressGestureRecognizer)
return passwordWithFolderCell
}
return cell
}
private func getPasswordEntry(by indexPath: IndexPath) -> PasswordsTableEntry {

View file

@ -0,0 +1,27 @@
//
// PasswordTableViewCell.swift
// pass
//
// Created by Mingshen Sun on 8/3/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
class PasswordWithFolderTableViewCell: UITableViewCell {
@IBOutlet weak var passwordLabel: UILabel!
@IBOutlet weak var folderLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}

View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12106.1" systemVersion="16E183b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12074.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="passwordWithFolderTableViewCell" rowHeight="43" id="KGk-i7-Jjw" customClass="PasswordWithFolderTableViewCell" customModule="pass" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<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">
<rect key="frame" x="0.0" y="0.0" width="320" height="42.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Password Entry" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="y5A-3S-tcq">
<rect key="frame" x="15" y="8" width="297" height="26.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Family &gt; Parents" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GEv-Cf-Cnx">
<rect key="frame" x="8" y="12.5" width="297" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="y5A-3S-tcq" firstAttribute="centerY" secondItem="GEv-Cf-Cnx" secondAttribute="centerY" id="Ev0-0v-v1c"/>
<constraint firstAttribute="trailingMargin" secondItem="GEv-Cf-Cnx" secondAttribute="trailing" constant="7" id="Hyk-Q8-5uU"/>
<constraint firstItem="y5A-3S-tcq" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="7" id="VDn-B1-Tyg"/>
<constraint firstItem="y5A-3S-tcq" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="e9F-C0-yGP"/>
<constraint firstAttribute="bottomMargin" secondItem="y5A-3S-tcq" secondAttribute="bottom" id="f52-hU-sEC"/>
<constraint firstAttribute="leadingMargin" secondItem="GEv-Cf-Cnx" secondAttribute="leading" id="rjm-bp-jT3"/>
<constraint firstAttribute="trailingMargin" secondItem="y5A-3S-tcq" secondAttribute="trailing" id="vsW-4d-EEl"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="folderLabel" destination="GEv-Cf-Cnx" id="HHd-LU-wYW"/>
<outlet property="passwordLabel" destination="y5A-3S-tcq" id="1OK-Io-6mP"/>
</connections>
<point key="canvasLocation" x="34" y="53.5"/>
</tableViewCell>
</objects>
</document>