@@ -96,62 +96,76 @@ private fun OnRampAmountScreenContent(
9696 onDecimal = { dispatchEvent(OnRampViewModel .Event .OnDecimalPressed ) }
9797 )
9898
99- Box (modifier = Modifier .fillMaxWidth()) {
100- val buttonColors = getButtonColors(state.canAdd, ButtonState . Filled , Color . Unspecified )
101- val (buttonText, assets) = when (provider) {
102- is OnRampProvider . Coinbase -> when (provider.type) {
103- // https://developers.google.com/pay/api/android/guides/brand-guidelines#using-pay-in-text
104- OnRampType . Virtual -> AnnotatedString (stringResource( R .string.action_addCashWithGooglePay)) to emptyMap()
105- OnRampType . PhysicalDebit -> AnnotatedString (stringResource( R .string.action_addCashWithDebitCard)) to emptyMap( )
106- OnRampType . PhysicalCredit -> AnnotatedString (stringResource( R .string.action_addCashWithCreditCard)) to emptyMap()
107- }
99+ ConfirmationButton (
100+ modifier = Modifier
101+ .fillMaxWidth(),
102+ state = state,
103+ provider = provider,
104+ dispatchEvent = dispatchEvent
105+ )
106+ }
107+ }
108108
109- OnRampProvider .Phantom -> buildAnnotatedString {
110- append(stringResource(R .string.label_confirmIn))
111- appendInlineContent(" [icon]" , alternateText = " " )
112- append(stringResource(R .string.label_phantom))
113- } to mapOf (
114- " [icon]" to InlineTextContent (
115- placeholder = Placeholder (
116- width = 25 .sp,
117- height = 14 .sp,
118- placeholderVerticalAlign = PlaceholderVerticalAlign .TextCenter
119- ),
120- children = {
121- Box (
122- modifier = Modifier .fillMaxSize(),
123- contentAlignment = Alignment .Center
124- ) {
125- Image (
126- modifier = Modifier .padding(
127- start = CodeTheme .dimens.staticGrid.x1 + 2 .dp,
128- end = CodeTheme .dimens.staticGrid.x1
129- ),
130- painter = painterResource(R .drawable.ic_phantom),
131- colorFilter = ColorFilter .tint(buttonColors.contentColor(state.canAdd).value),
132- contentDescription = null
133- )
134- }
135- }
136- )
137- )
138- null -> AnnotatedString (stringResource(R .string.action_addCash)) to emptyMap<String , InlineTextContent >()
139- }
140- CodeButton (
141- enabled = state.canAdd,
142- modifier = Modifier
143- .fillMaxWidth()
144- .padding(horizontal = CodeTheme .dimens.inset)
145- .padding(bottom = CodeTheme .dimens.grid.x2)
146- .navigationBarsPadding(),
147- buttonState = ButtonState .Filled ,
148- isLoading = state.confirmingAmount.loading,
149- isSuccess = state.confirmingAmount.success,
150- text = buttonText,
151- inlineContent = assets,
152- ) {
153- dispatchEvent(OnRampViewModel .Event .OnAmountConfirmed )
154- }
109+ @Composable
110+ private fun ConfirmationButton (
111+ state : AmountEntryState ,
112+ provider : OnRampProvider .ThirdParty ? ,
113+ modifier : Modifier = Modifier ,
114+ dispatchEvent : (OnRampViewModel .Event ) -> Unit
115+ ) {
116+ val buttonColors = getButtonColors(state.canAdd, ButtonState .Filled , Color .Unspecified )
117+ val (buttonText, assets) = when (provider) {
118+ is OnRampProvider .Coinbase -> when (provider.type) {
119+ // https://developers.google.com/pay/api/android/guides/brand-guidelines#using-pay-in-text
120+ OnRampType .Virtual -> AnnotatedString (stringResource(R .string.action_addCashWithGooglePay)) to emptyMap()
121+ OnRampType .PhysicalDebit -> AnnotatedString (stringResource(R .string.action_addCashWithDebitCard)) to emptyMap()
122+ OnRampType .PhysicalCredit -> AnnotatedString (stringResource(R .string.action_addCashWithCreditCard)) to emptyMap()
155123 }
124+
125+ OnRampProvider .Phantom -> buildAnnotatedString {
126+ append(stringResource(R .string.label_confirmIn))
127+ appendInlineContent(" [icon]" , alternateText = " " )
128+ append(stringResource(R .string.label_phantom))
129+ } to mapOf (
130+ " [icon]" to InlineTextContent (
131+ placeholder = Placeholder (
132+ width = 25 .sp,
133+ height = 14 .sp,
134+ placeholderVerticalAlign = PlaceholderVerticalAlign .TextCenter
135+ ),
136+ children = {
137+ Box (
138+ modifier = Modifier .fillMaxSize(),
139+ contentAlignment = Alignment .Center
140+ ) {
141+ Image (
142+ modifier = Modifier .padding(
143+ start = CodeTheme .dimens.staticGrid.x1 + 2 .dp,
144+ end = CodeTheme .dimens.staticGrid.x1
145+ ),
146+ painter = painterResource(R .drawable.ic_phantom),
147+ colorFilter = ColorFilter .tint(buttonColors.contentColor(state.canAdd).value),
148+ contentDescription = null
149+ )
150+ }
151+ }
152+ )
153+ )
154+
155+ null -> AnnotatedString (stringResource(R .string.action_addCash)) to emptyMap<String , InlineTextContent >()
156+ }
157+ CodeButton (
158+ enabled = state.canAdd,
159+ modifier = modifier
160+ .padding(horizontal = CodeTheme .dimens.inset)
161+ .padding(bottom = CodeTheme .dimens.grid.x2)
162+ .navigationBarsPadding(),
163+ buttonState = ButtonState .Filled ,
164+ isLoading = state.confirmingAmount.loading,
165+ isSuccess = state.confirmingAmount.success,
166+ text = buttonText,
167+ inlineContent = assets,
168+ ) {
169+ dispatchEvent(OnRampViewModel .Event .OnAmountConfirmed )
156170 }
157171}
0 commit comments