react-native-navigation的迁移库

BottomTabsOptions.java 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package com.reactnativenavigation.parse;
  2. import com.reactnativenavigation.parse.params.Bool;
  3. import com.reactnativenavigation.parse.params.Color;
  4. import com.reactnativenavigation.parse.params.NullBool;
  5. import com.reactnativenavigation.parse.params.NullColor;
  6. import com.reactnativenavigation.parse.params.NullNumber;
  7. import com.reactnativenavigation.parse.params.NullText;
  8. import com.reactnativenavigation.parse.params.Number;
  9. import com.reactnativenavigation.parse.params.Text;
  10. import com.reactnativenavigation.parse.params.TitleDisplayMode;
  11. import com.reactnativenavigation.parse.parsers.BoolParser;
  12. import com.reactnativenavigation.parse.parsers.ColorParser;
  13. import com.reactnativenavigation.parse.parsers.NumberParser;
  14. import com.reactnativenavigation.parse.parsers.TextParser;
  15. import org.json.JSONObject;
  16. public class BottomTabsOptions {
  17. public static BottomTabsOptions parse(JSONObject json) {
  18. BottomTabsOptions options = new BottomTabsOptions();
  19. if (json == null) return options;
  20. options.backgroundColor = ColorParser.parse(json, "backgroundColor");
  21. options.currentTabId = TextParser.parse(json, "currentTabId");
  22. options.currentTabIndex = NumberParser.parse(json,"currentTabIndex");
  23. options.visible = BoolParser.parse(json,"visible");
  24. options.drawBehind = BoolParser.parse(json, "drawBehind");
  25. options.animate = BoolParser.parse(json,"animate");
  26. options.testId = TextParser.parse(json, "testID");
  27. options.titleDisplayMode = TitleDisplayMode.fromString(json.optString("titleDisplayMode"));
  28. return options;
  29. }
  30. public Color backgroundColor = new NullColor();
  31. public Bool visible = new NullBool();
  32. public Bool drawBehind = new NullBool();
  33. public Bool animate = new NullBool();
  34. public Number currentTabIndex = new NullNumber();
  35. public Text currentTabId = new NullText();
  36. public Text testId = new NullText();
  37. public TitleDisplayMode titleDisplayMode = TitleDisplayMode.UNDEFINED;
  38. void mergeWith(final BottomTabsOptions other) {
  39. if (other.currentTabId.hasValue()) currentTabId = other.currentTabId;
  40. if (other.currentTabIndex.hasValue()) currentTabIndex = other.currentTabIndex;
  41. if (other.visible.hasValue()) visible = other.visible;
  42. if (other.drawBehind.hasValue()) drawBehind = other.drawBehind;
  43. if (other.animate.hasValue()) animate = other.animate;
  44. if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
  45. if (other.testId.hasValue()) testId = other.testId;
  46. if (other.titleDisplayMode.hasValue()) titleDisplayMode = other.titleDisplayMode;
  47. }
  48. void mergeWithDefault(final BottomTabsOptions defaultOptions) {
  49. if (!currentTabId.hasValue()) currentTabId = defaultOptions.currentTabId;
  50. if (!currentTabIndex.hasValue()) currentTabIndex = defaultOptions.currentTabIndex;
  51. if (!visible.hasValue()) visible = defaultOptions.visible;
  52. if (!drawBehind.hasValue()) drawBehind = defaultOptions.drawBehind;
  53. if (!animate.hasValue()) animate = defaultOptions.animate;
  54. if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
  55. if (!titleDisplayMode.hasValue()) titleDisplayMode = defaultOptions.titleDisplayMode;
  56. }
  57. }