-
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.
CLI-629: vault landing screen floating buttons & CLI-630: deposit/wit…
…hdraw screen (#242) * add withdraw/deposit buttons * font size adjustment * stubbed withdraw/deposit screen * enabled/disabled button states/texts --------- Co-authored-by: Mike <[email protected]>
- Loading branch information
Showing
11 changed files
with
440 additions
and
60 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
95 changes: 95 additions & 0 deletions
95
...dydxPresenters/_v4/Vault/DepositsAndWithdrawals/dydxVaultDepositWithdrawViewBuilder.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,95 @@ | ||
// | ||
// dydxVaultDepositWithdrawViewBuilder.swift | ||
// dydxPresenters | ||
// | ||
// Created by Michael Maguire on 8/22/24. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
import dydxStateManager | ||
import FloatingPanel | ||
import PlatformRouting | ||
import dydxFormatter | ||
|
||
public class dydxVaultDepositWithdrawViewBuilder: NSObject, ObjectBuilderProtocol { | ||
public func build<T>() -> T? { | ||
let presenter = dydxVaultDepositWithdrawViewPresenter() | ||
let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() | ||
let viewController = dydxVaultDepositWithdrawViewController(presenter: presenter, view: view, configuration: .default) | ||
return viewController as? T | ||
} | ||
} | ||
|
||
private class dydxVaultDepositWithdrawViewController: HostingViewController<PlatformView, dydxVaultDepositWithdrawViewModel> { | ||
|
||
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { | ||
let presenter = presenter as? dydxVaultDepositWithdrawViewPresenterProtocol | ||
if request?.path == "/vault/deposit" { | ||
presenter?.transferType = .deposit | ||
return true | ||
} else if request?.path == "/vault/withdraw" { | ||
presenter?.transferType = .withdraw | ||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
} | ||
|
||
private protocol dydxVaultDepositWithdrawViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxVaultDepositWithdrawViewModel? { get } | ||
var transferType: VaultTransferType { get set } | ||
} | ||
|
||
private class dydxVaultDepositWithdrawViewPresenter: HostedViewPresenter<dydxVaultDepositWithdrawViewModel>, dydxVaultDepositWithdrawViewPresenterProtocol { | ||
var transferType: VaultTransferType = .deposit | ||
|
||
override init() { | ||
let viewModel = dydxVaultDepositWithdrawViewModel(selectedTransferType: transferType, submitState: .disabled) | ||
|
||
super.init() | ||
|
||
self.viewModel = viewModel | ||
} | ||
|
||
override func start() { | ||
super.start() | ||
|
||
//TODO: replace with real hooks from abacus | ||
update() | ||
} | ||
|
||
//TODO: replace with real data from abacus | ||
func update() { | ||
var newInputReceiptChangeItems = [dydxReceiptChangeItemView]() | ||
var newButtonReceiptChangeItems = [dydxReceiptChangeItemView]() | ||
|
||
newInputReceiptChangeItems.append(dydxReceiptChangeItemView(title: DataLocalizer.localize(path: "APP.VAULTS.YOUR_VAULT_BALANCE"), | ||
value: AmountChangeModel(before: AmountTextModel(amount: 30.01), | ||
after: AmountTextModel(amount: 30.02)))) | ||
|
||
newButtonReceiptChangeItems.append(.init(title: DataLocalizer.localize(path: "APP.GENERAL.CROSS_FREE_COLLATERAL"), | ||
value: AmountChangeModel(before: AmountTextModel(amount: 30.01), | ||
after: AmountTextModel(amount: 30.02)))) | ||
|
||
newButtonReceiptChangeItems.append(.init(title: DataLocalizer.localize(path: "APP.VAULTS.EST_SLIPPAGE"), | ||
value: AmountChangeModel(before: AmountTextModel(amount: 30.01), | ||
after: AmountTextModel(amount: 30.02)))) | ||
|
||
newButtonReceiptChangeItems.append(.init(title: DataLocalizer.localize(path: "APP.WITHDRAW_MODAL.EXPECTED_AMOUNT_RECEIVED"), | ||
value: AmountChangeModel(before: AmountTextModel(amount: 30.01), | ||
after: AmountTextModel(amount: 30.02)))) | ||
|
||
viewModel?.inputReceiptChangeItems = newInputReceiptChangeItems | ||
viewModel?.buttonReceiptChangeItems = newButtonReceiptChangeItems | ||
|
||
viewModel?.inputInlineAlert = InlineAlertViewModel(InlineAlertViewModel.Config.init(title: "test alert", | ||
body: "test bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest bodytest body", | ||
level: .error)) | ||
} | ||
} |
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
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.