mmazzarolo/react-native-modal-datetime-picker

Android datetime picker change colors?

rendomnet opened this issue ยท 12 comments

Can we change colors of Android datetime picker?

Hi there,
to style it on Android you should tweak a bit the native code :)

Hi @mmazzarolo;
I have sort of a problem about this. I changed colors on my theme on native code but it doesn't change your dialogs. If I use react-native DatePickerAndroid and TimePickerAndroid separately it works perfectly but doesn't change when I use yours.

Here is my style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorAccent">@color/mainRed</item>
    </style>
    <style name="Dialog.Theme" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">@color/mainRed</item>
    </style>

</resources>

Edit: I found out that if I set react-native DatePickerAndroid mode it doesn't work either. If I don't pass a mode prop it works fine.

What do you think can cause this?

Thanks

Hey @bennygenel,

I found out that if I set react-native DatePickerAndroid mode it doesn't work either. If I don't pass a mode prop it works fine.

If you're talking about react-native's own DatePickerAndroid, it is a react-native issue indeed.
Do you mind opening an issue on the react-native official repo?
Feel free to link this issue if needed, I'll leave it open :)
Thank you!

Hey @mmazzarolo;

Thanks for reopening the issue. I was wondering if it is possible to not provide a mode prop to the DatePickerAndroid if the datePickerModeAndroid prop is omited?

At least this way default DatePickerDialog can be styled correctly.

Thanks again

Could you submit a PR (making sure that it doesn't break anything)?
I'll gladly merge it, but I'd also like to see the issue reported to the react-native official repo (I can do it by myself when I have some spare time if you can't do it!).

Thanks! ๐Ÿ‘

Android to get the date is not correct bad day

Closing for inactivity, feel free to post here if you want to discuss this subject further and I'll re-open it! ๐Ÿ‘จโ€๐Ÿ’ป

Passing datePickerModeAndroid={'default'} fixes the issue.
@mmazzarolo maybe this should be the default value instead of 'calendar'. What was the reason for using 'calendar' as the default value for this prop?

@bsonntag thank you for investigating on the issue.
Honestly, that prop comes from a previous PR, so I can't really answer your question.
Would you mind submitting a PR for fixing it? :)

@mmazzarolo done ๐Ÿ˜‰

what should i write on onConfirm function when i have 2 inputfields for date picker? please help me

I try the below blog for adding datePickerAndroid and it's working fine also provide when a user has multiple input field for date solution.

https://infinitbility.com/how-to-add-datepickerandroid-in-react-native-with-color-changes