ScrollViewProps.cpp 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #include "ScrollViewProps.h"
  8. #include <react/components/scrollview/conversions.h>
  9. #include <react/debug/debugStringConvertibleUtils.h>
  10. #include <react/graphics/conversions.h>
  11. #include <react/core/propsConversions.h>
  12. namespace facebook {
  13. namespace react {
  14. ScrollViewProps::ScrollViewProps(
  15. const ScrollViewProps &sourceProps,
  16. const RawProps &rawProps)
  17. : ViewProps(sourceProps, rawProps),
  18. alwaysBounceHorizontal(convertRawProp(
  19. rawProps,
  20. "alwaysBounceHorizontal",
  21. sourceProps.alwaysBounceHorizontal,
  22. {})),
  23. alwaysBounceVertical(convertRawProp(
  24. rawProps,
  25. "alwaysBounceVertical",
  26. sourceProps.alwaysBounceVertical,
  27. {})),
  28. bounces(convertRawProp(rawProps, "bounces", sourceProps.bounces, true)),
  29. bouncesZoom(convertRawProp(
  30. rawProps,
  31. "bouncesZoom",
  32. sourceProps.bouncesZoom,
  33. true)),
  34. canCancelContentTouches(convertRawProp(
  35. rawProps,
  36. "canCancelContentTouches",
  37. sourceProps.canCancelContentTouches,
  38. true)),
  39. centerContent(convertRawProp(
  40. rawProps,
  41. "centerContent",
  42. sourceProps.centerContent,
  43. {})),
  44. automaticallyAdjustContentInsets(convertRawProp(
  45. rawProps,
  46. "automaticallyAdjustContentInsets",
  47. sourceProps.automaticallyAdjustContentInsets,
  48. {})),
  49. decelerationRate(convertRawProp(
  50. rawProps,
  51. "decelerationRate",
  52. sourceProps.decelerationRate,
  53. (Float)0.998)),
  54. directionalLockEnabled(convertRawProp(
  55. rawProps,
  56. "directionalLockEnabled",
  57. sourceProps.directionalLockEnabled,
  58. {})),
  59. indicatorStyle(convertRawProp(
  60. rawProps,
  61. "indicatorStyle",
  62. sourceProps.indicatorStyle,
  63. {})),
  64. keyboardDismissMode(convertRawProp(
  65. rawProps,
  66. "keyboardDismissMode",
  67. sourceProps.keyboardDismissMode,
  68. {})),
  69. maximumZoomScale(convertRawProp(
  70. rawProps,
  71. "maximumZoomScale",
  72. sourceProps.maximumZoomScale,
  73. (Float)1.0)),
  74. minimumZoomScale(convertRawProp(
  75. rawProps,
  76. "minimumZoomScale",
  77. sourceProps.minimumZoomScale,
  78. (Float)1.0)),
  79. scrollEnabled(convertRawProp(
  80. rawProps,
  81. "scrollEnabled",
  82. sourceProps.scrollEnabled,
  83. true)),
  84. pagingEnabled(convertRawProp(
  85. rawProps,
  86. "pagingEnabled",
  87. sourceProps.pagingEnabled,
  88. {})),
  89. pinchGestureEnabled(convertRawProp(
  90. rawProps,
  91. "pinchGestureEnabled",
  92. sourceProps.pinchGestureEnabled,
  93. true)),
  94. scrollsToTop(convertRawProp(
  95. rawProps,
  96. "scrollsToTop",
  97. sourceProps.scrollsToTop,
  98. true)),
  99. showsHorizontalScrollIndicator(convertRawProp(
  100. rawProps,
  101. "showsHorizontalScrollIndicator",
  102. sourceProps.showsHorizontalScrollIndicator,
  103. true)),
  104. showsVerticalScrollIndicator(convertRawProp(
  105. rawProps,
  106. "showsVerticalScrollIndicator",
  107. sourceProps.showsVerticalScrollIndicator,
  108. true)),
  109. scrollEventThrottle(convertRawProp(
  110. rawProps,
  111. "scrollEventThrottle",
  112. sourceProps.scrollEventThrottle,
  113. {})),
  114. zoomScale(convertRawProp(
  115. rawProps,
  116. "zoomScale",
  117. sourceProps.zoomScale,
  118. (Float)1.0)),
  119. contentInset(convertRawProp(
  120. rawProps,
  121. "contentInset",
  122. sourceProps.contentInset,
  123. {})),
  124. scrollIndicatorInsets(convertRawProp(
  125. rawProps,
  126. "scrollIndicatorInsets",
  127. sourceProps.scrollIndicatorInsets,
  128. {})),
  129. snapToInterval(convertRawProp(
  130. rawProps,
  131. "snapToInterval",
  132. sourceProps.snapToInterval,
  133. {})),
  134. snapToAlignment(convertRawProp(
  135. rawProps,
  136. "snapToAlignment",
  137. sourceProps.snapToAlignment,
  138. {})) {}
  139. #pragma mark - DebugStringConvertible
  140. #if RN_DEBUG_STRING_CONVERTIBLE
  141. SharedDebugStringConvertibleList ScrollViewProps::getDebugProps() const {
  142. auto defaultScrollViewProps = ScrollViewProps{};
  143. return ViewProps::getDebugProps() +
  144. SharedDebugStringConvertibleList{
  145. debugStringConvertibleItem(
  146. "alwaysBounceHorizontal",
  147. alwaysBounceHorizontal,
  148. defaultScrollViewProps.alwaysBounceHorizontal),
  149. debugStringConvertibleItem(
  150. "alwaysBounceVertical",
  151. alwaysBounceVertical,
  152. defaultScrollViewProps.alwaysBounceVertical),
  153. debugStringConvertibleItem(
  154. "bounces", bounces, defaultScrollViewProps.bounces),
  155. debugStringConvertibleItem(
  156. "bouncesZoom", bouncesZoom, defaultScrollViewProps.bouncesZoom),
  157. debugStringConvertibleItem(
  158. "canCancelContentTouches",
  159. canCancelContentTouches,
  160. defaultScrollViewProps.canCancelContentTouches),
  161. debugStringConvertibleItem(
  162. "centerContent",
  163. centerContent,
  164. defaultScrollViewProps.centerContent),
  165. debugStringConvertibleItem(
  166. "automaticallyAdjustContentInsets",
  167. automaticallyAdjustContentInsets,
  168. defaultScrollViewProps.automaticallyAdjustContentInsets),
  169. debugStringConvertibleItem(
  170. "decelerationRate",
  171. decelerationRate,
  172. defaultScrollViewProps.decelerationRate),
  173. debugStringConvertibleItem(
  174. "directionalLockEnabled",
  175. directionalLockEnabled,
  176. defaultScrollViewProps.directionalLockEnabled),
  177. debugStringConvertibleItem(
  178. "indicatorStyle",
  179. indicatorStyle,
  180. defaultScrollViewProps.indicatorStyle),
  181. debugStringConvertibleItem(
  182. "keyboardDismissMode",
  183. keyboardDismissMode,
  184. defaultScrollViewProps.keyboardDismissMode),
  185. debugStringConvertibleItem(
  186. "maximumZoomScale",
  187. maximumZoomScale,
  188. defaultScrollViewProps.maximumZoomScale),
  189. debugStringConvertibleItem(
  190. "minimumZoomScale",
  191. minimumZoomScale,
  192. defaultScrollViewProps.minimumZoomScale),
  193. debugStringConvertibleItem(
  194. "scrollEnabled",
  195. scrollEnabled,
  196. defaultScrollViewProps.scrollEnabled),
  197. debugStringConvertibleItem(
  198. "pagingEnabled",
  199. pagingEnabled,
  200. defaultScrollViewProps.pagingEnabled),
  201. debugStringConvertibleItem(
  202. "pinchGestureEnabled",
  203. pinchGestureEnabled,
  204. defaultScrollViewProps.pinchGestureEnabled),
  205. debugStringConvertibleItem(
  206. "scrollsToTop",
  207. scrollsToTop,
  208. defaultScrollViewProps.scrollsToTop),
  209. debugStringConvertibleItem(
  210. "showsHorizontalScrollIndicator",
  211. showsHorizontalScrollIndicator,
  212. defaultScrollViewProps.showsHorizontalScrollIndicator),
  213. debugStringConvertibleItem(
  214. "showsVerticalScrollIndicator",
  215. showsVerticalScrollIndicator,
  216. defaultScrollViewProps.showsVerticalScrollIndicator),
  217. debugStringConvertibleItem(
  218. "scrollEventThrottle",
  219. scrollEventThrottle,
  220. defaultScrollViewProps.scrollEventThrottle),
  221. debugStringConvertibleItem(
  222. "zoomScale", zoomScale, defaultScrollViewProps.zoomScale),
  223. debugStringConvertibleItem(
  224. "contentInset",
  225. contentInset,
  226. defaultScrollViewProps.contentInset),
  227. debugStringConvertibleItem(
  228. "scrollIndicatorInsets",
  229. scrollIndicatorInsets,
  230. defaultScrollViewProps.scrollIndicatorInsets),
  231. debugStringConvertibleItem(
  232. "snapToInterval",
  233. snapToInterval,
  234. defaultScrollViewProps.snapToInterval),
  235. debugStringConvertibleItem(
  236. "snapToAlignment",
  237. snapToAlignment,
  238. defaultScrollViewProps.snapToAlignment),
  239. };
  240. }
  241. #endif
  242. } // namespace react
  243. } // namespace facebook