zodiac_love_intimacy_tab.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:flutter/cupertino.dart';
  2. import '../../../resource/assets.gen.dart';
  3. import '../../../resource/string.gen.dart';
  4. /// 星座分析Tab枚举
  5. enum ZodiacLoveIntimacyTab {
  6. /// 今日指数Tab
  7. today(0),
  8. /// 未来一周Tab
  9. futureWeek(1);
  10. /// Tab所在页面的索引
  11. final int tabIndex;
  12. const ZodiacLoveIntimacyTab(this.tabIndex);
  13. /// 获取Tab名称
  14. String getTabName() {
  15. switch (this) {
  16. case today:
  17. return StringName.zodiacLoveIntimacyTodayTab;
  18. case futureWeek:
  19. return StringName.zodiacLoveIntimacyFutureWeekTab;
  20. }
  21. }
  22. /// 获取Tab未选中时的背景
  23. ImageProvider getTabNormalBg() {
  24. switch (this) {
  25. case today:
  26. return Assets.images.zodiacLoveTabLeft2.provider();
  27. case futureWeek:
  28. return Assets.images.zodiacLoveTabRight1.provider();
  29. }
  30. }
  31. /// 获取Tab未选中时的背景
  32. ImageProvider getTabSelectedBg() {
  33. switch (this) {
  34. case today:
  35. return Assets.images.zodiacLoveTabLeft1.provider();
  36. case futureWeek:
  37. return Assets.images.zodiacLoveTabRight2.provider();
  38. }
  39. }
  40. /// 通过index,查找对应的Tab枚举实例
  41. static ZodiacLoveIntimacyTab? fromIndex(int index) {
  42. return ZodiacLoveIntimacyTab.values.firstWhere(
  43. (element) => element.tabIndex == index,
  44. );
  45. }
  46. }