import 'package:cashier_reserve/common/base/ui.dart';
import 'package:cashier_reserve/common/base/ui_model.dart';
import 'package:cashier_reserve/common/manager/app_manager.dart';
import 'package:cashier_reserve/common/print/print.dart';

class HomeViewModel extends BaseUIModel {
  int _currentIndex = 0;

  int get currentIndex => _currentIndex;

  final List<String> _tabTitles = [
    "预定",
    "订单",
    "打印预定",
    "历史订单",
    "来电",
    "客户",
    "消息",
    "更多"
  ];
  final List<String> _tabIcons = [
    "reserve",
    "order",
    "print",
    "history",
    "tel",
    "customer",
    "message",
    "more"
  ];

  List<String> get tabTitles => _tabTitles;

  List<String> get tabIcons => _tabIcons;

  PageController? _pageController;

  PageController? get pageController => _pageController;

  HomeViewModel() {
    _pageController = PageController(initialPage: 0);

    Future.delayed(const Duration(milliseconds: 700), () {
      _checkLogin();
    });
  }

  _checkLogin() {
    bool flag = AppManager.isLogin();
    yjPrint("is login $flag");
  }

  @override
  void dispose() {
    _pageController?.dispose();
    super.dispose();
  }

  void setIndex(int index) {
    if (_currentIndex == index) {
      return;
    }
    _currentIndex = index;
    notifyListeners();

    _pageController?.jumpToPage(index);
  }
}
