React-native-modal-datetime-picker: Dates and months not visible

Created on 15 Oct 2019  路  12Comments  路  Source: mmazzarolo/react-native-modal-datetime-picker

  react: 16.8.6 => 16.8.6 
  react-native: ^0.59.3 => 0.59.10

iOS 13.1.2

  • iOS:
  • react-native-modal-datetime-picker:

Description

I have been using react-native-modal-datetime-picker for a long time without any problem. But now I got a problem with the date picker. The dates and months are not visible. I am attaching a screenshot of the issue.

Reproducible Demo

`
import React, {Component} from "react";
import {StyleSheet, TouchableOpacity, View} from "react-native";
import {connect} from "react-redux";
import {Text} from "native-base";
import * as Strings from "../../utils/Strings";
import DateTimePicker from 'react-native-modal-datetime-picker';

class DatePickerField extends Component {
constructor(props) {
super(props);
this.state = {
isDateTimePickerVisible: false,
};
}

showDateTimePicker = () => {
    this.setState({isDateTimePickerVisible: true})
};
hideDateTimePicker = () => this.setState({isDateTimePickerVisible: false});


handleDatePicked = (date) => {
    this.hideDateTimePicker(date);
    this.props.onDateChange(date);

};

render() {
    return (
        <View style={styles.containerStyle}>
            {
                    <Text
                        style={[styles.labelStyle, {color: this.props.textLabelColor}]}>{this.props.textLabel}</Text>
            }
            <TouchableOpacity onPress={this.showDateTimePicker.bind(this)}
                              style={[styles.dateContainerStyle, this.props.backgroundContainerStyle]}>
                <Text style={[styles.dateTextStyle, this.props.placeholderTextStyle]}>
                    {convertDate(this.props.date)}
                </Text>
            </TouchableOpacity>
            <DateTimePicker
                titleIOS={Strings.DATE}
                isVisible={this.state.isDateTimePickerVisible}
                date={this.props.date}
                onConfirm={this.handleDatePicked}
                onCancel={this.hideDateTimePicker}
            />
        </View>
    );
}

}

const styles = StyleSheet.create({
containerStyle: {
flex: 1,
flexDirection: 'column',
},
labelStyle: {
fontSize: 12,
alignSelf: 'flex-start',
},
dateContainerStyle: {
borderRadius: 12,
backgroundColor: '#FFFFFF29',
height: 38,
alignItems: 'center',
paddingLeft: 8,
paddingRight: 8,
flexDirection: 'row',
alignSelf: 'flex-start',
marginTop: 4
},
dropDownIconStyle: {
justifyContent: 'flex-end'
},
dateTextStyle: {
color: '#FFFFFF70',
flex: 1
}
});

function convertDate(inputFormat) {
function pad(s) {
return (s < 10) ? '0' + s : s;
}

let date = new Date(inputFormat);
return [pad(date.getDate()), pad(date.getMonth() + 1), date.getFullYear()].join('/');

}

const mapStateToProps = state => ({});

export default connect(mapStateToProps, {})(DatePickerField);
IMG_05C76EBA2BAD-1

`

bug

Most helpful comment

I found a solution (see my SO article)

Add this to your Info.plist

<key>UIUserInterfaceStyle</key>
<string>Light</string>

All 12 comments

I am pretty sure that this is caused by the new ios 13 update and the dark mode. Have you found a workaround for it yet?

@schumannd Yes, you are right it is a problem with the new "Dark" mode in iOS. I changed to "Light" mode and the picker is looking fine. The problem is that some of the users(as I was) could be using "Dark" mode. I don't have a workaround for now. Hope that the guys from this repo could help us.

This happens for me as well when testing on iPhone Xs Max with iOS 13 and Dark mode.

Any solution / workaround for it yet?

I found a solution (see my SO article)

Add this to your Info.plist

<key>UIUserInterfaceStyle</key>
<string>Light</string>

<key>UIUserInterfaceStyle</key> <string>Light</string>

This works for me also! This is a dirty workaround but at least for now - it is something.

@alexstoyanov @schumannd hi! 馃憢

This is related to the iOS dark mode support.
Please see the README for a fix/workaround and the other related issues:

  • #293
  • #283
  • #294

Any solution for Expo?

@spyshower I would strongly suggest ejecting

@spyshower I would strongly suggest ejecting

I get your point but I am literally one step before my app's official release :(

@spyshower can鈥檛 you detect if the dark mode is enabled from Expo and update the UI accordingly (like is suggested in the README)?

@spyshower can鈥檛 you detect if the dark mode is enabled from Expo and update the UI accordingly (like is suggested in the README)?

Yep.. yep.. you right. Fixed. Thank you 馃崱

Is it currently explained in Readme? couldn't find it

Was this page helpful?
0 / 5 - 0 ratings