
import 'package:flutter/material.dart';
import 'package:twong/api/index.dart';
import 'package:twong/models/index.dart';
import 'package:twong/utils/index.dart';

class UserModel with ChangeNotifier {
  UserInfo _info;
  UserModel(this._info);

  UserInfo get info {
    if(_info == null) {
      if(Cache.user != null) {
        Network.inst.getUserInfo();
      }
    }

    return _info;
  }

  void update(UserInfo info) {
    this._info = info;
    notifyListeners();
  }

  void updateNickName(String nickname) {
    this._info.nickname = nickname;
    notifyListeners();
  }
}