Skip to content

Commit

Permalink
Merge pull request #19 from vergecurrency/add-disconnect-view
Browse files Browse the repository at this point in the history
Add disconnect wallet view and refactor pin unlock view closing 😇
  • Loading branch information
SwenVanZanten authored Aug 23, 2018
2 parents 7c35799 + af4693d commit c68ab16
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 14 deletions.
4 changes: 4 additions & 0 deletions VergeiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
A398B20D212B0F47004ACB73 /* LocalAuthKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = A398B20C212B0F47004ACB73 /* LocalAuthKey.swift */; };
A398B20F212B2886004ACB73 /* UIWindow+VisibleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A398B20E212B2886004ACB73 /* UIWindow+VisibleViewController.swift */; };
A398B213212EBDD7004ACB73 /* CreditsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A398B212212EBDD7004ACB73 /* CreditsTableViewController.swift */; };
A398B215212F0949004ACB73 /* DisconnectWalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A398B214212F0949004ACB73 /* DisconnectWalletViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -268,6 +269,7 @@
A398B20C212B0F47004ACB73 /* LocalAuthKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAuthKey.swift; sourceTree = "<group>"; };
A398B20E212B2886004ACB73 /* UIWindow+VisibleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIWindow+VisibleViewController.swift"; sourceTree = "<group>"; };
A398B212212EBDD7004ACB73 /* CreditsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditsTableViewController.swift; sourceTree = "<group>"; };
A398B214212F0949004ACB73 /* DisconnectWalletViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisconnectWalletViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -604,6 +606,7 @@
A302D34E212754BE00EA8091 /* DevelopmentTableViewController.swift */,
A398B203212AFAD6004ACB73 /* LocalAuthTableViewController.swift */,
A398B212212EBDD7004ACB73 /* CreditsTableViewController.swift */,
A398B214212F0949004ACB73 /* DisconnectWalletViewController.swift */,
);
path = Settings;
sourceTree = "<group>";
Expand Down Expand Up @@ -954,6 +957,7 @@
A376412C210A500E00E04521 /* PaperKeyDescriptionViewController.swift in Sources */,
A305DDB02107889200911B64 /* UIColor+Default.swift in Sources */,
A338E6AC210FD53E000D44EE /* WalletViewController.swift in Sources */,
A398B215212F0949004ACB73 /* DisconnectWalletViewController.swift in Sources */,
A338E6C32110F9CB000D44EE /* StringKey.swift in Sources */,
A338E69A210D1FC4000D44EE /* PaperKeyWordsViewController.swift in Sources */,
A305DDC32107C83200911B64 /* NumberKey.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
"template-rendering-intent" : "template",
"preserves-vector-representation" : true
}
}
3 changes: 2 additions & 1 deletion VergeiOS/Assets.xcassets/Icons/Pin.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
"template-rendering-intent" : "template",
"preserves-vector-representation" : true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "disconnet-wallet.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion VergeiOS/Components/UI/Buttons/SelectorButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
var placeholderLabel: UILabel?
var valueLabel: UILabel?

@IBInspectable var borderWidth: Int = 2
@IBInspectable var borderWidth: Double = 0.5
@IBInspectable var borderColor: UIColor = UIColor(red: 0.85, green: 0.85, blue: 0.9, alpha: 1)

@IBInspectable private var label: String = ""
Expand Down
6 changes: 6 additions & 0 deletions VergeiOS/Kernel/WalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ class WalletManager {
UserDefaults.standard.set(newValue, forKey: "wallet.localAuth.sendingXvg")
}
}

func reset() {
let domain = Bundle.main.bundleIdentifier!
UserDefaults.standard.removePersistentDomain(forName: domain)
UserDefaults.standard.synchronize()
}
}
90 changes: 88 additions & 2 deletions VergeiOS/Storyboards/Settings.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -43,6 +44,9 @@
</subviews>
</tableViewCellContentView>
<color key="tintColor" name="PrimaryLight"/>
<connections>
<segue destination="aSs-cW-UuY" kind="show" id="7q3-ur-lYW"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="OKG-Zv-0ED" imageView="18U-dF-nJM" style="IBUITableViewCellStyleDefault" id="DQR-O5-IZC">
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
Expand Down Expand Up @@ -418,6 +422,84 @@
</objects>
<point key="canvasLocation" x="3225" y="1692"/>
</scene>
<!--Disconnect Wallet View Controller-->
<scene sceneID="cl0-4N-jbc">
<objects>
<viewController hidesBottomBarWhenPushed="YES" id="aSs-cW-UuY" customClass="DisconnectWalletViewController" customModule="VergeiOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="yWC-6F-4Ky">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Disconnect this device from your current wallet" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L9g-jN-Hhp">
<rect key="frame" x="40" y="72" width="295" height="60.5"/>
<fontDescription key="fontDescription" name="AvenirNext-DemiBold" family="Avenir Next" pointSize="22"/>
<color key="textColor" name="SecondaryDark"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="DisconnectWalletPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="rrC-hP-YHx">
<rect key="frame" x="40" y="140" width="295" height="125"/>
<color key="tintColor" name="PrimaryLight"/>
<constraints>
<constraint firstAttribute="height" constant="125" id="de1-Fz-JCZ"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JEF-8K-bNN">
<rect key="frame" x="40" y="273" width="295" height="139.5"/>
<string key="text">Your about to disconnect this device from your current wallet. Please make absolutely sure you have written down your paperkey. Remember that your paperkey is the only way to restore your current wallet.</string>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="17"/>
<color key="textColor" name="SecondaryLight"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7P9-rp-OVn" customClass="RoundedButton" customModule="VergeiOS" customModuleProvider="target">
<rect key="frame" x="40" y="597" width="295" height="50"/>
<color key="backgroundColor" name="PrimaryLight"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="Tej-8k-lb4"/>
</constraints>
<fontDescription key="fontDescription" name="AvenirNext-DemiBold" family="Avenir Next" pointSize="17"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Disconnect" image="Disconnect">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="disconnectWallet:" destination="aSs-cW-UuY" eventType="touchUpInside" id="W7K-QP-LxT"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" name="BackgroundGrey"/>
<constraints>
<constraint firstItem="JEF-8K-bNN" firstAttribute="top" secondItem="rrC-hP-YHx" secondAttribute="bottom" constant="8" id="2Ut-Ow-8Rq"/>
<constraint firstItem="rCv-fT-eLO" firstAttribute="trailing" secondItem="L9g-jN-Hhp" secondAttribute="trailing" constant="40" id="71O-pe-f8s"/>
<constraint firstItem="7P9-rp-OVn" firstAttribute="leading" secondItem="rCv-fT-eLO" secondAttribute="leading" constant="40" id="8HS-qu-VLL"/>
<constraint firstItem="rCv-fT-eLO" firstAttribute="trailing" secondItem="rrC-hP-YHx" secondAttribute="trailing" constant="40" id="AzC-gh-uAo"/>
<constraint firstItem="JEF-8K-bNN" firstAttribute="leading" secondItem="rCv-fT-eLO" secondAttribute="leading" constant="40" id="By9-tn-Xyk"/>
<constraint firstItem="rrC-hP-YHx" firstAttribute="top" secondItem="L9g-jN-Hhp" secondAttribute="bottom" constant="8" id="DE4-72-9aK"/>
<constraint firstItem="rCv-fT-eLO" firstAttribute="trailing" secondItem="JEF-8K-bNN" secondAttribute="trailing" constant="40" id="QlF-OZ-fgx"/>
<constraint firstItem="L9g-jN-Hhp" firstAttribute="leading" secondItem="rCv-fT-eLO" secondAttribute="leading" constant="40" id="VfI-bZ-mng"/>
<constraint firstItem="rrC-hP-YHx" firstAttribute="leading" secondItem="rCv-fT-eLO" secondAttribute="leading" constant="40" id="Yoa-UZ-fuw"/>
<constraint firstItem="rCv-fT-eLO" firstAttribute="bottom" secondItem="7P9-rp-OVn" secondAttribute="bottom" constant="20" id="ZOI-S4-ShT"/>
<constraint firstItem="L9g-jN-Hhp" firstAttribute="top" secondItem="rCv-fT-eLO" secondAttribute="top" constant="8" id="Zbz-rw-aLV"/>
<constraint firstItem="7P9-rp-OVn" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="JEF-8K-bNN" secondAttribute="leading" constant="8" id="dpe-lj-gBW"/>
<constraint firstItem="rCv-fT-eLO" firstAttribute="trailing" secondItem="7P9-rp-OVn" secondAttribute="trailing" constant="40" id="rxE-OH-XTr"/>
</constraints>
<viewLayoutGuide key="safeArea" id="rCv-fT-eLO"/>
</view>
<connections>
<segue destination="ihU-0k-uOE" kind="showDetail" identifier="disconnectWallet" id="6td-2K-4h3"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="qVM-tY-sgf" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2589.5999999999999" y="1026.8365817091455"/>
</scene>
<!--WelcomeViewController-->
<scene sceneID="pNK-1S-NFM">
<objects>
<viewControllerPlaceholder storyboardName="Setup" referencedIdentifier="WelcomeViewController" id="ihU-0k-uOE" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="0iu-Wz-3Ex" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3318" y="1026"/>
</scene>
<!--Fiat currency-->
<scene sceneID="cTm-Aa-2iM">
<objects>
Expand Down Expand Up @@ -556,7 +638,7 @@
</constraints>
</view>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="creditTableViewCell" textLabel="AQc-ez-wJC" detailTextLabel="uL8-fU-VOg" rowHeight="44" style="IBUITableViewCellStyleSubtitle" id="3cY-da-3ab">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="creditTableViewCell" textLabel="AQc-ez-wJC" detailTextLabel="uL8-fU-VOg" style="IBUITableViewCellStyleSubtitle" id="3cY-da-3ab">
<rect key="frame" x="0.0" y="155.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="3cY-da-3ab" id="P2k-jg-dls">
Expand Down Expand Up @@ -598,6 +680,7 @@
<image name="Currency" width="30" height="30"/>
<image name="Development" width="30" height="30"/>
<image name="Disconnect" width="30" height="30"/>
<image name="DisconnectWalletPlaceholder" width="842" height="596"/>
<image name="Donate" width="30" height="30"/>
<image name="FaceID" width="30" height="30"/>
<image name="GitHub" width="30" height="30"/>
Expand Down Expand Up @@ -626,7 +709,10 @@
<color red="0.097999997437000275" green="0.23899999260902405" blue="0.33300000429153442" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="SecondaryDark">
<color red="0.09799999744" green="0.23899999259999999" blue="0.33300000429999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.097999997437000275" green="0.23899999260902405" blue="0.33300000429153442" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="SecondaryLight">
<color red="0.3919999897480011" green="0.47099998593330383" blue="0.52499997615814209" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="VergeGreen">
<color red="0.0" green="0.52156862745098043" blue="0.4392156862745098" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
2 changes: 1 addition & 1 deletion VergeiOS/Storyboards/Setup.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<!--Welcome View Controller-->
<scene sceneID="R7k-gx-MlN">
<objects>
<viewController id="2yg-Fp-n2B" customClass="WelcomeViewController" customModule="VergeiOS" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="WelcomeViewController" id="2yg-Fp-n2B" customClass="WelcomeViewController" customModule="VergeiOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="mgp-vw-fRC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
50 changes: 50 additions & 0 deletions VergeiOS/Views/Settings/DisconnectWalletViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// DisconnectWalletViewController.swift
// VergeiOS
//
// Created by Swen van Zanten on 23-08-18.
// Copyright © 2018 Verge Currency. All rights reserved.
//

import UIKit

class DisconnectWalletViewController: UIViewController {

@IBAction func disconnectWallet(_ sender: Any) {
let alert = UIAlertController(
title: "Disconnect Wallet",
message: "Your about to disconnect this device from your current wallet. " +
"Please make absolutely sure you have written down your paperkey. " +
"Remember that your paperkey is the only way to restore your current wallet.",
preferredStyle: .alert
)

let cancel = UIAlertAction(title: "Cancel", style: .cancel)
let confirm = UIAlertAction(title: "Disconnect", style: .destructive) { action in
// Show unlock view.
let pinUnlockView = PinUnlockViewController.createFromStoryBoard()
pinUnlockView.cancelable = true
pinUnlockView.completion = { authenticated in
if authenticated {
pinUnlockView.dismiss(animated: true) {
self.performSegue(withIdentifier: "disconnectWallet", sender: self)
}

// Reset wallet manager.
WalletManager.default.reset()
PriceTicker.shared.stop()
} else {
pinUnlockView.dismiss(animated: true)
}
}

self.present(pinUnlockView, animated: true)
}

alert.addAction(cancel)
alert.addAction(confirm)

present(alert, animated: true)
}

}
16 changes: 16 additions & 0 deletions VergeiOS/Views/Settings/SettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,28 @@ class SettingsTableViewController: UITableViewController {
if segue.identifier == "LocalAuthTableViewController" {
let pinUnlockView = PinUnlockViewController.createFromStoryBoard()
pinUnlockView.cancelable = true
pinUnlockView.completion = { authenticated in
if !authenticated {
self.navigationController?.popViewController(animated: false)
}

pinUnlockView.dismiss(animated: true)
}

present(pinUnlockView, animated: true)
}

if segue.identifier == "SelectPinViewController" {
let pinUnlockView = PinUnlockViewController.createFromStoryBoard()
pinUnlockView.cancelable = true
pinUnlockView.completion = { authenticated in
if !authenticated {
self.navigationController?.popViewController(animated: false)
}

pinUnlockView.dismiss(animated: true)
}

present(pinUnlockView, animated: true)

if let vc = segue.destination as? SelectPinViewController {
Expand Down
Loading

0 comments on commit c68ab16

Please sign in to comment.