UI Customization on iOS
Introduction
Appearance for the UI elements provided by the SDK can be customized completely or partially by creating Appearance
object,
modifying its properties and applying it to Wallet.instance
.
Certain components offer complete appearance overrides, enabling you to detach their styles from the global appearance.
While this approach requires more detailed configuration, it offers enhanced flexibility for creating unique designs.
Appearance
var appearance = Appearance.defaultAppearance
appearance.cornerRadius = Appearance.CornerRadius(small: 1, medium: 4, large: 8)
appearance.fonts = Appearance.Fonts(text1: UIFont.italicSystemFont(ofSize: 14),
text2: UIFont.boldSystemFont(ofSize: 14))
appearance.colors.background.base = .lightGray
Wallet.instance.setAppearance(appearance)
Appearance should be configured once before using any UI provided by the SDK.
Customize individual components
Certain components offer complete appearance overrides, enabling you to detach their styles from the global appearance. Here's how you configure individual components style configurations.
Wallet.instance.setAppearance(Appearance.defaultAppearance)
Wallet.instance.setStyleConfigurations(
.init(buttonStyleConfigurations: buttonStyleConfigs,
textFieldStyleConfiguration: textFieldStyleConfig,
checkboxStyleConfiguration: checkboxStyleConfig,
linksLabelStyleConfiguration: linksLabelStyleConfig
)
)
You can customize only some of the components if you want.
Wallet.instance.setAppearance(Appearance.defaultAppearance)
Wallet.instance.setStyleConfigurations(
.init(buttonStyleConfigurations: buttonStyleConfigs,
textFieldStyleConfiguration: textFieldStyleConfig
)
)
Bellow are more details about each components customization.
Button
The Button
component provides the following customization options:
colors
- Configurebackground
,foreground
, andborder
colors for various UI states, includingnormal
,pressed
,disabled
, andloading
.font
- Set the font used within the component.cornerRadius
- Adjust the cornerRadius to modify the button's shape.borderWidth
- Define the borderWidth for the button's outline.contentEdgeInsets
- Customize contentEdgeInsets to control padding within the button
let primaryButtonStyleConfig = StyleConfigurations.ButtonStyleConfiguration(
titleTextStyle: .subtitle2,
enabledColors: .init(background: .green, foreground: .white, border: .clear),
pressedColors: .init(background: .systemGreen, foreground: .white, border: .clear),
disabledColors: .init(background: .gray, foreground: .white, border: .clear),
loadingColors: .init(background: .gray, foreground: .white, border: .clear),
contentEdgeInsets: .init(top: 8, left: 16, bottom: 8, right: 16),
cornerRadius: 2,
borderWidth: 4
)
// ... secondaryButtonStyleConfig
let buttonStyleConfigs: StyleConfigurations.ButtonStyleConfigurations = .init(
primary: primaryButtonStyleConfig,
secondary: secondaryButtonStyleConfig
)
TextField
The TextField
component allows customizing the following: