Skip to content

Commit

Permalink
Merge pull request #625 from tari-project/kutsal-ridcully-compat-update
Browse files Browse the repository at this point in the history
Ridcully update & delete wallet option.
  • Loading branch information
kukabi authored Nov 4, 2020
2 parents 9324429 + 1ee3fca commit 8919ab0
Show file tree
Hide file tree
Showing 25 changed files with 545 additions and 164 deletions.
24 changes: 20 additions & 4 deletions MobileWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@
619197D2BB78CBBC06B0F87E /* UTXO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 619190C6EBD050DC647D1D7B /* UTXO.swift */; };
619198F3E20DFABEB23F63FE /* UTXO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 619190C6EBD050DC647D1D7B /* UTXO.swift */; };
83EF1C05BE3D003F97626E60 /* Pods_MobileWalletTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9926F406D47AD1335698D7E1 /* Pods_MobileWalletTests.framework */; };
A0779C612552C1AF00614EF3 /* DeleteWalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0779C602552C1AF00614EF3 /* DeleteWalletViewController.swift */; };
A0779C672552C1BB00614EF3 /* DeleteWalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0779C602552C1AF00614EF3 /* DeleteWalletViewController.swift */; };
A0779C6D2552C1BC00614EF3 /* DeleteWalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0779C602552C1AF00614EF3 /* DeleteWalletViewController.swift */; };
BF0A7766241EEA0A00861A3E /* FaceID.json in Resources */ = {isa = PBXBuildFile; fileRef = BF0A7765241EEA0A00861A3E /* FaceID.json */; };
BF0A7767241EEA0A00861A3E /* FaceID.json in Resources */ = {isa = PBXBuildFile; fileRef = BF0A7765241EEA0A00861A3E /* FaceID.json */; };
BF0A7768241EEA0A00861A3E /* FaceID.json in Resources */ = {isa = PBXBuildFile; fileRef = BF0A7765241EEA0A00861A3E /* FaceID.json */; };
Expand Down Expand Up @@ -826,6 +829,7 @@
619190C6EBD050DC647D1D7B /* UTXO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UTXO.swift; sourceTree = "<group>"; };
867662CACBB1C47B665EBA55 /* Pods-MobileWalletTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileWalletTests.release.xcconfig"; path = "Target Support Files/Pods-MobileWalletTests/Pods-MobileWalletTests.release.xcconfig"; sourceTree = "<group>"; };
9926F406D47AD1335698D7E1 /* Pods_MobileWalletTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MobileWalletTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A0779C602552C1AF00614EF3 /* DeleteWalletViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteWalletViewController.swift; sourceTree = "<group>"; };
BF0A7765241EEA0A00861A3E /* FaceID.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = FaceID.json; sourceTree = "<group>"; };
BF0A7799241F904D00861A3E /* faceId@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "faceId@3x.png"; sourceTree = "<group>"; };
BF0A779A241F904D00861A3E /* faceId.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = faceId.png; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1360,6 +1364,7 @@
3708D748247FCF0700807D72 /* Settings */ = {
isa = PBXGroup;
children = (
A0779C5F2552C19500614EF3 /* AdvancedSettings */,
3708D755247FF81900807D72 /* SettingsParentViewController.swift */,
37C8BA4E24813F98005BBC05 /* SettingsParentTableViewController.swift */,
3708D749247FCF2300807D72 /* SettingsViewController.swift */,
Expand Down Expand Up @@ -1555,6 +1560,14 @@
path = Pods;
sourceTree = "<group>";
};
A0779C5F2552C19500614EF3 /* AdvancedSettings */ = {
isa = PBXGroup;
children = (
A0779C602552C1AF00614EF3 /* DeleteWalletViewController.swift */,
);
path = AdvancedSettings;
sourceTree = "<group>";
};
BF0A7764241EE9E400861A3E /* FaceIdAnimation */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2271,6 +2284,7 @@
37049270247EA0770034EE5D /* RestoreWalletViewController.swift in Sources */,
00947CC723D1A35200526DD5 /* TxsProtocol.swift in Sources */,
004277EF23E03E1600AE7BD9 /* TxViewControllerExtension.swift in Sources */,
A0779C612552C1AF00614EF3 /* DeleteWalletViewController.swift in Sources */,
37EE285A2485649800335EDC /* WordsFlexView.swift in Sources */,
004277F323E0407900AE7BD9 /* TextButton.swift in Sources */,
372AECAB24B4A293005CBA0F /* UserDefaultsWrapper.swift in Sources */,
Expand Down Expand Up @@ -2443,6 +2457,7 @@
BFAB5D1223FDEA6A009E8563 /* EmojiIdView.swift in Sources */,
00BCE480240D5A9700B181F3 /* OnionManager.swift in Sources */,
00E2BCAA236AB28200C2A105 /* TxTableViewCell.swift in Sources */,
A0779C672552C1BB00614EF3 /* DeleteWalletViewController.swift in Sources */,
0087A1AA23F4235400B89EE7 /* ScanViewController.swift in Sources */,
005387252405136700901A68 /* AddNoteViewController.swift in Sources */,
009BF8AD237ABB4700C02E44 /* TariLib.swift in Sources */,
Expand Down Expand Up @@ -2565,6 +2580,7 @@
370E887A24FEA54100576F61 /* NetworkTools.m in Sources */,
37CB9F8C2451A2AD00C495F2 /* String+Emoji.swift in Sources */,
3723A7AD24ACD03E003382EB /* PasswordField.swift in Sources */,
A0779C6D2552C1BC00614EF3 /* DeleteWalletViewController.swift in Sources */,
37ABB69624781F8600F08163 /* UILabelWithPadding.swift in Sources */,
375DB1E2246E90D100B2BEF4 /* NavigationBar.swift in Sources */,
376C62B0247574850091BB28 /* Animation+EnumInit.swift in Sources */,
Expand Down Expand Up @@ -2727,7 +2743,7 @@
CODE_SIGN_ENTITLEMENTS = MobileWalletNotificationService/MobileWalletNotificationService.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 8XGMD9X2H2;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2765,7 +2781,7 @@
CODE_SIGN_ENTITLEMENTS = MobileWalletNotificationService/MobileWalletNotificationService.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 8XGMD9X2H2;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2922,7 +2938,7 @@
CODE_SIGN_ENTITLEMENTS = MobileWallet/Tari.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 8XGMD9X2H2;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2959,7 +2975,7 @@
CODE_SIGN_ENTITLEMENTS = MobileWallet/Tari.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 8XGMD9X2H2;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
6 changes: 3 additions & 3 deletions MobileWallet/Assets.xcassets/Images/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ForwardIconRed.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ForwardIconRed@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ForwardIconRed@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import UIKit

class AlwaysPoppableNavigationController: UINavigationController {

private weak var alwaysPoppableDelegate: AlwaysPoppableDelegate!
private weak var alwaysPoppableDelegate: AlwaysPoppableDelegate?

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -54,6 +54,10 @@ class AlwaysPoppableNavigationController: UINavigationController {
override var childForStatusBarStyle: UIViewController? {
return topViewController?.childForStatusBarStyle ?? topViewController
}

deinit {
alwaysPoppableDelegate = nil
}
}

private class AlwaysPoppableDelegate: NSObject, UIGestureRecognizerDelegate {
Expand Down
51 changes: 1 addition & 50 deletions MobileWallet/Common/CommandLineArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,60 +40,11 @@

import UIKit

/*
Delete all app content and settings. Used only for UITesting on a simulator.
*/
func wipeApp() {
TariLogger.warn("Wiping app")

let fileManager = FileManager.default
if let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first {
do {
let directoryContents = try fileManager.contentsOfDirectory(atPath: documentsDirectory.path)

for path in directoryContents {
let pathToDelete = documentsDirectory.appendingPathComponent(path).path
if fileManager.fileExists(atPath: pathToDelete, isDirectory: nil) {
do {
try fileManager.removeItem(at: URL(fileURLWithPath: pathToDelete))
} catch {
TariLogger.error("Failed to delete documents directory", error: error)
fatalError()
}
}
}
} catch {
TariLogger.error("Failed to read documents directory", error: error)
fatalError()
}
}

//Remove all user defaults
let domain = Bundle.main.bundleIdentifier!
UserDefaults.standard.removePersistentDomain(forName: domain)
UserDefaults.standard.synchronize()

TariLogger.warn("Wipe complete")
}

/*
Disable animations which is useful for UI tests in simulator.
*/
func disableAnimations() {
UIView.setAnimationsEnabled(false)
}

/*
Needs to be called in AppDelegate.swift with didFinishLaunchingWithOptions
*/
func handleCommandLineArgs() {
if CommandLine.arguments.contains("-wipe-app") {
#if targetEnvironment(simulator)
wipeApp()
#endif
}

if CommandLine.arguments.contains("-disable-animations") {
disableAnimations()
UIView.setAnimationsEnabled(false)
}
}
5 changes: 5 additions & 0 deletions MobileWallet/Common/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ struct Theme {
}

struct Colors: Loopable {
// common
let warning = UIColor(named: "Warning")

let gradientStartColor = UIColor(named: "GradientStartColor")
let gradientEndColor = UIColor(named: "GradientEndColor")

Expand Down Expand Up @@ -272,6 +275,7 @@ struct Images: Loopable {
let qrButton = UIImage(named: "QRButton")
let backArrow = UIImage(named: "BackArrow")
let forwardArrow = UIImage(named: "ForwardArrow")
let forwardArrowRed = UIImage(named: "ForwardArrowRed")
let downArrow = UIImage(named: "DownArrow")
let close = UIImage(named: "Close")
let share = UIImage(named: "share")
Expand Down Expand Up @@ -364,6 +368,7 @@ struct Fonts: Loopable {
let feedbackPopupTitle = UIFont.Avenir.light.withSize(18.0)
let feedbackPopupHeavy = UIFont.Avenir.black.withSize(18.0)
let feedbackPopupDescription = UIFont.Avenir.medium.withSize(14.0)
let feedbackPopupDescriptionBold = UIFont.Avenir.black.withSize(14.0)

//Simple text button
let textButton = UIFont.Avenir.medium.withSize(14.0)
Expand Down
33 changes: 25 additions & 8 deletions MobileWallet/Common/UserFeedback/FeedbackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ class FeedbackView: UIView {
closeButton.addTarget(self, action: #selector(onCloseButtonPressed), for: .touchUpInside)
}

private func setupCallToActionButton(_ action: Selector) {
private func setupCallToActionButton(isDestructive: Bool = false,
_ action: Selector) {
callToActionButton.translatesAutoresizingMaskIntoConstraints = false
if isDestructive { callToActionButton.variation = .destructive }
addSubview(callToActionButton)
callToActionButton.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
callToActionButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 160).isActive = true
Expand Down Expand Up @@ -151,7 +153,8 @@ class FeedbackView: UIView {
}
}

private func setDescription(_ description: String) {
private func setDescription(_ description: String,
boldParts: [String]? = nil) {
let attributedDescription = NSMutableAttributedString(string: description)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
Expand All @@ -160,7 +163,17 @@ class FeedbackView: UIView {
value: paragraphStyle,
range: NSRange(location: 0, length: attributedDescription.length)
)

// add bold parts if any
for boldPart in boldParts ?? [] {
if let startIndex = description.indexDistance(of: boldPart) {
let range = NSRange(location: startIndex, length: boldPart.count)
attributedDescription.addAttribute(
.font,
value: Theme.shared.fonts.feedbackPopupDescriptionBold,
range: range
)
}
}
descriptionLabel.attributedText = attributedDescription
}

Expand Down Expand Up @@ -214,14 +227,13 @@ class FeedbackView: UIView {
title: String,
boldedTitle: String? = nil,
description: String,
descriptionBoldParts: [String]? = nil,
cancelTitle: String,
actionTitle: String,
isDestructive: Bool = false,
onClose: @escaping () -> Void,
onAction: @escaping () -> Void) {
setupTitle()

titleLabel.text = title

if let boldText = boldedTitle {
if let startIndex = title.indexDistance(of: boldText) {
let attributedTitle = NSMutableAttributedString(
Expand All @@ -237,20 +249,25 @@ class FeedbackView: UIView {

titleLabel.attributedText = attributedTitle
}
} else {
titleLabel.text = title
}

titleLabel.topAnchor.constraint(equalTo: topAnchor, constant: sidePadding).isActive = true

setupDescription()
setDescription(description)
setDescription(description, boldParts: descriptionBoldParts)
descriptionLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: elementPadding).isActive = true

setupCallToActionButton(#selector(onCallToActionButtonPressed))
setupCallToActionButton(isDestructive: isDestructive, #selector(onCallToActionButtonPressed))
onCallToActionHandler = onAction
callToActionButton.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: elementPadding).isActive = true
callToActionButton.setTitle(actionTitle, for: .normal)

setupCloseButton()
if isDestructive {
closeButton.setVariation(.primary)
}
onCloseHandler = onClose
closeButton.setTitle(cancelTitle, for: .normal)
closeButton.topAnchor.constraint(equalTo: callToActionButton.bottomAnchor, constant: elementPadding).isActive = true
Expand Down
14 changes: 12 additions & 2 deletions MobileWallet/Common/UserFeedback/UserFeedback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,24 @@ class UserFeedback {
TariLogger.verbose("User success feedback: title=\(title)")
}

func callToAction(title: String, boldedTitle: String? = nil, description: String, actionTitle: String, cancelTitle: String, onAction: @escaping () -> Void, onCancel: (() -> Void)? = nil) {
func callToAction(title: String,
boldedTitle: String? = nil,
description: String,
descriptionBoldParts: [String]? = nil,
actionTitle: String,
cancelTitle: String,
isDestructive: Bool = false,
onAction: @escaping () -> Void,
onCancel: (() -> Void)? = nil) {
let ctaFeedbackView = FeedbackView()
ctaFeedbackView.setupCallToAction(
title: title,
boldedTitle: boldedTitle,
description: description,
descriptionBoldParts: descriptionBoldParts,
cancelTitle: cancelTitle,
actionTitle: actionTitle,
isDestructive: isDestructive,
onClose: {
SwiftEntryKit.dismiss()
onCancel?()
Expand All @@ -148,7 +158,7 @@ class UserFeedback {
var attributes = defaultAttributes
attributes.displayDuration = .infinity
attributes.hapticFeedbackType = .success
attributes.screenInteraction = .absorbTouches
attributes.screenInteraction = isDestructive ? .dismiss : .absorbTouches

SwiftEntryKit.display(entry: ctaFeedbackView, using: attributes)
closeKeyboard()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ class SplashViewController: UIViewController, UITextViewDelegate {
do {
try TariLib.shared.createNewWallet()

Tracker.shared.track("/onboarding/create_wallet", "Onboarding - Create Wallet")
Tracker.shared.track(
"/onboarding/create_wallet",
"Onboarding - Create Wallet"
)

if let _ = self.ticketTopLayoutConstraint {
self.topAnimationAndRemoveVideoAnimation { [weak self] () in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ extension SplashViewController {
versionLabel.textColor = Theme.shared.colors.splashVersionLabel
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,
let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
versionLabel.text = "\(TariSettings.shared.network.networkDisplayName.uppercased()) v\(version) (\(build))"
versionLabel.text = "\(TariSettings.shared.network.rawValue.uppercased()) v\(version) (b\(build))"
}

generalContainer.addSubview(versionLabel)
Expand Down
Loading

0 comments on commit 8919ab0

Please sign in to comment.