Skip to content

Commit ec18bef

Browse files
author
Artem Lukyanau
committed
SDK-2486: Add support for dark mode to be set at sdk config creation
1 parent 721a8cf commit ec18bef

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/DocScanConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,8 @@ private DocScanConstants() { }
8686
public static final String EAGER = "EAGER";
8787
public static final String JUST_IN_TIME = "JUST_IN_TIME";
8888

89+
public static final String ON = "ON";
90+
public static final String OFF = "OFF";
91+
public static final String AUTO = "AUTO";
92+
8993
}

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class SdkConfig {
2424
@JsonProperty(Property.FONT_COLOUR)
2525
private final String fontColour;
2626

27+
@JsonProperty(Property.DARK_MODE)
28+
private final String darkMode;
29+
2730
@JsonProperty(Property.LOCALE)
2831
private final String locale;
2932

@@ -57,6 +60,7 @@ public class SdkConfig {
5760
String secondaryColour,
5861
String fontColour,
5962
String locale,
63+
String darkMode,
6064
String presetIssuingCountry,
6165
String successUrl,
6266
String errorUrl,
@@ -71,6 +75,7 @@ public class SdkConfig {
7175
this.secondaryColour = secondaryColour;
7276
this.fontColour = fontColour;
7377
this.locale = locale;
78+
this.darkMode = darkMode;
7479
this.presetIssuingCountry = presetIssuingCountry;
7580
this.successUrl = successUrl;
7681
this.errorUrl = errorUrl;
@@ -104,7 +109,7 @@ public String getPrimaryColour() {
104109
}
105110

106111
/**
107-
* The primary colour for the dark mode
112+
* The primary colour for dark mode, configured for the session
108113
*
109114
* @return the primary colour
110115
*/
@@ -139,6 +144,15 @@ public String getLocale() {
139144
return locale;
140145
}
141146

147+
/**
148+
* The dark mode option configured for the session
149+
*
150+
* @return the dark mode
151+
*/
152+
public String getDarkMode() {
153+
return darkMode;
154+
}
155+
142156
/**
143157
* The preset issuing country
144158
*
@@ -222,6 +236,7 @@ public static class Builder {
222236
private String secondaryColour;
223237
private String fontColour;
224238
private String locale;
239+
private String darkMode;
225240
private String presetIssuingCountry;
226241
private String successUrl;
227242
private String errorUrl;
@@ -317,6 +332,47 @@ public Builder withLocale(String locale) {
317332
return this;
318333
}
319334

335+
/**
336+
* Sets the dark mode to be used by the web/native client
337+
*
338+
* @param darkMode the dark mode, e.g. "ON"
339+
* @return the builder
340+
*/
341+
public Builder withDarkMode(String darkMode) {
342+
this.darkMode = darkMode;
343+
return this;
344+
}
345+
346+
/**
347+
* Sets the dark mode to 'ON' to be used by the web/native client
348+
*
349+
* @return the builder
350+
*/
351+
public Builder withDarkModeOn() {
352+
this.darkMode = DocScanConstants.ON;
353+
return this;
354+
}
355+
356+
/**
357+
* Sets the dark mode to 'OFF' to be used by the web/native client
358+
*
359+
* @return the builder
360+
*/
361+
public Builder withDarkModeOff() {
362+
this.darkMode = DocScanConstants.OFF;
363+
return this;
364+
}
365+
366+
/**
367+
* Sets the dark mode to 'AUTO' to be used by the web/native client
368+
*
369+
* @return the builder
370+
*/
371+
public Builder withDarkModeAuto() {
372+
this.darkMode = DocScanConstants.AUTO;
373+
return this;
374+
}
375+
320376
/**
321377
* Sets the preset issuing country used by the web/native client
322378
*
@@ -436,6 +492,7 @@ public SdkConfig build() {
436492
secondaryColour,
437493
fontColour,
438494
locale,
495+
darkMode,
439496
presetIssuingCountry,
440497
successUrl,
441498
errorUrl,
@@ -455,6 +512,7 @@ private static final class Property {
455512
private static final String PRIMARY_COLOUR_DARK_MODE = "primary_colour_dark_mode";
456513
private static final String SECONDARY_COLOUR = "secondary_colour";
457514
private static final String FONT_COLOUR = "font_colour";
515+
private static final String DARK_MODE = "dark_mode";
458516
private static final String LOCALE = "locale";
459517
private static final String PRESET_ISSUING_COUNTRY = "preset_issuing_country";
460518
private static final String SUCCESS_URL = "success_url";

yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class SdkConfigTest {
1717
private static final String SOME_SECONDARY_COLOUR = "#679bdd";
1818
private static final String SOME_FONT_COLOUR = "#b40c12";
1919
private static final String SOME_LOCALE = "en";
20+
private static final String SOME_DARK_MODE = "ON";
2021
private static final String SOME_PRESET_ISSUING_COUNTRY = "USA";
2122
private static final String SOME_BRAND_ID = "someBrandId";
2223

@@ -35,6 +36,7 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() {
3536
.withSecondaryColour(SOME_SECONDARY_COLOUR)
3637
.withFontColour(SOME_FONT_COLOUR)
3738
.withLocale(SOME_LOCALE)
39+
.withDarkMode(SOME_DARK_MODE)
3840
.withPresetIssuingCountry(SOME_PRESET_ISSUING_COUNTRY)
3941
.withSuccessUrl(SOME_SUCCESS_URL)
4042
.withErrorUrl(SOME_ERROR_URL)
@@ -52,6 +54,7 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() {
5254
assertThat(result.getSecondaryColour(), is(SOME_SECONDARY_COLOUR));
5355
assertThat(result.getFontColour(), is(SOME_FONT_COLOUR));
5456
assertThat(result.getLocale(), is(SOME_LOCALE));
57+
assertThat(result.getDarkMode(), is(SOME_DARK_MODE));
5558
assertThat(result.getPresetIssuingCountry(), is(SOME_PRESET_ISSUING_COUNTRY));
5659
assertThat(result.getSuccessUrl(), is(SOME_SUCCESS_URL));
5760
assertThat(result.getErrorUrl(), is(SOME_ERROR_URL));
@@ -115,5 +118,31 @@ public void shouldOverridePreviousAllowedCaptureMethods() {
115118
assertThat(result.getAllowedCaptureMethods(), is("CAMERA"));
116119
}
117120

121+
@Test
122+
public void shouldSetDarkModeToOn() {
123+
SdkConfig result = SdkConfig.builder()
124+
.withDarkModeOn()
125+
.build();
126+
127+
assertThat(result.getDarkMode(), is("ON"));
128+
}
129+
130+
@Test
131+
public void shouldSetDarkModeToOff() {
132+
SdkConfig result = SdkConfig.builder()
133+
.withDarkModeOff()
134+
.build();
135+
136+
assertThat(result.getDarkMode(), is("OFF"));
137+
}
138+
139+
@Test
140+
public void shouldSetDarkModeToAuto() {
141+
SdkConfig result = SdkConfig.builder()
142+
.withDarkModeAuto()
143+
.build();
144+
145+
assertThat(result.getDarkMode(), is("AUTO"));
146+
}
118147

119148
}

0 commit comments

Comments
 (0)