File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -105,4 +105,15 @@ describe('Scheme', () => {
105
105
expect ( listener ) . toHaveBeenCalledTimes ( 1 ) ;
106
106
} ) ;
107
107
} ) ;
108
+
109
+ describe ( 'isDarkMode' , ( ) => {
110
+ it ( 'should return false when app is on light mode' , ( ) => {
111
+ expect ( Scheme . isDarkMode ( ) ) . toBe ( false ) ;
112
+ } ) ;
113
+
114
+ it ( 'should return true when app is on dark mode' , ( ) => {
115
+ Scheme . setScheme ( 'dark' ) ;
116
+ expect ( Scheme . isDarkMode ( ) ) . toBe ( true ) ;
117
+ } ) ;
118
+ } ) ;
108
119
} ) ;
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ export class Colors {
177
177
return validColors ? undefined : results [ 0 ] ;
178
178
}
179
179
180
- shouldReverseOnDark = ( avoidReverseOnDark ?: boolean ) => ! avoidReverseOnDark && this . shouldSupportDarkMode && Scheme . getSchemeType ( ) === 'dark' ;
180
+ shouldReverseOnDark = ( avoidReverseOnDark ?: boolean ) => ! avoidReverseOnDark && this . shouldSupportDarkMode && Scheme . isDarkMode ( ) ;
181
181
182
182
getColorTint ( colorValue : string | OpaqueColorValue , tintKey : string | number , options : GetColorTintOptions = { } ) {
183
183
if ( _ . isUndefined ( tintKey ) || isNaN ( tintKey as number ) || _ . isUndefined ( colorValue ) ) {
Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ class Scheme {
32
32
return scheme ?? 'light' ;
33
33
}
34
34
35
+ /**
36
+ * Whether the app's scheme is 'dark', i.e. is on dark mode
37
+ */
38
+ isDarkMode ( ) {
39
+ return this . getSchemeType ( ) === 'dark' ;
40
+ }
41
+
35
42
/**
36
43
* Set color scheme for app
37
44
* arguments:
You can’t perform that action at this time.
0 commit comments