From ac99256a849fc08e572b94862f1cd51f895b5359 Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Mon, 18 Jul 2022 00:06:49 +0200 Subject: [PATCH] Support dark theme by default (#547) --- src/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6bbe0c7..e5a3ed4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import React from 'react' -import { Platform } from 'react-native' +import { Platform, Appearance } from 'react-native' import DatePickerIOS from './DatePickerIOS' import DatePickerAndroid from './DatePickerAndroid' import propTypes from './propTypes' @@ -19,7 +19,8 @@ const DatePickerWrapper = (props) => { { ) } +const getTheme = (props) => { + if (props.theme) return props.theme + if (!Appearance) return 'auto' + return Appearance.getColorScheme() +} + +const getTextColor = (props) => { + if (props.textColor) return props.textColor + const darkTheme = getTheme(props) === 'dark' + if (darkTheme) return 'white' + return undefined +} + const getAndroidVariant = (props) => { const { modal, androidVariant } = props if (androidVariant) return androidVariant