RATreeView+Enums.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //The MIT License (MIT)
  2. //
  3. //Copyright (c) 2013 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 RATreeViewRowAnimationNone:
  27. return UITableViewRowAnimationNone;
  28. case RATreeViewRowAnimationAutomatic:
  29. return UITableViewRowAnimationAutomatic;
  30. case RATreeViewRowAnimationBottom:
  31. return UITableViewRowAnimationBottom;
  32. case RATreeViewRowAnimationLeft:
  33. return UITableViewRowAnimationLeft;
  34. case RATreeViewRowAnimationMiddle:
  35. return UITableViewRowAnimationMiddle;
  36. case RATreeViewRowAnimationRight:
  37. return UITableViewRowAnimationRight;
  38. case RATreeViewRowAnimationTop:
  39. return UITableViewRowAnimationTop;
  40. default:
  41. return UITableViewRowAnimationNone;
  42. }
  43. }
  44. #pragma mark Cell Separator Styles
  45. + (RATreeViewCellSeparatorStyle)treeViewCellSeparatorStyleForTableViewSeparatorStyle:(UITableViewCellSeparatorStyle)style
  46. {
  47. switch (style) {
  48. case UITableViewCellSeparatorStyleNone:
  49. return RATreeViewCellSeparatorStyleNone;
  50. case UITableViewCellSeparatorStyleSingleLine:
  51. return RATreeViewCellSeparatorStyleSingleLine;
  52. // case UITableViewCellSeparatorStyleSingleLineEtched:
  53. // return RATreeViewCellSeparatorStyleSingleLineEtched;
  54. default:
  55. return RATreeViewCellSeparatorStyleNone;
  56. }
  57. }
  58. + (UITableViewCellSeparatorStyle)tableViewCellSeparatorStyleForTreeViewCellSeparatorStyle:(RATreeViewCellSeparatorStyle)style
  59. {
  60. switch (style) {
  61. case RATreeViewCellSeparatorStyleNone:
  62. return UITableViewCellSeparatorStyleNone;
  63. case RATreeViewCellSeparatorStyleSingleLine:
  64. return UITableViewCellSeparatorStyleSingleLine;
  65. // case RATreeViewCellSeparatorStyleSingleLineEtched:
  66. // return UITableViewCellSeparatorStyleSingleLineEtched;
  67. default:
  68. return UITableViewCellSeparatorStyleNone;
  69. }
  70. }
  71. #pragma mark Tree View Style
  72. + (UITableViewStyle)tableViewStyleForTreeViewStyle:(RATreeViewStyle)treeViewStyle
  73. {
  74. switch (treeViewStyle) {
  75. case RATreeViewStylePlain:
  76. return UITableViewStylePlain;
  77. case RATreeViewStyleGrouped:
  78. return UITableViewStyleGrouped;
  79. }
  80. }
  81. + (RATreeViewStyle)treeViewStyleForTableViewStyle:(UITableViewStyle)tableViewStyle
  82. {
  83. switch (tableViewStyle) {
  84. case UITableViewStylePlain:
  85. return RATreeViewStylePlain;
  86. case UITableViewStyleGrouped:
  87. return RATreeViewStyleGrouped;
  88. default:
  89. return RATreeViewStylePlain;
  90. }
  91. }
  92. #pragma mark Scroll Positions
  93. + (UITableViewScrollPosition)tableViewScrollPositionForTreeViewScrollPosition:(RATreeViewScrollPosition)scrollPosition
  94. {
  95. switch (scrollPosition) {
  96. case RATreeViewScrollPositionNone:
  97. return UITableViewScrollPositionNone;
  98. case RATreeViewScrollPositionTop:
  99. return UITableViewScrollPositionTop;
  100. case RATreeViewScrollPositionMiddle:
  101. return UITableViewScrollPositionMiddle;
  102. case RATreeViewScrollPositionBottom:
  103. return UITableViewScrollPositionBottom;
  104. default:
  105. return UITableViewScrollPositionNone;
  106. }
  107. }
  108. @end