Merge, fix conflict
This commit is contained in:
commit
d28dde8719
26 changed files with 262 additions and 55 deletions
|
|
@ -10,6 +10,7 @@ import UIKit
|
|||
|
||||
protocol FillPasswordTableViewCellDelegate {
|
||||
func generateAndCopyPassword()
|
||||
func showHidePasswordSettings()
|
||||
}
|
||||
|
||||
class FillPasswordTableViewCell: ContentTableViewCell {
|
||||
|
|
@ -17,10 +18,17 @@ class FillPasswordTableViewCell: ContentTableViewCell {
|
|||
@IBOutlet weak var contentTextField: UITextField!
|
||||
var delegate: FillPasswordTableViewCellDelegate?
|
||||
|
||||
@IBOutlet weak var settingButton: UIButton!
|
||||
@IBOutlet weak var generateButton: UIButton!
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
// Initialization code
|
||||
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) {
|
||||
|
|
@ -33,6 +41,10 @@ class FillPasswordTableViewCell: ContentTableViewCell {
|
|||
self.delegate?.generateAndCopyPassword()
|
||||
}
|
||||
|
||||
@IBAction func showHidePasswordSettings() {
|
||||
self.delegate?.showHidePasswordSettings()
|
||||
}
|
||||
|
||||
// re-color
|
||||
@IBAction func textFieldDidChange(_ sender: UITextField) {
|
||||
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
|
||||
<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="89"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="password" textAlignment="natural" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="k0U-2N-YaX">
|
||||
<rect key="frame" x="15" y="8" width="220" height="74"/>
|
||||
<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="78" height="73.5"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="qVX-ui-dIn"/>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="9gX-VT-F9P"/>
|
||||
</constraints>
|
||||
<nil key="textColor"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
|
|
@ -31,31 +31,49 @@
|
|||
<action selector="textFieldDidChange:" destination="KGk-i7-Jjw" eventType="editingChanged" id="U0t-2B-JxY"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hTh-ek-Xam">
|
||||
<rect key="frame" x="243" y="-0.5" width="64" height="89.5"/>
|
||||
<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="285" y="8" width="20" height="73.5"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="64" id="X1A-kc-qJy"/>
|
||||
<constraint firstAttribute="width" constant="20" id="D9D-FC-ANz"/>
|
||||
</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>
|
||||
<action selector="generatePassword:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="M61-hs-PCP"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<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="hTh-ek-Xam" firstAttribute="centerY" secondItem="k0U-2N-YaX" secondAttribute="centerY" id="Fls-do-khd"/>
|
||||
<constraint firstItem="hTh-ek-Xam" firstAttribute="height" secondItem="H2p-sc-9uM" secondAttribute="height" id="Gok-dX-tQ5"/>
|
||||
<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="k0U-2N-YaX" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="jKd-Xa-tr5"/>
|
||||
<constraint firstItem="k0U-2N-YaX" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="7" id="lAm-D6-pir"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="k0U-2N-YaX" secondAttribute="bottom" constant="-1" id="pLC-H7-JTU" userLabel="bottomMargin = Content Text Field.bottom"/>
|
||||
<constraint firstItem="SZJ-aY-45Y" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="5XP-xZ-YWY"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="SZJ-aY-45Y" secondAttribute="trailing" constant="7" id="5bp-bm-9vv"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="SZJ-aY-45Y" secondAttribute="bottom" id="CMF-1f-MdG"/>
|
||||
<constraint firstItem="hTh-ek-Xam" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="OjQ-mD-CWV"/>
|
||||
<constraint firstItem="SZJ-aY-45Y" firstAttribute="leading" secondItem="hTh-ek-Xam" secondAttribute="trailing" constant="10" id="UlR-NB-9So"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="hTh-ek-Xam" secondAttribute="bottom" id="bvu-Q0-QAG"/>
|
||||
<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>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<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>
|
||||
<point key="canvasLocation" x="34" y="77"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="HorizontalSettings" width="25" height="25"/>
|
||||
<image name="Refresh" width="32" height="32"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ class LabelTableViewCell: UITableViewCell {
|
|||
|
||||
weak var delegatePasswordTableView : PasswordDetailTableViewController?
|
||||
|
||||
var passwordDisplayButton: UIButton?
|
||||
var buttons: UIView?
|
||||
|
||||
var cellData: LabelTableViewCellData? {
|
||||
didSet {
|
||||
titleLabel.text = cellData?.title ?? ""
|
||||
|
|
@ -43,9 +46,11 @@ class LabelTableViewCell: UITableViewCell {
|
|||
} else {
|
||||
contentLabel.text = Globals.passwordDots
|
||||
}
|
||||
contentLabel.font = UIFont(name: Globals.passwordFonts, size: contentLabel.font.pointSize)
|
||||
} else {
|
||||
contentLabel.text = cellData?.content
|
||||
}
|
||||
updateButtons()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +63,13 @@ class LabelTableViewCell: UITableViewCell {
|
|||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
if buttons != nil {
|
||||
self.accessoryView = buttons
|
||||
}
|
||||
}
|
||||
|
||||
override func setSelected(_ selected: Bool, animated: Bool) {
|
||||
super.setSelected(selected, animated: animated)
|
||||
|
|
@ -99,13 +111,26 @@ class LabelTableViewCell: UITableViewCell {
|
|||
contentLabel.text = ""
|
||||
}
|
||||
isReveal = true
|
||||
passwordDisplayButton?.setImage(#imageLiteral(resourceName: "Invisible"), for: .normal)
|
||||
}
|
||||
|
||||
func concealPassword(_ sender: Any?) {
|
||||
contentLabel.text = Globals.passwordDots
|
||||
isReveal = false
|
||||
passwordDisplayButton?.setImage(#imageLiteral(resourceName: "Visible"), for: .normal)
|
||||
}
|
||||
|
||||
func reversePasswordDisplay(_ sender: Any?) {
|
||||
if isReveal {
|
||||
// conceal
|
||||
concealPassword(sender)
|
||||
} else {
|
||||
// reveal
|
||||
revealPassword(sender)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func openLink(_ sender: Any?) {
|
||||
// if isURLCell, passwordTableView should not be nil
|
||||
delegatePasswordTableView!.openLink()
|
||||
|
|
@ -115,4 +140,41 @@ class LabelTableViewCell: UITableViewCell {
|
|||
// if isHOTPCell, passwordTableView should not be nil
|
||||
delegatePasswordTableView!.getNextHOTP()
|
||||
}
|
||||
|
||||
func updateButtons() {
|
||||
passwordDisplayButton = nil
|
||||
buttons = nil
|
||||
if isPasswordCell {
|
||||
// password button
|
||||
passwordDisplayButton = UIButton(type: .system)
|
||||
passwordDisplayButton!.frame = CGRect(x: 0, y: 0, width: Globals.tableCellButtonSize, height: Globals.tableCellButtonSize)
|
||||
passwordDisplayButton!.setImage(#imageLiteral(resourceName: "Visible"), for: .normal)
|
||||
passwordDisplayButton!.imageView?.contentMode = .scaleAspectFit
|
||||
passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControlEvents.touchUpInside)
|
||||
buttons = passwordDisplayButton
|
||||
} else if isHOTPCell {
|
||||
let spacing = CGFloat(10.0)
|
||||
|
||||
// hotp button
|
||||
let nextButton = UIButton(type: .system)
|
||||
nextButton.frame = CGRect(x: 0, y: 0,
|
||||
width: Globals.tableCellButtonSize, height: Globals.tableCellButtonSize)
|
||||
nextButton.setImage(#imageLiteral(resourceName: "Refresh"), for: .normal)
|
||||
nextButton.imageView?.contentMode = .scaleAspectFit
|
||||
nextButton.addTarget(self, action: #selector(getNextHOTP), for: UIControlEvents.touchUpInside)
|
||||
|
||||
// password button
|
||||
passwordDisplayButton = UIButton(type: .system)
|
||||
passwordDisplayButton!.frame = CGRect(x: Globals.tableCellButtonSize + spacing, y: 0,
|
||||
width: Globals.tableCellButtonSize, height: Globals.tableCellButtonSize)
|
||||
passwordDisplayButton!.setImage(#imageLiteral(resourceName: "Visible"), for: .normal)
|
||||
passwordDisplayButton!.imageView?.contentMode = .scaleAspectFit
|
||||
passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControlEvents.touchUpInside)
|
||||
|
||||
buttons = UIView()
|
||||
buttons!.frame = CGRect(x: 0, y: 0, width: Globals.tableCellButtonSize * 2 + spacing, height: Globals.tableCellButtonSize)
|
||||
buttons!.addSubview(nextButton)
|
||||
buttons!.addSubview(passwordDisplayButton!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="320" height="74"/>
|
||||
<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="73.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="73"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<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="highlightedColor"/>
|
||||
</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"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="38" id="8Tz-Qo-Mkg"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue