A good example to consider would be the iBooks app in iOS which allows users to enable the dark theme automatically depending on the light sensor detection.

However as PS86 rightly pointed out, don't build this automatically into the system but enable the user to set as a desired parameter. To quote this article, the iBooks app enables this by an option called auto night Theme
You can always enable the Night theme manually, but in the latest
version of iBooks you can also enable a new setting called Auto-Night
Theme. This changes your theme from your default (either White or
Sepia) to the Night theme automatically. Despite the “Night” name
designating the late hours of the day, the switch is based on ambient
lighting conditions, not time. If you have Auto-Night Theme enabled,
any time your iPhone or iPad’s ambient light sensor detects a dark
room, iBooks will instantly switch over to the Night theme and then
switch back when light in the room returns, whether that’s due to the
sun rising or a lamp being turned on.
Also since the brightness of the content would define the comfort level while reading , allow users to choose a brightness option while changing themes or within the theme itself.
Lastly while designing the night or darker theme, I recommend looking at this interesting article which talks about the impact of brightness of the text and readablity when the text is placed on darker background'.
I would recommend looking at this article on the for inputs on readable text and the tools you can potentially use for contrast checking. To quote the article
First, it's helpful to establish good body text values. I usually
start with a neutral color palette and aim for the lightest gray with
a AAA (Section 508 compliant) rating (here's a good plain language
explanation of ratings, WCAG 2.0 Level A/AA/AAA versus Section
508.) The AAA rating ensures optimal readability while some
brightness allows for softness in the text.
