import 'package:flutter/cupertino.dart';

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

/// 星座分析Tab枚举
enum ZodiacLoveIntimacyTab {
  /// 今日指数Tab
  today(0),

  /// 未来一周Tab
  futureWeek(1);

  /// Tab所在页面的索引
  final int tabIndex;

  const ZodiacLoveIntimacyTab(this.tabIndex);

  /// 获取Tab名称
  String getTabName() {
    switch (this) {
      case today:
        return StringName.zodiacLoveIntimacyTodayTab;
      case futureWeek:
        return StringName.zodiacLoveIntimacyFutureWeekTab;
    }
  }

  /// 获取Tab未选中时的背景
  ImageProvider getTabNormalBg() {
    switch (this) {
      case today:
        return Assets.images.zodiacLoveTabLeft2.provider();
      case futureWeek:
        return Assets.images.zodiacLoveTabRight1.provider();
    }
  }

  /// 获取Tab未选中时的背景
  ImageProvider getTabSelectedBg() {
    switch (this) {
      case today:
        return Assets.images.zodiacLoveTabLeft1.provider();
      case futureWeek:
        return Assets.images.zodiacLoveTabRight2.provider();
    }
  }

  /// 通过index，查找对应的Tab枚举实例
  static ZodiacLoveIntimacyTab? fromIndex(int index) {
    return ZodiacLoveIntimacyTab.values.firstWhere(
      (element) => element.tabIndex == index,
    );
  }
}
