import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:injectable/injectable.dart';

import '../../base/base_controller.dart';
import '../../resource/assets.gen.dart';
import '../../resource/string.gen.dart';

import '../character/character_view.dart';
import '../keyboard/keyboard_view.dart';
import '../mine/mine_view.dart';

@injectable
class MainController extends BaseController {
  final _currentIndex = 0.obs;

  int get currentIndex => _currentIndex.value;

  final List<TabBean> tabBeans = [
    TabBean(
      StringName.mainTabKeyboard,
      Assets.images.iconTabKeyboardUnselect.path,
      Assets.anim.animTabKeyboardSelectedData,
      KeyBoardView(),
    ),
    TabBean(
      StringName.mainTabCharacter,
      Assets.images.iconTabCharacterUnselect.path,
      Assets.anim.animTabCharacterSelectedData,
      CharacterView(),
    ),
    TabBean(
      StringName.mainTabMine,
      Assets.images.iconTabMineUnselect.path,
      Assets.anim.animTabMineSelectedData,
      MineView(),
    ),
  ];

  void changeIndex(int index) {
    if (_currentIndex.value != index) {
      _currentIndex.value = index;
    }
  }

  @override
  void onInit() {
    super.onInit();
  }
}

class TabBean {
  final String title;
  final String normalIcon;
  final String selectedIcon;
  final Widget page;

  const TabBean(this.title, this.normalIcon, this.selectedIcon, this.page);
}
