From 67d7ec8554d40ce0645e1f65c3b902705462d682 Mon Sep 17 00:00:00 2001 From: DenisDemyanko Date: Thu, 22 Oct 2020 17:49:47 +0300 Subject: [PATCH] release --- BeamWallet.xcodeproj/project.pbxproj | 16 +-- BeamWallet/AppDelegate.swift | 60 ++++-------- BeamWallet/BeamSDK/AppModel.h | 5 +- BeamWallet/BeamSDK/AppModel.mm | 51 ++++++++-- BeamWallet/BeamSDK/Objects/BMTransaction.m | 11 ++- BeamWallet/BeamSDK/WalletModel.mm | 11 ++- .../SendTransactionViewModel.swift | 35 ++++++- .../Settings/TrustedNodeViewController.swift | 97 ++++++++++++------- .../Wallet/Cells/WalletTransactionCell.swift | 7 +- .../Wallet/Cells/WalletTransactionCell.xib | 27 ++++-- .../Cells/WalletTransactionSearchCell.swift | 7 +- .../Cells/WalletTransactionSearchCell.xib | 24 +++-- .../Cells/ReceiveAddressTokensCell.swift | 18 +++- .../Cells/ReceiveAddressTokensCell.xib | 16 +-- .../Receive/ReceiveViewController.swift | 4 + .../Send/SaveContactViewController.swift | 16 ++- .../Send/SendConfirmViewController.swift | 15 ++- .../Main/Wallet/Send/SendViewController.swift | 29 ++++-- .../Transaction/TransactionShareView.xib | 5 +- .../Main/Wallet/WalletViewController.swift | 1 + 20 files changed, 310 insertions(+), 145 deletions(-) diff --git a/BeamWallet.xcodeproj/project.pbxproj b/BeamWallet.xcodeproj/project.pbxproj index b15192d7..714706ce 100644 --- a/BeamWallet.xcodeproj/project.pbxproj +++ b/BeamWallet.xcodeproj/project.pbxproj @@ -4418,7 +4418,7 @@ CLANG_WARN_ENUM_CONVERSION = NO; CODE_SIGN_ENTITLEMENTS = Resources/BeamWallet.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 5; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; @@ -4452,7 +4452,7 @@ "$(PROJECT_DIR)", "$(PROJECT_DIR)/Frameworks/boost", ); - MARKETING_VERSION = 5.0; + MARKETING_VERSION = 5.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -4493,7 +4493,7 @@ CLANG_WARN_ENUM_CONVERSION = NO; CODE_SIGN_ENTITLEMENTS = Resources/BeamWallet.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -4526,7 +4526,7 @@ "$(PROJECT_DIR)", "$(PROJECT_DIR)/Frameworks/boost", ); - MARKETING_VERSION = 5.0; + MARKETING_VERSION = 5.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -4568,7 +4568,7 @@ CODE_SIGN_ENTITLEMENTS = Resources/BeamWalletTestNet.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 10; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; @@ -4646,7 +4646,7 @@ CODE_SIGN_ENTITLEMENTS = Resources/BeamWalletTestNet.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 10; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -4731,7 +4731,7 @@ CODE_SIGN_ENTITLEMENTS = Resources/BeamWalletMasterNet.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 43; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; @@ -4808,7 +4808,7 @@ CODE_SIGN_ENTITLEMENTS = Resources/BeamWalletMasterNet.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 43; + CURRENT_PROJECT_VERSION = 55; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/BeamWallet/AppDelegate.swift b/BeamWallet/AppDelegate.swift index b3a1f7fb..56d4e459 100644 --- a/BeamWallet/AppDelegate.swift +++ b/BeamWallet/AppDelegate.swift @@ -86,27 +86,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if let crash = UserDefaults.standard.string(forKey: "crash"), let crash_name = UserDefaults.standard.string(forKey: "crash_name") { - - self.window?.rootViewController?.confirmAlert(title: Localizable.shared.strings.crash_title, message: Localizable.shared.strings.crash_message, cancelTitle: Localizable.shared.strings.crash_positive, confirmTitle: Localizable.shared.strings.crash_negative, cancelHandler: { _ in - - var name = ""; - - if Settings.sharedManager().target == Mainnet { - name = "GoogleServiceMain" - } - else if Settings.sharedManager().target == Testnet { - name = "GoogleServiceTest" - } - else if Settings.sharedManager().target == Masternet { - name = "GoogleServiceMaster" + + var name = ""; + + if Settings.sharedManager().target == Mainnet { + name = "GoogleServiceMain" + } + else if Settings.sharedManager().target == Testnet { + name = "GoogleServiceTest" + } + else if Settings.sharedManager().target == Masternet { + name = "GoogleServiceMaster" + } + + if let filePath = Bundle.main.path(forResource: name, ofType: "plist") { + if let options = FirebaseOptions(contentsOfFile: filePath) { + FirebaseApp.configure(options: options) } -// -// if let filePath = Bundle.main.path(forResource: name, ofType: "plist") { -// if let options = FirebaseOptions(contentsOfFile: filePath) { -// FirebaseApp.configure(options: options) -// } -// } - + } + + self.window?.rootViewController?.confirmAlert(title: Localizable.shared.strings.crash_title, message: Localizable.shared.strings.crash_message, cancelTitle: Localizable.shared.strings.crash_positive, confirmTitle: Localizable.shared.strings.crash_negative, cancelHandler: { _ in + let ex = ExceptionModel.init(name:crash_name, reason:crash) ex.stackTrace = [] @@ -124,25 +124,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if #available(iOS 13.0, *) { window?.overrideUserInterfaceStyle = Settings.sharedManager().isDarkMode ? .dark : .light } - - var name = ""; - - if Settings.sharedManager().target == Mainnet { - name = "GoogleServiceMain" - } - else if Settings.sharedManager().target == Testnet { - name = "GoogleServiceTest" - } - else if Settings.sharedManager().target == Masternet { - name = "GoogleServiceMaster" - } - - - if let filePath = Bundle.main.path(forResource: name, ofType: "plist") { - if let options = FirebaseOptions(contentsOfFile: filePath) { - FirebaseApp.configure(options: options) - } - } + return true } diff --git a/BeamWallet/BeamSDK/AppModel.h b/BeamWallet/BeamSDK/AppModel.h index 18d4d8d8..78bd8830 100644 --- a/BeamWallet/BeamSDK/AppModel.h +++ b/BeamWallet/BeamSDK/AppModel.h @@ -76,7 +76,7 @@ typedef int BMRestoreType; typedef void(^NewAddressGeneratedBlock)(BMAddress* _Nullable address, NSError* _Nullable error); typedef void(^ExportOwnerKey)(NSString * _Nonnull key); -typedef void(^FeecalculatedBlock)(uint64_t fee); +typedef void(^FeecalculatedBlock)(uint64_t fee, double change, uint64_t shieldedInputsFee); @interface AppModel : NSObject @@ -188,7 +188,7 @@ typedef void(^FeecalculatedBlock)(uint64_t fee); -(void)prepareDeleteAddress:(BMAddress*_Nonnull)address removeTransactions:(BOOL)removeTransactions; -(void)cancelDeleteAddress:(NSString*_Nonnull)address; -(void)deletePreparedAddresses:(NSString*_Nonnull)address; --(void)addContact:(NSString*_Nonnull)addressId name:(NSString*_Nonnull)name categories:(NSArray*_Nonnull)categories; +-(void)addContact:(NSString*_Nonnull)addressId name:(NSString*_Nonnull)name categories:(NSArray*_Nonnull)categories identidy:(NSString*_Nullable)identidy; -(BMAddress*_Nullable)findAddressByID:(NSString*_Nonnull)ID; -(BMAddress*_Nullable)findAddressByName:(NSString*_Nonnull)name; @@ -207,6 +207,7 @@ typedef void(^FeecalculatedBlock)(uint64_t fee); -(double)remaining:(double)amount fee:(double)fee; -(BMTransactionParameters*_Nonnull)getTransactionParameters:(NSString*_Nonnull)token; -(void)calculateFee:(double)amount fee:(double)fee isShielded:(BOOL) isShielded result:(FeecalculatedBlock _Nonnull )block; +-(void)calculateFee2:(double)amount fee:(double)fee isShielded:(BOOL) isShielded result:(FeecalculatedBlock _Nonnull )block; // logs -(NSString*_Nonnull)getZipLogs ; diff --git a/BeamWallet/BeamSDK/AppModel.mm b/BeamWallet/BeamSDK/AppModel.mm index 3c50e0ad..d0c43a19 100644 --- a/BeamWallet/BeamSDK/AppModel.mm +++ b/BeamWallet/BeamSDK/AppModel.mm @@ -296,10 +296,8 @@ -(void)changeNotifications { -(void)setWalletStatus:(BMWalletStatus *)walletStatus { _walletStatus = walletStatus; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:self->_walletStatus] forKey:walletStatusKey]; - [[NSUserDefaults standardUserDefaults] synchronize]; - }); + [[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:self->_walletStatus] forKey:walletStatusKey]; + [[NSUserDefaults standardUserDefaults] synchronize]; } #pragma mark - Exchange @@ -868,6 +866,12 @@ -(void)changeNodeAddress { } -(BOOL)isMyAddress:(NSString*_Nullable)address { + if ([self isToken:address]) + { + BMTransactionParameters *params = [self getTransactionParameters:address]; + address = params.address; + } + for (BMAddress *add in _walletAddresses) { if ([add.walletId isEqualToString:address]) { return YES; @@ -1127,6 +1131,10 @@ -(BOOL)isValidAddress:(NSString*_Nullable)address { return NO; } + if (address.length < 15) { + return NO; + } + return [self isAddress:address] || [self isToken:address]; } @@ -1232,7 +1240,8 @@ -(void)setContactComment:(NSString*)comment toAddress:(NSString*_Nonnull)address _address.m_category = addresses[i].m_category; _address.m_walletID = walletID; _address.m_createTime = NSDate.date.timeIntervalSince1970; - + _address.m_Identity = addresses[i].m_Identity; + try{ wallet->getAsync()->saveAddress(_address, false); } @@ -1571,11 +1580,16 @@ -(void)editCategoryAddress:(BMAddress*_Nonnull)address { WalletID walletID(Zero); if (walletID.FromHex(address.walletId.string)) { + bool isValid = false; + auto buf = from_hex(contact.address.identity.string, &isValid); + PeerID m_Identity = Blob(buf); + WalletAddress _address; _address.m_label = address.label.string; _address.m_category = [address.categories componentsJoinedByString:@","].string; _address.m_walletID = walletID; _address.m_createTime = NSDate.date.timeIntervalSince1970; + _address.m_Identity = m_Identity; walletDb->saveAddress(_address); } } @@ -1604,10 +1618,15 @@ -(void)editAddress:(BMAddress*_Nonnull)address { WalletID walletID(Zero); if (walletID.FromHex(address.walletId.string)) { + bool isValid = false; + auto buf = from_hex(contact.address.identity.string, &isValid); + PeerID m_Identity = Blob(buf); + WalletAddress _address; _address.m_label = address.label.string; _address.m_category = [address.categories componentsJoinedByString:@","].string; _address.m_walletID = walletID; + _address.m_Identity = m_Identity; _address.m_createTime = NSDate.date.timeIntervalSince1970; walletDb->saveAddress(_address); } @@ -1657,6 +1676,8 @@ -(void)editAddress:(BMAddress*_Nonnull)address { } } +// NSString *s = [NSString stringWithUTF8String:to_string(addresses[i].m_Identity).c_str()]; + wallet->getAsync()->saveAddress(addresses[i], true); break; @@ -1685,15 +1706,21 @@ -(NSString*_Nonnull)generateQRCodeString:(NSString*_Nonnull)address amount:(NSSt return qrString; } --(void)addContact:(NSString*_Nonnull)addressId name:(NSString*_Nonnull)name categories:(NSArray*_Nonnull)categories { +-(void)addContact:(NSString*_Nonnull)addressId name:(NSString*_Nonnull)name categories:(NSArray*_Nonnull)categories identidy:(NSString*_Nullable)identidy { WalletID walletID(Zero); if (walletID.FromHex(addressId.string)) - { + { WalletAddress address; address.m_label = name.string; address.m_category = [categories componentsJoinedByString:@","].string; address.m_walletID = walletID; + if (identidy!=nil) { + bool isValid = false; + auto buf = from_hex(identidy.string, &isValid); + PeerID m_Identity = Blob(buf); + address.m_Identity = m_Identity; + } address.m_createTime = NSDate.date.timeIntervalSince1970; walletDb->saveAddress(address); } @@ -1864,6 +1891,16 @@ -(void)calculateFee:(double)amount fee:(double)fee isShielded:(BOOL) isShielded wallet->getAsync()->calcShieldedCoinSelectionInfo(bAmount, bFee, isShielded); } +-(void)calculateFee2:(double)amount fee:(double)fee isShielded:(BOOL) isShielded result:(FeecalculatedBlock _Nonnull )block { + + self.feecalculatedBlock = block; + + Amount bAmount = round(amount * Rules::Coin); + Amount bFee = fee; + + wallet->getAsync()->calcShieldedCoinSelectionInfo(bAmount, bFee, isShielded); +} + -(NSString*)sendError:(double)amount fee:(double)fee checkMinAmount:(BOOL)check { Amount bAmount = round(amount * Rules::Coin); diff --git a/BeamWallet/BeamSDK/Objects/BMTransaction.m b/BeamWallet/BeamSDK/Objects/BMTransaction.m index 7a0caac4..d8f49302 100644 --- a/BeamWallet/BeamSDK/Objects/BMTransaction.m +++ b/BeamWallet/BeamSDK/Objects/BMTransaction.m @@ -601,7 +601,12 @@ -(NSString*)textDetails { } else if(_isIncome) { - sender = [NSString stringWithFormat:@"%@\n%@",[[@"contact" localized]uppercaseString], _senderAddress]; + if (self.enumType == BMTransactionTypePushTransaction) { + sender = [NSString stringWithFormat:@"%@\n%@",[[@"contact" localized]uppercaseString], [@"shielded_pool" localized]]; + } + else { + sender = [NSString stringWithFormat:@"%@\n%@",[[@"contact" localized]uppercaseString], _senderAddress]; + } receiver = [NSString stringWithFormat:@"%@\n%@",[[@"my_address" localized]uppercaseString], _receiverAddress]; } else{ @@ -618,7 +623,9 @@ -(NSString*)textDetails { [details addObject:amount]; [details addObject:sender]; [details addObject:receiver]; - [details addObject:fee]; + if (_realFee > 0) { + [details addObject:fee]; + } [details addObject:trid]; if(_identity.length > 0){ diff --git a/BeamWallet/BeamSDK/WalletModel.mm b/BeamWallet/BeamSDK/WalletModel.mm index 7ba19af9..4a28bdbc 100644 --- a/BeamWallet/BeamSDK/WalletModel.mm +++ b/BeamWallet/BeamSDK/WalletModel.mm @@ -439,6 +439,7 @@ address.label = [NSString stringWithUTF8String:walletAddr.m_label.c_str()]; address.walletId = [NSString stringWithUTF8String:to_string(walletAddr.m_walletID).c_str()]; address.categories = (categories.length == 0 ? [NSMutableArray new] : [NSMutableArray arrayWithArray:[categories componentsSeparatedByString:@","]]); + address.identity = [NSString stringWithUTF8String:to_string(walletAddr.m_Identity).c_str()]; BMContact *contact = [[BMContact alloc] init]; contact.address = address; @@ -1102,7 +1103,15 @@ void WalletModel::onShieldedCoinsSelectionCalculated(const ShieldedCoinsSelectionInfo& selectionRes) { auto result = selectionRes.minimalFee; - [AppModel sharedManager].feecalculatedBlock(result); + auto change = selectionRes.change; + auto shieldedInputsFee = selectionRes.shieldedInputsFee; + +// if (change > 0) { +// change = change + selectionRes.selectedFee; //+ selectionRes.requestedFee; +// } + double amount = double(int64_t(change)) / Rules::Coin; + + [AppModel sharedManager].feecalculatedBlock(result, amount, shieldedInputsFee); NSLog(@"onShieldedCoinsSelectionCalculated"); } diff --git a/BeamWallet/Model/Transaction/SendTransactionViewModel.swift b/BeamWallet/Model/Transaction/SendTransactionViewModel.swift index a09bb7f8..8d871e6d 100644 --- a/BeamWallet/Model/Transaction/SendTransactionViewModel.swift +++ b/BeamWallet/Model/Transaction/SendTransactionViewModel.swift @@ -29,6 +29,7 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate { public var newVersionError:String? public var comment = String.empty() + public var shieldedInputsFee:UInt64 = 0 public var outgoindAdderss:BMAddress? public var pickedOutgoingAddress:BMAddress? @@ -75,8 +76,9 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate { public func calculateFee() { if AppModel.sharedManager().walletStatus?.shielded ?? 0 > 0 { - AppModel.sharedManager().calculateFee(Double(amount) ?? 0, fee: 0, isShielded: maxPrivacy) { (result) in + AppModel.sharedManager().calculateFee(Double(amount) ?? 0, fee: 0, isShielded: maxPrivacy) { (result, changed, shieldedInputsFee) in DispatchQueue.main.async { + self.shieldedInputsFee = shieldedInputsFee let current = UInt64(self.fee) ?? 0 if result > current { self.fee = String(result) @@ -110,6 +112,8 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate { } } + public var onCalculateChanged : ((Double) -> Void)? + public var toAddress = String.empty() { didSet { toAddressError = nil @@ -255,7 +259,12 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate { } public func send() { - AppModel.sharedManager().prepareSend(Double(amount) ?? 0, fee: Double(fee) ?? 0, to: toAddress, comment: comment, from: outgoindAdderss?.walletId, saveContact: saveContact, maxPrivacy: maxPrivacy) + var sendedFee = Double(fee) ?? 0 + if shieldedInputsFee > 0 { + sendedFee = sendedFee - Double(shieldedInputsFee) + } + + AppModel.sharedManager().prepareSend(Double(amount) ?? 0, fee: sendedFee, to: toAddress, comment: comment, from: outgoindAdderss?.walletId, saveContact: saveContact, maxPrivacy: maxPrivacy) AppStoreReviewManager.incrementAppTransactions() } @@ -307,13 +316,22 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate { let valid = AppModel.sharedManager().isValidAddress(toAddress) let expired = AppModel.sharedManager().isExpiredAddress(toAddress) let canSend = AppModel.sharedManager().canSend((Double(amount) ?? 0), fee: (Double(fee) ?? 0), to: toAddress) - let isError = (!valid || expired || canSend != nil) + var isError = (!valid || expired || canSend != nil) + + let isMyAddress = AppModel.sharedManager().isMyAddress(toAddress) + + if(isMyAddress && maxPrivacy) { + isError = true + } if isError { amountError = nil toAddressError = nil - if !valid { + if(isMyAddress && maxPrivacy) { + toAddressError = "Can not sent offline transaction to own address" + } + else if !valid { toAddressError = Localizable.shared.strings.incorrect_address } else if expired { @@ -489,7 +507,14 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate { } public func calculateChange() { - AppModel.sharedManager().calculateChange(Double(amount) ?? 0, fee: Double(fee) ?? 0) + if (AppModel.sharedManager().walletStatus?.shielded ?? 0) > 0 { + AppModel.sharedManager().calculateFee2((Double(amount) ?? 0), fee: (Double(fee) ?? 0), isShielded: maxPrivacy || requestedMaxPrivacy) { (fee, change, shieldedInputsFee) in + self.onCalculateChanged?(change) + } + } + else { + AppModel.sharedManager().calculateChange(Double(amount) ?? 0, fee: Double(fee) ?? 0) + } if AppModel.sharedManager().isToken(toAddress) { _ = AppModel.sharedManager().getTransactionParameters(toAddress) diff --git a/BeamWallet/ViewControllers/Main/Settings/TrustedNodeViewController.swift b/BeamWallet/ViewControllers/Main/Settings/TrustedNodeViewController.swift index 95674ef2..f6144b99 100644 --- a/BeamWallet/ViewControllers/Main/Settings/TrustedNodeViewController.swift +++ b/BeamWallet/ViewControllers/Main/Settings/TrustedNodeViewController.swift @@ -29,6 +29,7 @@ class TrustedNodeViewController: BMInputViewController { private var isPresented = false private var timer = Timer() + private var timeoutTimer = Timer() private var event: EventType! private var oldAddress: String! @@ -109,7 +110,7 @@ class TrustedNodeViewController: BMInputViewController { } } else if let fullAddress = inputField.text, let password = KeychainManager.getPassword() { - if AppModel.sharedManager().isValidNodeAddress(fullAddress) { + if AppModel.sharedManager().isValidNodeAddress(fullAddress) && !fullAddress.isEmpty { SVProgressHUD.show() AppModel.sharedManager().resetOnlyWallet() @@ -162,42 +163,31 @@ class TrustedNodeViewController: BMInputViewController { } private func openMainPage() { - if let password = KeychainManager.getPassword() { - + if KeychainManager.getPassword() != nil { AppModel.sharedManager().stopChangeWallet() - - AppModel.sharedManager().removeDelegate(self) AppModel.sharedManager().isRestoreFlow = false AppModel.sharedManager().isOwnNode = true - - AppModel.sharedManager().refreshAddresses() - AppModel.sharedManager().getUTXO() - AppModel.sharedManager().getWalletStatus() - AppModel.sharedManager().getNetworkStatus() - - let vc = OpenWalletProgressViewController(password: password, phrase: nil) - self.pushViewController(vc: vc) - } -// -// let mainVC = BaseNavigationController.navigationController(rootViewController: WalletViewController()) -// let menuViewController = LeftMenuViewController() -// -// let sideMenuController = LGSideMenuController(rootViewController: mainVC, -// leftViewController: menuViewController, -// rightViewController: nil) -// -// sideMenuController.leftViewWidth = UIScreen.main.bounds.size.width - 60 -// sideMenuController.leftViewPresentationStyle = LGSideMenuPresentationStyle.slideAbove -// sideMenuController.rootViewLayerShadowRadius = 0 -// sideMenuController.rootViewLayerShadowColor = UIColor.clear -// sideMenuController.leftViewLayerShadowRadius = 0 -// sideMenuController.rootViewCoverAlphaForLeftView = 0.5 -// sideMenuController.rootViewCoverAlphaForRightView = 0.5 -// sideMenuController.leftViewCoverAlpha = 0.5 -// sideMenuController.rightViewCoverAlpha = 0.5 -// sideMenuController.modalTransitionStyle = .crossDissolve -// -// navigationController?.setViewControllers([sideMenuController], animated: true) + } + + let mainVC = BaseNavigationController.navigationController(rootViewController: WalletViewController()) + let menuViewController = LeftMenuViewController() + + let sideMenuController = LGSideMenuController(rootViewController: mainVC, + leftViewController: menuViewController, + rightViewController: nil) + + sideMenuController.leftViewWidth = UIScreen.main.bounds.size.width - 60 + sideMenuController.leftViewPresentationStyle = LGSideMenuPresentationStyle.slideAbove + sideMenuController.rootViewLayerShadowRadius = 0 + sideMenuController.rootViewLayerShadowColor = UIColor.clear + sideMenuController.leftViewLayerShadowRadius = 0 + sideMenuController.rootViewCoverAlphaForLeftView = 0.5 + sideMenuController.rootViewCoverAlphaForRightView = 0.5 + sideMenuController.leftViewCoverAlpha = 0.5 + sideMenuController.rightViewCoverAlpha = 0.5 + sideMenuController.modalTransitionStyle = .crossDissolve + + navigationController?.setViewControllers([sideMenuController], animated: true) } } @@ -246,8 +236,32 @@ extension TrustedNodeViewController: UITextFieldDelegate { } extension TrustedNodeViewController: WalletModelDelegate { - @objc private func timerAction() { + + func onWalletStatusChange(_ status: BMWalletStatus) { + if status.available > 0 { + DispatchQueue.main.async { [weak self] in + guard let strongSelf = self else { return } + if !strongSelf.isPresented { + strongSelf.isPresented = true + strongSelf.timer.invalidate() + SVProgressHUD.dismiss() + strongSelf.openMainPage() + } + } + } + } + + @objc private func timeout() { SVProgressHUD.dismiss() + if !isPresented { + isPresented = true + timer.invalidate() + timeoutTimer.invalidate() + openMainPage() + } + } + + @objc private func timerAction() { let connected = AppModel.sharedManager().isConnected @@ -256,11 +270,20 @@ extension TrustedNodeViewController: WalletModelDelegate { inputField.status = .normal if !isPresented { - isPresented = true - openMainPage() + DispatchQueue.main.asyncAfter(deadline: .now() + 5) { + AppModel.sharedManager().getWalletStatus() + } + timer.invalidate() + + timeoutTimer = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(timeout), userInfo: nil, repeats: false) + } + else { + SVProgressHUD.dismiss() } } else { + SVProgressHUD.dismiss() + inputField.status = .error errorLabel.isHidden = false } diff --git a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.swift b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.swift index 3d6936fa..55499280 100755 --- a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.swift +++ b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.swift @@ -31,10 +31,14 @@ class WalletTransactionCell: UITableViewCell { @IBOutlet weak private var commentView: UIStackView! @IBOutlet weak private var commentLabel: UILabel! + @IBOutlet weak private var secondAvailableLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() + secondAvailableLabel.textColor = Settings.sharedManager().isDarkMode ? UIColor.main.steel : UIColor.main.blueyGrey + secondAvailableLabel.font = RegularFont(size: 14) + let selectedView = UIView() selectedView.backgroundColor = UIColor.main.selectedColor self.selectedBackgroundView = selectedView @@ -44,7 +48,8 @@ class WalletTransactionCell: UITableViewCell { extension WalletTransactionCell: Configurable { func configure(with options: (row: Int, transaction:BMTransaction, additionalInfo:Bool)) { - + secondAvailableLabel.text = AppModel.sharedManager().exchangeValue(options.transaction.realAmount) + mainView.backgroundColor = (options.row % 2 == 0) ? UIColor.main.cellBackgroundColor : UIColor.main.marine statusIcon.image = options.transaction.statusIcon() diff --git a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.xib b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.xib index 1481037d..1f1aadac 100755 --- a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.xib +++ b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionCell.xib @@ -1,9 +1,9 @@ - + - + @@ -11,6 +11,9 @@ SFProDisplay-Bold + + SFProDisplay-Light + SFProDisplay-LightItalic @@ -101,10 +104,10 @@ - + - + + - + + + + + + @@ -149,8 +163,8 @@ - + @@ -158,6 +172,7 @@ + diff --git a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.swift b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.swift index ee682ffa..6cc9084a 100644 --- a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.swift +++ b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.swift @@ -28,12 +28,16 @@ class WalletTransactionSearchCell: UITableViewCell { @IBOutlet weak private var amountLabel: UILabel! @IBOutlet weak private var balanceView: UIView! @IBOutlet weak private var statusIcon: UIImageView! + @IBOutlet weak private var secondAvailableLabel: UILabel! @IBOutlet weak private var searchLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() + secondAvailableLabel.textColor = Settings.sharedManager().isDarkMode ? UIColor.main.steel : UIColor.main.blueyGrey + secondAvailableLabel.font = RegularFont(size: 14) + let selectedView = UIView() selectedView.backgroundColor = UIColor.main.selectedColor self.selectedBackgroundView = selectedView @@ -56,7 +60,8 @@ extension WalletTransactionSearchCell: Configurable { func configure(with options: (row: Int, transaction:BMTransaction, additionalInfo:Bool)) { mainView.backgroundColor = (options.row % 2 == 0) ? UIColor.main.cellBackgroundColor : UIColor.main.marine - + secondAvailableLabel.text = AppModel.sharedManager().exchangeValue(options.transaction.realAmount) + statusIcon.image = options.transaction.statusIcon() typeLabel.text = options.transaction.statusName() statusLabel.text = options.transaction.statusType() diff --git a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.xib b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.xib index aed550b6..bc45a98a 100644 --- a/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.xib +++ b/BeamWallet/ViewControllers/Main/Wallet/Cells/WalletTransactionSearchCell.xib @@ -1,9 +1,9 @@ - + - + @@ -11,6 +11,9 @@ SFProDisplay-Bold + + SFProDisplay-Light + SFProDisplay-Regular @@ -86,10 +89,10 @@ - + - + + - + + + @@ -137,14 +148,15 @@ - + + diff --git a/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.swift b/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.swift index c1deef7b..22beb141 100644 --- a/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.swift +++ b/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.swift @@ -12,9 +12,10 @@ import UIKit @objc optional func onShowToken(token:String) @objc optional func onShowQR(token:String) @objc optional func onSwitchToPool() + @objc optional func onShareToken() } -class ReceiveAddressTokensCell: BaseCell { +class ReceiveAddressTokensCell: BaseCell, BMCopyLabelDelegate { weak var delegate: ReceiveAddressTokensCellDelegate? @@ -26,10 +27,10 @@ class ReceiveAddressTokensCell: BaseCell { @IBOutlet private var exchangeTokenView: UIView! @IBOutlet private var onlineTokenLabel: UILabel! - @IBOutlet private var onlineTokenValueLabel: UILabel! + @IBOutlet private var onlineTokenValueLabel: BMCopyLabel! @IBOutlet private var offlineTokenLabel: UILabel! - @IBOutlet private var offlineTokenValueLabel: UILabel! + @IBOutlet private var offlineTokenValueLabel: BMCopyLabel! @IBOutlet private var exchangeTokenLabel: UILabel! @IBOutlet private var exchangeTokenValueLabel: UILabel! @@ -37,6 +38,9 @@ class ReceiveAddressTokensCell: BaseCell { override func awakeFromNib() { super.awakeFromNib() + offlineTokenValueLabel.delegate = self + onlineTokenValueLabel.delegate = self + if Settings.sharedManager().isDarkMode { onlineTokenLabel.textColor = UIColor.main.steel; offlineTokenLabel.textColor = UIColor.main.steel; @@ -58,7 +62,9 @@ extension ReceiveAddressTokensCell: Configurable { func configure(with options: (oneTime: Bool, maxPrivacy: Bool, address: BMAddress)) { onlineTokenValueLabel.text = options.address.token - + onlineTokenValueLabel.copiedText = Localizable.shared.strings.address_copied + offlineTokenValueLabel.copiedText = Localizable.shared.strings.address_copied + switchButton.setTitle(Localizable.shared.strings.switch_to_permanent, for: .normal) qrButton2.isHidden = true @@ -131,4 +137,8 @@ extension ReceiveAddressTokensCell: Configurable { @IBAction func onSwitch(sender: UIButton) { self.delegate?.onSwitchToPool?() } + + func onCopied() { + self.delegate?.onShareToken?() + } } diff --git a/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.xib b/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.xib index 4a8585f1..de36227a 100644 --- a/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.xib +++ b/BeamWallet/ViewControllers/Main/Wallet/Receive/Cells/ReceiveAddressTokensCell.xib @@ -1,9 +1,9 @@ - + - + @@ -49,7 +49,7 @@ -