Пример #1
0
 /**
  * Set the status bar style
  * @param style Status bar style to set
  * @param animated Animate the style change.
  */
 static setBarStyle(style: StatusBarStyle, animated?: boolean) {
   animated = animated || false;
   StatusBar._defaultProps.barStyle.value = style;
   if (Platform.OS === 'ios') {
     StatusBarManager.setStyle(style, animated);
   } else if (Platform.OS === 'android') {
     StatusBarManager.setStyle(style);
   }
 }
Пример #2
0
  // Provide an imperative API as static functions of the component.
  // See the corresponding prop for more detail.

  /**
   * Show or hide the status bar
   * @param hidden Hide the status bar.
   * @param animation Optional animation when
   *    changing the status bar hidden property.
   */
  static setHidden(hidden: boolean, animation?: StatusBarAnimation) {
    animation = animation || 'none';
    StatusBar._defaultProps.hidden.value = hidden;
    if (Platform.OS === 'ios') {
      StatusBarManager.setHidden(hidden, animation);
    } else if (Platform.OS === 'android') {
      StatusBarManager.setHidden(hidden);
    }
  }
 /**
  * Set the background color for the status bar
  * @param color Background color.
  * @param animated Animate the style change.
  */
 static setBackgroundColor(color: string, animated?: boolean) {
   if (Platform.OS === 'ios') {
     console.warn('`setBackgroundColor` is only available on Android and Windows');
   } else if (Platform.OS === 'android') {
     animated = animated || false;
     StatusBar._defaultProps.backgroundColor.value = color;
     StatusBarManager.setColor(processColor(color), animated);
   } else if (Platform.OS === 'windows') {
     StatusBar._defaultProps.backgroundColor.value = color;
     StatusBarManager.setColor(processColor(color));      
   }
 }
 /**
  * Set the status bar style
  * @param style Status bar style to set
  * @param animated Animate the style change.
  */
 static setBarStyle(style: StatusBarStyle, animated?: boolean) {
   animated = animated || false;
   StatusBar._defaultProps.barStyle.value = style;
   if (Platform.OS === 'ios') {
     StatusBarManager.setStyle(style, animated);
   } else if (Platform.OS === 'android') {
     StatusBarManager.setStyle(style);
   } else if (Platform.OS === 'windows') {
     console.warn('`setBarStyle` is not available on Windows');
     return;
   }
 }
    StatusBar._updateImmediate = setImmediate(() => {
      const oldProps = StatusBar._currentValues;
      const mergedProps = mergePropsStack(StatusBar._propsStack, StatusBar._defaultProps);

      // Update the props that have changed using the merged values from the props stack.
      if (Platform.OS === 'ios') {
        if (!oldProps || oldProps.barStyle.value !== mergedProps.barStyle.value) {
          StatusBarManager.setStyle(
            mergedProps.barStyle.value,
            mergedProps.barStyle.animated,
          );
        }
        if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) {
          StatusBarManager.setHidden(
            mergedProps.hidden.value,
            mergedProps.hidden.animated ?
              mergedProps.hidden.transition :
              'none',
          );
        }

        if (!oldProps || oldProps.networkActivityIndicatorVisible !== mergedProps.networkActivityIndicatorVisible) {
          StatusBarManager.setNetworkActivityIndicatorVisible(
            mergedProps.networkActivityIndicatorVisible
          );
        }
      } else if (Platform.OS === 'android') {
        if (!oldProps || oldProps.backgroundColor.value !== mergedProps.backgroundColor.value) {
          StatusBarManager.setColor(
            processColor(mergedProps.backgroundColor.value),
            mergedProps.backgroundColor.animated,
          );
        }
        if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) {
          StatusBarManager.setHidden(mergedProps.hidden.value);
        }
        if (!oldProps || oldProps.translucent !== mergedProps.translucent) {
          StatusBarManager.setTranslucent(mergedProps.translucent);
        }
      } else if (Platform.OS === 'windows') {
        if (!oldProps || oldProps.backgroundColor.value !== mergedProps.backgroundColor.value) {
          StatusBarManager.setColor(
            processColor(mergedProps.backgroundColor.value),
          );
        }
        if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) {
          StatusBarManager.setHidden(mergedProps.hidden.value);
        }
        if (!oldProps || oldProps.translucent !== mergedProps.translucent) {
          StatusBarManager.setTranslucent(mergedProps.translucent);
        }
      }
      // Update the current prop values.
      StatusBar._currentValues = mergedProps;
    });
 /**
  * Control the translucency of the status bar
  * @param translucent Set as translucent.
  */
 static setTranslucent(translucent: boolean) {
   if (Platform.OS === 'ios') {
     console.warn('`setTranslucent` is not available on iOS');
     return;
   }
   StatusBar._defaultProps.translucent = translucent;
   StatusBarManager.setTranslucent(translucent);
 }
Пример #7
0
 /**
  * Control the translucency of the status bar
  * @param translucent Set as translucent.
  */
 static setTranslucent(translucent: boolean) {
   if (Platform.OS !== 'android') {
     console.warn('`setTranslucent` is only available on Android');
     return;
   }
   StatusBar._defaultProps.translucent = translucent;
   StatusBarManager.setTranslucent(translucent);
 }
Пример #8
0
 /**
  * Control the visibility of the network activity indicator
  * @param visible Show the indicator.
  */
 static setNetworkActivityIndicatorVisible(visible: boolean) {
   if (Platform.OS !== 'ios') {
     console.warn('`setNetworkActivityIndicatorVisible` is only available on iOS');
     return;
   }
   StatusBar._defaultProps.networkActivityIndicatorVisible = visible;
   StatusBarManager.setNetworkActivityIndicatorVisible(visible);
 }
    // TODO(janic): Provide a real API to deal with status bar height. See the
    // discussion in #6195.
    /**
     * The current height of the status bar on the device.
     *
     * @platform android
     */
    currentHeight: StatusBarManager.HEIGHT,

    // Provide an imperative API as static functions of the component.
    // See the corresponding prop for more detail.
    setHidden(hidden: boolean, animation?: StatusBarAnimation) {
      animation = animation || 'none';
      StatusBar._defaultProps.hidden.value = hidden;
      if (Platform.OS === 'ios') {
        StatusBarManager.setHidden(hidden, animation);
      } else if (Platform.OS === 'android') {
        StatusBarManager.setHidden(hidden);
      } else if (Platform.OS === 'windows') {
        StatusBarManager.setHidden(hidden);
      }
    },

    setBarStyle(style: StatusBarStyle, animated?: boolean) {
      if (Platform.OS !== 'ios') {
        console.warn('`setBarStyle` is only available on iOS');
        return;
      }
      animated = animated || false;
      StatusBar._defaultProps.barStyle.value = style;
      StatusBarManager.setStyle(style, animated);