@aws-amplify/ui-react-native 0.0.0-in-app-messaging-20220826014803

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/.eslintrc.js +100 -0
  2. package/.lintstagedrc.js +6 -0
  3. package/.turbo/turbo-build.log +4 -0
  4. package/CHANGELOG.md +11 -0
  5. package/LICENSE +201 -0
  6. package/README.md +25 -0
  7. package/babel.config.js +3 -0
  8. package/dist/InAppMessaging/components/BannerMessage/BannerMessage.d.ts +3 -0
  9. package/dist/InAppMessaging/components/BannerMessage/BannerMessage.js +16 -0
  10. package/dist/InAppMessaging/components/BannerMessage/index.d.ts +2 -0
  11. package/dist/InAppMessaging/components/BannerMessage/index.js +1 -0
  12. package/dist/InAppMessaging/components/BannerMessage/styles.d.ts +7 -0
  13. package/dist/InAppMessaging/components/BannerMessage/styles.js +77 -0
  14. package/dist/InAppMessaging/components/BannerMessage/types.d.ts +12 -0
  15. package/dist/InAppMessaging/components/BannerMessage/types.js +1 -0
  16. package/dist/InAppMessaging/components/CarouselMessage/CarouselMessage.d.ts +3 -0
  17. package/dist/InAppMessaging/components/CarouselMessage/CarouselMessage.js +20 -0
  18. package/dist/InAppMessaging/components/CarouselMessage/CarouselMessageItem.d.ts +3 -0
  19. package/dist/InAppMessaging/components/CarouselMessage/CarouselMessageItem.js +18 -0
  20. package/dist/InAppMessaging/components/CarouselMessage/index.d.ts +2 -0
  21. package/dist/InAppMessaging/components/CarouselMessage/index.js +1 -0
  22. package/dist/InAppMessaging/components/CarouselMessage/styles.d.ts +5 -0
  23. package/dist/InAppMessaging/components/CarouselMessage/styles.js +98 -0
  24. package/dist/InAppMessaging/components/CarouselMessage/types.d.ts +18 -0
  25. package/dist/InAppMessaging/components/CarouselMessage/types.js +1 -0
  26. package/dist/InAppMessaging/components/FullScreenMessage/FullScreenMessage.d.ts +3 -0
  27. package/dist/InAppMessaging/components/FullScreenMessage/FullScreenMessage.js +18 -0
  28. package/dist/InAppMessaging/components/FullScreenMessage/index.d.ts +2 -0
  29. package/dist/InAppMessaging/components/FullScreenMessage/index.js +1 -0
  30. package/dist/InAppMessaging/components/FullScreenMessage/styles.d.ts +3 -0
  31. package/dist/InAppMessaging/components/FullScreenMessage/styles.js +86 -0
  32. package/dist/InAppMessaging/components/FullScreenMessage/types.d.ts +6 -0
  33. package/dist/InAppMessaging/components/FullScreenMessage/types.js +1 -0
  34. package/dist/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.d.ts +10 -0
  35. package/dist/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.js +29 -0
  36. package/dist/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.d.ts +3 -0
  37. package/dist/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +24 -0
  38. package/dist/InAppMessaging/components/InAppMessageDisplay/index.d.ts +2 -0
  39. package/dist/InAppMessaging/components/InAppMessageDisplay/index.js +1 -0
  40. package/dist/InAppMessaging/components/InAppMessageDisplay/types.d.ts +24 -0
  41. package/dist/InAppMessaging/components/InAppMessageDisplay/types.js +1 -0
  42. package/dist/InAppMessaging/components/MessageLayout/MessageLayout.d.ts +3 -0
  43. package/dist/InAppMessaging/components/MessageLayout/MessageLayout.js +34 -0
  44. package/dist/InAppMessaging/components/MessageLayout/index.d.ts +1 -0
  45. package/dist/InAppMessaging/components/MessageLayout/index.js +1 -0
  46. package/dist/InAppMessaging/components/MessageLayout/types.d.ts +7 -0
  47. package/dist/InAppMessaging/components/MessageLayout/types.js +1 -0
  48. package/dist/InAppMessaging/components/MessageWrapper/MessageWrapper.d.ts +3 -0
  49. package/dist/InAppMessaging/components/MessageWrapper/MessageWrapper.js +20 -0
  50. package/dist/InAppMessaging/components/MessageWrapper/index.d.ts +2 -0
  51. package/dist/InAppMessaging/components/MessageWrapper/index.js +1 -0
  52. package/dist/InAppMessaging/components/MessageWrapper/styles.d.ts +2 -0
  53. package/dist/InAppMessaging/components/MessageWrapper/styles.js +5 -0
  54. package/dist/InAppMessaging/components/MessageWrapper/types.d.ts +10 -0
  55. package/dist/InAppMessaging/components/MessageWrapper/types.js +1 -0
  56. package/dist/InAppMessaging/components/ModalMessage/ModalMessage.d.ts +3 -0
  57. package/dist/InAppMessaging/components/ModalMessage/ModalMessage.js +18 -0
  58. package/dist/InAppMessaging/components/ModalMessage/index.d.ts +2 -0
  59. package/dist/InAppMessaging/components/ModalMessage/index.js +1 -0
  60. package/dist/InAppMessaging/components/ModalMessage/styles.d.ts +4 -0
  61. package/dist/InAppMessaging/components/ModalMessage/styles.js +99 -0
  62. package/dist/InAppMessaging/components/ModalMessage/types.d.ts +6 -0
  63. package/dist/InAppMessaging/components/ModalMessage/types.js +1 -0
  64. package/dist/InAppMessaging/components/index.d.ts +6 -0
  65. package/dist/InAppMessaging/components/index.js +2 -0
  66. package/dist/InAppMessaging/components/withInAppMessaging/index.d.ts +1 -0
  67. package/dist/InAppMessaging/components/withInAppMessaging/index.js +1 -0
  68. package/dist/InAppMessaging/components/withInAppMessaging/withInAppMessaging.d.ts +5 -0
  69. package/dist/InAppMessaging/components/withInAppMessaging/withInAppMessaging.js +11 -0
  70. package/dist/InAppMessaging/constants.d.ts +31 -0
  71. package/dist/InAppMessaging/constants.js +43 -0
  72. package/dist/InAppMessaging/hooks/index.d.ts +2 -0
  73. package/dist/InAppMessaging/hooks/index.js +2 -0
  74. package/dist/InAppMessaging/hooks/useMessageImage/constants.d.ts +8 -0
  75. package/dist/InAppMessaging/hooks/useMessageImage/constants.js +18 -0
  76. package/dist/InAppMessaging/hooks/useMessageImage/index.d.ts +2 -0
  77. package/dist/InAppMessaging/hooks/useMessageImage/index.js +1 -0
  78. package/dist/InAppMessaging/hooks/useMessageImage/types.d.ts +15 -0
  79. package/dist/InAppMessaging/hooks/useMessageImage/types.js +6 -0
  80. package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.d.ts +10 -0
  81. package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.js +50 -0
  82. package/dist/InAppMessaging/hooks/useMessageImage/utils.d.ts +4 -0
  83. package/dist/InAppMessaging/hooks/useMessageImage/utils.js +56 -0
  84. package/dist/InAppMessaging/hooks/useMessageProps/index.d.ts +2 -0
  85. package/dist/InAppMessaging/hooks/useMessageProps/index.js +1 -0
  86. package/dist/InAppMessaging/hooks/useMessageProps/types.d.ts +109 -0
  87. package/dist/InAppMessaging/hooks/useMessageProps/types.js +1 -0
  88. package/dist/InAppMessaging/hooks/useMessageProps/useMessageProps.d.ts +12 -0
  89. package/dist/InAppMessaging/hooks/useMessageProps/useMessageProps.js +49 -0
  90. package/dist/InAppMessaging/hooks/useMessageProps/utils.d.ts +43 -0
  91. package/dist/InAppMessaging/hooks/useMessageProps/utils.js +192 -0
  92. package/dist/InAppMessaging/index.d.ts +2 -0
  93. package/dist/InAppMessaging/index.js +2 -0
  94. package/dist/__mocks__/react-native-safe-area-context.d.ts +3 -0
  95. package/dist/__mocks__/react-native-safe-area-context.js +4 -0
  96. package/dist/assets/close.png +0 -0
  97. package/dist/assets/index.d.ts +5 -0
  98. package/dist/assets/index.js +4 -0
  99. package/dist/assets/index.ts +7 -0
  100. package/dist/hooks/index.d.ts +1 -0
  101. package/dist/hooks/index.js +1 -0
  102. package/dist/hooks/useDeviceOrientation/index.d.ts +1 -0
  103. package/dist/hooks/useDeviceOrientation/index.js +1 -0
  104. package/dist/hooks/useDeviceOrientation/useDeviceOrientation.d.ts +6 -0
  105. package/dist/hooks/useDeviceOrientation/useDeviceOrientation.js +33 -0
  106. package/dist/index.d.ts +1 -0
  107. package/dist/index.js +1 -0
  108. package/dist/primitives/Button/Button.d.ts +3 -0
  109. package/dist/primitives/Button/Button.js +8 -0
  110. package/dist/primitives/Button/index.d.ts +2 -0
  111. package/dist/primitives/Button/index.js +1 -0
  112. package/dist/primitives/Button/styles.d.ts +2 -0
  113. package/dist/primitives/Button/styles.js +4 -0
  114. package/dist/primitives/Button/types.d.ts +7 -0
  115. package/dist/primitives/Button/types.js +1 -0
  116. package/dist/primitives/Carousel/Carousel.d.ts +3 -0
  117. package/dist/primitives/Carousel/Carousel.js +58 -0
  118. package/dist/primitives/Carousel/CarouselPageIndicator.d.ts +3 -0
  119. package/dist/primitives/Carousel/CarouselPageIndicator.js +10 -0
  120. package/dist/primitives/Carousel/constants.d.ts +9 -0
  121. package/dist/primitives/Carousel/constants.js +18 -0
  122. package/dist/primitives/Carousel/index.d.ts +3 -0
  123. package/dist/primitives/Carousel/index.js +2 -0
  124. package/dist/primitives/Carousel/styles.d.ts +2 -0
  125. package/dist/primitives/Carousel/styles.js +11 -0
  126. package/dist/primitives/Carousel/types.d.ts +19 -0
  127. package/dist/primitives/Carousel/types.js +1 -0
  128. package/dist/primitives/IconButton/IconButton.d.ts +3 -0
  129. package/dist/primitives/IconButton/IconButton.js +9 -0
  130. package/dist/primitives/IconButton/index.d.ts +2 -0
  131. package/dist/primitives/IconButton/index.js +1 -0
  132. package/dist/primitives/IconButton/styles.d.ts +2 -0
  133. package/dist/primitives/IconButton/styles.js +9 -0
  134. package/dist/primitives/IconButton/types.d.ts +18 -0
  135. package/dist/primitives/IconButton/types.js +1 -0
  136. package/dist/primitives/index.d.ts +3 -0
  137. package/dist/primitives/index.js +3 -0
  138. package/dist/utils/index.d.ts +1 -0
  139. package/dist/utils/index.js +4 -0
  140. package/jest.config.js +20 -0
  141. package/package.json +55 -0
  142. package/src/InAppMessaging/components/BannerMessage/BannerMessage.tsx +37 -0
  143. package/src/InAppMessaging/components/BannerMessage/__tests__/BannerMessage.spec.tsx +138 -0
  144. package/src/InAppMessaging/components/BannerMessage/__tests__/__snapshots__/BannerMessage.spec.tsx.snap +224 -0
  145. package/src/InAppMessaging/components/BannerMessage/index.ts +2 -0
  146. package/src/InAppMessaging/components/BannerMessage/styles.ts +105 -0
  147. package/src/InAppMessaging/components/BannerMessage/types.ts +15 -0
  148. package/src/InAppMessaging/components/CarouselMessage/CarouselMessage.tsx +42 -0
  149. package/src/InAppMessaging/components/CarouselMessage/CarouselMessageItem.tsx +37 -0
  150. package/src/InAppMessaging/components/CarouselMessage/__tests__/CarouselMessage.spec.tsx +55 -0
  151. package/src/InAppMessaging/components/CarouselMessage/__tests__/CarouselMessageItem.spec.tsx +56 -0
  152. package/src/InAppMessaging/components/CarouselMessage/__tests__/__snapshots__/CarouselMessage.spec.tsx.snap +86 -0
  153. package/src/InAppMessaging/components/CarouselMessage/__tests__/__snapshots__/CarouselMessageItem.spec.tsx.snap +248 -0
  154. package/src/InAppMessaging/components/CarouselMessage/index.ts +2 -0
  155. package/src/InAppMessaging/components/CarouselMessage/styles.ts +125 -0
  156. package/src/InAppMessaging/components/CarouselMessage/types.ts +28 -0
  157. package/src/InAppMessaging/components/FullScreenMessage/FullScreenMessage.tsx +38 -0
  158. package/src/InAppMessaging/components/FullScreenMessage/__tests__/FullScreenMessage.spec.tsx +53 -0
  159. package/src/InAppMessaging/components/FullScreenMessage/__tests__/__snapshots__/FullScreenMessage.spec.tsx.snap +236 -0
  160. package/src/InAppMessaging/components/FullScreenMessage/index.ts +2 -0
  161. package/src/InAppMessaging/components/FullScreenMessage/styles.ts +106 -0
  162. package/src/InAppMessaging/components/FullScreenMessage/types.ts +7 -0
  163. package/src/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.tsx +48 -0
  164. package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/InAppMessageDisplay.spec.tsx +33 -0
  165. package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/__snapshots__/InAppMessageDisplay.spec.tsx.snap +9 -0
  166. package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/handleMessageLinkAction.spec.ts +51 -0
  167. package/src/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.ts +30 -0
  168. package/src/InAppMessaging/components/InAppMessageDisplay/index.ts +2 -0
  169. package/src/InAppMessaging/components/InAppMessageDisplay/types.ts +32 -0
  170. package/src/InAppMessaging/components/MessageLayout/MessageLayout.tsx +102 -0
  171. package/src/InAppMessaging/components/MessageLayout/index.ts +1 -0
  172. package/src/InAppMessaging/components/MessageLayout/types.ts +15 -0
  173. package/src/InAppMessaging/components/MessageWrapper/MessageWrapper.tsx +34 -0
  174. package/src/InAppMessaging/components/MessageWrapper/__tests__/MessageWrapper.spec.tsx +19 -0
  175. package/src/InAppMessaging/components/MessageWrapper/__tests__/__snapshots__/MessageWrapper.spec.tsx.snap +35 -0
  176. package/src/InAppMessaging/components/MessageWrapper/index.ts +2 -0
  177. package/src/InAppMessaging/components/MessageWrapper/styles.ts +7 -0
  178. package/src/InAppMessaging/components/MessageWrapper/types.ts +12 -0
  179. package/src/InAppMessaging/components/ModalMessage/ModalMessage.tsx +37 -0
  180. package/src/InAppMessaging/components/ModalMessage/__tests__/ModalMessage.spec.tsx +155 -0
  181. package/src/InAppMessaging/components/ModalMessage/__tests__/__snapshots__/ModalMessage.spec.tsx.snap +323 -0
  182. package/src/InAppMessaging/components/ModalMessage/index.ts +2 -0
  183. package/src/InAppMessaging/components/ModalMessage/styles.ts +132 -0
  184. package/src/InAppMessaging/components/ModalMessage/types.ts +8 -0
  185. package/src/InAppMessaging/components/index.ts +6 -0
  186. package/src/InAppMessaging/components/withInAppMessaging/__tests__/__snapshots__/withInAppMessaging.spec.tsx.snap +3 -0
  187. package/src/InAppMessaging/components/withInAppMessaging/__tests__/withInAppMessaging.spec.tsx +15 -0
  188. package/src/InAppMessaging/components/withInAppMessaging/index.ts +1 -0
  189. package/src/InAppMessaging/components/withInAppMessaging/withInAppMessaging.tsx +18 -0
  190. package/src/InAppMessaging/constants.ts +56 -0
  191. package/src/InAppMessaging/hooks/index.ts +9 -0
  192. package/src/InAppMessaging/hooks/useMessageImage/__tests__/useMessageImage.spec.ts +141 -0
  193. package/src/InAppMessaging/hooks/useMessageImage/__tests__/utils.spec.ts +107 -0
  194. package/src/InAppMessaging/hooks/useMessageImage/constants.ts +27 -0
  195. package/src/InAppMessaging/hooks/useMessageImage/index.ts +2 -0
  196. package/src/InAppMessaging/hooks/useMessageImage/types.ts +18 -0
  197. package/src/InAppMessaging/hooks/useMessageImage/useMessageImage.ts +74 -0
  198. package/src/InAppMessaging/hooks/useMessageImage/utils.ts +80 -0
  199. package/src/InAppMessaging/hooks/useMessageProps/__tests__/__snapshots__/utils.spec.ts.snap +223 -0
  200. package/src/InAppMessaging/hooks/useMessageProps/__tests__/useMessageProps.spec.ts +162 -0
  201. package/src/InAppMessaging/hooks/useMessageProps/__tests__/utils.spec.ts +354 -0
  202. package/src/InAppMessaging/hooks/useMessageProps/index.ts +8 -0
  203. package/src/InAppMessaging/hooks/useMessageProps/types.ts +131 -0
  204. package/src/InAppMessaging/hooks/useMessageProps/useMessageProps.ts +70 -0
  205. package/src/InAppMessaging/hooks/useMessageProps/utils.ts +274 -0
  206. package/src/InAppMessaging/index.ts +14 -0
  207. package/src/__mocks__/react-native-safe-area-context.ts +6 -0
  208. package/src/__tests__/__snapshots__/index.spec.ts.snap +15 -0
  209. package/src/__tests__/index.spec.ts +8 -0
  210. package/src/assets/close.png +0 -0
  211. package/src/assets/index.ts +7 -0
  212. package/src/hooks/index.ts +4 -0
  213. package/src/hooks/useDeviceOrientation/__tests__/useDeviceOrientation.spec.ts +87 -0
  214. package/src/hooks/useDeviceOrientation/index.ts +4 -0
  215. package/src/hooks/useDeviceOrientation/useDeviceOrientation.ts +47 -0
  216. package/src/index.ts +1 -0
  217. package/src/primitives/Button/Button.tsx +21 -0
  218. package/src/primitives/Button/__tests__/Button.spec.tsx +24 -0
  219. package/src/primitives/Button/__tests__/__snapshots__/Button.spec.tsx.snap +52 -0
  220. package/src/primitives/Button/index.ts +2 -0
  221. package/src/primitives/Button/styles.ts +6 -0
  222. package/src/primitives/Button/types.ts +9 -0
  223. package/src/primitives/Carousel/Carousel.tsx +115 -0
  224. package/src/primitives/Carousel/CarouselPageIndicator.tsx +39 -0
  225. package/src/primitives/Carousel/__tests__/Carousel.spec.tsx +185 -0
  226. package/src/primitives/Carousel/__tests__/CarouselPageIndicator.spec.tsx +71 -0
  227. package/src/primitives/Carousel/__tests__/__snapshots__/Carousel.spec.tsx.snap +216 -0
  228. package/src/primitives/Carousel/__tests__/__snapshots__/CarouselPageIndicator.spec.tsx.snap +191 -0
  229. package/src/primitives/Carousel/constants.ts +25 -0
  230. package/src/primitives/Carousel/index.ts +3 -0
  231. package/src/primitives/Carousel/styles.ts +14 -0
  232. package/src/primitives/Carousel/types.ts +22 -0
  233. package/src/primitives/IconButton/IconButton.tsx +20 -0
  234. package/src/primitives/IconButton/__tests__/IconButton.spec.tsx +13 -0
  235. package/src/primitives/IconButton/__tests__/__snapshots__/IconButton.spec.tsx.snap +34 -0
  236. package/src/primitives/IconButton/index.ts +2 -0
  237. package/src/primitives/IconButton/styles.ts +16 -0
  238. package/src/primitives/IconButton/types.ts +27 -0
  239. package/src/primitives/index.ts +3 -0
  240. package/src/utils/index.ts +6 -0
  241. package/tsconfig.dist.json +4 -0
  242. package/tsconfig.json +21 -0
@@ -0,0 +1,248 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CarouselMessageItem renders as expected in landscape mode 1`] = `
4
+ <SafeAreaView
5
+ style={
6
+ Array [
7
+ Object {
8
+ "backgroundColor": "#fff",
9
+ "flex": 1,
10
+ },
11
+ Object {},
12
+ Object {},
13
+ Object {},
14
+ ]
15
+ }
16
+ >
17
+ <MessageLayout
18
+ hasButtons={false}
19
+ hasPrimaryButton={false}
20
+ hasRenderableImage={false}
21
+ hasSecondaryButton={false}
22
+ layout="CAROUSEL"
23
+ orientation="landscape"
24
+ shouldRenderMessage={true}
25
+ styles={
26
+ Object {
27
+ "body": Array [
28
+ Object {
29
+ "fontSize": 16,
30
+ "fontWeight": "400",
31
+ "lineHeight": 24,
32
+ },
33
+ Object {},
34
+ undefined,
35
+ ],
36
+ "buttonsContainer": Object {
37
+ "flexDirection": "row",
38
+ "justifyContent": "center",
39
+ },
40
+ "container": Array [
41
+ Array [
42
+ Object {
43
+ "flex": 1,
44
+ "padding": 16,
45
+ },
46
+ Object {},
47
+ Object {},
48
+ ],
49
+ Object {
50
+ "paddingBottom": 36,
51
+ },
52
+ ],
53
+ "contentContainer": Object {
54
+ "alignContent": "center",
55
+ "flex": 1,
56
+ "flexDirection": "row",
57
+ "justifyContent": "center",
58
+ },
59
+ "header": Array [
60
+ Object {
61
+ "fontSize": 18,
62
+ "fontWeight": "400",
63
+ "lineHeight": 27,
64
+ },
65
+ Object {},
66
+ undefined,
67
+ ],
68
+ "iconButton": Object {
69
+ "container": Array [
70
+ Object {
71
+ "alignSelf": "flex-start",
72
+ "marginBottom": 8,
73
+ "marginLeft": "auto",
74
+ "marginRight": 8,
75
+ },
76
+ undefined,
77
+ ],
78
+ "iconColor": undefined,
79
+ },
80
+ "image": Array [
81
+ Object {
82
+ "height": null,
83
+ "width": null,
84
+ },
85
+ undefined,
86
+ ],
87
+ "imageContainer": Object {
88
+ "alignItems": "center",
89
+ "justifyContent": "center",
90
+ "margin": 12,
91
+ },
92
+ "primaryButton": Object {
93
+ "container": [Function],
94
+ "text": Array [
95
+ Object {
96
+ "fontSize": 16,
97
+ "fontWeight": "400",
98
+ "lineHeight": 24,
99
+ "textAlign": "center",
100
+ },
101
+ Object {},
102
+ Object {},
103
+ ],
104
+ },
105
+ "secondaryButton": Object {
106
+ "container": [Function],
107
+ "text": Array [
108
+ Object {
109
+ "fontSize": 16,
110
+ "fontWeight": "400",
111
+ "lineHeight": 24,
112
+ "textAlign": "center",
113
+ },
114
+ Object {},
115
+ Object {},
116
+ ],
117
+ },
118
+ "textContainer": Object {
119
+ "flex": 1,
120
+ "justifyContent": "center",
121
+ "paddingHorizontal": 8,
122
+ },
123
+ }
124
+ }
125
+ />
126
+ </SafeAreaView>
127
+ `;
128
+
129
+ exports[`CarouselMessageItem renders as expected in portrait mode 1`] = `
130
+ <SafeAreaView
131
+ style={
132
+ Array [
133
+ Object {
134
+ "backgroundColor": "#fff",
135
+ "flex": 1,
136
+ },
137
+ Object {},
138
+ Object {},
139
+ Object {},
140
+ ]
141
+ }
142
+ >
143
+ <MessageLayout
144
+ hasButtons={false}
145
+ hasPrimaryButton={false}
146
+ hasRenderableImage={false}
147
+ hasSecondaryButton={false}
148
+ layout="CAROUSEL"
149
+ orientation="portrait"
150
+ shouldRenderMessage={true}
151
+ styles={
152
+ Object {
153
+ "body": Array [
154
+ Object {
155
+ "fontSize": 16,
156
+ "fontWeight": "400",
157
+ "lineHeight": 24,
158
+ },
159
+ Object {},
160
+ undefined,
161
+ ],
162
+ "buttonsContainer": Object {
163
+ "flexDirection": "row",
164
+ "justifyContent": "center",
165
+ },
166
+ "container": Array [
167
+ Array [
168
+ Object {
169
+ "flex": 1,
170
+ "padding": 16,
171
+ },
172
+ Object {},
173
+ Object {},
174
+ ],
175
+ Object {
176
+ "paddingBottom": 36,
177
+ },
178
+ ],
179
+ "contentContainer": Object {
180
+ "flex": 1,
181
+ },
182
+ "header": Array [
183
+ Object {
184
+ "fontSize": 18,
185
+ "fontWeight": "400",
186
+ "lineHeight": 27,
187
+ },
188
+ Object {},
189
+ undefined,
190
+ ],
191
+ "iconButton": Object {
192
+ "container": Array [
193
+ Object {
194
+ "alignSelf": "flex-start",
195
+ "marginBottom": 8,
196
+ "marginLeft": "auto",
197
+ "marginRight": 8,
198
+ },
199
+ undefined,
200
+ ],
201
+ "iconColor": undefined,
202
+ },
203
+ "image": Array [
204
+ Object {
205
+ "height": null,
206
+ "width": null,
207
+ },
208
+ undefined,
209
+ ],
210
+ "imageContainer": Object {
211
+ "alignItems": "center",
212
+ "margin": 12,
213
+ },
214
+ "primaryButton": Object {
215
+ "container": [Function],
216
+ "text": Array [
217
+ Object {
218
+ "fontSize": 16,
219
+ "fontWeight": "400",
220
+ "lineHeight": 24,
221
+ "textAlign": "center",
222
+ },
223
+ Object {},
224
+ Object {},
225
+ ],
226
+ },
227
+ "secondaryButton": Object {
228
+ "container": [Function],
229
+ "text": Array [
230
+ Object {
231
+ "fontSize": 16,
232
+ "fontWeight": "400",
233
+ "lineHeight": 24,
234
+ "textAlign": "center",
235
+ },
236
+ Object {},
237
+ Object {},
238
+ ],
239
+ },
240
+ "textContainer": Object {
241
+ "marginVertical": 12,
242
+ "paddingHorizontal": 8,
243
+ },
244
+ }
245
+ }
246
+ />
247
+ </SafeAreaView>
248
+ `;
@@ -0,0 +1,2 @@
1
+ export { default as CarouselMessage } from './CarouselMessage';
2
+ export { CarouselMessageProps } from './types';
@@ -0,0 +1,125 @@
1
+ import { ImageStyle, StyleSheet } from 'react-native';
2
+ import {
3
+ BORDER_RADIUS_BASE,
4
+ COLOR_GREY,
5
+ COLOR_LIGHT_GREY,
6
+ COLOR_LIGHT_GREY_2,
7
+ COLOR_WHITE,
8
+ FONT_SIZE_BASE,
9
+ FONT_SIZE_LARGE,
10
+ FONT_WEIGHT_BASE,
11
+ LINE_HEIGHT_BASE,
12
+ LINE_HEIGHT_LARGE,
13
+ SPACING_EXTRA_LARGE,
14
+ SPACING_LARGE,
15
+ SPACING_MEDIUM,
16
+ SPACING_SMALL,
17
+ } from '../../constants';
18
+
19
+ import { CarouselMessageStyle, CarouselMessageComponentStyle } from './types';
20
+
21
+ export const defaultStyle: CarouselMessageComponentStyle = StyleSheet.create({
22
+ pageIndicatorActive: {
23
+ backgroundColor: COLOR_GREY,
24
+ borderRadius: SPACING_LARGE / 2,
25
+ height: SPACING_LARGE,
26
+ margin: SPACING_SMALL,
27
+ width: SPACING_LARGE,
28
+ },
29
+ pageIndicatorInactive: {
30
+ backgroundColor: COLOR_LIGHT_GREY_2,
31
+ borderRadius: SPACING_LARGE / 2,
32
+ height: SPACING_LARGE,
33
+ margin: SPACING_SMALL,
34
+ width: SPACING_LARGE,
35
+ },
36
+ });
37
+
38
+ const commonStyles: Omit<CarouselMessageStyle, 'image'> = {
39
+ body: {
40
+ fontSize: FONT_SIZE_BASE,
41
+ fontWeight: FONT_WEIGHT_BASE,
42
+ lineHeight: LINE_HEIGHT_BASE,
43
+ },
44
+ buttonContainer: {
45
+ backgroundColor: COLOR_LIGHT_GREY,
46
+ borderRadius: BORDER_RADIUS_BASE,
47
+ flex: 1,
48
+ margin: SPACING_MEDIUM,
49
+ padding: SPACING_LARGE,
50
+ },
51
+ buttonsContainer: {
52
+ flexDirection: 'row',
53
+ justifyContent: 'center',
54
+ },
55
+ buttonText: {
56
+ fontSize: FONT_SIZE_BASE,
57
+ fontWeight: FONT_WEIGHT_BASE,
58
+ lineHeight: LINE_HEIGHT_BASE,
59
+ textAlign: 'center',
60
+ },
61
+ container: {
62
+ flex: 1,
63
+ padding: SPACING_EXTRA_LARGE,
64
+ },
65
+ contentContainer: {
66
+ flex: 1,
67
+ },
68
+ header: {
69
+ fontSize: FONT_SIZE_LARGE,
70
+ fontWeight: FONT_WEIGHT_BASE,
71
+ lineHeight: LINE_HEIGHT_LARGE,
72
+ },
73
+ iconButton: {
74
+ alignSelf: 'flex-start',
75
+ marginBottom: SPACING_MEDIUM,
76
+ marginLeft: 'auto',
77
+ marginRight: SPACING_MEDIUM,
78
+ },
79
+ imageContainer: {
80
+ alignItems: 'center',
81
+ margin: SPACING_LARGE,
82
+ },
83
+ textContainer: {
84
+ paddingHorizontal: SPACING_MEDIUM,
85
+ },
86
+ wrapper: {
87
+ backgroundColor: COLOR_WHITE,
88
+ flex: 1,
89
+ },
90
+ };
91
+
92
+ export const getPortraitStyles = (
93
+ imageDimensions: ImageStyle
94
+ ): CarouselMessageStyle =>
95
+ StyleSheet.create({
96
+ ...commonStyles,
97
+ image: { ...imageDimensions },
98
+ textContainer: {
99
+ ...commonStyles.textContainer,
100
+ marginVertical: SPACING_LARGE,
101
+ },
102
+ });
103
+
104
+ export const getLandscapeStyles = (
105
+ imageDimensions: ImageStyle
106
+ ): CarouselMessageStyle =>
107
+ StyleSheet.create({
108
+ ...commonStyles,
109
+ contentContainer: {
110
+ ...commonStyles.contentContainer,
111
+ alignContent: 'center',
112
+ justifyContent: 'center',
113
+ flexDirection: 'row',
114
+ },
115
+ image: { ...imageDimensions },
116
+ imageContainer: {
117
+ ...commonStyles.imageContainer,
118
+ justifyContent: 'center',
119
+ },
120
+ textContainer: {
121
+ ...commonStyles.textContainer,
122
+ flex: 1,
123
+ justifyContent: 'center',
124
+ },
125
+ });
@@ -0,0 +1,28 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+
3
+ import {
4
+ CarouselMessageCommonProps,
5
+ MessageComponentBaseProps,
6
+ } from '@aws-amplify/ui-react-core';
7
+
8
+ import { MessageDefaultStyle, MessageOverrideStyle } from '../../hooks';
9
+
10
+ interface CarouselMessageOverrideStyle extends MessageOverrideStyle {
11
+ pageIndicatorActive?: StyleProp<ViewStyle>;
12
+ pageIndicatorInactive?: StyleProp<ViewStyle>;
13
+ }
14
+
15
+ export interface CarouselMessageProps
16
+ extends CarouselMessageCommonProps<
17
+ CarouselMessageOverrideStyle | undefined
18
+ > {}
19
+
20
+ export interface CarouselMessageItemProps
21
+ extends MessageComponentBaseProps<CarouselMessageOverrideStyle> {}
22
+
23
+ export interface CarouselMessageStyle extends MessageDefaultStyle {}
24
+
25
+ export interface CarouselMessageComponentStyle {
26
+ pageIndicatorActive: ViewStyle;
27
+ pageIndicatorInactive: ViewStyle;
28
+ }
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+
3
+ import { useDeviceOrientation } from '../../../hooks';
4
+
5
+ import { useMessageProps } from '../../hooks';
6
+ import { MessageLayout } from '../MessageLayout';
7
+ import { MessageWrapper } from '../MessageWrapper';
8
+
9
+ import { getLandscapeStyles, getPortraitStyles } from './styles';
10
+ import { FullScreenMessageProps } from './types';
11
+
12
+ export default function FullScreenMessage(
13
+ props: FullScreenMessageProps
14
+ ): JSX.Element | null {
15
+ const { deviceOrientation, isPortraitMode } = useDeviceOrientation();
16
+ const messageProps = useMessageProps(
17
+ props,
18
+ isPortraitMode ? getPortraitStyles : getLandscapeStyles
19
+ );
20
+ const { shouldRenderMessage, styles } = messageProps;
21
+
22
+ if (!shouldRenderMessage) {
23
+ return null;
24
+ }
25
+
26
+ const { wrapper, ...messageStyles } = styles!;
27
+
28
+ return (
29
+ <MessageWrapper style={wrapper}>
30
+ <MessageLayout
31
+ {...props}
32
+ {...messageProps}
33
+ orientation={deviceOrientation}
34
+ styles={messageStyles}
35
+ />
36
+ </MessageWrapper>
37
+ );
38
+ }
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import TestRenderer from 'react-test-renderer';
3
+
4
+ import { useDeviceOrientation } from '../../../../hooks';
5
+ import { useMessageImage } from '../../../hooks';
6
+
7
+ import FullScreenMessage from '../FullScreenMessage';
8
+
9
+ jest.mock('../../../../hooks');
10
+ jest.mock('../../../hooks/useMessageImage');
11
+ jest.mock('../../MessageWrapper', () => ({ MessageWrapper: 'MessageWrapper' }));
12
+ jest.mock('../../MessageLayout', () => ({ MessageLayout: 'MessageLayout' }));
13
+
14
+ const baseProps = { layout: 'FULL_SCREEN' as const };
15
+
16
+ const mockUseMessageImage = useMessageImage as jest.Mock;
17
+
18
+ describe('FullScreenMessage', () => {
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ it.each([
24
+ ['landscape', false],
25
+ ['portrait', true],
26
+ ])('renders as expected in %s mode', (deviceOrientation, isPortraitMode) => {
27
+ (useDeviceOrientation as jest.Mock).mockReturnValue({
28
+ deviceOrientation,
29
+ isPortraitMode,
30
+ });
31
+ mockUseMessageImage.mockReturnValueOnce({
32
+ hasRenderableImage: false,
33
+ imageDimensions: { height: null, width: null },
34
+ isImageFetching: false,
35
+ });
36
+
37
+ const renderer = TestRenderer.create(<FullScreenMessage {...baseProps} />);
38
+
39
+ expect(renderer.toJSON()).toMatchSnapshot();
40
+ });
41
+
42
+ it('returns null while an image is fetching', () => {
43
+ mockUseMessageImage.mockReturnValueOnce({
44
+ hasRenderableImage: false,
45
+ imageDimensions: { height: null, width: null },
46
+ isImageFetching: true,
47
+ });
48
+
49
+ const renderer = TestRenderer.create(<FullScreenMessage {...baseProps} />);
50
+
51
+ expect(renderer.toJSON()).toBeNull();
52
+ });
53
+ });