RATreeView+Enums.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //The MIT License (MIT)
  2. //
  3. //Copyright (c) 2014 Rafał Augustyniak
  4. //
  5. //Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. //this software and associated documentation files (the "Software"), to deal in
  7. //the Software without restriction, including without limitation the rights to
  8. //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. //the Software, and to permit persons to whom the Software is furnished to do so,
  10. //subject to the following conditions:
  11. //
  12. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. //
  19. #import "RATreeView+Enums.h"
  20. #import "RATreeView.h"
  21. @implementation RATreeView (Enums)
  22. #pragma mark Row Animations
  23. + (UITableViewRowAnimation)tableViewRowAnimationForTreeViewRowAnimation:(RATreeViewRowAnimation)rowAnimation
  24. {
  25. switch (rowAnimation) {
  26. case RATreeViewRowAnimationFade:
  27. return UITableViewRowAnimationFade;
  28. case RATreeViewRowAnimationNone:
  29. return UITableViewRowAnimationNone;
  30. case RATreeViewRowAnimationAutomatic:
  31. return UITableViewRowAnimationAutomatic;
  32. case RATreeViewRowAnimationBottom:
  33. return UITableViewRowAnimationBottom;
  34. case RATreeViewRowAnimationLeft:
  35. return UITableViewRowAnimationLeft;
  36. case RATreeViewRowAnimationMiddle:
  37. return UITableViewRowAnimationMiddle;
  38. case RATreeViewRowAnimationRight:
  39. return UITableViewRowAnimationRight;
  40. case RATreeViewRowAnimationTop:
  41. return UITableViewRowAnimationTop;
  42. default:
  43. return UITableViewRowAnimationNone;
  44. }
  45. }
  46. #if TARGET_OS_IOS
  47. #pragma mark Cell Separator Styles
  48. + (RATreeViewCellSeparatorStyle)treeViewCellSeparatorStyleForTableViewSeparatorStyle:(UITableViewCellSeparatorStyle)style
  49. {
  50. switch (style) {
  51. case UITableViewCellSeparatorStyleNone:
  52. return RATreeViewCellSeparatorStyleNone;
  53. case UITableViewCellSeparatorStyleSingleLine:
  54. return RATreeViewCellSeparatorStyleSingleLine;
  55. case UITableViewCellSeparatorStyleSingleLineEtched:
  56. return RATreeViewCellSeparatorStyleSingleLineEtched;
  57. default:
  58. return RATreeViewCellSeparatorStyleNone;
  59. }
  60. }
  61. + (UITableViewCellSeparatorStyle)tableViewCellSeparatorStyleForTreeViewCellSeparatorStyle:(RATreeViewCellSeparatorStyle)style
  62. {
  63. switch (style) {
  64. case RATreeViewCellSeparatorStyleNone:
  65. return UITableViewCellSeparatorStyleNone;
  66. case RATreeViewCellSeparatorStyleSingleLine:
  67. return UITableViewCellSeparatorStyleSingleLine;
  68. case RATreeViewCellSeparatorStyleSingleLineEtched:
  69. return UITableViewCellSeparatorStyleSingleLineEtched;
  70. default:
  71. return UITableViewCellSeparatorStyleNone;
  72. }
  73. }
  74. #endif
  75. #pragma mark Tree View Style
  76. + (UITableViewStyle)tableViewStyleForTreeViewStyle:(RATreeViewStyle)treeViewStyle
  77. {
  78. switch (treeViewStyle) {
  79. case RATreeViewStylePlain:
  80. return UITableViewStylePlain;
  81. case RATreeViewStyleGrouped:
  82. return UITableViewStyleGrouped;
  83. }
  84. }
  85. + (RATreeViewStyle)treeViewStyleForTableViewStyle:(UITableViewStyle)tableViewStyle
  86. {
  87. switch (tableViewStyle) {
  88. case UITableViewStylePlain:
  89. return RATreeViewStylePlain;
  90. case UITableViewStyleGrouped:
  91. return RATreeViewStyleGrouped;
  92. }
  93. }
  94. #pragma mark Scroll Positions
  95. + (UITableViewScrollPosition)tableViewScrollPositionForTreeViewScrollPosition:(RATreeViewScrollPosition)scrollPosition
  96. {
  97. switch (scrollPosition) {
  98. case RATreeViewScrollPositionNone:
  99. return UITableViewScrollPositionNone;
  100. case RATreeViewScrollPositionTop:
  101. return UITableViewScrollPositionTop;
  102. case RATreeViewScrollPositionMiddle:
  103. return UITableViewScrollPositionMiddle;
  104. case RATreeViewScrollPositionBottom:
  105. return UITableViewScrollPositionBottom;
  106. default:
  107. return UITableViewScrollPositionNone;
  108. }
  109. }
  110. @end