Skip to content

Commit

Permalink
SDK-2486: Add support for dark mode to be set at sdk config creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Lukyanau committed Sep 22, 2024
1 parent 013d2f7 commit 28d16b5
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class SdkConfig {
@JsonProperty(Property.FONT_COLOUR)
private final String fontColour;

@JsonProperty(Property.DARK_MODE)
private final String darkMode;

@JsonProperty(Property.LOCALE)
private final String locale;

Expand Down Expand Up @@ -54,6 +57,7 @@ public class SdkConfig {
String secondaryColour,
String fontColour,
String locale,
String darkMode,
String presetIssuingCountry,
String successUrl,
String errorUrl,
Expand All @@ -66,6 +70,7 @@ public class SdkConfig {
this.secondaryColour = secondaryColour;
this.fontColour = fontColour;
this.locale = locale;
this.darkMode = darkMode;
this.presetIssuingCountry = presetIssuingCountry;
this.successUrl = successUrl;
this.errorUrl = errorUrl;
Expand Down Expand Up @@ -133,6 +138,15 @@ public String getLocale() {
return locale;
}

/**
* The dark mode
*
* @return the dark mode
*/
public String getDarkMode() {
return darkMode;
}

/**
* The preset issuing country
*
Expand Down Expand Up @@ -207,6 +221,7 @@ public static class Builder {
private String secondaryColour;
private String fontColour;
private String locale;
private String darkMode;
private String presetIssuingCountry;
private String successUrl;
private String errorUrl;
Expand Down Expand Up @@ -301,6 +316,47 @@ public Builder withLocale(String locale) {
return this;
}

/**
* Sets the dark mode to be used by the web/native client
*
* @param darkMode the dark mode, e.g. "ON"
* @return the builder
*/
public Builder withDarkMode(String darkMode) {
this.darkMode = darkMode;
return this;
}

/**
* Sets the dark mode to 'ON' to be used by the web/native client
*
* @return the builder
*/
public Builder withDarkModeOn() {
this.darkMode = "ON";
return this;
}

/**
* Sets the dark mode to 'OFF' to be used by the web/native client
*
* @return the builder
*/
public Builder withDarkModeOff() {
this.darkMode = "OFF";
return this;
}

/**
* Sets the dark mode to 'AUTO' to be used by the web/native client
*
* @return the builder
*/
public Builder withDarkModeAuto() {
this.darkMode = "AUTO";
return this;
}

/**
* Sets the preset issuing country used by the web/native client
*
Expand Down Expand Up @@ -391,6 +447,7 @@ public SdkConfig build() {
secondaryColour,
fontColour,
locale,
darkMode,
presetIssuingCountry,
successUrl,
errorUrl,
Expand All @@ -409,6 +466,7 @@ private static final class Property {
private static final String PRIMARY_COLOUR_DARK_MODE = "primary_colour_dark_mode";
private static final String SECONDARY_COLOUR = "secondary_colour";
private static final String FONT_COLOUR = "font_colour";
private static final String DARK_MODE = "dark_mode";
private static final String LOCALE = "locale";
private static final String PRESET_ISSUING_COUNTRY = "preset_issuing_country";
private static final String SUCCESS_URL = "success_url";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class SdkConfigTest {
private static final String SOME_SECONDARY_COLOUR = "#679bdd";
private static final String SOME_FONT_COLOUR = "#b40c12";
private static final String SOME_LOCALE = "en";
private static final String SOME_DARK_MODE = "ON";
private static final String SOME_PRESET_ISSUING_COUNTRY = "USA";
private static final String SOME_BRAND_ID = "someBrandId";

Expand All @@ -35,6 +36,7 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() {
.withSecondaryColour(SOME_SECONDARY_COLOUR)
.withFontColour(SOME_FONT_COLOUR)
.withLocale(SOME_LOCALE)
.withDarkMode(SOME_DARK_MODE)
.withPresetIssuingCountry(SOME_PRESET_ISSUING_COUNTRY)
.withSuccessUrl(SOME_SUCCESS_URL)
.withErrorUrl(SOME_ERROR_URL)
Expand All @@ -52,6 +54,7 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() {
assertThat(result.getSecondaryColour(), is(SOME_SECONDARY_COLOUR));
assertThat(result.getFontColour(), is(SOME_FONT_COLOUR));
assertThat(result.getLocale(), is(SOME_LOCALE));
assertThat(result.getDarkMode(), is(SOME_DARK_MODE));
assertThat(result.getPresetIssuingCountry(), is(SOME_PRESET_ISSUING_COUNTRY));
assertThat(result.getSuccessUrl(), is(SOME_SUCCESS_URL));
assertThat(result.getErrorUrl(), is(SOME_ERROR_URL));
Expand Down Expand Up @@ -97,5 +100,31 @@ public void shouldOverridePreviousAllowedCaptureMethods() {
assertThat(result.getAllowedCaptureMethods(), is("CAMERA"));
}

@Test
public void shouldSetDarkModeToOn() {
SdkConfig result = SdkConfig.builder()
.withDarkModeOn()
.build();

assertThat(result.getDarkMode(), is("ON"));
}

@Test
public void shouldSetDarkModeToOff() {
SdkConfig result = SdkConfig.builder()
.withDarkModeOff()
.build();

assertThat(result.getDarkMode(), is("OFF"));
}

@Test
public void shouldSetDarkModeToAuto() {
SdkConfig result = SdkConfig.builder()
.withDarkModeAuto()
.build();

assertThat(result.getDarkMode(), is("AUTO"));
}

}

0 comments on commit 28d16b5

Please sign in to comment.