Add show/hide button to password on add accounts and credentials update. Issue #1066
This commit is contained in:
parent
411ed18551
commit
b52c67595f
|
@ -184,6 +184,9 @@
|
|||
51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */; };
|
||||
51D6A5BC23199C85001C27D8 /* MasterTimelineDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6A5BB23199C85001C27D8 /* MasterTimelineDataSource.swift */; };
|
||||
51D87EE12311D34700E63F03 /* ActivityType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D87EE02311D34700E63F03 /* ActivityType.swift */; };
|
||||
51E149B3234D82E40004F7A5 /* PasswordField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E149B2234D82E40004F7A5 /* PasswordField.swift */; };
|
||||
51E149C0234D839E0004F7A5 /* ShowHidePasswordView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51E149BF234D839E0004F7A5 /* ShowHidePasswordView.xib */; };
|
||||
51E149C2234D852F0004F7A5 /* ShowHidePasswordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E149C1234D852F0004F7A5 /* ShowHidePasswordView.swift */; };
|
||||
51E3EB33229AB02C00645299 /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E3EB32229AB02C00645299 /* ErrorHandler.swift */; };
|
||||
51E3EB3D229AB08300645299 /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E3EB3C229AB08300645299 /* ErrorHandler.swift */; };
|
||||
51E595A5228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E595A4228CC36500FCC42B /* ArticleStatusSyncTimer.swift */; };
|
||||
|
@ -802,6 +805,9 @@
|
|||
51CC9B3D231720B2000E842F /* MasterFeedDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedDataSource.swift; sourceTree = "<group>"; };
|
||||
51D6A5BB23199C85001C27D8 /* MasterTimelineDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineDataSource.swift; sourceTree = "<group>"; };
|
||||
51D87EE02311D34700E63F03 /* ActivityType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityType.swift; sourceTree = "<group>"; };
|
||||
51E149B2234D82E40004F7A5 /* PasswordField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordField.swift; sourceTree = "<group>"; };
|
||||
51E149BF234D839E0004F7A5 /* ShowHidePasswordView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShowHidePasswordView.xib; sourceTree = "<group>"; };
|
||||
51E149C1234D852F0004F7A5 /* ShowHidePasswordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowHidePasswordView.swift; sourceTree = "<group>"; };
|
||||
51E3EB32229AB02C00645299 /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = "<group>"; };
|
||||
51E3EB3C229AB08300645299 /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = "<group>"; };
|
||||
51E595A4228CC36500FCC42B /* ArticleStatusSyncTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleStatusSyncTimer.swift; sourceTree = "<group>"; };
|
||||
|
@ -1244,6 +1250,9 @@
|
|||
DF999FF622B5AEFA0064B687 /* SafariView.swift */,
|
||||
51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */,
|
||||
51322854232EED360033D4ED /* VibrantSelectAction.swift */,
|
||||
51E149B2234D82E40004F7A5 /* PasswordField.swift */,
|
||||
51E149C1234D852F0004F7A5 /* ShowHidePasswordView.swift */,
|
||||
51E149BF234D839E0004F7A5 /* ShowHidePasswordView.xib */,
|
||||
);
|
||||
path = "SwiftUI Extensions";
|
||||
sourceTree = "<group>";
|
||||
|
@ -2481,6 +2490,7 @@
|
|||
51F85BED227251DF00C787DC /* Acknowledgments.rtf in Resources */,
|
||||
511D43D1231FA62800FB1562 /* SidebarKeyboardShortcuts.plist in Resources */,
|
||||
51C452AB22650DC600C03939 /* template.html in Resources */,
|
||||
51E149C0234D839E0004F7A5 /* ShowHidePasswordView.xib in Resources */,
|
||||
51F85BF12272524100C787DC /* Credits.rtf in Resources */,
|
||||
84A3EE61223B667F00557320 /* DefaultFeeds.opml in Resources */,
|
||||
511D43CF231FA62200FB1562 /* DetailKeyboardShortcuts.plist in Resources */,
|
||||
|
@ -2709,6 +2719,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
840D617F2029031C009BC708 /* AppDelegate.swift in Sources */,
|
||||
51E149B3234D82E40004F7A5 /* PasswordField.swift in Sources */,
|
||||
512E08E72268801200BDCFDD /* FeedTreeControllerDelegate.swift in Sources */,
|
||||
51C452A422650A2D00C03939 /* ArticleUtilities.swift in Sources */,
|
||||
51EF0F79227716380050506E /* ColorHash.swift in Sources */,
|
||||
|
@ -2777,6 +2788,7 @@
|
|||
51C4529A22650A0400C03939 /* ArticleStyle.swift in Sources */,
|
||||
51C4527F2265092C00C03939 /* ArticleViewController.swift in Sources */,
|
||||
51C4526A226508F600C03939 /* MasterFeedTableViewCellLayout.swift in Sources */,
|
||||
51E149C2234D852F0004F7A5 /* ShowHidePasswordView.swift in Sources */,
|
||||
51C452AE2265104D00C03939 /* TimelineStringFormatter.swift in Sources */,
|
||||
512E08E62268800D00BDCFDD /* FolderTreeControllerDelegate.swift in Sources */,
|
||||
51C4529922650A0000C03939 /* ArticleStylesManager.swift in Sources */,
|
||||
|
|
|
@ -31,7 +31,7 @@ struct SettingsFeedbinAccountView : View {
|
|||
TextField("Email", text: $viewModel.email)
|
||||
.keyboardType(.emailAddress)
|
||||
.textContentType(.emailAddress)
|
||||
SecureField("Password", text: $viewModel.password)
|
||||
PasswordField(password: $viewModel.password)
|
||||
}
|
||||
Section(footer:
|
||||
HStack {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// PasswordField.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 10/8/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PasswordField: UIViewRepresentable {
|
||||
|
||||
let password: Binding<String>
|
||||
|
||||
func makeUIView(context: Context) -> ShowHidePasswordView {
|
||||
let showHideView = Bundle.main.loadNibNamed("ShowHidePasswordView", owner: Self.self, options: nil)?[0] as! ShowHidePasswordView
|
||||
showHideView.passwordTextField.bindingString = password
|
||||
return showHideView
|
||||
}
|
||||
|
||||
func updateUIView(_ showHideView: ShowHidePasswordView, context: Context) {
|
||||
showHideView.passwordTextField.bindingString = password
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// ShowHidePasswordView.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 10/8/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class ShowHidePasswordView: UIView {
|
||||
|
||||
@IBOutlet weak var passwordTextField: BindingTextField!
|
||||
@IBOutlet weak var showHideButton: UIButton!
|
||||
|
||||
@IBAction func toggleShowHideButton(_ sender: Any) {
|
||||
if passwordTextField.isSecureTextEntry {
|
||||
passwordTextField.isSecureTextEntry = false
|
||||
showHideButton.setTitle(NSLocalizedString("Hide", comment: "Hide"), for: .normal)
|
||||
} else {
|
||||
passwordTextField.isSecureTextEntry = true
|
||||
showHideButton.setTitle(NSLocalizedString("Show", comment: "Show"), for: .normal)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class BindingTextField: UITextField, UITextFieldDelegate {
|
||||
|
||||
var bindingString: Binding<String>? = nil
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
delegate = self
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
delegate = self
|
||||
}
|
||||
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
if let currentValue = textField.text as NSString? {
|
||||
let proposedValue = currentValue.replacingCharacters(in: range, with: string)
|
||||
bindingString?.wrappedValue = proposedValue
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15508"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.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"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="ShowHidePasswordView" customModule="NetNewsWire" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="284" height="54"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TT2-5T-DdA">
|
||||
<rect key="frame" x="246" y="12" width="38" height="30"/>
|
||||
<state key="normal" title="Show"/>
|
||||
<connections>
|
||||
<action selector="toggleShowHideButton:" destination="iN0-l3-epB" eventType="touchUpInside" id="DTB-2f-JoB"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Password" textAlignment="natural" adjustsFontForContentSizeCategory="YES" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Iwe-LN-7ZI" customClass="BindingTextField" customModule="NetNewsWire" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="16.5" width="238" height="21"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstItem="TT2-5T-DdA" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="Buq-YS-fG8"/>
|
||||
<constraint firstItem="TT2-5T-DdA" firstAttribute="leading" secondItem="Iwe-LN-7ZI" secondAttribute="trailing" constant="8" symbolic="YES" id="FIM-1x-LoT"/>
|
||||
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="TT2-5T-DdA" secondAttribute="trailing" id="b4w-k0-zUR"/>
|
||||
<constraint firstItem="Iwe-LN-7ZI" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="eGg-IF-dp6"/>
|
||||
<constraint firstItem="Iwe-LN-7ZI" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="mUI-zV-GHb"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
|
||||
<connections>
|
||||
<outlet property="passwordTextField" destination="Iwe-LN-7ZI" id="Tvk-Q4-kHr"/>
|
||||
<outlet property="showHideButton" destination="TT2-5T-DdA" id="1GH-1O-ma0"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="43.478260869565219" y="-127.23214285714285"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
Loading…
Reference in New Issue