diff --git a/Kukai Mobile.xcodeproj/project.pbxproj b/Kukai Mobile.xcodeproj/project.pbxproj index 296afad7..71b0ef81 100644 --- a/Kukai Mobile.xcodeproj/project.pbxproj +++ b/Kukai Mobile.xcodeproj/project.pbxproj @@ -104,6 +104,9 @@ C02F3CB22BFF5B6300FA6383 /* AccountsAddHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C02F3CB12BFF5B6300FA6383 /* AccountsAddHeaderCell.swift */; }; C02F3CB42BFF5B8E00FA6383 /* AccountsAddOptionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C02F3CB32BFF5B8E00FA6383 /* AccountsAddOptionCell.swift */; }; C02F3CB62BFF77A900FA6383 /* AddWalletViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C02F3CB52BFF77A900FA6383 /* AddWalletViewModel.swift */; }; + C03016042CFF498D0058A457 /* PublicBakerAttributeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016032CFF498D0058A457 /* PublicBakerAttributeCell.swift */; }; + C03016062CFF49D90058A457 /* BakerDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016052CFF49D90058A457 /* BakerDetailsViewModel.swift */; }; + C03016082D007DB00058A457 /* SuggestedActionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016072D007DB00058A457 /* SuggestedActionCell.swift */; }; C031D3E927D114A600EABBE6 /* TokenDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C031D3E827D114A600EABBE6 /* TokenDetailsViewController.swift */; }; C031D3EB27D114BC00EABBE6 /* TokenDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C031D3EA27D114BC00EABBE6 /* TokenDetailsViewModel.swift */; }; C031D3ED27D114D000EABBE6 /* CollectiblesDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C031D3EC27D114D000EABBE6 /* CollectiblesDetailsViewModel.swift */; }; @@ -545,6 +548,9 @@ C02F3CB12BFF5B6300FA6383 /* AccountsAddHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsAddHeaderCell.swift; sourceTree = ""; }; C02F3CB32BFF5B8E00FA6383 /* AccountsAddOptionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsAddOptionCell.swift; sourceTree = ""; }; C02F3CB52BFF77A900FA6383 /* AddWalletViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWalletViewModel.swift; sourceTree = ""; }; + C03016032CFF498D0058A457 /* PublicBakerAttributeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicBakerAttributeCell.swift; sourceTree = ""; }; + C03016052CFF49D90058A457 /* BakerDetailsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BakerDetailsViewModel.swift; sourceTree = ""; }; + C03016072D007DB00058A457 /* SuggestedActionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestedActionCell.swift; sourceTree = ""; }; C031D3E827D114A600EABBE6 /* TokenDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenDetailsViewController.swift; sourceTree = ""; }; C031D3EA27D114BC00EABBE6 /* TokenDetailsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenDetailsViewModel.swift; sourceTree = ""; }; C031D3EC27D114D000EABBE6 /* CollectiblesDetailsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectiblesDetailsViewModel.swift; sourceTree = ""; }; @@ -1539,6 +1545,7 @@ children = ( C009308E28CB3DC500763885 /* ChooseBakerHeadingCell.swift */, C0C6B5CC28CA25BD00368AEA /* PublicBakerCell.swift */, + C03016032CFF498D0058A457 /* PublicBakerAttributeCell.swift */, ); path = Cells; sourceTree = ""; @@ -1637,6 +1644,7 @@ C0717B1D2A697D3D007F9419 /* EnterCustomBakerViewController.swift */, C034F2C22A6A913B000F4C4C /* ChooseBakerConfirmViewController.swift */, C034F2C42A6AD2E5000F4C4C /* BakerDetailsViewController.swift */, + C03016052CFF49D90058A457 /* BakerDetailsViewModel.swift */, C0DB694A2CEE40D3000C1A17 /* StakeAmountViewController.swift */, C0DB694C2CEF567A000C1A17 /* StakeConfirmViewController.swift */, C04BA1F52CF765B900951249 /* StakeOnboardingContainerViewController.swift */, @@ -1673,6 +1681,7 @@ isa = PBXGroup; children = ( C054BCA32A682B6F006BDFBB /* BackUpCell.swift */, + C03016072D007DB00058A457 /* SuggestedActionCell.swift */, C04E0EB12ADE7EE7001BF56F /* UpdateWarningCell.swift */, C0D921D1293E49A20020E0BF /* TokenBalanceHeaderCell.swift */, C08694DD27BD1B84000A4909 /* TokenBalanceCell.swift */, @@ -2037,9 +2046,11 @@ C057CF622AB0BC0900E82D41 /* UIDevice+extensions.swift in Sources */, C04E2868293F94EA00DC4171 /* TokenDetailsStakingRewardsCell.swift in Sources */, C0FBC891292C12E200B29921 /* FavouriteBalancesViewController.swift in Sources */, + C03016042CFF498D0058A457 /* PublicBakerAttributeCell.swift in Sources */, C02A4FDA27DA421100F42DE4 /* Date+extensions.swift in Sources */, C0248CEE2AA21B5900B1F63C /* String+extensions_shared.swift in Sources */, C003CECD27FDED5D00F64B4C /* CKRecord+extensions.swift in Sources */, + C03016082D007DB00058A457 /* SuggestedActionCell.swift in Sources */, C04D985A2CE65884009491BD /* TokenDetailsStakeBalanceCell.swift in Sources */, C06AEDFD2C00997E005CFDAA /* AddAccountViewController.swift in Sources */, C04E2864293F94C500DC4171 /* TokenDetailsBalanceCell.swift in Sources */, @@ -2166,6 +2177,7 @@ C049E74028819E3800887B64 /* DiscoverViewModel.swift in Sources */, C0C6B5CF28CA27AF00368AEA /* ChooseBakerViewController.swift in Sources */, C03BF88D2A279836003BD343 /* ActivityItemBatchCell.swift in Sources */, + C03016062CFF49D90058A457 /* BakerDetailsViewModel.swift in Sources */, C04BA1F02CF4CFBE00951249 /* LearnMoreItemCell.swift in Sources */, C01372B229B206FF0083E297 /* MenuHeaderCell.swift in Sources */, C06AEDFF2C00998D005CFDAA /* AddAccountViewModel.swift in Sources */, @@ -2525,7 +2537,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.2.0; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ""; OTHER_SWIFT_FLAGS = ""; @@ -2568,7 +2580,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.2.0; OTHER_CFLAGS = ""; OTHER_SWIFT_FLAGS = "-Xfrontend -internalize-at-link"; PRODUCT_BUNDLE_IDENTIFIER = "app.kukai.mobile${BUNDLE_ID_SUFFIX}"; @@ -2755,7 +2767,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.2.0; OTHER_CFLAGS = ""; OTHER_SWIFT_FLAGS = "-Xfrontend -internalize-at-link"; PRODUCT_BUNDLE_IDENTIFIER = "app.kukai.mobile${BUNDLE_ID_SUFFIX}"; diff --git a/Kukai Mobile/Modules/Account/Account.storyboard b/Kukai Mobile/Modules/Account/Account.storyboard index 5780ce26..738ccb33 100644 --- a/Kukai Mobile/Modules/Account/Account.storyboard +++ b/Kukai Mobile/Modules/Account/Account.storyboard @@ -29,11 +29,11 @@ - + - + @@ -48,7 +48,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -106,7 +106,7 @@ - + @@ -124,8 +124,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -213,7 +291,7 @@ - + @@ -266,7 +344,7 @@ - + @@ -329,7 +407,7 @@ - + @@ -441,7 +519,7 @@ - + @@ -544,7 +622,7 @@ - + @@ -752,29 +830,29 @@ - + - + - - + - - - - + - + + + + - - + @@ -475,7 +495,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -491,7 +511,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -545,112 +565,11 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -678,19 +667,19 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + - + - - + + @@ -700,15 +689,12 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - - - - + - + @@ -760,16 +746,16 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + - + - + - + @@ -790,54 +776,88 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - - + + - - + + - - - + + - - - + + - - - + + + + + + + - - + - - + + @@ -896,13 +920,13 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -1010,7 +1034,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + - - + + - - + + - - - + + - - - + + - - - + + + + + + - - - + + + - + - - + - @@ -1779,7 +1846,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -1905,13 +1972,13 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + - + - + @@ -1932,54 +1999,88 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - - + + - - + + - - - + + - - - + + - - - + + + + + + - + - - + - + + @@ -2014,7 +2119,6 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - @@ -2031,7 +2135,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -2420,7 +2527,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -2442,7 +2549,7 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y - + @@ -3061,7 +3168,7 @@ Bakers also vote on behalf of users to make changes to the network, during the G - + @@ -3085,8 +3192,8 @@ Bakers also vote on behalf of users to make changes to the network, during the G @@ -3137,7 +3244,7 @@ Bakers also vote on behalf of users to make changes to the network, during the G - + @@ -3191,7 +3298,7 @@ Bakers also vote on behalf of users to make changes to the network, during the G - + @@ -3250,7 +3357,7 @@ You can see these rewards, change your baker, stake more, unstake, or finalise y - + @@ -3266,9 +3373,28 @@ You can see these rewards, change your baker, stake more, unstake, or finalise y - + + + + + + + + + + + + + + + + + + + + diff --git a/Kukai Mobile/Modules/Stake/StakeAmountViewController.swift b/Kukai Mobile/Modules/Stake/StakeAmountViewController.swift index 740a2a3c..68361b21 100644 --- a/Kukai Mobile/Modules/Stake/StakeAmountViewController.swift +++ b/Kukai Mobile/Modules/Stake/StakeAmountViewController.swift @@ -12,9 +12,12 @@ class StakeAmountViewController: UIViewController { @IBOutlet weak var bakerIcon: UIImageView! @IBOutlet weak var bakerNameLabel: UILabel! - @IBOutlet weak var bakerSplitValueLabel: UILabel! - @IBOutlet weak var bakerSpaceValueLabel: UILabel! - @IBOutlet weak var bakerRewardsValueLabel: UILabel! + @IBOutlet weak var bakerDelegationSplitValueLabel: UILabel! + @IBOutlet weak var bakerDelegationApyValueLabel: UILabel! + @IBOutlet weak var bakerDelegationFreeSpaceValueLabel: UILabel! + @IBOutlet weak var bakerStakingSplitValueLabel: UILabel! + @IBOutlet weak var bakerStakingApyValueLabel: UILabel! + @IBOutlet weak var bakerStakingFreeSpaceValueLabel: UILabel! @IBOutlet weak var tokenNameLabel: UILabel! @IBOutlet weak var tokenBalanceTitleLabel: UILabel! @@ -57,9 +60,35 @@ class StakeAmountViewController: UIViewController { // To section MediaProxyService.load(url: baker.logo, to: bakerIcon, withCacheType: .temporary, fallback: UIImage.unknownToken()) bakerNameLabel.text = baker.name ?? baker.address.truncateTezosAddress() - bakerSplitValueLabel.text = "\(baker.staking.fee * 100)%" - bakerSpaceValueLabel.text = DependencyManager.shared.coinGeckoService.formatLargeTokenDisplay(baker.staking.freeSpace, decimalPlaces: token.decimalPlaces, includeThousand: true, maximumFractionDigits: 0) - bakerRewardsValueLabel.text = "\(baker.staking.estimatedApy * 100)%" + if baker.name == nil && baker.delegation.fee == 0 && baker.delegation.capacity == 0 && baker.delegation.estimatedApy == 0 { + bakerDelegationSplitValueLabel.text = "N/A" + bakerDelegationApyValueLabel.text = "N/A" + bakerDelegationFreeSpaceValueLabel.text = "N/A" + bakerStakingSplitValueLabel.text = "N/A" + bakerStakingApyValueLabel.text = "N/A" + bakerStakingFreeSpaceValueLabel.text = "N/A" + + } else { + bakerDelegationSplitValueLabel.text = (Decimal(baker.delegation.fee) * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerDelegationApyValueLabel.text = Decimal(baker.delegation.estimatedApy * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerDelegationFreeSpaceValueLabel.text = DependencyManager.shared.coinGeckoService.formatLargeTokenDisplay(baker.delegation.freeSpace, decimalPlaces: 0, allowNegative: true) + " XTZ" + + if baker.delegation.freeSpace < 0 { + bakerDelegationFreeSpaceValueLabel.textColor = .colorNamed("TxtAlert4") + } else { + bakerDelegationFreeSpaceValueLabel.textColor = .colorNamed("Txt8") + } + + bakerStakingSplitValueLabel.text = (Decimal(baker.staking.fee) * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerStakingApyValueLabel.text = Decimal(baker.staking.estimatedApy * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerStakingFreeSpaceValueLabel.text = DependencyManager.shared.coinGeckoService.formatLargeTokenDisplay(baker.staking.freeSpace, decimalPlaces: 0, allowNegative: true) + " XTZ" + + if baker.delegation.freeSpace < 0 { + bakerStakingFreeSpaceValueLabel.textColor = .colorNamed("TxtAlert4") + } else { + bakerStakingFreeSpaceValueLabel.textColor = .colorNamed("Txt8") + } + } // Token data diff --git a/Kukai Mobile/Modules/Stake/StakeConfirmViewController.swift b/Kukai Mobile/Modules/Stake/StakeConfirmViewController.swift index 7bcc977e..691494b0 100644 --- a/Kukai Mobile/Modules/Stake/StakeConfirmViewController.swift +++ b/Kukai Mobile/Modules/Stake/StakeConfirmViewController.swift @@ -31,9 +31,12 @@ class StakeConfirmViewController: SendAbstractConfirmViewController, SlideButton // Baker @IBOutlet weak var bakerIcon: UIImageView! @IBOutlet weak var bakerNameLabel: UILabel! - @IBOutlet weak var bakerSplitValueLabel: UILabel! - @IBOutlet weak var bakerSpaceValueLabel: UILabel! - @IBOutlet weak var bakerRewardsValueLabel: UILabel! + @IBOutlet weak var bakerDelegationSplitValueLabel: UILabel! + @IBOutlet weak var bakerDelegationApyValueLabel: UILabel! + @IBOutlet weak var bakerDelegationFreeSpaceValueLabel: UILabel! + @IBOutlet weak var bakerStakingSplitValueLabel: UILabel! + @IBOutlet weak var bakerStakingApyValueLabel: UILabel! + @IBOutlet weak var bakerStakingFreeSpaceValueLabel: UILabel! // Stake @IBOutlet weak var actionTitleLabel: UILabel! @@ -144,14 +147,33 @@ class StakeConfirmViewController: SendAbstractConfirmViewController, SlideButton // Baker info config bakerNameLabel.text = baker.name ?? baker.address.truncateTezosAddress() if baker.name == nil && baker.delegation.fee == 0 && baker.delegation.capacity == 0 && baker.delegation.estimatedApy == 0 { - bakerSplitValueLabel.text = "N/A" - bakerSpaceValueLabel.text = "N/A" - bakerRewardsValueLabel.text = "N/A" + bakerDelegationSplitValueLabel.text = "N/A" + bakerDelegationApyValueLabel.text = "N/A" + bakerDelegationFreeSpaceValueLabel.text = "N/A" + bakerStakingSplitValueLabel.text = "N/A" + bakerStakingApyValueLabel.text = "N/A" + bakerStakingFreeSpaceValueLabel.text = "N/A" } else { - bakerSplitValueLabel.text = (Decimal(baker.delegation.fee) * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" - bakerSpaceValueLabel.text = DependencyManager.shared.coinGeckoService.formatLargeTokenDisplay(baker.delegation.freeSpace, decimalPlaces: 0) + " XTZ" - bakerRewardsValueLabel.text = Decimal(baker.delegation.estimatedApy * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerDelegationSplitValueLabel.text = (Decimal(baker.delegation.fee) * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerDelegationApyValueLabel.text = Decimal(baker.delegation.estimatedApy * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerDelegationFreeSpaceValueLabel.text = DependencyManager.shared.coinGeckoService.formatLargeTokenDisplay(baker.delegation.freeSpace, decimalPlaces: 0, allowNegative: true) + " XTZ" + + if baker.delegation.freeSpace < 0 { + bakerDelegationFreeSpaceValueLabel.textColor = .colorNamed("TxtAlert4") + } else { + bakerDelegationFreeSpaceValueLabel.textColor = .colorNamed("Txt8") + } + + bakerStakingSplitValueLabel.text = (Decimal(baker.staking.fee) * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerStakingApyValueLabel.text = Decimal(baker.staking.estimatedApy * 100).rounded(scale: 2, roundingMode: .bankers).description + "%" + bakerStakingFreeSpaceValueLabel.text = DependencyManager.shared.coinGeckoService.formatLargeTokenDisplay(baker.staking.freeSpace, decimalPlaces: 0, allowNegative: true) + " XTZ" + + if baker.delegation.freeSpace < 0 { + bakerStakingFreeSpaceValueLabel.textColor = .colorNamed("TxtAlert4") + } else { + bakerStakingFreeSpaceValueLabel.textColor = .colorNamed("Txt8") + } } diff --git a/Kukai Mobile/Modules/Stake/StakeOnboardingContainerViewController.swift b/Kukai Mobile/Modules/Stake/StakeOnboardingContainerViewController.swift index cbd8a458..0210c7f2 100644 --- a/Kukai Mobile/Modules/Stake/StakeOnboardingContainerViewController.swift +++ b/Kukai Mobile/Modules/Stake/StakeOnboardingContainerViewController.swift @@ -11,6 +11,10 @@ import Combine class StakeOnboardingContainerViewController: UIViewController { + @IBOutlet weak var indicatorStackview: UIStackView! + @IBOutlet weak var indicatorStackviewLeadingConstraint: NSLayoutConstraint! + @IBOutlet weak var indicatorStackviewTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var pageIndicator1: PageIndicatorContainerView! @IBOutlet weak var progressSegment1: UIProgressView! @IBOutlet weak var pageIndicator2: PageIndicatorContainerView! @@ -18,22 +22,52 @@ class StakeOnboardingContainerViewController: UIViewController { @IBOutlet weak var pageIndicator3: PageIndicatorContainerView! @IBOutlet weak var progressSegment3: UIProgressView! @IBOutlet weak var pageIndicator4: PageIndicatorContainerView! - @IBOutlet weak var progressSegment4: UIProgressView! - @IBOutlet weak var pageIndicator5: PageIndicatorContainerView! @IBOutlet weak var actionButton: CustomisableButton! - @IBOutlet weak var navigationContainerView: UIView! + @IBOutlet weak var delegateAndStakeContainer: UIView! + @IBOutlet weak var stakeOnlyContainer: UIView! + private var childNavigationController: UINavigationController? = nil private var currentChildViewController: UIViewController? = nil private var bag = [AnyCancellable]() private var currentStep: String = "" + private var isStakeOnly = false + + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + + isStakeOnly = (DependencyManager.shared.balanceService.account.delegate != nil) + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + + isStakeOnly = (DependencyManager.shared.balanceService.account.delegate != nil) + } override func viewDidLoad() { super.viewDidLoad() GradientView.add(toView: self.view, withType: .fullScreenBackground) - actionButton.customButtonType = .primary + + // If user only needs to stake we hide the first few screens and 2 steps + delegateAndStakeContainer.isHidden = isStakeOnly + stakeOnlyContainer.isHidden = !isStakeOnly + + if isStakeOnly { + indicatorStackview.removeArrangedSubview(pageIndicator1) + pageIndicator1.isHidden = true + indicatorStackview.removeArrangedSubview(pageIndicator2) + pageIndicator2.isHidden = true + progressSegment1.removeFromSuperview() + + // With only 2 steps it looks odd to have it the full length of the screen, reduce it a bit + indicatorStackviewLeadingConstraint.constant = 24 * 5 + indicatorStackviewTrailingConstraint.constant = 24 * 5 + } + + DependencyManager.shared.activityService.$addressesWithPendingOperation .dropFirst() .sink { [weak self] addresses in @@ -58,10 +92,6 @@ class StakeOnboardingContainerViewController: UIViewController { super.viewDidDisappear(animated) } - @IBAction func closeTapped(_ sender: Any) { - self.navigationController?.popToDetails() - } - func setProgressSegmentComplete(_ view: UIProgressView?) { UIView.animate(withDuration: 0.7) { view?.setProgress(1, animated: true) @@ -69,7 +99,10 @@ class StakeOnboardingContainerViewController: UIViewController { } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - if segue.identifier == "embed", let dest = segue.destination as? UINavigationController { + if !isStakeOnly, segue.identifier == "embed-delegate", let dest = segue.destination as? UINavigationController { + childNavigationController = dest + + } else if isStakeOnly, segue.identifier == "embed-stake", let dest = segue.destination as? UINavigationController { childNavigationController = dest } } @@ -102,12 +135,16 @@ class StakeOnboardingContainerViewController: UIViewController { case "step4": currentChildVc.performSegue(withIdentifier: "next", sender: nil) + if isStakeOnly { + self.pageIndicator3.setInprogress(pageNumber: 1) + } + case "step5": if handlePageControllerNext(vc: currentChildVc) == true { actionButton.setTitle("Stake", for: .normal) self.pageIndicator3.setComplete() self.setProgressSegmentComplete(self.progressSegment3) - self.pageIndicator4.setInprogress(pageNumber: 4) + self.pageIndicator4.setInprogress(pageNumber: isStakeOnly ? 2 : 4) } case "step6": @@ -135,8 +172,6 @@ class StakeOnboardingContainerViewController: UIViewController { case "step6": self.pageIndicator4.setComplete() - self.setProgressSegmentComplete(self.progressSegment4) - self.pageIndicator5.setInprogress(pageNumber: 5) self.currentChildViewController?.performSegue(withIdentifier: "next", sender: nil) self.actionButton.setTitle("Done", for: .normal) diff --git a/Kukai Mobile/Services/CoinGeckoService.swift b/Kukai Mobile/Services/CoinGeckoService.swift index 92f0c6b5..5e45d2bd 100644 --- a/Kukai Mobile/Services/CoinGeckoService.swift +++ b/Kukai Mobile/Services/CoinGeckoService.swift @@ -323,11 +323,11 @@ public class CoinGeckoService { return numberFormatter.string(from: 0.00) ?? "0" } - public func format(decimal: Decimal, numberStyle: NumberFormatter.Style, maximumFractionDigits: Int? = nil) -> String { + public func format(decimal: Decimal, numberStyle: NumberFormatter.Style, allowNegative: Bool = false, maximumFractionDigits: Int? = nil) -> String { let numberFormatter = sharedNumberFormatter() numberFormatter.numberStyle = numberStyle - guard decimal >= 0 else { + guard decimal >= 0 || allowNegative else { if numberStyle == .decimal { return dashedString() } else { @@ -348,11 +348,11 @@ public class CoinGeckoService { return outputString } - func formatLargeTokenDisplay(_ num: Decimal, decimalPlaces: Int, includeThousand: Bool = false, maximumFractionDigits: Int = 3) -> String { + func formatLargeTokenDisplay(_ num: Decimal, decimalPlaces: Int, includeThousand: Bool = false, allowNegative: Bool, maximumFractionDigits: Int = 3) -> String { var reducedNumber: Decimal = 0 var reducedNumberSymbol: String? = nil - switch num { + switch abs(num) { case 1_000_000_000_000...: reducedNumber = num / 1_000_000_000 reducedNumberSymbol = "t" @@ -378,11 +378,11 @@ public class CoinGeckoService { var stringToReturn = "" if let symbol = reducedNumberSymbol { - stringToReturn = format(decimal: reducedNumber, numberStyle: .decimal, maximumFractionDigits: maximumFractionDigits) + stringToReturn = format(decimal: reducedNumber, numberStyle: .decimal, allowNegative: allowNegative, maximumFractionDigits: maximumFractionDigits) stringToReturn += symbol } else { - stringToReturn = format(decimal: reducedNumber, numberStyle: .decimal, maximumFractionDigits: decimalPlaces) + stringToReturn = format(decimal: reducedNumber, numberStyle: .decimal, allowNegative: allowNegative, maximumFractionDigits: decimalPlaces) } return stringToReturn