Theme Detection

The ThemeDetection API provides simple methods to detect whether the dark mode is enabled on the device or not.

Usage
ThemeDetection.isAvailable()
.then((res) => {
    if(res.value) {
        ThemeDetection.isDarkModeEnabled().then((res) => {
        console.log(res);
        })
        .catch((error) => console.error(error));
    }
})
.catch((error) => console.error(error));
window.ThemeDetection.isAvailable()
    .then((res) => {
        if (res.value) {
            window.ThemeDetection.isDarkModeEnabled()
                .then((res) => {
                    console.log(res);
                })
                .catch((error) => console.error(error));
        }
    })
    .catch((error) => console.error(error));
window.ThemeDetection.isAvailable()
    .then((res) => {
        if (res.value) {
            window.ThemeDetection.isDarkModeEnabled()
                .then((res) => {
                    console.log(res);
                })
                .catch((error) => console.error(error));
        }
    })
    .catch((error) => console.error(error));
(<any>window).ThemeDetection.isAvailable()
    .then((res) => {
        if (res.value) {
        (<any>window).ThemeDetection.isDarkModeEnabled()
            .then((res) => {
            console.log(res);
            })
            .catch((error) => console.error(error));
        }
    })
    .catch((error) => console.error(error));
window.ThemeDetection.isAvailable()
    .then((res) => {
        if (res.value) {
            window.ThemeDetection.isDarkModeEnabled()
                .then((res) => {
                    console.log(res);
                })
                .catch((error) => console.error(error));
        }
    })
    .catch((error) => console.error(error));

Classes


ThemeDetection

isAvailable
isAvailable(): Promise <ThemeDetectionResponse>

Checks if dark mode is supported by the device and returns an ThemeDetectionResponse object with a boolean value and a message.


RETURN
returns: Promise <ThemeDetectionResponse>
isDarkModeEnabled
isDarkModeEnabled(): Promise <ThemeDetectionResponse>

Checks whether the dark mode is enabled on device and returns an ThemeDetectionResponse object with a boolean value and a message.


RETURN
returns: Promise <ThemeDetectionResponse>

Interfaces Used

ThemeDetectionResponse

ThemeDetectionResponse {
    value: boolean; // True is enabled/available
    message: string;
}