-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mike/trcl 3314 trading rewards profile card (#36)
* refactor fees card with reusable title card view * refactor history view to use dydxTitledCardView * change name for profile "rewards" -> "balances" card * do not wrap "reduce-only" text * add rewards card to profile landing screen * add comment * reorder cards * clean up * set up presenter view model links
- Loading branch information
Showing
12 changed files
with
400 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...dxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileBalancesViewPresenter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// dydxProfileBalancesViewPresenter.swift | ||
// dydxPresenters | ||
// | ||
// Created by Rui Huang on 9/18/23. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
import Abacus | ||
import dydxStateManager | ||
import dydxFormatter | ||
import Combine | ||
|
||
public protocol dydxProfileBalancesViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxProfileBalancesViewModel? { get } | ||
} | ||
|
||
public class dydxProfileBalancesViewPresenter: HostedViewPresenter<dydxProfileBalancesViewModel>, dydxProfileBalancesViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxProfileBalancesViewModel() | ||
viewModel?.nativeTokenName = dydxTokenConstants.nativeTokenName | ||
viewModel?.nativeTokenLogoUrl = dydxTokenConstants.nativeTokenLogoUrl | ||
} | ||
|
||
public override func start() { | ||
super.start() | ||
|
||
AbacusStateManager.shared.state.accountBalance(of: .dydx) | ||
.sink { [weak self] dydxAmount in | ||
if let dydxAmount = dydxAmount { | ||
self?.viewModel?.walletAmount = dydxFormatter.shared.raw(number: Parser.standard.asNumber(dydxAmount), digits: 4) | ||
self?.viewModel?.transferAction = { | ||
Router.shared?.navigate(to: RoutingRequest(path: "/transfer", params: ["section": "transferOut"]), animated: true, completion: nil) | ||
} | ||
} else { | ||
self?.viewModel?.walletAmount = "-" | ||
self?.viewModel?.transferAction = nil | ||
} | ||
} | ||
.store(in: &subscriptions) | ||
|
||
AbacusStateManager.shared.state.stakingBalance(of: .dydx) | ||
.sink { [weak self] dydxAmount in | ||
if let dydxAmount = dydxAmount { | ||
self?.viewModel?.stakedAmount = dydxFormatter.shared.raw(number: Parser.standard.asNumber(dydxAmount), digits: 4) | ||
} else { | ||
self?.viewModel?.stakedAmount = "-" | ||
} | ||
} | ||
.store(in: &subscriptions) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.