Browse Source

Support dark theme by default (#547)

master
Henning Hall 3 years ago
committed by GitHub
parent
commit
ac99256a84
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      src/index.js

+ 16
- 2
src/index.js View File

@ -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) => {
<DatePicker
ref={props.innerRef}
{...props}
textColor={colorToHex(props.textColor)}
textColor={colorToHex(getTextColor(props))}
theme={getTheme(props)}
fadeToColor={colorToHex(props.fadeToColor)}
title={getTitle(props)}
confirmText={props.confirmText ? props.confirmText : 'Confirm'}
@ -31,6 +32,19 @@ 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

Loading…
Cancel
Save