/**
 * 自定义状态栏(Android)
 * @邠心vbe on 2023/02/15
 */
import React, { Component } from 'react';
import { StatusBar } from 'react-native';

let statusBar;
export default class MyStatusBar extends Component {
  constructor(props) {
    super(props);
    this.state = {
      statusTheme: themeStatusBar,
      statusColor: colorPrimaryDark
    };
    statusBar = this;
  }

  static DARK_STYLE = "dark-content";
  static LIGHT_STYLE = "light-content";

  /**
   * 设置状态栏颜色
   * @param {String} color 颜色值
   */
  static setStatusBarColor(color) {
    statusBar.setStatusBarColor(color);
  }

  /**
   * 设置状态栏主题(字体图标颜色)
   * @param {String} theme 主题：MyStatusBar.DARK_STYLE, MyStatusBar.LIGHT_STYLE
   */
  static setStatusBarTheme(theme) {
    statusBar.setStatusBarTheme(theme);
  }

  /**
   * 设置状态栏主题和颜色
   * @param {*} theme 主题：MyStatusBar.DARK_STYLE, MyStatusBar.LIGHT_STYLE
   * @param {*} color 颜色
   */
  static setStatusBarThemes(theme, color) {
    statusBar.setStatusBarThemes(theme, color);
  }

  setStatusBarColor(color) {
    this.setState({
      statusColor: color
    })
  }

  setStatusBarTheme(theme) {
    this.setState({
      statusTheme: theme
    })
  }

  setStatusBarThemes(theme, color) {
    this.setState({
      statusColor: color,
      statusTheme: theme
    })
  }

  render() {
    return (
      <StatusBar barStyle={this.state.statusTheme} backgroundColor={this.state.statusColor}/>
    );
  }
}
