From 3b2e0c8fe8ef548464db316c13e9822a5bceb610 Mon Sep 17 00:00:00 2001 From: Abubakar Suleiman Date: Tue, 2 Jun 2020 08:47:15 +0100 Subject: [PATCH] Rename default account and other UI fixes (#694) * Rename default account to language translation and fix UI on wallet migration,delete watch only message and smaller screens * Fix overlapping UI on sync details screen * Refactor create/restore wallet function * remove commented code --- Decred Wallet.xcodeproj/project.pbxproj | 2 +- Decred Wallet/Constants/Constants.swift | 2 + .../StartScreenViewController.swift | 30 ++++++++++----- .../Custom Dialogs/CustomDialogs.storyboard | 4 +- .../More/More Features/About/About.storyboard | 10 ++--- .../Features/Overview/Overview.storyboard | 38 +++++++++++-------- .../Features/Security/Security.storyboard | 34 ++++++++--------- .../RestoreExistingWalletViewController.swift | 37 ++++++++++-------- .../Wallets/WalletInfoTableViewCell.xib | 2 +- .../WalletSettingsViewController.swift | 3 +- .../Wallets/WalletsViewController.swift | 20 +++++----- Decred Wallet/Utils/LocalizedStrings.swift | 3 ++ Decred Wallet/Utils/Utils.swift | 10 +++++ Decred Wallet/Wallet Utils/WalletLoader.swift | 32 ---------------- Decred Wallet/en.lproj/Localizable.strings | 3 ++ Decred Wallet/es.lproj/Localizable.strings | 3 ++ Decred Wallet/pl.lproj/Localizable.strings | 3 ++ Decred Wallet/pt-BR.lproj/Localizable.strings | 3 ++ Decred Wallet/ru-RU.lproj/Localizable.strings | 3 ++ Decred Wallet/vi.lproj/Localizable.strings | 3 ++ .../zh-Hans.lproj/Localizable.strings | 3 ++ 21 files changed, 138 insertions(+), 110 deletions(-) diff --git a/Decred Wallet.xcodeproj/project.pbxproj b/Decred Wallet.xcodeproj/project.pbxproj index c1cb85ab8..e322060d2 100644 --- a/Decred Wallet.xcodeproj/project.pbxproj +++ b/Decred Wallet.xcodeproj/project.pbxproj @@ -834,8 +834,8 @@ DD493C01247654BC00C0D772 /* WatchOnlyWalletInfoTableViewCell.swift */, DD493C05247654BC00C0D772 /* WatchOnlyWalletTableViewCell.xib */, DD493BFF247654BC00C0D772 /* WatchOnlyWalletInfoTableViewCell.xib */, - B3E727C523DD4ABF003B06B4 /* WalletAccountTableViewCell.xib */, DD493C03247654BC00C0D772 /* WatchOnlyWalletTableViewCell.swift */, + B3E727C523DD4ABF003B06B4 /* WalletAccountTableViewCell.xib */, B3E727C923DD4AE7003B06B4 /* WalletAccountTableViewCell.swift */, B3B9432823E4D0B30088EC3E /* WalletSettingsViewController.swift */, B3D474DE23E55B5D00B6E305 /* WalletSettings.swift */, diff --git a/Decred Wallet/Constants/Constants.swift b/Decred Wallet/Constants/Constants.swift index c70ad0881..c16bdcec7 100644 --- a/Decred Wallet/Constants/Constants.swift +++ b/Decred Wallet/Constants/Constants.swift @@ -20,9 +20,11 @@ struct GlobalConstants { static let LEGACY_TESTNET_HD_PATH = "m / 44' / 11' /" static let MAINNET_HD_PATH = "m / 44' / 42' /" static let LEGACY_MAINNET_HD_PATH = "m / 44' / 20' /" + static let DEFAULT = "default" } struct Wallet { static let defaultRequiredConfirmations: Int32 = 2 + static let DEFAULT_ACCOUNT_NUMBER = 0 } } diff --git a/Decred Wallet/Features/App Launch/StartScreenViewController.swift b/Decred Wallet/Features/App Launch/StartScreenViewController.swift index 614158c99..2edfb4ebc 100644 --- a/Decred Wallet/Features/App Launch/StartScreenViewController.swift +++ b/Decred Wallet/Features/App Launch/StartScreenViewController.swift @@ -43,7 +43,11 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { print("init multiwallet error: \(initError!.localizedDescription)") } - if WalletLoader.shared.oneOrMoreWalletsExist { + if SingleToMultiWalletMigration.migrationNeeded { + self.loadingLabel.text = LocalizedStrings.migratingWallet + self.animationDurationSeconds = 5 + + } else if WalletLoader.shared.oneOrMoreWalletsExist { self.loadingLabel.text = LocalizedStrings.openingWallet self.animationDurationSeconds = 5 } @@ -136,15 +140,21 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { @IBAction func createNewwallet(_ sender: Any) { Security.spending(initialSecurityType: .password) .requestNewCode(sender: self, isChangeAttempt: false) { pinOrPassword, type, completion in - - WalletLoader.shared.createWallet(spendingPinOrPassword: pinOrPassword, securityType: type, walletName: LocalizedStrings.myWallet) { - createWalletError in - - if createWalletError != nil { - completion?.displayError(errorMessage: createWalletError!.localizedDescription) - } else { - completion?.dismissDialog() - NavigationMenuTabBarController.setupMenuAndLaunchApp(isNewWallet: true) + + DispatchQueue.global(qos: .userInitiated).async { + do { + let wallet = try WalletLoader.shared.multiWallet.createNewWallet(LocalizedStrings.myWallet, privatePassphrase: pinOrPassword, privatePassphraseType: type.type) + + Utils.renameDefaultAccountToLocalLanguage(wallet: wallet) + + DispatchQueue.main.async { + completion?.dismissDialog() + NavigationMenuTabBarController.setupMenuAndLaunchApp(isNewWallet: true) + } + } catch let error { + DispatchQueue.main.async { + completion?.displayError(errorMessage: error.localizedDescription) + } } } } diff --git a/Decred Wallet/Features/Custom Dialogs/CustomDialogs.storyboard b/Decred Wallet/Features/Custom Dialogs/CustomDialogs.storyboard index dc3c76f59..f4172e5f0 100644 --- a/Decred Wallet/Features/Custom Dialogs/CustomDialogs.storyboard +++ b/Decred Wallet/Features/Custom Dialogs/CustomDialogs.storyboard @@ -164,7 +164,7 @@ -