import 'package:fengshui_compass/models/user_bean.dart';
import 'package:fengshui_compass/utils/sp_utils.dart';

class UserHelper {
  UserHelper._();

  static UserHelper getInstance = UserHelper._();

  UserBean _userBean;

  bool get isLogin => _userBean != null;

  set userBean(UserBean bean) {
    _userBean = bean;
    SPUtil.saveObject("user_bean", _userBean);
  }

  void init() {
    Map<String, dynamic> map = SPUtil.getObject("user_bean");
    if (map != null) {
      //加载缓存
      _userBean = UserBean.fromMap(map);
    }
  }

  void clear() {
    _userBean = null;
    SPUtil.remove("user_bean");
  }

}
