How to use the react-native-windows.AppTheme.currentTheme function in react-native-windows

To help you get started, we’ve selected a few react-native-windows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / react-native-windows / vnext / src / RNTester / js / AccessibilityExampleWindows.tsx View on Github external
);
  }
}

class HighContrastExample extends React.Component {
  state = {
    isHighContrast: AppTheme.isHighContrast,
    highContrastColorValues: AppTheme.currentHighContrastColors,
    currentTheme: AppTheme.currentTheme,
  };

  componentDidMount() {
    AppTheme.addListener('highContrastChanged', this.onHighContrastChanged);
    AppTheme.addListener('appThemeChanged', this.onAppThemeChanged);
  }

  componenetWillUnmount() {
    AppTheme.removeListener('highContrastChanged', this.onHighContrastChanged);
    AppTheme.removeListener('appThemeChanged', this.onAppThemeChanged);
  }

  // TODO: Make args props
  onHighContrastChanged = (event: IHighContrastChangedEvent) => {
    this.setState({
      isHighContrast: event.isHighContrast,
github microsoft / react-native-windows / vnext / src / RNTester / js / ThemingExample.windows.tsx View on Github external
/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 * @format
 */

import React = require('react');
import {Text, View, Button} from 'react-native';
import {AppTheme, IAppThemeChangedEvent} from 'react-native-windows';

class ThemeExample extends React.Component {
  state = {
    currentTheme: AppTheme.currentTheme,
  };

  componentDidMount() {
    AppTheme.addListener('appThemeChanged', this.onAppThemeChanged);
  }

  componentWillUnmount() {
    AppTheme.removeListener('appThemeChanged', this.onAppThemeChanged);
  }

  onAppThemeChanged = (event: IAppThemeChangedEvent) => {
    const currentTheme = event.currentTheme;
    this.setState({currentTheme});
  };

  _onPress = () => {};