import 'package:flutter/widgets.dart';

import 'ViewState.dart';

class BaseViewModel with ChangeNotifier {
  var _viewState;
  var num = ValueNotifier<int>(0);

  set viewState(ViewState viewState) => setViewState(viewState);
  get viewState => _viewState;

  void click() {
    num.value = (num.value ?? 0) + 1;
    num.notifyListeners();
  }

  void setNormal() {
    viewState = ViewState.Normal;
  }

  void setEmpty() {
    viewState = ViewState.Empty;
  }

  void setLoading() {
    viewState = ViewState.Loading;
  }

  void setError() {
    viewState = ViewState.Error;
  }

  setViewState(ViewState viewState) {
    if (_viewState == viewState) {
      return;
    }
    _viewState = viewState;
    notifyListeners();
  }
}
