1
1
// @flow strict-local
2
2
import React , { useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
3
3
import type { Node } from 'react' ;
4
- import { AccessibilityInfo , View , Animated , LayoutAnimation , Platform , Easing } from 'react-native' ;
4
+ import {
5
+ AccessibilityInfo ,
6
+ View ,
7
+ Animated ,
8
+ LayoutAnimation ,
9
+ Platform ,
10
+ Easing ,
11
+ useColorScheme ,
12
+ } from 'react-native' ;
5
13
import NetInfo from '@react-native-community/netinfo' ;
6
14
import { SafeAreaView } from 'react-native-safe-area-context' ;
7
15
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes' ;
@@ -10,6 +18,7 @@ import type { DimensionValue } from 'react-native/Libraries/StyleSheet/StyleShee
10
18
import * as logging from '../utils/logging' ;
11
19
import { useDispatch , useGlobalSelector } from '../react-redux' ;
12
20
import { getGlobalSession , getGlobalSettings } from '../directSelectors' ;
21
+ import { getThemeToUse } from '../settings/settingsSelectors' ;
13
22
import { useHasStayedTrueForMs , usePrevious } from '../reactUtils' ;
14
23
import type { JSONableDict } from '../utils/jsonable' ;
15
24
import { createStyleSheet } from '../styles' ;
@@ -148,6 +157,8 @@ const backgroundColorForTheme = (theme: ThemeName): string =>
148
157
*/
149
158
export function OfflineNoticeProvider ( props : ProviderProps ) : Node {
150
159
const theme = useGlobalSelector ( state => getGlobalSettings ( state ) . theme ) ;
160
+ const osScheme = useColorScheme ( ) ;
161
+ const themeToUse = getThemeToUse ( theme , osScheme ) ;
151
162
const _ = useContext ( TranslationContext ) ;
152
163
const isOnline = useGlobalSelector ( state => getGlobalSession ( state ) . isOnline ) ;
153
164
const shouldShowUncertaintyNotice = useShouldShowUncertaintyNotice ( ) ;
@@ -249,7 +260,7 @@ export function OfflineNoticeProvider(props: ProviderProps): Node {
249
260
250
261
// If changing, also change the status bar color in
251
262
// OfflineNoticePlaceholder.
252
- backgroundColor : backgroundColorForTheme ( theme ) ,
263
+ backgroundColor : backgroundColorForTheme ( themeToUse ) ,
253
264
254
265
justifyContent : 'center' ,
255
266
alignItems : 'center' ,
@@ -262,7 +273,7 @@ export function OfflineNoticeProvider(props: ProviderProps): Node {
262
273
} ,
263
274
noticeText : { fontSize : 14 } ,
264
275
} ) ,
265
- [ isNoticeVisible , theme ] ,
276
+ [ isNoticeVisible , themeToUse ] ,
266
277
) ;
267
278
268
279
/**
@@ -382,6 +393,8 @@ type PlaceholderProps = $ReadOnly<{|
382
393
*/
383
394
export function OfflineNoticePlaceholder ( props : PlaceholderProps ) : Node {
384
395
const theme = useGlobalSelector ( state => getGlobalSettings ( state ) . theme ) ;
396
+ const osScheme = useColorScheme ( ) ;
397
+ const themeToUse = getThemeToUse ( theme , osScheme ) ;
385
398
const { style : callerStyle } = props ;
386
399
387
400
const { isNoticeVisible, noticeContentAreaHeight } = useContext ( OfflineNoticeContext ) ;
@@ -451,7 +464,7 @@ export function OfflineNoticePlaceholder(props: PlaceholderProps): Node {
451
464
isNoticeVisible && (
452
465
< ZulipStatusBar
453
466
// Should match the notice's surface; see OfflineNoticeProvider.
454
- backgroundColor = { backgroundColorForTheme ( theme ) }
467
+ backgroundColor = { backgroundColorForTheme ( themeToUse ) }
455
468
/>
456
469
)
457
470
}
0 commit comments