Skip to content

Commit 1adcbf7

Browse files
committed
Infra/ add appScheme to config (#1973)
* Infra/ add appScheme to config * update test
1 parent 5389e1d commit 1adcbf7

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/commons/Config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1+
import {SchemeType} from '../style';
12
interface ConfigOptions {
23
/**
34
* Should use platform colors for design tokens
45
*/
56
usePlatformColors?: boolean;
7+
/**
8+
* The app's colors scheme (default | light | dark)
9+
*/
10+
appScheme?: SchemeType;
611
}
712

813
class Config {
914
usePlatformColors?: boolean;
15+
appScheme: SchemeType = 'light';
1016

1117
constructor() {
1218
this.setConfig({});
1319
}
1420

1521
public setConfig(options: ConfigOptions) {
16-
const {usePlatformColors = false} = options;
22+
const {usePlatformColors = false, appScheme = 'light'} = options;
1723
this.usePlatformColors = usePlatformColors;
24+
this.appScheme = appScheme;
1825
}
1926
}
2027

src/style/__tests__/scheme.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('Scheme', () => {
1010
expect(Scheme.schemes).toEqual({dark: {}, light: {}});
1111
});
1212

13-
it('should initial current scheme type be "default"', () => {
14-
expect(Scheme.currentScheme).toBe('default');
13+
it('should initial current scheme type be "light"', () => {
14+
expect(Scheme.currentScheme).toBe('light');
1515
});
1616

1717
it('should retrieve actual scheme type (defaulting to "light")', () => {

src/style/colors.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {OpaqueColorValue} from 'react-native';
55
import tinycolor from 'tinycolor2';
66
import {colorsPalette, themeColors} from './colorsPalette';
77
import DesignTokens from './designTokens';
8-
// import DesignTokensDM from './designTokensDM';
8+
import DesignTokensDM from './designTokensDM';
99
//@ts-ignore
1010
import ColorName from './colorName';
1111
import Scheme, {Schemes, SchemeType} from './scheme';
@@ -17,9 +17,7 @@ export class Colors {
1717
constructor() {
1818
const colors = Object.assign(colorsPalette, themeColors);
1919
Object.assign(this, colors);
20-
// TODO: For now we load the same design tokens for both schemes to not force it until it's ready
21-
this.loadSchemes({light: DesignTokens, dark: DesignTokens});
22-
// this.loadSchemes({light: DesignTokens, dark: DesignTokensDM});
20+
this.loadSchemes({light: DesignTokens, dark: DesignTokensDM});
2321

2422
Scheme.addChangeListener(() => {
2523
Object.assign(this, Scheme.getScheme());

src/style/scheme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type SchemeType = 'default' | 'light' | 'dark';
88
export type SchemeChangeListener = (schemeType?: 'light' | 'dark') => void;
99

1010
class Scheme {
11-
private currentScheme: SchemeType = 'default';
11+
private currentScheme: SchemeType = Config.appScheme;
1212
private schemes: Schemes = {light: {}, dark: {}};
1313
private changeListeners: SchemeChangeListener[] = [];
1414

0 commit comments

Comments
 (0)