Skip to content

Commit

Permalink
update demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
saperi22 committed Mar 12, 2024
1 parent 51ae8dc commit 11dad0c
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.paypal.android.ui.paypalbuttons

import android.content.Context
import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -19,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.viewinterop.AndroidView
Expand Down Expand Up @@ -154,7 +157,11 @@ fun PayPalButtonFactory(uiState: PayPalButtonsUiState) {
ButtonFundingType.PAYPAL -> {
AndroidView(
factory = { context ->
PayPalButton(context)
PayPalButton(context).apply {
setOnClickListener {
showToast(context, "PayPalButton clicked!")
}
}
},
update = { button ->
configureButton(button, uiState)
Expand All @@ -166,7 +173,11 @@ fun PayPalButtonFactory(uiState: PayPalButtonsUiState) {
ButtonFundingType.PAY_LATER -> {
AndroidView(
factory = { context ->
PayLaterButton(context)
PayLaterButton(context).apply {
setOnClickListener {
showToast(context, "PayLaterButton clicked!")
}
}
},
update = { button ->
configureButton(button, uiState)
Expand All @@ -178,7 +189,11 @@ fun PayPalButtonFactory(uiState: PayPalButtonsUiState) {
ButtonFundingType.PAYPAL_CREDIT -> {
AndroidView(
factory = { context ->
PayPalCreditButton(context)
PayPalCreditButton(context).apply {
setOnClickListener {
showToast(context, "PayPalCreditButton clicked!")
}
}
},
update = { button ->
configureButton(button, uiState)
Expand Down Expand Up @@ -237,6 +252,10 @@ fun PayPalButtonColorOptionListFactory(
}
}

private fun showToast(context: Context, message: String) {
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
}

@ExperimentalMaterial3Api
@Preview
@Composable
Expand Down

0 comments on commit 11dad0c

Please sign in to comment.