@@ -140,48 +140,65 @@ internal class DefaultSendComponent @AssistedInject constructor(
140140 ),
141141 )
142142
143- private fun getAmountComponent (factoryContext : AppComponentContext , route : SendRoute ) = SendAmountComponent (
144- appComponentContext = factoryContext,
145- params = SendAmountComponentParams .AmountParams (
146- state = model.uiState.value.amountUM,
147- currentRoute = currentRoute.filterIsInstance<SendRoute .Amount >(),
148- isBalanceHidingFlow = model.isBalanceHiddenFlow,
149- analyticsCategoryName = SendAnalyticEvents .SEND_CATEGORY ,
150- userWallet = model.userWallet,
151- appCurrency = model.appCurrency,
152- cryptoCurrencyStatus = model.cryptoCurrencyStatus,
153- callback = model,
154- isEditMode = route.isEditMode,
155- predefinedAmountValue = model.predefinedAmountValue,
156- ),
157- )
143+ private fun getAmountComponent (factoryContext : AppComponentContext , route : SendRoute ): ComposableContentComponent {
144+ val cryptoCurrencyStatus = model.cryptoCurrencyStatus
145+ return if (cryptoCurrencyStatus != null ) {
146+ SendAmountComponent (
147+ appComponentContext = factoryContext,
148+ params = SendAmountComponentParams .AmountParams (
149+ state = model.uiState.value.amountUM,
150+ currentRoute = currentRoute.filterIsInstance<SendRoute .Amount >(),
151+ isBalanceHidingFlow = model.isBalanceHiddenFlow,
152+ analyticsCategoryName = SendAnalyticEvents .SEND_CATEGORY ,
153+ userWallet = model.userWallet,
154+ appCurrency = model.appCurrency,
155+ cryptoCurrencyStatus = cryptoCurrencyStatus,
156+ callback = model,
157+ isEditMode = route.isEditMode,
158+ predefinedAmountValue = model.predefinedAmountValue,
159+ ),
160+ )
161+ } else {
162+ model.showAlertError()
163+ getStubComponent()
164+ }
165+ }
158166
167+ @Suppress(" ComplexCondition" )
159168 private fun getFeeComponent (factoryContext : AppComponentContext ): ComposableContentComponent {
160169 val state = model.uiState.value
161170 val sendAmount = (state.amountUM as ? AmountState .Data )?.amountTextField?.cryptoAmount?.value
162171 val destinationAddress = (state.destinationUM as ? DestinationUM .Content )?.addressTextField?.value
163- return if (sendAmount != null && destinationAddress != null ) {
172+ val cryptoCurrencyStatus = model.cryptoCurrencyStatus
173+ val feeCryptoCurrencyStatus = model.feeCryptoCurrencyStatus
174+
175+ return if (sendAmount != null && destinationAddress != null &&
176+ feeCryptoCurrencyStatus != null && cryptoCurrencyStatus != null
177+ ) {
164178 SendFeeComponent (
165179 appComponentContext = factoryContext,
166180 params = SendFeeComponentParams .FeeParams (
167181 state = model.uiState.value.feeUM,
168182 currentRoute = currentRoute.filterIsInstance<SendRoute .Fee >(),
169183 analyticsCategoryName = SendAnalyticEvents .SEND_CATEGORY ,
170184 userWallet = model.userWallet,
171- cryptoCurrencyStatus = model. cryptoCurrencyStatus,
172- feeCryptoCurrencyStatus = model. feeCryptoCurrencyStatus,
185+ cryptoCurrencyStatus = cryptoCurrencyStatus,
186+ feeCryptoCurrencyStatus = feeCryptoCurrencyStatus,
173187 appCurrency = model.appCurrency,
174188 sendAmount = sendAmount,
175189 destinationAddress = destinationAddress,
176190 callback = model,
177191 ),
178192 )
179193 } else {
194+ model.showAlertError()
180195 getStubComponent()
181196 }
182197 }
183198
184- private fun getConfirmComponent (factoryContext : AppComponentContext ): SendConfirmComponent {
199+ private fun getConfirmComponent (factoryContext : AppComponentContext ): ComposableContentComponent {
200+ val cryptoCurrencyStatus = model.cryptoCurrencyStatus
201+ val feeCryptoCurrencyStatus = model.feeCryptoCurrencyStatus
185202 val predefinedAmount = params.amount
186203 val predefinedTxId = params.transactionId
187204 val predefinedAddress = params.destinationAddress
@@ -196,31 +213,44 @@ internal class DefaultSendComponent @AssistedInject constructor(
196213 } else {
197214 SendConfirmComponent .Params .PredefinedValues .Empty
198215 }
199- return SendConfirmComponent (
200- appComponentContext = factoryContext,
201- params = SendConfirmComponent .Params (
202- state = model.uiState.value,
203- userWallet = model.userWallet,
204- currentRoute = currentRoute,
205- isBalanceHidingFlow = model.isBalanceHiddenFlow,
206- analyticsCategoryName = SendAnalyticEvents .SEND_CATEGORY ,
207- cryptoCurrencyStatus = model.cryptoCurrencyStatus,
208- feeCryptoCurrencyStatus = model.feeCryptoCurrencyStatus,
209- appCurrency = model.appCurrency,
210- callback = model,
211- predefinedValues = predefinedValues,
212- ),
213- )
216+ return if (cryptoCurrencyStatus != null && feeCryptoCurrencyStatus != null ) {
217+ SendConfirmComponent (
218+ appComponentContext = factoryContext,
219+ params = SendConfirmComponent .Params (
220+ state = model.uiState.value,
221+ userWallet = model.userWallet,
222+ currentRoute = currentRoute,
223+ isBalanceHidingFlow = model.isBalanceHiddenFlow,
224+ analyticsCategoryName = SendAnalyticEvents .SEND_CATEGORY ,
225+ cryptoCurrencyStatus = cryptoCurrencyStatus,
226+ feeCryptoCurrencyStatus = feeCryptoCurrencyStatus,
227+ appCurrency = model.appCurrency,
228+ callback = model,
229+ predefinedValues = predefinedValues,
230+ ),
231+ )
232+ } else {
233+ model.showAlertError()
234+ getStubComponent()
235+ }
214236 }
215237
216- private fun getStubComponent () = ComposableContentComponent { }
238+ private fun getStubComponent () = StubComponent ()
239+
240+ class StubComponent : ComposableContentComponent {
241+ @Composable
242+ override fun Content (modifier : Modifier ) {
243+ }
244+ }
217245
218246 private fun onChildBack () {
219247 val isEmptyRoute = childStack.value.active.configuration == SendRoute .Empty
220248 val isEmptyStack = childStack.value.backStack.isEmpty()
221249 val isSuccess = model.uiState.value.confirmUM is ConfirmUM .Success
250+ val isStubComponent = childStack.value.active.instance is StubComponent
222251
223- if (isEmptyRoute || isEmptyStack || isSuccess) {
252+ val isPopSend = isEmptyRoute || isEmptyStack || isSuccess || isStubComponent
253+ if (isPopSend) {
224254 router.pop()
225255 } else {
226256 stackNavigation.pop()
0 commit comments