diff --git a/README.md b/README.md index 77aea667..ed24d0e9 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ React Native date & time picker component for iOS and Android - [`dayOfWeekFormat` (`optional`, `Windows only`)](#dayOfWeekFormat-optional-windows-only) - [`dateFormat` (`optional`, `Windows only`)](#dateFormat-optional-windows-only) - [`firstDayOfWeek` (`optional`, `Windows only`)](#firstDayOfWeek-optional-windows-only) + - [`textColor` (`optional`, `iOS only`)](#textColor-optional-ios-only) - [`locale` (`optional`, `iOS only`)](#locale-optional-ios-only) - [`is24Hour` (`optional`, `Android only`)](#is24hour-optional-android-only) - [`neutralButtonLabel` (`optional`, `Android only`)](#neutralbuttonlabel-optional-android-only) @@ -322,8 +323,11 @@ Possible values are: `1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30` #### `style` (`optional`, `iOS only`) -Sets style directly on picker component. -By default height of picker is fixed to 216px. +Sets style directly on picker component. By default, the picker height is fixed to 216px. + +Please note that by default, picker's text color is controlled by the application theme (light / dark mode). In dark mode, text is white and in light mode, text is black. + +This means that eg. if the device has dark mode turned on, and your screen background color is white, you will not see the picker. Please use the `Appearance` api to adjust the picker's background color so that it is visible, as we do in the [example App](/example/App.js) or [opt-out from dark mode](https://stackoverflow.com/a/56546554/2070942). ```js diff --git a/example/App.js b/example/App.js index 1b48a3ef..7abd59ad 100644 --- a/example/App.js +++ b/example/App.js @@ -8,6 +8,7 @@ import { Button, Platform, TextInput, + useColorScheme, } from 'react-native'; import DateTimePicker from '@react-native-community/datetimepicker'; import {Header, Colors} from 'react-native/Libraries/NewAppScreen'; @@ -16,6 +17,17 @@ import {Picker} from 'react-native-windows'; import moment from 'moment'; import {DAY_OF_WEEK} from '../src/constants'; +const ThemedText = props => { + const isDarkMode = useColorScheme() === 'dark'; + + const textColorByMode = {color: isDarkMode ? Colors.white : Colors.black}; + + const TextElement = React.createElement(Text, props); + return React.cloneElement(TextElement, { + style: [props.style, textColorByMode], + }); +}; + export const App = () => { const [date, setDate] = useState(new Date(1598051730000)); const [mode, setMode] = useState('date'); @@ -68,97 +80,103 @@ export const App = () => { setDisplay('spinner'); }; + const isDarkMode = useColorScheme() === 'dark'; + + const backgroundStyle = { + backgroundColor: isDarkMode ? Colors.dark : Colors.lighter, + }; + if (Platform.OS !== 'windows') { return ( - <> + - - -
- {global.HermesInternal !== null && ( - - - Engine: Hermes - - - )} - - - - Example DateTime Picker - - - - text color (iOS only) - - { - setColor(text.toLowerCase()); - }} - placeholder="color" - /> - - -