Skip to content

Commit 17f0c16

Browse files
fix: make status bar work great in all kind of modes
1 parent c61eae9 commit 17f0c16

File tree

11 files changed

+411
-364
lines changed

11 files changed

+411
-364
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.18.1
1+
18.15.0

example/app.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"ios": {
1616
"supportsTablet": true
1717
},
18+
"androidStatusBar": {
19+
"translucent": true
20+
},
1821
"web": {
1922
"favicon": "./favicon.png",
2023
"name": "React Native Paper Dates",

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"expo-splash-screen": "~0.20.5",
1717
"react": "18.2.0",
1818
"react-dom": "18.2.0",
19-
"react-native": "0.72.4",
19+
"react-native": "0.72.6",
2020
"react-native-paper": "^5.10.4",
2121
"react-native-web": "~0.19.8"
2222
},

example/src/App.tsx

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
Chip,
2525
MD3DarkTheme,
2626
MD3LightTheme,
27+
MD2LightTheme,
2728
} from 'react-native-paper'
2829
import {
2930
DatePickerModal,
@@ -55,6 +56,7 @@ import {
5556
} from 'react-native-paper-dates'
5657
import { useCallback, useState } from 'react'
5758

59+
const presentationStyles = ['overFullScreen', 'pageSheet'] as const
5860
const locales: [string, TranslationsType][] = [
5961
['ar', ar],
6062
['ca', ca],
@@ -83,7 +85,13 @@ locales.forEach((locale) => {
8385
registerTranslation(locale[0], locale[1])
8486
})
8587

86-
function App() {
88+
function App({
89+
materialYouEnabled,
90+
setMaterialYouEnabled,
91+
}: {
92+
materialYouEnabled: boolean
93+
setMaterialYouEnabled: (v: boolean) => void
94+
}) {
8795
/** Hooks. */
8896
const theme = useTheme()
8997
const insets = useSafeAreaInsets()
@@ -101,6 +109,8 @@ function App() {
101109
minutes: number | undefined
102110
}>({ hours: undefined, minutes: undefined })
103111
const [locale, setLocale] = useState('en-GB')
112+
const [presentationStyle, setPresentationStyle] =
113+
useState<(typeof presentationStyles)[number]>('overFullScreen')
104114
const [timeOpen, setTimeOpen] = useState(false)
105115
const [rangeOpen, setRangeOpen] = useState(false)
106116
const [singleOpen, setSingleOpen] = useState(false)
@@ -182,16 +192,16 @@ function App() {
182192
return (
183193
<>
184194
<StatusBar
185-
barStyle="light-content"
186-
backgroundColor={theme.colors.primary}
195+
// barStyle="light-content"
196+
// backgroundColor={theme.colors.primary}
187197
translucent={true}
188198
/>
189199
<ScrollView
190200
style={{ backgroundColor: theme.colors.background }}
191201
contentContainerStyle={[
192202
styles.contentContainer,
193203
styles.paddingSixteen,
194-
{ marginTop: insets.top },
204+
{ paddingTop: insets.top + 24, paddingBottom: insets.bottom },
195205
]}
196206
>
197207
<View style={isLarge && styles.surface}>
@@ -269,7 +279,58 @@ function App() {
269279
View documentation
270280
</Button>
271281
</View>
282+
<Divider style={styles.marginVerticalEight} />
283+
<Text
284+
maxFontSizeMultiplier={maxFontSizeMultiplier}
285+
style={[styles.marginVerticalEight, styles.bold]}
286+
>
287+
Material theme
288+
</Text>
289+
<View style={styles.chipContainer}>
290+
<Chip
291+
compact
292+
selected={materialYouEnabled}
293+
onPress={() => setMaterialYouEnabled(true)}
294+
style={styles.chip}
295+
>
296+
Material You
297+
</Chip>
298+
<Chip
299+
compact
300+
selected={!materialYouEnabled}
301+
onPress={() => setMaterialYouEnabled(false)}
302+
style={styles.chip}
303+
>
304+
Material Design 2
305+
</Chip>
306+
</View>
272307

308+
<Divider style={styles.marginVerticalEight} />
309+
<Text
310+
maxFontSizeMultiplier={maxFontSizeMultiplier}
311+
style={[styles.marginVerticalEight, styles.bold]}
312+
>
313+
Presentation Style (iOS only)
314+
</Text>
315+
<View style={styles.chipContainer}>
316+
{presentationStyles.map((option) => {
317+
return (
318+
<Chip
319+
compact
320+
key={option}
321+
selected={presentationStyle === option}
322+
onPress={() =>
323+
setPresentationStyle(
324+
option as (typeof presentationStyles)[number]
325+
)
326+
}
327+
style={styles.chip}
328+
>
329+
{option}
330+
</Chip>
331+
)
332+
})}
333+
</View>
273334
<Divider style={styles.marginVerticalEight} />
274335
<Text
275336
maxFontSizeMultiplier={maxFontSizeMultiplier}
@@ -468,6 +529,7 @@ function App() {
468529
startDate={range.startDate}
469530
endDate={range.endDate}
470531
onConfirm={onChangeRange}
532+
presentationStyle={presentationStyle}
471533
/>
472534
<DatePickerModal
473535
locale={locale}
@@ -480,6 +542,7 @@ function App() {
480542
startDate: pastDate,
481543
disabledDates: [futureDate],
482544
}}
545+
presentationStyle={presentationStyle}
483546
/>
484547
<DatePickerModal
485548
locale={locale}
@@ -489,6 +552,7 @@ function App() {
489552
dates={dates}
490553
validRange={{ startDate: new Date() }}
491554
onConfirm={onChangeMulti}
555+
presentationStyle={presentationStyle}
492556
/>
493557
<TimePickerModal
494558
locale={locale}
@@ -504,12 +568,16 @@ function App() {
504568

505569
export default function AppWithProviders() {
506570
const colorScheme = useColorScheme()
571+
const [materialYouEnabled, setMaterialYouEnabled] = React.useState(true)
572+
const m3Theme = colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme
573+
const m2Theme = colorScheme === 'dark' ? MD2LightTheme : MD2LightTheme
507574
return (
508575
<SafeAreaProvider>
509-
<PaperProvider
510-
theme={colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme}
511-
>
512-
<App />
576+
<PaperProvider theme={materialYouEnabled ? m3Theme : m2Theme}>
577+
<App
578+
materialYouEnabled={materialYouEnabled}
579+
setMaterialYouEnabled={setMaterialYouEnabled}
580+
/>
513581
</PaperProvider>
514582
</SafeAreaProvider>
515583
)

0 commit comments

Comments
 (0)