The SaveCardBox
component is used to determine if the user wants to save the card details.
Optional component; can be replaced by your own implementation that invokes the following function:
PaymentProcessor.setSaveCard to set the switch state and
PaymentProcessor.canSaveCards to check if the user can save the card.
Parameters
Parameter | Description |
---|---|
modifier |
The modifier to be applied to the layout. |
fontSize |
The font size of the text. |
fontWeight |
The font weight of the text. |
defaultState |
The default state of the switch. |
Example Usage
Compose Multiplatform
SaveCardBox(
modifier = Modifier,
fontSize = 16.sp,
fontWeight = ComponentFontWeight.BOLD,
defaultState = false,
)
Android View
<com.accesspaysuite.mobilesdk.ui.save.SaveCardView
android:id="@+id/saveCards"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
val saveCards = findViewById<SaveCardView>(R.id.saveCards)
saveCards.init(
state = SaveCardState(),
onCheck = { isChecked ->
// Handle the switch state change
}
)
iOS
Create the Controller Representable
import SwiftUI
import mobilesdk
struct SaveCardBoxControllerRepresentable: UIViewControllerRepresentable {
@Binding var state: SaveCardState
init(state: Binding) {
self._state = state
}
func makeUIViewController(context: Context) -> UIViewController {
return SaveCardBoxController().make()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
SaveCardBoxController().update(state: state)
}
}
Create the SaveCardsBox View
import SwiftUI
import mobilesdk
struct SaveCardsBox: View {
@Binding var state: SaveCardsState
init(state: Binding) {
self._state = state
}
var body: some View {
SaveCardBoxControllerRepresentable(state: $state)
}
}
Use the SaveCardsBox View
import SwiftUI
import mobilesdk
struct PaymentView: View {
@State private var state = SaveCardsState()
var body: some View {
SaveCardsBox(
state: $state
)
}
}