-
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.
Bump Abacus, update AGP version and fix transfer fee display (#265)
- Loading branch information
Showing
15 changed files
with
116 additions
and
20 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
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
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
34 changes: 34 additions & 0 deletions
34
...n/java/exchange/dydx/trading/feature/receipt/components/fee/DydxReceiptTransferFeeView.kt
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,34 @@ | ||
package exchange.dydx.trading.feature.receipt.components.fee | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import exchange.dydx.platformui.compose.collectAsStateWithLifecycle | ||
import exchange.dydx.platformui.theme.DydxThemedPreviewSurface | ||
import exchange.dydx.trading.common.component.DydxComponent | ||
import exchange.dydx.trading.feature.receipt.components.fee.DydxReceiptBaseFeeView.ViewState | ||
|
||
@Preview | ||
@Composable | ||
fun Preview_DydxReceiptTransferFeeView() { | ||
DydxThemedPreviewSurface { | ||
DydxReceiptTransferFeeView.Content(Modifier, ViewState.preview) | ||
} | ||
} | ||
|
||
object DydxReceiptTransferFeeView : DydxReceiptBaseFeeView(), DydxComponent { | ||
|
||
@Composable | ||
override fun Content(modifier: Modifier) { | ||
val viewModel: DydxReceiptTransferFeeViewModel = hiltViewModel() | ||
|
||
val state = viewModel.state.collectAsStateWithLifecycle(initialValue = null).value | ||
Content(modifier, state) | ||
} | ||
|
||
@Composable | ||
fun Content(modifier: Modifier, state: ViewState?) { | ||
DydxReceiptBaseFeeView.Content(modifier, state) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...a/exchange/dydx/trading/feature/receipt/components/fee/DydxReceiptTransferFeeViewModel.kt
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,47 @@ | ||
package exchange.dydx.trading.feature.receipt.components.fee | ||
|
||
import androidx.lifecycle.ViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import exchange.dydx.abacus.output.input.TransferInput | ||
import exchange.dydx.abacus.protocols.LocalizerProtocol | ||
import exchange.dydx.dydxstatemanager.AbacusStateManagerProtocol | ||
import exchange.dydx.trading.common.DydxViewModel | ||
import exchange.dydx.trading.common.formatter.DydxFormatter | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.distinctUntilChanged | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class DydxReceiptTransferFeeViewModel @Inject constructor( | ||
private val localizer: LocalizerProtocol, | ||
private val abacusStateManager: AbacusStateManagerProtocol, | ||
private val formatter: DydxFormatter, | ||
) : ViewModel(), DydxViewModel { | ||
|
||
val state: Flow<DydxReceiptBaseFeeView.ViewState?> = | ||
abacusStateManager.state.transferInput | ||
.map { | ||
createViewState(it) | ||
} | ||
.distinctUntilChanged() | ||
|
||
private fun createViewState( | ||
transferInput: TransferInput? | ||
): DydxReceiptBaseFeeView.ViewState { | ||
val gasFee = transferInput?.summary?.gasFee | ||
return DydxReceiptBaseFeeView.ViewState( | ||
localizer = localizer, | ||
feeType = "Gas", | ||
feeFont = if (gasFee == null) { | ||
null | ||
} else if (gasFee > 0.0) { | ||
DydxReceiptBaseFeeView.FeeFont.Number( | ||
formatter.dollar(gasFee, 2) ?: "", | ||
) | ||
} else { | ||
DydxReceiptBaseFeeView.FeeFont.String(localizer.localize("APP.GENERAL.FREE")) | ||
}, | ||
) | ||
} | ||
} |
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