File tree Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Original file line number Diff line number Diff line change
1
+ import { SchemeType } from '../style' ;
1
2
interface ConfigOptions {
2
3
/**
3
4
* Should use platform colors for design tokens
4
5
*/
5
6
usePlatformColors ?: boolean ;
7
+ /**
8
+ * The app's colors scheme (default | light | dark)
9
+ */
10
+ appScheme ?: SchemeType ;
6
11
}
7
12
8
13
class Config {
9
14
usePlatformColors ?: boolean ;
15
+ appScheme : SchemeType = 'light' ;
10
16
11
17
constructor ( ) {
12
18
this . setConfig ( { } ) ;
13
19
}
14
20
15
21
public setConfig ( options : ConfigOptions ) {
16
- const { usePlatformColors = false } = options ;
22
+ const { usePlatformColors = false , appScheme = 'light' } = options ;
17
23
this . usePlatformColors = usePlatformColors ;
24
+ this . appScheme = appScheme ;
18
25
}
19
26
}
20
27
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ describe('Scheme', () => {
10
10
expect ( Scheme . schemes ) . toEqual ( { dark : { } , light : { } } ) ;
11
11
} ) ;
12
12
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 ' ) ;
15
15
} ) ;
16
16
17
17
it ( 'should retrieve actual scheme type (defaulting to "light")' , ( ) => {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import {OpaqueColorValue} from 'react-native';
5
5
import tinycolor from 'tinycolor2' ;
6
6
import { colorsPalette , themeColors } from './colorsPalette' ;
7
7
import DesignTokens from './designTokens' ;
8
- // import DesignTokensDM from './designTokensDM';
8
+ import DesignTokensDM from './designTokensDM' ;
9
9
//@ts -ignore
10
10
import ColorName from './colorName' ;
11
11
import Scheme , { Schemes , SchemeType } from './scheme' ;
@@ -17,9 +17,7 @@ export class Colors {
17
17
constructor ( ) {
18
18
const colors = Object . assign ( colorsPalette , themeColors ) ;
19
19
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 } ) ;
23
21
24
22
Scheme . addChangeListener ( ( ) => {
25
23
Object . assign ( this , Scheme . getScheme ( ) ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export type SchemeType = 'default' | 'light' | 'dark';
8
8
export type SchemeChangeListener = ( schemeType ?: 'light' | 'dark' ) => void ;
9
9
10
10
class Scheme {
11
- private currentScheme : SchemeType = 'default' ;
11
+ private currentScheme : SchemeType = Config . appScheme ;
12
12
private schemes : Schemes = { light : { } , dark : { } } ;
13
13
private changeListeners : SchemeChangeListener [ ] = [ ] ;
14
14
You can’t perform that action at this time.
0 commit comments