react-native-datetimepicker / datetimepicker

React Native date & time picker component for iOS, Android and Windows
MIT License
2.54k stars 413 forks source link

Unable to force light mode #937

Closed TimHi closed 1 month ago

TimHi commented 1 month ago

The app I'm working on does not offer a dark mode, hence I need to ignore the system set dark mode. In Android it's looking like this:

Screenshot 2024-10-21 at 13 13 22

So far I've tried to edit the styles.xml. Neither forceDarkAllowed or the timePickerDialogTheme/datePickerDialogTheme seem to. make any difference.

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:forceDarkAllowed">false</item>
        <item name="android:spinnerItemStyle">@style/SpinnerItem</item>
        <item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item>
        <item name="android:timePickerDialogTheme">@style/DialogDatePicker.Theme</item>
        <item name="android:datePickerDialogTheme">@style/DialogDatePicker.Theme</item>
    </style>

    <style name="DialogDatePicker.Theme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorAccent">@color/primary_blue</item>
        <item name="android:textColor">@color/primary_dark</item>
        <item name="android:textColorPrimary">@color/colorBottomNavigationNotification</item>
    </style>

I'm on the latest version 8.2.0. Is there something I'm missing?

vonovak commented 1 month ago

Hello and thanks for asking, Please use the theme-control library that's recommended in https://github.com/react-native-datetimepicker/datetimepicker#themevariant-optional-ios-only

That should work best, Thank you 🙂

TimHi commented 1 month ago

Hello @vonovak , thank you for the suggestion, I saw the themevariant prop but it is marked as iOS only, this is an issue with Android, does the prop work for Android as well?

vonovak commented 1 month ago

Hi Tim, My comment above, as well as the prop documentation mention the theme-control library.

Did you have a look at it too?

TimHi commented 1 month ago

I apologize, I missread the part in the doc. Using the theme-control library worked. Thank you for the quick support!

vonovak commented 1 month ago

Actually, for your use case this might be enough

https://reactnative.dev/docs/next/appearance#setcolorscheme