react-native-acoustic-connect 19.0.11 → 19.0.28

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 (376) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +390 -1
  3. package/android/build.gradle +86 -3
  4. package/android/config.gradle +123 -13
  5. package/android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt +407 -34
  6. package/app.plugin.js +2 -2
  7. package/ios/AcousticConnectRNConfig.json +2 -2
  8. package/ios/ConnectRNParsing.swift +229 -0
  9. package/ios/HybridAcousticConnectRN.swift +290 -30
  10. package/lib/commonjs/TLTRN.js +116 -3
  11. package/lib/commonjs/TLTRN.js.map +1 -1
  12. package/lib/commonjs/components/Connect.js +145 -27
  13. package/lib/commonjs/components/Connect.js.map +1 -1
  14. package/lib/commonjs/index.js +3 -0
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/module/TLTRN.js +116 -3
  17. package/lib/module/TLTRN.js.map +1 -1
  18. package/lib/module/components/Connect.js +146 -28
  19. package/lib/module/components/Connect.js.map +1 -1
  20. package/lib/module/index.js +5 -0
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/typescript/src/TLTRN.d.ts +85 -1
  23. package/lib/typescript/src/TLTRN.d.ts.map +1 -1
  24. package/lib/typescript/src/components/Connect.d.ts.map +1 -1
  25. package/lib/typescript/src/index.d.ts +1 -0
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts +178 -10
  28. package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts.map +1 -1
  29. package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.cpp +5 -9
  30. package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.hpp +1 -1
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/HybridAcousticConnectRNSpec.kt +2 -1
  32. package/nitrogen/generated/ios/AcousticConnectRN-Swift-Cxx-Umbrella.hpp +1 -0
  33. package/nitrogen/generated/ios/c++/HybridAcousticConnectRNSpecSwift.hpp +2 -1
  34. package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec.swift +1 -1
  35. package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec_cxx.swift +2 -25
  36. package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.hpp +2 -1
  37. package/package.json +4 -7
  38. package/plugin/build/withConnectAndroidConfig.d.ts +2 -2
  39. package/plugin/build/withConnectAndroidConfig.js +2 -2
  40. package/plugin/build/withConnectIosSigning.d.ts +1 -1
  41. package/plugin/build/withConnectIosSigning.js +1 -1
  42. package/plugin/src/withConnectAndroidConfig.ts +2 -2
  43. package/plugin/src/withConnectIosSigning.ts +1 -1
  44. package/scripts/gradleParser.js +1 -1
  45. package/src/TLTRN.ts +125 -4
  46. package/src/components/Connect.tsx +150 -27
  47. package/src/index.ts +5 -0
  48. package/src/specs/react-native-acoustic-connect.nitro.ts +180 -10
  49. package/Examples/SampleUI/.bundle/config +0 -2
  50. package/Examples/SampleUI/.detoxrc.js +0 -83
  51. package/Examples/SampleUI/.eslintrc.js +0 -4
  52. package/Examples/SampleUI/.prettierrc.js +0 -7
  53. package/Examples/SampleUI/.watchmanconfig +0 -1
  54. package/Examples/SampleUI/App.js +0 -1
  55. package/Examples/SampleUI/Gemfile +0 -10
  56. package/Examples/SampleUI/Gemfile.lock +0 -121
  57. package/Examples/SampleUI/README.md +0 -79
  58. package/Examples/SampleUI/__tests__/App.test.tsx +0 -17
  59. package/Examples/SampleUI/android/app/build.gradle +0 -129
  60. package/Examples/SampleUI/android/app/debug.keystore +0 -0
  61. package/Examples/SampleUI/android/app/proguard-rules.pro +0 -10
  62. package/Examples/SampleUI/android/app/src/debug/AndroidManifest.xml +0 -9
  63. package/Examples/SampleUI/android/app/src/main/AndroidManifest.xml +0 -31
  64. package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainActivity.kt +0 -30
  65. package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainApplication.kt +0 -53
  66. package/Examples/SampleUI/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -37
  67. package/Examples/SampleUI/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  68. package/Examples/SampleUI/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  69. package/Examples/SampleUI/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  70. package/Examples/SampleUI/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  71. package/Examples/SampleUI/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  72. package/Examples/SampleUI/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  73. package/Examples/SampleUI/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  74. package/Examples/SampleUI/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  75. package/Examples/SampleUI/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  76. package/Examples/SampleUI/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  77. package/Examples/SampleUI/android/app/src/main/res/values/strings.xml +0 -3
  78. package/Examples/SampleUI/android/app/src/main/res/values/styles.xml +0 -9
  79. package/Examples/SampleUI/android/build.gradle +0 -21
  80. package/Examples/SampleUI/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  81. package/Examples/SampleUI/android/gradle/wrapper/gradle-wrapper.properties +0 -7
  82. package/Examples/SampleUI/android/gradle.properties +0 -39
  83. package/Examples/SampleUI/android/gradlew +0 -252
  84. package/Examples/SampleUI/android/gradlew.bat +0 -94
  85. package/Examples/SampleUI/android/settings.gradle +0 -21
  86. package/Examples/SampleUI/app.json +0 -51
  87. package/Examples/SampleUI/assets/fonts/Abel-Regular.ttf +0 -0
  88. package/Examples/SampleUI/assets/fonts/NotoSans-Regular.ttf +0 -0
  89. package/Examples/SampleUI/assets/images/android-icon.png +0 -0
  90. package/Examples/SampleUI/assets/images/artist-1.jpg +0 -0
  91. package/Examples/SampleUI/assets/images/artist-2.jpg +0 -0
  92. package/Examples/SampleUI/assets/images/avatar.png +0 -0
  93. package/Examples/SampleUI/assets/images/beach.jpg +0 -0
  94. package/Examples/SampleUI/assets/images/bridge.jpg +0 -0
  95. package/Examples/SampleUI/assets/images/chameleon.jpg +0 -0
  96. package/Examples/SampleUI/assets/images/city.jpg +0 -0
  97. package/Examples/SampleUI/assets/images/email-icon.png +0 -0
  98. package/Examples/SampleUI/assets/images/favorite.png +0 -0
  99. package/Examples/SampleUI/assets/images/forest.jpg +0 -0
  100. package/Examples/SampleUI/assets/images/paper-icon.png +0 -0
  101. package/Examples/SampleUI/assets/images/players-2.jpg +0 -0
  102. package/Examples/SampleUI/assets/images/players.jpg +0 -0
  103. package/Examples/SampleUI/assets/images/restaurant-1.jpg +0 -0
  104. package/Examples/SampleUI/assets/images/restaurant-2.jpg +0 -0
  105. package/Examples/SampleUI/assets/images/song-1.jpg +0 -0
  106. package/Examples/SampleUI/assets/images/song-2.jpg +0 -0
  107. package/Examples/SampleUI/assets/images/splash.png +0 -0
  108. package/Examples/SampleUI/assets/images/strawberries.jpg +0 -0
  109. package/Examples/SampleUI/assets/images/wrecked-ship.jpg +0 -0
  110. package/Examples/SampleUI/assets/styles/fonts.css +0 -47
  111. package/Examples/SampleUI/babel.config.js +0 -22
  112. package/Examples/SampleUI/index.js +0 -9
  113. package/Examples/SampleUI/ios/.xcode.env +0 -11
  114. package/Examples/SampleUI/ios/Podfile +0 -71
  115. package/Examples/SampleUI/ios/Podfile.lock +0 -2276
  116. package/Examples/SampleUI/ios/SampleUI/AppDelegate.h +0 -7
  117. package/Examples/SampleUI/ios/SampleUI/AppDelegate.mm +0 -31
  118. package/Examples/SampleUI/ios/SampleUI/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  119. package/Examples/SampleUI/ios/SampleUI/Images.xcassets/Contents.json +0 -6
  120. package/Examples/SampleUI/ios/SampleUI/Info.plist +0 -52
  121. package/Examples/SampleUI/ios/SampleUI/LaunchScreen.storyboard +0 -47
  122. package/Examples/SampleUI/ios/SampleUI/PrivacyInfo.xcprivacy +0 -48
  123. package/Examples/SampleUI/ios/SampleUI/main.m +0 -10
  124. package/Examples/SampleUI/ios/SampleUI.xcodeproj/project.pbxproj +0 -785
  125. package/Examples/SampleUI/ios/SampleUI.xcodeproj/xcshareddata/xcschemes/SampleUI.xcscheme +0 -105
  126. package/Examples/SampleUI/ios/SampleUI.xcworkspace/contents.xcworkspacedata +0 -10
  127. package/Examples/SampleUI/ios/SampleUITests/Info.plist +0 -24
  128. package/Examples/SampleUI/ios/SampleUITests/SampleUITests.m +0 -66
  129. package/Examples/SampleUI/jest.config.js +0 -3
  130. package/Examples/SampleUI/metro.config.js +0 -54
  131. package/Examples/SampleUI/package.json +0 -65
  132. package/Examples/SampleUI/scripts/integration-test-android.sh +0 -292
  133. package/Examples/SampleUI/src/DrawerItems.tsx +0 -322
  134. package/Examples/SampleUI/src/ExampleList.tsx +0 -175
  135. package/Examples/SampleUI/src/Examples/ActivityIndicatorExample.tsx +0 -73
  136. package/Examples/SampleUI/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx +0 -220
  137. package/Examples/SampleUI/src/Examples/AnimatedFABExample/CustomFAB.tsx +0 -70
  138. package/Examples/SampleUI/src/Examples/AnimatedFABExample/CustomFABControls.tsx +0 -146
  139. package/Examples/SampleUI/src/Examples/AnimatedFABExample/index.ts +0 -1
  140. package/Examples/SampleUI/src/Examples/AppbarExample.tsx +0 -263
  141. package/Examples/SampleUI/src/Examples/AvatarExample.tsx +0 -76
  142. package/Examples/SampleUI/src/Examples/BadgeExample.tsx +0 -97
  143. package/Examples/SampleUI/src/Examples/BannerExample.tsx +0 -152
  144. package/Examples/SampleUI/src/Examples/BottomNavigationBarExample.tsx +0 -94
  145. package/Examples/SampleUI/src/Examples/BottomNavigationExample.tsx +0 -205
  146. package/Examples/SampleUI/src/Examples/ButtonExample.tsx +0 -405
  147. package/Examples/SampleUI/src/Examples/CardExample.tsx +0 -245
  148. package/Examples/SampleUI/src/Examples/CheckboxExample.tsx +0 -87
  149. package/Examples/SampleUI/src/Examples/CheckboxItemExample.tsx +0 -72
  150. package/Examples/SampleUI/src/Examples/ChipExample.tsx +0 -432
  151. package/Examples/SampleUI/src/Examples/DataTableExample.tsx +0 -128
  152. package/Examples/SampleUI/src/Examples/DialogExample.tsx +0 -217
  153. package/Examples/SampleUI/src/Examples/Dialogs/DialogTextComponent.tsx +0 -31
  154. package/Examples/SampleUI/src/Examples/Dialogs/DialogTrackingTest.tsx +0 -307
  155. package/Examples/SampleUI/src/Examples/Dialogs/DialogWithCustomColors.tsx +0 -57
  156. package/Examples/SampleUI/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx +0 -38
  157. package/Examples/SampleUI/src/Examples/Dialogs/DialogWithIcon.tsx +0 -42
  158. package/Examples/SampleUI/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx +0 -48
  159. package/Examples/SampleUI/src/Examples/Dialogs/DialogWithLongText.tsx +0 -81
  160. package/Examples/SampleUI/src/Examples/Dialogs/DialogWithRadioBtns.tsx +0 -111
  161. package/Examples/SampleUI/src/Examples/Dialogs/UndismissableDialog.tsx +0 -30
  162. package/Examples/SampleUI/src/Examples/Dialogs/index.tsx +0 -44
  163. package/Examples/SampleUI/src/Examples/DividerExample.tsx +0 -30
  164. package/Examples/SampleUI/src/Examples/FABExample.tsx +0 -226
  165. package/Examples/SampleUI/src/Examples/IconButtonExample.tsx +0 -230
  166. package/Examples/SampleUI/src/Examples/IconExample.tsx +0 -50
  167. package/Examples/SampleUI/src/Examples/ListAccordionExample.tsx +0 -65
  168. package/Examples/SampleUI/src/Examples/ListAccordionGroupExample.tsx +0 -80
  169. package/Examples/SampleUI/src/Examples/ListItemExample.tsx +0 -310
  170. package/Examples/SampleUI/src/Examples/ListSectionExample.tsx +0 -159
  171. package/Examples/SampleUI/src/Examples/MaterialBottomTabNavigatorExample.tsx +0 -87
  172. package/Examples/SampleUI/src/Examples/MenuExample.tsx +0 -211
  173. package/Examples/SampleUI/src/Examples/ProgressBarExample.tsx +0 -142
  174. package/Examples/SampleUI/src/Examples/RadioButtonExample.tsx +0 -104
  175. package/Examples/SampleUI/src/Examples/RadioButtonGroupExample.tsx +0 -67
  176. package/Examples/SampleUI/src/Examples/RadioButtonItemExample.tsx +0 -77
  177. package/Examples/SampleUI/src/Examples/SearchbarExample.tsx +0 -249
  178. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonCustomColorCheck.tsx +0 -93
  179. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonDefault.tsx +0 -49
  180. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonDisabled.tsx +0 -47
  181. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonMultiselect.tsx +0 -50
  182. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonMultiselectIcons.tsx +0 -49
  183. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonMultiselectRealCase.tsx +0 -114
  184. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonOnlyIcons.tsx +0 -40
  185. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonOnlyIconsWithCheck.tsx +0 -43
  186. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonRealCase.tsx +0 -97
  187. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonWithDensity.tsx +0 -47
  188. package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonWithSelectedCheck.tsx +0 -52
  189. package/Examples/SampleUI/src/Examples/SegmentedButtons/index.ts +0 -9
  190. package/Examples/SampleUI/src/Examples/SegmentedButtonsExample.tsx +0 -57
  191. package/Examples/SampleUI/src/Examples/SnackbarExample.tsx +0 -141
  192. package/Examples/SampleUI/src/Examples/SurfaceExample.tsx +0 -130
  193. package/Examples/SampleUI/src/Examples/SwitchExample.tsx +0 -105
  194. package/Examples/SampleUI/src/Examples/TeamDetails.tsx +0 -291
  195. package/Examples/SampleUI/src/Examples/TeamsList.tsx +0 -57
  196. package/Examples/SampleUI/src/Examples/TextExample.tsx +0 -132
  197. package/Examples/SampleUI/src/Examples/TextInputExample.tsx +0 -914
  198. package/Examples/SampleUI/src/Examples/ThemeExample.tsx +0 -41
  199. package/Examples/SampleUI/src/Examples/ThemingWithReactNavigation.tsx +0 -75
  200. package/Examples/SampleUI/src/Examples/ToggleButtonExample.tsx +0 -128
  201. package/Examples/SampleUI/src/Examples/TooltipExample.tsx +0 -191
  202. package/Examples/SampleUI/src/Examples/TouchableRippleExample.tsx +0 -37
  203. package/Examples/SampleUI/src/RootNavigator.tsx +0 -95
  204. package/Examples/SampleUI/src/ScreenWrapper.tsx +0 -67
  205. package/Examples/SampleUI/src/components/ActivityIndicator.tsx +0 -254
  206. package/Examples/SampleUI/src/components/Appbar/Appbar.tsx +0 -364
  207. package/Examples/SampleUI/src/components/Appbar/AppbarAction.tsx +0 -132
  208. package/Examples/SampleUI/src/components/Appbar/AppbarBackAction.tsx +0 -77
  209. package/Examples/SampleUI/src/components/Appbar/AppbarBackIcon.tsx +0 -52
  210. package/Examples/SampleUI/src/components/Appbar/AppbarContent.tsx +0 -249
  211. package/Examples/SampleUI/src/components/Appbar/AppbarHeader.tsx +0 -174
  212. package/Examples/SampleUI/src/components/Appbar/index.ts +0 -22
  213. package/Examples/SampleUI/src/components/Appbar/utils.ts +0 -188
  214. package/Examples/SampleUI/src/components/Avatar/Avatar.tsx +0 -8
  215. package/Examples/SampleUI/src/components/Avatar/AvatarIcon.tsx +0 -87
  216. package/Examples/SampleUI/src/components/Avatar/AvatarImage.tsx +0 -128
  217. package/Examples/SampleUI/src/components/Avatar/AvatarText.tsx +0 -127
  218. package/Examples/SampleUI/src/components/Badge.tsx +0 -138
  219. package/Examples/SampleUI/src/components/Banner.tsx +0 -302
  220. package/Examples/SampleUI/src/components/BottomNavigation/BottomNavigation.tsx +0 -643
  221. package/Examples/SampleUI/src/components/BottomNavigation/BottomNavigationBar.tsx +0 -1039
  222. package/Examples/SampleUI/src/components/BottomNavigation/BottomNavigationRouteScreen.tsx +0 -31
  223. package/Examples/SampleUI/src/components/BottomNavigation/utils.ts +0 -70
  224. package/Examples/SampleUI/src/components/Button/Button.tsx +0 -503
  225. package/Examples/SampleUI/src/components/Button/utils.tsx +0 -272
  226. package/Examples/SampleUI/src/components/Card/Card.tsx +0 -373
  227. package/Examples/SampleUI/src/components/Card/CardActions.tsx +0 -74
  228. package/Examples/SampleUI/src/components/Card/CardContent.tsx +0 -99
  229. package/Examples/SampleUI/src/components/Card/CardCover.tsx +0 -96
  230. package/Examples/SampleUI/src/components/Card/CardTitle.tsx +0 -236
  231. package/Examples/SampleUI/src/components/Card/utils.tsx +0 -110
  232. package/Examples/SampleUI/src/components/Checkbox/Checkbox.tsx +0 -78
  233. package/Examples/SampleUI/src/components/Checkbox/CheckboxAndroid.tsx +0 -180
  234. package/Examples/SampleUI/src/components/Checkbox/CheckboxIOS.tsx +0 -104
  235. package/Examples/SampleUI/src/components/Checkbox/CheckboxItem.tsx +0 -236
  236. package/Examples/SampleUI/src/components/Checkbox/index.ts +0 -19
  237. package/Examples/SampleUI/src/components/Checkbox/utils.ts +0 -183
  238. package/Examples/SampleUI/src/components/Chip/Chip.tsx +0 -513
  239. package/Examples/SampleUI/src/components/Chip/helpers.tsx +0 -322
  240. package/Examples/SampleUI/src/components/CrossFadeIcon.tsx +0 -140
  241. package/Examples/SampleUI/src/components/DataTable/DataTable.tsx +0 -138
  242. package/Examples/SampleUI/src/components/DataTable/DataTableCell.tsx +0 -132
  243. package/Examples/SampleUI/src/components/DataTable/DataTableHeader.tsx +0 -82
  244. package/Examples/SampleUI/src/components/DataTable/DataTablePagination.tsx +0 -407
  245. package/Examples/SampleUI/src/components/DataTable/DataTableRow.tsx +0 -107
  246. package/Examples/SampleUI/src/components/DataTable/DataTableTitle.tsx +0 -208
  247. package/Examples/SampleUI/src/components/Dialog/Dialog.tsx +0 -191
  248. package/Examples/SampleUI/src/components/Dialog/DialogActions.tsx +0 -94
  249. package/Examples/SampleUI/src/components/Dialog/DialogContent.tsx +0 -54
  250. package/Examples/SampleUI/src/components/Dialog/DialogIcon.tsx +0 -100
  251. package/Examples/SampleUI/src/components/Dialog/DialogScrollArea.tsx +0 -88
  252. package/Examples/SampleUI/src/components/Dialog/DialogTitle.tsx +0 -94
  253. package/Examples/SampleUI/src/components/Divider.tsx +0 -102
  254. package/Examples/SampleUI/src/components/Drawer/Drawer.tsx +0 -8
  255. package/Examples/SampleUI/src/components/Drawer/DrawerCollapsedItem.tsx +0 -282
  256. package/Examples/SampleUI/src/components/Drawer/DrawerItem.tsx +0 -209
  257. package/Examples/SampleUI/src/components/Drawer/DrawerSection.tsx +0 -138
  258. package/Examples/SampleUI/src/components/FAB/AnimatedFAB.tsx +0 -619
  259. package/Examples/SampleUI/src/components/FAB/FAB.tsx +0 -371
  260. package/Examples/SampleUI/src/components/FAB/FABGroup.tsx +0 -532
  261. package/Examples/SampleUI/src/components/FAB/index.ts +0 -13
  262. package/Examples/SampleUI/src/components/FAB/utils.ts +0 -474
  263. package/Examples/SampleUI/src/components/HelperText/HelperText.tsx +0 -168
  264. package/Examples/SampleUI/src/components/HelperText/utils.ts +0 -30
  265. package/Examples/SampleUI/src/components/Icon.tsx +0 -170
  266. package/Examples/SampleUI/src/components/IconButton/IconButton.tsx +0 -234
  267. package/Examples/SampleUI/src/components/IconButton/utils.ts +0 -190
  268. package/Examples/SampleUI/src/components/List/List.tsx +0 -20
  269. package/Examples/SampleUI/src/components/List/ListAccordion.tsx +0 -391
  270. package/Examples/SampleUI/src/components/List/ListAccordionGroup.tsx +0 -88
  271. package/Examples/SampleUI/src/components/List/ListIcon.tsx +0 -79
  272. package/Examples/SampleUI/src/components/List/ListImage.tsx +0 -89
  273. package/Examples/SampleUI/src/components/List/ListItem.tsx +0 -313
  274. package/Examples/SampleUI/src/components/List/ListSection.tsx +0 -87
  275. package/Examples/SampleUI/src/components/List/ListSubheader.tsx +0 -79
  276. package/Examples/SampleUI/src/components/List/utils.ts +0 -113
  277. package/Examples/SampleUI/src/components/MaterialCommunityIcon.tsx +0 -121
  278. package/Examples/SampleUI/src/components/Menu/Menu.tsx +0 -711
  279. package/Examples/SampleUI/src/components/Menu/MenuItem.tsx +0 -257
  280. package/Examples/SampleUI/src/components/Menu/utils.ts +0 -110
  281. package/Examples/SampleUI/src/components/Modal.tsx +0 -245
  282. package/Examples/SampleUI/src/components/Portal/Portal.tsx +0 -69
  283. package/Examples/SampleUI/src/components/Portal/PortalConsumer.tsx +0 -44
  284. package/Examples/SampleUI/src/components/Portal/PortalHost.tsx +0 -143
  285. package/Examples/SampleUI/src/components/Portal/PortalManager.tsx +0 -54
  286. package/Examples/SampleUI/src/components/ProgressBar.tsx +0 -292
  287. package/Examples/SampleUI/src/components/RadioButton/RadioButton.tsx +0 -86
  288. package/Examples/SampleUI/src/components/RadioButton/RadioButtonAndroid.tsx +0 -202
  289. package/Examples/SampleUI/src/components/RadioButton/RadioButtonGroup.tsx +0 -67
  290. package/Examples/SampleUI/src/components/RadioButton/RadioButtonIOS.tsx +0 -130
  291. package/Examples/SampleUI/src/components/RadioButton/RadioButtonItem.tsx +0 -268
  292. package/Examples/SampleUI/src/components/RadioButton/index.ts +0 -22
  293. package/Examples/SampleUI/src/components/RadioButton/utils.ts +0 -37
  294. package/Examples/SampleUI/src/components/Searchbar.tsx +0 -459
  295. package/Examples/SampleUI/src/components/SegmentedButtons/SegmentedButtonItem.tsx +0 -271
  296. package/Examples/SampleUI/src/components/SegmentedButtons/SegmentedButtons.tsx +0 -197
  297. package/Examples/SampleUI/src/components/SegmentedButtons/utils.ts +0 -179
  298. package/Examples/SampleUI/src/components/Snackbar.tsx +0 -430
  299. package/Examples/SampleUI/src/components/Surface.tsx +0 -376
  300. package/Examples/SampleUI/src/components/Switch/Switch.tsx +0 -108
  301. package/Examples/SampleUI/src/components/Switch/utils.ts +0 -113
  302. package/Examples/SampleUI/src/components/TextInput/Addons/Outline.tsx +0 -64
  303. package/Examples/SampleUI/src/components/TextInput/Addons/Underline.tsx +0 -78
  304. package/Examples/SampleUI/src/components/TextInput/Adornment/TextInputAdornment.tsx +0 -208
  305. package/Examples/SampleUI/src/components/TextInput/Adornment/TextInputAffix.tsx +0 -212
  306. package/Examples/SampleUI/src/components/TextInput/Adornment/TextInputIcon.tsx +0 -195
  307. package/Examples/SampleUI/src/components/TextInput/Adornment/enums.tsx +0 -12
  308. package/Examples/SampleUI/src/components/TextInput/Adornment/types.tsx +0 -11
  309. package/Examples/SampleUI/src/components/TextInput/Adornment/utils.ts +0 -48
  310. package/Examples/SampleUI/src/components/TextInput/Label/InputLabel.tsx +0 -217
  311. package/Examples/SampleUI/src/components/TextInput/Label/LabelBackground.tsx +0 -100
  312. package/Examples/SampleUI/src/components/TextInput/TextInput.tsx +0 -572
  313. package/Examples/SampleUI/src/components/TextInput/TextInputFlat.tsx +0 -475
  314. package/Examples/SampleUI/src/components/TextInput/TextInputOutlined.tsx +0 -450
  315. package/Examples/SampleUI/src/components/TextInput/constants.tsx +0 -48
  316. package/Examples/SampleUI/src/components/TextInput/helpers.tsx +0 -612
  317. package/Examples/SampleUI/src/components/TextInput/types.tsx +0 -155
  318. package/Examples/SampleUI/src/components/ToggleButton/ToggleButton.tsx +0 -187
  319. package/Examples/SampleUI/src/components/ToggleButton/ToggleButtonGroup.tsx +0 -72
  320. package/Examples/SampleUI/src/components/ToggleButton/ToggleButtonRow.tsx +0 -107
  321. package/Examples/SampleUI/src/components/ToggleButton/index.ts +0 -16
  322. package/Examples/SampleUI/src/components/ToggleButton/utils.ts +0 -26
  323. package/Examples/SampleUI/src/components/Tooltip/Tooltip.tsx +0 -249
  324. package/Examples/SampleUI/src/components/Tooltip/utils.ts +0 -129
  325. package/Examples/SampleUI/src/components/TouchableRipple/Pressable.tsx +0 -41
  326. package/Examples/SampleUI/src/components/TouchableRipple/TouchableRipple.native.tsx +0 -145
  327. package/Examples/SampleUI/src/components/TouchableRipple/TouchableRipple.tsx +0 -317
  328. package/Examples/SampleUI/src/components/TouchableRipple/utils.ts +0 -66
  329. package/Examples/SampleUI/src/components/Typography/AnimatedText.tsx +0 -107
  330. package/Examples/SampleUI/src/components/Typography/Text.tsx +0 -184
  331. package/Examples/SampleUI/src/components/Typography/types.tsx +0 -5
  332. package/Examples/SampleUI/src/components/Typography/v2/Caption.tsx +0 -50
  333. package/Examples/SampleUI/src/components/Typography/v2/Headline.tsx +0 -52
  334. package/Examples/SampleUI/src/components/Typography/v2/Paragraph.tsx +0 -49
  335. package/Examples/SampleUI/src/components/Typography/v2/StyledText.tsx +0 -56
  336. package/Examples/SampleUI/src/components/Typography/v2/Subheading.tsx +0 -50
  337. package/Examples/SampleUI/src/components/Typography/v2/Text.tsx +0 -62
  338. package/Examples/SampleUI/src/components/Typography/v2/Title.tsx +0 -49
  339. package/Examples/SampleUI/src/components/Typography/v2/index.ts +0 -5
  340. package/Examples/SampleUI/src/core/PaperProvider.tsx +0 -122
  341. package/Examples/SampleUI/src/core/SafeAreaProviderCompat.tsx +0 -65
  342. package/Examples/SampleUI/src/core/settings.tsx +0 -23
  343. package/Examples/SampleUI/src/core/theming.tsx +0 -170
  344. package/Examples/SampleUI/src/index.native.tsx +0 -285
  345. package/Examples/SampleUI/src/index.tsx +0 -226
  346. package/Examples/SampleUI/src/react-navigation/index.tsx +0 -19
  347. package/Examples/SampleUI/src/react-navigation/navigators/createMaterialBottomTabNavigator.tsx +0 -72
  348. package/Examples/SampleUI/src/react-navigation/types.tsx +0 -126
  349. package/Examples/SampleUI/src/react-navigation/views/MaterialBottomTabView.tsx +0 -140
  350. package/Examples/SampleUI/src/styles/__tests__/fonts.test.js +0 -290
  351. package/Examples/SampleUI/src/styles/fonts.tsx +0 -143
  352. package/Examples/SampleUI/src/styles/overlay.tsx +0 -70
  353. package/Examples/SampleUI/src/styles/shadow.tsx +0 -109
  354. package/Examples/SampleUI/src/styles/themes/index.ts +0 -4
  355. package/Examples/SampleUI/src/styles/themes/v2/DarkTheme.tsx +0 -30
  356. package/Examples/SampleUI/src/styles/themes/v2/LightTheme.tsx +0 -30
  357. package/Examples/SampleUI/src/styles/themes/v2/colors.tsx +0 -277
  358. package/Examples/SampleUI/src/styles/themes/v3/DarkTheme.tsx +0 -66
  359. package/Examples/SampleUI/src/styles/themes/v3/LightTheme.tsx +0 -69
  360. package/Examples/SampleUI/src/styles/themes/v3/tokens.tsx +0 -230
  361. package/Examples/SampleUI/src/utils/BackHandler/BackHandler.native.tsx +0 -3
  362. package/Examples/SampleUI/src/utils/BackHandler/BackHandler.tsx +0 -11
  363. package/Examples/SampleUI/src/utils/addEventListener.tsx +0 -56
  364. package/Examples/SampleUI/src/utils/forwardRef.tsx +0 -23
  365. package/Examples/SampleUI/src/utils/getContrastingColor.tsx +0 -15
  366. package/Examples/SampleUI/src/utils/hasTouchHandler.tsx +0 -23
  367. package/Examples/SampleUI/src/utils/roundLayoutSize.ts +0 -2
  368. package/Examples/SampleUI/src/utils/splitStyles.ts +0 -60
  369. package/Examples/SampleUI/src/utils/useAnimatedValue.tsx +0 -9
  370. package/Examples/SampleUI/src/utils/useAnimatedValueArray.tsx +0 -13
  371. package/Examples/SampleUI/src/utils/useIsKeyboardShown.tsx +0 -55
  372. package/Examples/SampleUI/src/utils/useLayout.tsx +0 -29
  373. package/Examples/SampleUI/src/utils/useLazyRef.tsx +0 -11
  374. package/Examples/SampleUI/tsconfig.json +0 -3
  375. package/Examples/SampleUI/utils/index.ts +0 -1426
  376. package/cli/__tests__/doctor.test.mjs +0 -88
@@ -1,711 +0,0 @@
1
- import * as React from 'react';
2
- import {
3
- Animated,
4
- Dimensions,
5
- Easing,
6
- EmitterSubscription,
7
- findNodeHandle,
8
- I18nManager,
9
- Keyboard,
10
- KeyboardEvent as RNKeyboardEvent,
11
- LayoutRectangle,
12
- NativeEventSubscription,
13
- Platform,
14
- ScrollView,
15
- ScrollViewProps,
16
- StyleProp,
17
- StyleSheet,
18
- View,
19
- ViewStyle,
20
- Pressable,
21
- } from 'react-native';
22
-
23
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
24
-
25
- import MenuItem from './MenuItem';
26
- import { useInternalTheme } from '../../core/theming';
27
- import type { MD3Elevation, ThemeProp } from '../../types';
28
- import { ElevationLevels } from '../../types';
29
- import { addEventListener } from '../../utils/addEventListener';
30
- import { BackHandler } from '../../utils/BackHandler/BackHandler';
31
- import Portal from '../Portal/Portal';
32
- import Surface from '../Surface';
33
-
34
- export type Props = {
35
- /**
36
- * Whether the Menu is currently visible.
37
- */
38
- visible: boolean;
39
- /**
40
- * The anchor to open the menu from. In most cases, it will be a button that opens the menu.
41
- */
42
- anchor: React.ReactNode | { x: number; y: number };
43
- /**
44
- * Whether the menu should open at the top of the anchor or at its bottom.
45
- * Applied only when anchor is a node, not an x/y position.
46
- */
47
- anchorPosition?: 'top' | 'bottom';
48
- /**
49
- * Extra margin to add at the top of the menu to account for translucent status bar on Android.
50
- * If you are using Expo, we assume translucent status bar and set a height for status bar automatically.
51
- * Pass `0` or a custom value to and customize it.
52
- * This is automatically handled on iOS.
53
- */
54
- statusBarHeight?: number;
55
- /**
56
- * Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
57
- */
58
- onDismiss?: () => void;
59
- /**
60
- * Accessibility label for the overlay. This is read by the screen reader when the user taps outside the menu.
61
- */
62
- overlayAccessibilityLabel?: string;
63
- /**
64
- * Content of the `Menu`.
65
- */
66
- children: React.ReactNode;
67
- /**
68
- * Style of menu's inner content.
69
- */
70
- contentStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
71
- style?: StyleProp<ViewStyle>;
72
- /**
73
- * Elevation level of the menu's content. Shadow styles are calculated based on this value. Default `backgroundColor` is taken from the corresponding `theme.colors.elevation` property. By default equals `2`.
74
- * @supported Available in v5.x with theme version 3
75
- */
76
- elevation?: MD3Elevation;
77
- /**
78
- * Mode of the menu's content.
79
- * - `elevated` - Surface with a shadow and background color corresponding to set `elevation` value.
80
- * - `flat` - Surface without a shadow, with the background color corresponding to set `elevation` value.
81
- *
82
- * @supported Available in v5.x with theme version 3
83
- */
84
- mode?: 'flat' | 'elevated';
85
- /**
86
- * @optional
87
- */
88
- theme?: ThemeProp;
89
- /**
90
- * Inner ScrollView prop
91
- */
92
- keyboardShouldPersistTaps?: ScrollViewProps['keyboardShouldPersistTaps'];
93
- /**
94
- * testID to be used on tests.
95
- */
96
- testID?: string;
97
- };
98
-
99
- // Minimum padding between the edge of the screen and the menu
100
- const SCREEN_INDENT = 8;
101
- // From https://material.io/design/motion/speed.html#duration
102
- const ANIMATION_DURATION = 250;
103
- // From the 'Standard easing' section of https://material.io/design/motion/speed.html#easing
104
- const EASING = Easing.bezier(0.4, 0, 0.2, 1);
105
-
106
- const WINDOW_LAYOUT = Dimensions.get('window');
107
-
108
- const DEFAULT_ELEVATION: MD3Elevation = 2;
109
- export const ELEVATION_LEVELS_MAP = Object.values(
110
- ElevationLevels
111
- ) as ElevationLevels[];
112
-
113
- const DEFAULT_MODE = 'elevated';
114
-
115
- const focusFirstDOMNode = (el: View | null | undefined) => {
116
- if (el && Platform.OS === 'web') {
117
- // When in the browser, we want to focus the first focusable item on toggle
118
- // For example, when menu is shown, focus the first item in the menu
119
- // And when menu is dismissed, send focus back to the button to resume tabbing
120
- const node: any = findNodeHandle(el);
121
- const focusableNode = node.querySelector(
122
- // This is a rough list of selectors that can be focused
123
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
124
- );
125
-
126
- focusableNode?.focus();
127
- }
128
- };
129
-
130
- const isCoordinate = (anchor: any): anchor is { x: number; y: number } =>
131
- !React.isValidElement(anchor) &&
132
- typeof anchor?.x === 'number' &&
133
- typeof anchor?.y === 'number';
134
-
135
- const isBrowser = () => Platform.OS === 'web' && 'document' in global;
136
-
137
- /**
138
- * Menus display a list of choices on temporary elevated surfaces. Their placement varies based on the element that opens them.
139
- *
140
- * ## Usage
141
- * ```js
142
- * import * as React from 'react';
143
- * import { View } from 'react-native';
144
- * import { Button, Menu, Divider, PaperProvider } from 'react-native-paper';
145
- *
146
- * const MyComponent = () => {
147
- * const [visible, setVisible] = React.useState(false);
148
- *
149
- * const openMenu = () => setVisible(true);
150
- *
151
- * const closeMenu = () => setVisible(false);
152
- *
153
- * return (
154
- * <PaperProvider>
155
- * <View
156
- * style={{
157
- * paddingTop: 50,
158
- * flexDirection: 'row',
159
- * justifyContent: 'center',
160
- * }}>
161
- * <Menu
162
- * visible={visible}
163
- * onDismiss={closeMenu}
164
- * anchor={<Button onPress={openMenu}>Show menu</Button>}>
165
- * <Menu.Item onPress={() => {}} title="Item 1" />
166
- * <Menu.Item onPress={() => {}} title="Item 2" />
167
- * <Divider />
168
- * <Menu.Item onPress={() => {}} title="Item 3" />
169
- * </Menu>
170
- * </View>
171
- * </PaperProvider>
172
- * );
173
- * };
174
- *
175
- * export default MyComponent;
176
- * ```
177
- *
178
- * ### Note
179
- * When using `Menu` within a React Native's `Modal` component, you need to wrap all
180
- * `Modal` contents within a `PaperProvider` in order for the menu to show. This
181
- * wrapping is not necessary if you use Paper's `Modal` instead.
182
- */
183
-
184
- const Menu = ({
185
- visible,
186
- statusBarHeight,
187
- overlayAccessibilityLabel = 'Close menu',
188
- testID = 'menu',
189
- anchor,
190
- onDismiss,
191
- anchorPosition,
192
- contentStyle,
193
- style,
194
- elevation = DEFAULT_ELEVATION,
195
- mode = DEFAULT_MODE,
196
- children,
197
- theme: themeOverrides,
198
- keyboardShouldPersistTaps,
199
- }: Props) => {
200
- const theme = useInternalTheme(themeOverrides);
201
- const insets = useSafeAreaInsets();
202
- const [rendered, setRendered] = React.useState(visible);
203
- const [left, setLeft] = React.useState(0);
204
- const [top, setTop] = React.useState(0);
205
- const [menuLayout, setMenuLayout] = React.useState({ width: 0, height: 0 });
206
- const [anchorLayout, setAnchorLayout] = React.useState({
207
- width: 0,
208
- height: 0,
209
- });
210
- const [windowLayout, setWindowLayout] = React.useState({
211
- width: WINDOW_LAYOUT.width,
212
- height: WINDOW_LAYOUT.height,
213
- });
214
-
215
- const opacityAnimationRef = React.useRef(new Animated.Value(0));
216
- const scaleAnimationRef = React.useRef(new Animated.ValueXY({ x: 0, y: 0 }));
217
- const keyboardHeightRef = React.useRef(0);
218
- const prevVisible = React.useRef<boolean | null>(null);
219
- const anchorRef = React.useRef<View | null>(null);
220
- const menuRef = React.useRef<View | null>(null);
221
- const prevRendered = React.useRef(false);
222
-
223
- const keyboardDidShow = React.useCallback((e: RNKeyboardEvent) => {
224
- const keyboardHeight = e.endCoordinates.height;
225
- keyboardHeightRef.current = keyboardHeight;
226
- }, []);
227
-
228
- const keyboardDidHide = React.useCallback(() => {
229
- keyboardHeightRef.current = 0;
230
- }, []);
231
-
232
- const keyboardDidShowListenerRef: React.MutableRefObject<
233
- EmitterSubscription | undefined
234
- > = React.useRef();
235
- const keyboardDidHideListenerRef: React.MutableRefObject<
236
- EmitterSubscription | undefined
237
- > = React.useRef();
238
-
239
- const backHandlerSubscriptionRef: React.MutableRefObject<
240
- NativeEventSubscription | undefined
241
- > = React.useRef();
242
- const dimensionsSubscriptionRef: React.MutableRefObject<
243
- NativeEventSubscription | undefined
244
- > = React.useRef();
245
-
246
- const handleDismiss = React.useCallback(() => {
247
- if (visible) {
248
- onDismiss?.();
249
- }
250
- }, [onDismiss, visible]);
251
-
252
- const handleKeypress = React.useCallback(
253
- (e: KeyboardEvent) => {
254
- if (e.key === 'Escape') {
255
- onDismiss?.();
256
- }
257
- },
258
- [onDismiss]
259
- );
260
-
261
- const removeListeners = React.useCallback(() => {
262
- backHandlerSubscriptionRef.current?.remove();
263
- dimensionsSubscriptionRef.current?.remove();
264
- isBrowser() && document.removeEventListener('keyup', handleKeypress);
265
- }, [handleKeypress]);
266
-
267
- const attachListeners = React.useCallback(() => {
268
- backHandlerSubscriptionRef.current = addEventListener(
269
- BackHandler,
270
- 'hardwareBackPress',
271
- handleDismiss
272
- );
273
- dimensionsSubscriptionRef.current = addEventListener(
274
- Dimensions,
275
- 'change',
276
- handleDismiss
277
- );
278
- Platform.OS === 'web' && document.addEventListener('keyup', handleKeypress);
279
- }, [handleDismiss, handleKeypress]);
280
-
281
- const measureMenuLayout = () =>
282
- new Promise<LayoutRectangle>((resolve) => {
283
- if (menuRef.current) {
284
- menuRef.current.measureInWindow((x, y, width, height) => {
285
- resolve({ x, y, width, height });
286
- });
287
- }
288
- });
289
-
290
- const measureAnchorLayout = React.useCallback(
291
- () =>
292
- new Promise<LayoutRectangle>((resolve) => {
293
- if (isCoordinate(anchor)) {
294
- resolve({ x: anchor.x, y: anchor.y, width: 0, height: 0 });
295
- return;
296
- }
297
-
298
- if (anchorRef.current) {
299
- anchorRef.current.measureInWindow((x, y, width, height) => {
300
- resolve({ x, y, width, height });
301
- });
302
- }
303
- }),
304
- [anchor]
305
- );
306
-
307
- const show = React.useCallback(async () => {
308
- const windowLayoutResult = Dimensions.get('window');
309
- const [menuLayoutResult, anchorLayoutResult] = await Promise.all([
310
- measureMenuLayout(),
311
- measureAnchorLayout(),
312
- ]);
313
-
314
- // When visible is true for first render
315
- // native views can be still not rendered and
316
- // measureMenuLayout/measureAnchorLayout functions
317
- // return wrong values e.g { x:0, y: 0, width: 0, height: 0 }
318
- // so we have to wait until views are ready
319
- // and rerun this function to show menu
320
- if (
321
- !windowLayoutResult.width ||
322
- !windowLayoutResult.height ||
323
- !menuLayoutResult.width ||
324
- !menuLayoutResult.height ||
325
- (!anchorLayoutResult.width && !isCoordinate(anchor)) ||
326
- (!anchorLayoutResult.height && !isCoordinate(anchor))
327
- ) {
328
- requestAnimationFrame(show);
329
- return;
330
- }
331
-
332
- setLeft(anchorLayoutResult.x);
333
- setTop(anchorLayoutResult.y);
334
- setAnchorLayout({
335
- height: anchorLayoutResult.height,
336
- width: anchorLayoutResult.width,
337
- });
338
-
339
- setMenuLayout({
340
- height: menuLayoutResult.height,
341
- width: menuLayoutResult.width,
342
- });
343
-
344
- setWindowLayout({
345
- height: windowLayoutResult.height - keyboardHeightRef.current,
346
- width: windowLayoutResult.width,
347
- });
348
-
349
- attachListeners();
350
- const { animation } = theme;
351
- Animated.parallel([
352
- Animated.timing(scaleAnimationRef.current, {
353
- toValue: { x: menuLayoutResult.width, y: menuLayoutResult.height },
354
- duration: ANIMATION_DURATION * animation.scale,
355
- easing: EASING,
356
- useNativeDriver: true,
357
- }),
358
- Animated.timing(opacityAnimationRef.current, {
359
- toValue: 1,
360
- duration: ANIMATION_DURATION * animation.scale,
361
- easing: EASING,
362
- useNativeDriver: true,
363
- }),
364
- ]).start(({ finished }) => {
365
- if (finished) {
366
- focusFirstDOMNode(menuRef.current);
367
- prevRendered.current = true;
368
- }
369
- });
370
- }, [anchor, attachListeners, measureAnchorLayout, theme]);
371
-
372
- const hide = React.useCallback(() => {
373
- removeListeners();
374
-
375
- const { animation } = theme;
376
-
377
- Animated.timing(opacityAnimationRef.current, {
378
- toValue: 0,
379
- duration: ANIMATION_DURATION * animation.scale,
380
- easing: EASING,
381
- useNativeDriver: true,
382
- }).start(({ finished }) => {
383
- if (finished) {
384
- setMenuLayout({ width: 0, height: 0 });
385
- setRendered(false);
386
- prevRendered.current = false;
387
- focusFirstDOMNode(anchorRef.current);
388
- }
389
- });
390
- }, [removeListeners, theme]);
391
-
392
- const updateVisibility = React.useCallback(
393
- async (display: boolean) => {
394
- // Menu is rendered in Portal, which updates items asynchronously
395
- // We need to do the same here so that the ref is up-to-date
396
- await Promise.resolve().then(() => {
397
- if (display && !prevRendered.current) {
398
- show();
399
- return;
400
- }
401
-
402
- if (!display && prevRendered.current) {
403
- hide();
404
- }
405
-
406
- return;
407
- });
408
- },
409
- [hide, show]
410
- );
411
-
412
- React.useEffect(() => {
413
- const opacityAnimation = opacityAnimationRef.current;
414
- const scaleAnimation = scaleAnimationRef.current;
415
- keyboardDidShowListenerRef.current = Keyboard.addListener(
416
- 'keyboardDidShow',
417
- keyboardDidShow
418
- );
419
- keyboardDidHideListenerRef.current = Keyboard.addListener(
420
- 'keyboardDidHide',
421
- keyboardDidHide
422
- );
423
-
424
- return () => {
425
- removeListeners();
426
- keyboardDidShowListenerRef.current?.remove();
427
- keyboardDidHideListenerRef.current?.remove();
428
- scaleAnimation.removeAllListeners();
429
- opacityAnimation?.removeAllListeners();
430
- };
431
- }, [removeListeners, keyboardDidHide, keyboardDidShow]);
432
-
433
- React.useEffect(() => {
434
- if (prevVisible.current !== visible) {
435
- prevVisible.current = visible;
436
-
437
- if (visible !== rendered) {
438
- setRendered(visible);
439
- }
440
- }
441
- }, [visible, rendered]);
442
-
443
- React.useEffect(() => {
444
- updateVisibility(rendered);
445
- }, [rendered, updateVisibility]);
446
-
447
- // I don't know why but on Android measure function is wrong by 24
448
- const additionalVerticalValue = Platform.select({
449
- android: statusBarHeight ?? insets.top,
450
- default: 0,
451
- });
452
-
453
- // We need to translate menu while animating scale to imitate transform origin for scale animation
454
- const positionTransforms = [];
455
- let leftTransformation = left;
456
- let topTransformation =
457
- !isCoordinate(anchorRef.current) && anchorPosition === 'bottom'
458
- ? top + anchorLayout.height
459
- : top;
460
-
461
- // Check if menu fits horizontally and if not align it to right.
462
- if (left <= windowLayout.width - menuLayout.width - SCREEN_INDENT) {
463
- positionTransforms.push({
464
- translateX: scaleAnimationRef.current.x.interpolate({
465
- inputRange: [0, menuLayout.width],
466
- outputRange: [-(menuLayout.width / 2), 0],
467
- }),
468
- });
469
-
470
- // Check if menu position has enough space from left side
471
- if (leftTransformation < SCREEN_INDENT) {
472
- leftTransformation = SCREEN_INDENT;
473
- }
474
- } else {
475
- positionTransforms.push({
476
- translateX: scaleAnimationRef.current.x.interpolate({
477
- inputRange: [0, menuLayout.width],
478
- outputRange: [menuLayout.width / 2, 0],
479
- }),
480
- });
481
-
482
- leftTransformation += anchorLayout.width - menuLayout.width;
483
-
484
- const right = leftTransformation + menuLayout.width;
485
- // Check if menu position has enough space from right side
486
- if (right > windowLayout.width - SCREEN_INDENT) {
487
- leftTransformation =
488
- windowLayout.width - SCREEN_INDENT - menuLayout.width;
489
- }
490
- }
491
-
492
- // If the menu is larger than available vertical space,
493
- // calculate the height of scrollable view
494
- let scrollableMenuHeight = 0;
495
-
496
- // Check if the menu should be scrollable
497
- if (
498
- // Check if the menu overflows from bottom side
499
- topTransformation >=
500
- windowLayout.height -
501
- menuLayout.height -
502
- SCREEN_INDENT -
503
- additionalVerticalValue &&
504
- // And bottom side of the screen has more space than top side
505
- topTransformation <= windowLayout.height - topTransformation
506
- ) {
507
- // Scrollable menu should be below the anchor (expands downwards)
508
- scrollableMenuHeight =
509
- windowLayout.height -
510
- topTransformation -
511
- SCREEN_INDENT -
512
- additionalVerticalValue;
513
- } else if (
514
- // Check if the menu overflows from bottom side
515
- topTransformation >=
516
- windowLayout.height -
517
- menuLayout.height -
518
- SCREEN_INDENT -
519
- additionalVerticalValue &&
520
- // And top side of the screen has more space than bottom side
521
- topTransformation >= windowLayout.height - top &&
522
- // And menu overflows from top side
523
- topTransformation <=
524
- menuLayout.height -
525
- anchorLayout.height +
526
- SCREEN_INDENT -
527
- additionalVerticalValue
528
- ) {
529
- // Scrollable menu should be above the anchor (expands upwards)
530
- scrollableMenuHeight =
531
- topTransformation +
532
- anchorLayout.height -
533
- SCREEN_INDENT +
534
- additionalVerticalValue;
535
- }
536
-
537
- // Scrollable menu max height
538
- scrollableMenuHeight =
539
- scrollableMenuHeight > windowLayout.height - 2 * SCREEN_INDENT
540
- ? windowLayout.height - 2 * SCREEN_INDENT
541
- : scrollableMenuHeight;
542
-
543
- // Menu is typically positioned below the element that generates it
544
- // So first check if it fits below the anchor (expands downwards)
545
- if (
546
- // Check if menu fits vertically
547
- topTransformation <=
548
- windowLayout.height -
549
- menuLayout.height -
550
- SCREEN_INDENT -
551
- additionalVerticalValue ||
552
- // Or if the menu overflows from bottom side
553
- (topTransformation >=
554
- windowLayout.height -
555
- menuLayout.height -
556
- SCREEN_INDENT -
557
- additionalVerticalValue &&
558
- // And bottom side of the screen has more space than top side
559
- topTransformation <= windowLayout.height - topTransformation)
560
- ) {
561
- positionTransforms.push({
562
- translateY: scaleAnimationRef.current.y.interpolate({
563
- inputRange: [0, menuLayout.height],
564
- outputRange: [-((scrollableMenuHeight || menuLayout.height) / 2), 0],
565
- }),
566
- });
567
-
568
- // Check if menu position has enough space from top side
569
- if (topTransformation < SCREEN_INDENT) {
570
- topTransformation = SCREEN_INDENT;
571
- }
572
- } else {
573
- positionTransforms.push({
574
- translateY: scaleAnimationRef.current.y.interpolate({
575
- inputRange: [0, menuLayout.height],
576
- outputRange: [(scrollableMenuHeight || menuLayout.height) / 2, 0],
577
- }),
578
- });
579
-
580
- topTransformation +=
581
- anchorLayout.height - (scrollableMenuHeight || menuLayout.height);
582
-
583
- const bottom =
584
- topTransformation +
585
- (scrollableMenuHeight || menuLayout.height) +
586
- additionalVerticalValue;
587
-
588
- // Check if menu position has enough space from bottom side
589
- if (bottom > windowLayout.height - SCREEN_INDENT) {
590
- topTransformation =
591
- scrollableMenuHeight === windowLayout.height - 2 * SCREEN_INDENT
592
- ? -SCREEN_INDENT * 2
593
- : windowLayout.height -
594
- menuLayout.height -
595
- SCREEN_INDENT -
596
- additionalVerticalValue;
597
- }
598
- }
599
-
600
- const shadowMenuContainerStyle = {
601
- opacity: opacityAnimationRef.current,
602
- transform: [
603
- {
604
- scaleX: scaleAnimationRef.current.x.interpolate({
605
- inputRange: [0, menuLayout.width],
606
- outputRange: [0, 1],
607
- }),
608
- },
609
- {
610
- scaleY: scaleAnimationRef.current.y.interpolate({
611
- inputRange: [0, menuLayout.height],
612
- outputRange: [0, 1],
613
- }),
614
- },
615
- ],
616
- borderRadius: theme.roundness,
617
- ...(!theme.isV3 && { elevation: 8 }),
618
- ...(scrollableMenuHeight ? { height: scrollableMenuHeight } : {}),
619
- };
620
-
621
- const positionStyle = {
622
- top: isCoordinate(anchor)
623
- ? topTransformation
624
- : topTransformation + additionalVerticalValue,
625
- ...(I18nManager.getConstants().isRTL
626
- ? { right: leftTransformation }
627
- : { left: leftTransformation }),
628
- };
629
-
630
- const pointerEvents = visible ? 'box-none' : 'none';
631
-
632
- return (
633
- <View ref={(ref) => (anchorRef.current = ref)} collapsable={false}>
634
- {isCoordinate(anchor) ? null : anchor}
635
- {rendered ? (
636
- <Portal>
637
- <Pressable
638
- accessibilityLabel={overlayAccessibilityLabel}
639
- accessibilityRole="button"
640
- onPress={onDismiss}
641
- style={styles.pressableOverlay}
642
- />
643
- <View
644
- ref={(ref) => (menuRef.current = ref)}
645
- collapsable={false}
646
- accessibilityViewIsModal={visible}
647
- style={[styles.wrapper, positionStyle, style]}
648
- pointerEvents={pointerEvents}
649
- onAccessibilityEscape={onDismiss}
650
- testID={`${testID}-view`}
651
- >
652
- <Animated.View
653
- pointerEvents={pointerEvents}
654
- style={{
655
- transform: positionTransforms,
656
- }}
657
- >
658
- <Surface
659
- mode={mode}
660
- pointerEvents={pointerEvents}
661
- style={[
662
- styles.shadowMenuContainer,
663
- shadowMenuContainerStyle,
664
- theme.isV3 && {
665
- backgroundColor:
666
- theme.colors.elevation[ELEVATION_LEVELS_MAP[elevation]],
667
- },
668
- contentStyle,
669
- ]}
670
- {...(theme.isV3 && { elevation })}
671
- testID={`${testID}-surface`}
672
- theme={theme}
673
- >
674
- {(scrollableMenuHeight && (
675
- <ScrollView
676
- keyboardShouldPersistTaps={keyboardShouldPersistTaps}
677
- >
678
- {children}
679
- </ScrollView>
680
- )) || <React.Fragment>{children}</React.Fragment>}
681
- </Surface>
682
- </Animated.View>
683
- </View>
684
- </Portal>
685
- ) : null}
686
- </View>
687
- );
688
- };
689
-
690
- Menu.Item = MenuItem;
691
-
692
- const styles = StyleSheet.create({
693
- wrapper: {
694
- position: 'absolute',
695
- },
696
- shadowMenuContainer: {
697
- opacity: 0,
698
- paddingVertical: 8,
699
- },
700
- pressableOverlay: {
701
- ...Platform.select({
702
- web: {
703
- cursor: 'auto',
704
- },
705
- }),
706
- ...StyleSheet.absoluteFillObject,
707
- width: '100%',
708
- },
709
- });
710
-
711
- export default Menu;