1 min read

Common customisations

Create new fields

If you need to create a new field, for a new country form or for an existing one, you need to:

  • Define an id for you new field or reuse an existing one. If you reuse the same id for 2 fields, i.e. same field on different country forms, they will share the same value.
  • Initialize your new fields states using InitTextFieldMaps
  • Use getValue to get the value of your new field from SaveAddressFormDTO.textFieldMap. the error from SaveAddressFormDTO.textFieldErrorMap and create the Composable with these values.

Create new validations

If you have a new field and you want to add validations to it, you need to:

  • Create your new ValidationField using the field id as the id for the validtion field.
  • Return your new list of validations from your country from or send it to an existing one via SaveAddressFormDTO.extraValidations.

Modify existing validations

If you want to modify existing field validations, you need to:

  • Delete the existing validation from the returning List<ValidationField<*> extending the specific country form or overriding PoqSaveAddressScreen.addressCountryFormSelector
  • Create you new validation using the same id and include it to the returning validation list.

Add extra fields to all or specific country forms

The different country forms, and BaseSaveAddressForm, have composable slots to include new fields. To use them, you need to:

  • Extend PoqSaveAddressScreen and override the function addressCountryFormSelector.
  • Create your new fields and add them to the appropriate slot included in SaveAddressFormDTO.
  • Create the fields validations and add them to SaveAddressFormDTO.extraValidations.

From PoqSaveAddressScreen.addressCountryFormSelector you have the choice to include your new fields to all country forms or only when saveAddressFormDTO.addressState.countryCode matches with the country code you want to modify.

New Country form

SaveAddressScreen supports specific forms per country. If you want to create a new form for a country, you need to:

  • Create a new Composable that returns Pair<List<ValidationField<*>>, Address> where List<ValidationField<*>> are the validations to be performed on your new fields and Address is the address to be saved.
  • Extend PoqSaveAddressScreen and override the function addressCountryFormSelector.
  • Compare saveAddressFormDTO.addressState.countryCode with your country code and call your new Composable form.

Remove fields from BaseSaveAddressForm

BaseSaveAddressForm, the common Composable to all forms screens, allows remove its fields. To do so you only need to send null on the appropiate label on BaseSaveAddressLabels. If you need to remove fields from a specific country, you can decorate BaseSaveAddressForm passing null on the appropiate labels when saveAddressFormDTO.addressState.countryCode matches with your desired country.