@react-native-vector-icons/common 0.0.1-alpha.8 → 11.0.0-alpha.0

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 (169) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +49 -91
  3. package/android/build.gradle +37 -3
  4. package/android/generated/java/com/reactnativevectoricons/common/NativeVectorIconsSpec.java +42 -0
  5. package/android/generated/jni/CMakeLists.txt +49 -0
  6. package/android/generated/jni/RNVectorIconsSpec-generated.cpp +38 -0
  7. package/android/generated/jni/RNVectorIconsSpec.h +31 -0
  8. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
  9. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
  10. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.cpp +16 -0
  11. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.h +17 -0
  12. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/Props.cpp +19 -0
  13. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/Props.h +18 -0
  14. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI-generated.cpp +40 -0
  15. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI.h +76 -0
  16. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
  17. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.h +23 -0
  18. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/States.cpp +16 -0
  19. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/States.h +19 -0
  20. package/android/src/main/AndroidManifestNew.xml +1 -1
  21. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.kt +90 -0
  22. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.kt +35 -0
  23. package/android/src/newarch/VectorIconsSpec.kt +7 -0
  24. package/android/src/oldarch/VectorIconsSpec.kt +38 -0
  25. package/ios/VectorIcons.h +13 -17
  26. package/ios/VectorIcons.mm +76 -92
  27. package/ios/generated/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
  28. package/ios/generated/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
  29. package/ios/generated/RNVectorIconsSpec/EventEmitters.cpp +16 -0
  30. package/ios/generated/RNVectorIconsSpec/EventEmitters.h +17 -0
  31. package/ios/generated/RNVectorIconsSpec/Props.cpp +19 -0
  32. package/ios/generated/RNVectorIconsSpec/Props.h +18 -0
  33. package/ios/generated/RNVectorIconsSpec/RCTComponentViewHelpers.h +18 -0
  34. package/ios/generated/RNVectorIconsSpec/RNVectorIconsSpec-generated.mm +36 -0
  35. package/ios/generated/RNVectorIconsSpec/RNVectorIconsSpec.h +58 -0
  36. package/ios/generated/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
  37. package/ios/generated/RNVectorIconsSpec/ShadowNodes.h +23 -0
  38. package/ios/generated/RNVectorIconsSpec/States.cpp +16 -0
  39. package/ios/generated/RNVectorIconsSpec/States.h +19 -0
  40. package/ios/generated/RNVectorIconsSpecJSI-generated.cpp +40 -0
  41. package/ios/generated/RNVectorIconsSpecJSI.h +76 -0
  42. package/lib/commonjs/NativeVectorIcons.js.map +1 -1
  43. package/lib/commonjs/create-icon-set.js +49 -36
  44. package/lib/commonjs/create-icon-set.js.map +1 -1
  45. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +92 -0
  46. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -0
  47. package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js +20 -0
  48. package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
  49. package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +50 -0
  50. package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -0
  51. package/lib/commonjs/dynamicLoading/types.js +2 -0
  52. package/lib/commonjs/dynamicLoading/types.js.map +1 -0
  53. package/lib/commonjs/ensure-native-module-available.js +1 -1
  54. package/lib/commonjs/ensure-native-module-available.js.map +1 -1
  55. package/lib/commonjs/index.js +57 -1
  56. package/lib/commonjs/index.js.map +1 -1
  57. package/lib/commonjs/scripts/common.js +49 -0
  58. package/lib/commonjs/scripts/common.js.map +1 -0
  59. package/lib/commonjs/scripts/getFonts.js +6 -40
  60. package/lib/commonjs/scripts/getFonts.js.map +1 -1
  61. package/lib/commonjs/scripts/updatePlist.js +54 -0
  62. package/lib/commonjs/scripts/updatePlist.js.map +1 -0
  63. package/lib/module/NativeVectorIcons.js +2 -0
  64. package/lib/module/NativeVectorIcons.js.map +1 -1
  65. package/lib/module/NativeVectorIcons.web.js +2 -0
  66. package/lib/module/NativeVectorIcons.web.js.map +1 -1
  67. package/lib/module/create-icon-set.js +49 -34
  68. package/lib/module/create-icon-set.js.map +1 -1
  69. package/lib/module/create-icon-source-cache.js +2 -0
  70. package/lib/module/create-icon-source-cache.js.map +1 -1
  71. package/lib/module/dynamicLoading/dynamic-font-loading.js +85 -0
  72. package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -0
  73. package/lib/module/dynamicLoading/dynamic-font-loading.web.js +16 -0
  74. package/lib/module/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
  75. package/lib/module/dynamicLoading/dynamic-loading-setting.js +41 -0
  76. package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -0
  77. package/lib/module/dynamicLoading/types.js +2 -0
  78. package/lib/module/dynamicLoading/types.js.map +1 -0
  79. package/lib/module/ensure-native-module-available.js +2 -0
  80. package/lib/module/ensure-native-module-available.js.map +1 -1
  81. package/lib/module/index.js +33 -1
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/scripts/common.js +43 -0
  84. package/lib/module/scripts/common.js.map +1 -0
  85. package/lib/module/scripts/getFonts.js +8 -39
  86. package/lib/module/scripts/getFonts.js.map +1 -1
  87. package/lib/module/scripts/updatePlist.js +51 -0
  88. package/lib/module/scripts/updatePlist.js.map +1 -0
  89. package/lib/typescript/commonjs/package.json +1 -0
  90. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts +8 -0
  91. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/NativeVectorIcons.web.d.ts.map +1 -0
  93. package/lib/typescript/commonjs/src/create-icon-set.d.ts +36 -0
  94. package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
  97. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
  99. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
  101. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts +9 -0
  103. package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/ensure-native-module-available.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/src/index.d.ts +6 -0
  106. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/scripts/common.d.ts +2 -0
  108. package/lib/typescript/commonjs/src/scripts/common.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/scripts/getFonts.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts +3 -0
  111. package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts.map +1 -0
  112. package/lib/typescript/module/package.json +1 -0
  113. package/lib/typescript/module/src/NativeVectorIcons.d.ts +8 -0
  114. package/lib/typescript/module/src/NativeVectorIcons.d.ts.map +1 -0
  115. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts +3 -0
  116. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts.map +1 -0
  117. package/lib/typescript/module/src/create-icon-set.d.ts +36 -0
  118. package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -0
  119. package/lib/typescript/module/src/create-icon-source-cache.d.ts +21 -0
  120. package/lib/typescript/module/src/create-icon-source-cache.d.ts.map +1 -0
  121. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
  122. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
  123. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
  124. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
  125. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
  126. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
  127. package/lib/typescript/module/src/dynamicLoading/types.d.ts +9 -0
  128. package/lib/typescript/module/src/dynamicLoading/types.d.ts.map +1 -0
  129. package/lib/typescript/module/src/ensure-native-module-available.d.ts +2 -0
  130. package/lib/typescript/module/src/ensure-native-module-available.d.ts.map +1 -0
  131. package/lib/typescript/module/src/index.d.ts +6 -0
  132. package/lib/typescript/module/src/index.d.ts.map +1 -0
  133. package/lib/typescript/module/src/scripts/common.d.ts +2 -0
  134. package/lib/typescript/module/src/scripts/common.d.ts.map +1 -0
  135. package/lib/typescript/module/src/scripts/getFonts.d.ts +3 -0
  136. package/lib/typescript/module/src/scripts/getFonts.d.ts.map +1 -0
  137. package/lib/typescript/module/src/scripts/updatePlist.d.ts +3 -0
  138. package/lib/typescript/module/src/scripts/updatePlist.d.ts.map +1 -0
  139. package/package.json +72 -44
  140. package/react-native-vector-icons.podspec +67 -42
  141. package/react-native.config.js +12 -0
  142. package/src/NativeVectorIcons.ts +2 -4
  143. package/src/create-icon-set.tsx +79 -32
  144. package/src/dynamicLoading/dynamic-font-loading.ts +97 -0
  145. package/src/dynamicLoading/dynamic-font-loading.web.ts +15 -0
  146. package/src/dynamicLoading/dynamic-loading-setting.ts +77 -0
  147. package/src/dynamicLoading/types.ts +10 -0
  148. package/src/index.ts +48 -1
  149. package/src/scripts/common.ts +52 -0
  150. package/src/scripts/getFonts.ts +6 -47
  151. package/src/scripts/updatePlist.ts +58 -0
  152. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.java +0 -121
  153. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.java +0 -45
  154. package/android/src/newarch/VectorIconsSpec.java +0 -9
  155. package/android/src/oldarch/VectorIconsSpec.java +0 -18
  156. package/lib/typescript/src/NativeVectorIcons.d.ts +0 -9
  157. package/lib/typescript/src/NativeVectorIcons.d.ts.map +0 -1
  158. package/lib/typescript/src/NativeVectorIcons.web.d.ts.map +0 -1
  159. package/lib/typescript/src/create-icon-set.d.ts +0 -26
  160. package/lib/typescript/src/create-icon-set.d.ts.map +0 -1
  161. package/lib/typescript/src/create-icon-source-cache.d.ts.map +0 -1
  162. package/lib/typescript/src/ensure-native-module-available.d.ts.map +0 -1
  163. package/lib/typescript/src/index.d.ts +0 -3
  164. package/lib/typescript/src/index.d.ts.map +0 -1
  165. package/lib/typescript/src/scripts/getFonts.d.ts.map +0 -1
  166. /package/lib/typescript/{src → commonjs/src}/NativeVectorIcons.web.d.ts +0 -0
  167. /package/lib/typescript/{src → commonjs/src}/create-icon-source-cache.d.ts +0 -0
  168. /package/lib/typescript/{src → commonjs/src}/ensure-native-module-available.d.ts +0 -0
  169. /package/lib/typescript/{src → commonjs/src}/scripts/getFonts.d.ts +0 -0
package/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2015 Joel Arvidsson
4
-
5
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
5
  of this software and associated documentation files (the "Software"), to deal
7
6
  in the Software without restriction, including without limitation the rights
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Vector Icons for React Native](https://cloud.githubusercontent.com/assets/378279/12009887/33f4ae1c-ac8d-11e5-8666-7a87458753ee.png)
2
2
 
3
- [![Travis](https://img.shields.io/travis/react-native-vector-icons/react-native-vector-icons.svg)](https://travis-ci.org/react-native-vector-icons/react-native-vector-icons) [![npm](https://img.shields.io/npm/v/react-native-vector-icons.svg)](https://npmjs.com/package/react-native-vector-icons) [![npm](https://img.shields.io/npm/dm/react-native-vector-icons.svg)](https://npmjs.com/package/react-native-vector-icons)
3
+ [![npm](https://img.shields.io/npm/v/@react-native-vector-icons/common.svg)](https://npmjs.com/package/@react-native-vector-icons/common.svg) [![npm](https://img.shields.io/npm/dm/@react-native-vector-icons/common.svg)](https://npmjs.com/package/@react-native-vector-icons/common)
4
4
 
5
5
  # React Native Vector Icons
6
6
 
@@ -11,22 +11,22 @@ extension and styling effortless.
11
11
 
12
12
  For the integration of `.svg` files natively, you can explore [`react-native-vector-image`](https://github.com/oblador/react-native-vector-image).
13
13
 
14
+ > [!TIP]
15
+ > If you are still using the old single package `react-native-vector-icons` please visit https://github.com/oblador/react-native-vector-icons/tree/legacy
16
+
14
17
  ## Table of Contents
15
18
 
16
19
  - [Sponsorship](#sponsorship)
17
20
  - [Available Icon Sets](#available-icon-sets)
18
21
  - [Installation](#installation)
19
- - [iOS Setup](#ios-setup)
20
- - [macOS Setup](#macos-setup)
21
- - [Windows Setup](#windows-setup)
22
- - [Web Setup](#web-setup)
22
+ - [Setup](#setup)
23
23
  - [Icon Component](#icon-component)
24
24
  - [Usage as PNG Image/Source Object](#usage-as-png-imagesource-object)
25
25
  - [Multi-Style Fonts](#multi-style-fonts)
26
26
  - [Custom Fonts](#custom-fonts)
27
27
  - [Animation](#animation)
28
+ - [Dynamic icon font loading](#dynamic-icon-font-loading)
28
29
  - [Usage Examples](#usage-examples)
29
- - [Generating Your Own Icon Package](#generating-your-own-icon-package)
30
30
  - [Changelog](https://github.com/react-native-vector-icons/react-native-vector-icons/releases)
31
31
  - [License](#license)
32
32
 
@@ -41,14 +41,14 @@ Should you find this library beneficial, kindly contemplate the option of
41
41
 
42
42
  RNVI comes with the following supported icons. You can [search NPM](https://www.npmjs.com/search?q=keywords%3Areact-native-vector-icons-icon) for third party icons.
43
43
 
44
- ### Actively maintained fonts
44
+ ### Actively maintained
45
45
  - [`AntDesign`](https://ant.design/components/icon) from Ant Group (v4.4.2 with _449_ icons)
46
46
  - [`Feather`](http://feathericons.com) created by Cole Bemis & Contributors (v4.29.2 featuring _287_ icons)
47
- - [`FontAwesome 6`](https://fontawesome.com/search) designed by Fonticons, Inc. (v6.5.2 featuring _2045_ free and _30199_ pro icons)
47
+ - [`FontAwesome 6`](https://fontawesome.com/search) designed by Fonticons, Inc. (v6.6.0 featuring _2050_ free and _30213_ pro icons)
48
48
  - [`Foundation`](http://zurb.com/playground/foundation-icon-fonts-3) by ZURB, Inc. (v3.0 with _283_ icons)
49
49
  - [`Ionicons`](https://ionic.io/ionicons) crafted by Ionic (v7.4.0 containing _1356_ icons)
50
50
  - [`MaterialDesignIcons`](https://pictogrammers.com/library/mdi/) from MaterialDesignIcons.com (v7.4.47 including _7448_ icons)
51
- - [`Octicons`](https://primer.style/foundations/icons) designed by Github, Inc. (v19.9.0 with _321_ icons)
51
+ - [`Octicons`](https://primer.style/foundations/icons) designed by GitHub, Inc. (v19.11.0 with _331_ icons)
52
52
 
53
53
  ### No longer maintained upstream
54
54
  - [`Entypo`](http://entypo.com) by Daniel Bruce (v1.0.1 with _411_ icons)
@@ -62,7 +62,7 @@ RNVI comes with the following supported icons. You can [search NPM](https://www.
62
62
 
63
63
  ## Migration
64
64
 
65
- See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-icons`
65
+ See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-icons` to the package-per-icon-set approach.
66
66
 
67
67
  ## Installation
68
68
 
@@ -70,86 +70,22 @@ See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-
70
70
  ```sh
71
71
  npm install --save @react-native-vector-icons/common
72
72
  ```
73
- 1. Install the packages for the icons you want use
73
+ 2. Install the packages for the icons you want use
74
74
  ```sh
75
75
  npm install --save @react-native-vector-icons/fontawesome6 @react-native-vector-icons/evilicons
76
76
  ```
77
- 1. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions.
78
- 1. If you are using one of the following fonts refer to their guides for further instructions
79
- * [FontAwesome 5](packages/fontawesome5/README.md)
80
- * [FontAwesome 5 Pro](packages/fontawesome5-pro/README.md)
77
+ 3. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions below.
78
+ 4. If you are using one of the following fonts refer to their guides for further instructions
81
79
  * [FontAwesome 6](packages/fontawesome6/README.md)
82
80
  * [FontAwesome 6 Pro](packages/fontawesome6-pro/README.md)
81
+ * [FontAwesome 5](packages/fontawesome5/README.md)
82
+ * [FontAwesome 5 Pro](packages/fontawesome5-pro/README.md)
83
83
  * [Fontello](packages/fontello/README.md)
84
84
  * [Icomoon](packages/icomoon/README.md)
85
85
 
86
- ### android
87
-
88
- Nothing else needed.
89
-
90
- ### iOS
91
-
92
- To use the bundled icons on iOS, follow these steps:
93
-
94
- 1. Update your pods
95
- ```sh
96
- cd ios && pod update
97
- ```
98
-
99
- ### macOS
100
-
101
- This needs more work, see details in #1624
102
-
103
- ### Windows
104
-
105
- TBA: It should just work???
106
-
107
- ### Web Setup
108
-
109
- FIXME: Can we improve on this?
110
-
111
- To integrate the library with your web project using [webpack](https://webpack.js.org/), follow these steps:
86
+ ## Setup
112
87
 
113
- 1. In your webpack configuration file, add a section to handle TTF files using `url-loader` or `file-loader`:
114
-
115
- ```js
116
- {
117
- test: /\.ttf$/,
118
- loader: "url-loader", // or directly file-loader
119
- include: path.resolve(__dirname, "node_modules/react-native-vector-icons"),
120
- }
121
- ```
122
-
123
- 2. In your JavaScript entry point, consume the font files and inject the necessary style tag:
124
-
125
- ```js
126
- import Icon from '@react-native-vector-icons/fontAwesome';
127
-
128
- // Generate the required CSS
129
- import iconFont from '@react-native-vector-icons/fontawesome/fonts/FontAwesome.ttf';
130
- const iconFontStyles = `@font-face {
131
- src: url(${iconFont});
132
- font-family: FontAwesome;
133
- }`;
134
-
135
- // Create a stylesheet
136
- const style = document.createElement('style');
137
- style.type = 'text/css';
138
-
139
- // Append the iconFontStyles to the stylesheet
140
- if (style.styleSheet) {
141
- style.styleSheet.cssText = iconFontStyles;
142
- } else {
143
- style.appendChild(document.createTextNode(iconFontStyles));
144
- }
145
-
146
- // Inject the stylesheet into the document head
147
- document.head.appendChild(style);
148
- ```
149
-
150
- By following these steps, you will seamlessly integrate the vector icons
151
- library into your web project using [webpack](https://webpack.js.org/),
152
- enabling you to effortlessly use the icons within your web application.
88
+ Please refer to the guide for [Expo](./docs/SETUP-EXPO.md), [React Native](./docs/SETUP-REACT-NATIVE.md) or [Web](./docs/SETUP-WEB.md) for further instructions.
153
89
 
154
90
  ## `Icon` Component
155
91
 
@@ -160,9 +96,9 @@ import Icon from '@react-native-vector-icons/fontawesome';
160
96
  const myIcon = <Icon name="rocket" size={30} color="#900" />;
161
97
  ```
162
98
 
163
- ### Properties
99
+ ### Props
164
100
 
165
- Any [Text property](https://reactnative.dev/docs/text.html) and the following:
101
+ Any [Text props](https://reactnative.dev/docs/text.html#props) and the following:
166
102
 
167
103
  | Prop | Description | Default |
168
104
  | ----------- | ----------------------------------------------------------------------- | ----------- |
@@ -234,20 +170,25 @@ All static methods from `Icon` is supported by multi-styled fonts.
234
170
 
235
171
  The best approach is to use our icon generator to create your own icon package.
236
172
 
237
- See [CREATE_FONT_PACKAGE.md] to learn how to create your own font packages.
173
+ See [CREATE_FONT_PACKAGE.md](./docs/CREATE_FONT_PACKAGE.md) to learn how to create your own font packages.
238
174
 
239
- You can also use `createIconSet(glyphMap, fontFamily[, fontFile])` directly in your project. This
175
+ You can also use `createIconSet()` directly in your project. This
240
176
  returns your own custom font based on the `glyphMap` where the key is the icon
241
177
  name and the value is either a UTF-8 character or it's character code.
242
- `fontFamily` is the name of the postscript font **NOT** the filename. Open the font in
243
- Font Book.app or similar to learn the name. Optionally pass the third
244
- `fontFile` argument for android support, it should be the custom font file
245
- name.
178
+ `postScriptName` is the name of the postscript font. Open the font in https://fontdrop.info/,
179
+ Font Book.app or similar to learn the name. Also pass the `fontFileName` argument for Android support.
246
180
 
247
181
  ```js
248
182
  import { createIconSet } from '@react-native-vector-icons/common';
249
183
  const glyphMap = { 'icon-name': 1234, test: '∆' };
250
- const Icon = createIconSet(glyphMap, 'FontName', 'font-name.ttf');
184
+
185
+ // use createIconSet() with object parameter
186
+ // or use positional parameters for compatibility with version <= 10: `createIconSet(glyphMap, fontFamily[, fontFile])`
187
+ const Icon = createIconSet(glyphMap, {
188
+ postScriptName: 'FontName',
189
+ fontFileName: 'font-name.ttf',
190
+ fontSource: require('../fonts/font-name.ttf') // optional, for dynamic loading. Can also be a local file uri.
191
+ })
251
192
  ```
252
193
 
253
194
  You should place the font ttf file into `rnvi-fonts`. You can customise this location by adding the following snippet to your package.json
@@ -268,9 +209,26 @@ Animated.createAnimatedComponent(Icon)`. You can also use the higher level
268
209
  animation library
269
210
  [react-native-animatable](https://github.com/oblador/react-native-animatable).
270
211
 
212
+ ## Dynamic icon font loading
213
+
214
+ > At the moment, dynamic loading is supported on native platforms (not on web) only if you use Expo. In the future, it should become available for all React Native projects via React Native core.
215
+
216
+ Fonts can be available in an app statically (since build time) or loaded dynamically at runtime. The latter can be useful e.g. for apps that use over-the-air updates and want to load new fonts with an update, or when you need to use a font from a remote location.
217
+
218
+ Dynamic loading in react-native-vector-icons is currently limited to those fonts that are bundled within the provided packages: it doesn't support Pro fonts (such as FontAwesome 5 Pro). However, loading of custom fonts is not difficult to implement: see any of the free font packages for reference.
219
+
220
+ By default, dynamic loading is enabled if supported by the version of Expo that you're using. It doesn't change the way you work with the package: If rendering an icon requires a font that is not known to the app, it will be loaded automatically and icon will render as expected.
221
+
222
+ `@react-native-vector-icons/common` exports several functions which you can use to control dynamic loading:
223
+
224
+ - `isDynamicLoadingEnabled`: Returns whether dynamic loading is enabled.
225
+ - `isDynamicLoadingSupported`: Returns whether dynamic loading is supported by your runtime (checks that necessary Expo features are present).
226
+ - `setDynamicLoadingEnabled`: Enables or disables dynamic loading.
227
+ - `setDynamicLoadingErrorCallback`: Sets a callback that is called (in the unlikely case) when an error occurs during dynamic loading. An example of when an error might happen is loading a misconfigured OTA update which doesn't include a necessary font file.
228
+
271
229
  ## Usage Examples
272
230
 
273
- ### IconExplorer
231
+ ### Icon Explorer
274
232
 
275
233
  Try the `IconExplorer` project in `Examples/IconExplorer` folder, there you can also search for any icon.
276
234
 
@@ -1,4 +1,7 @@
1
1
  buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["VectorIcons_kotlinVersion"]
4
+
2
5
  repositories {
3
6
  google()
4
7
  mavenCentral()
@@ -6,14 +9,22 @@ buildscript {
6
9
 
7
10
  dependencies {
8
11
  classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9
14
  }
10
15
  }
11
16
 
17
+ def reactNativeArchitectures() {
18
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
19
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20
+ }
21
+
12
22
  def isNewArchitectureEnabled() {
13
23
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
14
24
  }
15
25
 
16
26
  apply plugin: "com.android.library"
27
+ apply plugin: "kotlin-android"
17
28
 
18
29
  if (isNewArchitectureEnabled()) {
19
30
  apply plugin: "com.facebook.react"
@@ -36,6 +47,18 @@ def supportsNamespace() {
36
47
  return (major == 7 && minor >= 3) || major >= 8
37
48
  }
38
49
 
50
+ import groovy.json.JsonSlurper
51
+
52
+ def generatedCompat() {
53
+ def rnviProject = rootProject.allprojects.find { it.name == 'react-native-vector-icons_common' }
54
+ if (rnviProject == null) return false
55
+
56
+ def reactNativeManifest = file("${rnviProject.projectDir}/../../../react-native/package.json")
57
+ def reactNativeVersion = new JsonSlurper().parseText(reactNativeManifest.text).version as String
58
+
59
+ reactNativeVersion.matches('(0.71.*|0.72.*|0.73.*)')
60
+ }
61
+
39
62
  android {
40
63
  if (supportsNamespace()) {
41
64
  namespace "com.reactnativevectoricons.common"
@@ -80,9 +103,18 @@ android {
80
103
  if (isNewArchitectureEnabled()) {
81
104
  java.srcDirs += [
82
105
  "src/newarch",
83
- // This is needed to build Kotlin project with NewArch enabled
84
- "${project.buildDir}/generated/source/codegen/java"
85
106
  ]
107
+ if (!generatedCompat()) {
108
+ println("Adding generated directories")
109
+ println("Adding generated directories")
110
+ println("Adding generated directories")
111
+ // NOTE: create-react-native-library has these here but it breaks <= 0.73
112
+ java.srcDirs += [
113
+ // Codegen specs
114
+ "generated/java",
115
+ "generated/jni"
116
+ ]
117
+ }
86
118
  } else {
87
119
  java.srcDirs += ["src/oldarch"]
88
120
  }
@@ -95,12 +127,14 @@ repositories {
95
127
  google()
96
128
  }
97
129
 
130
+ def kotlin_version = getExtOrDefault("kotlinVersion")
98
131
 
99
132
  dependencies {
100
133
  // For < 0.71, this will be from the local maven repo
101
134
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
102
135
  //noinspection GradleDynamicVersion
103
136
  implementation "com.facebook.react:react-native:+"
137
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
104
138
  }
105
139
 
106
140
  if (isNewArchitectureEnabled()) {
@@ -114,7 +148,7 @@ if (isNewArchitectureEnabled()) {
114
148
  android.sourceSets.main.assets.srcDirs += file("$buildDir/intermediates/RNVI")
115
149
 
116
150
  task copyFonts(type: Exec) {
117
- commandLine 'node', '../lib/commonjs/scripts/getFonts.js', rootDir.parentFile.absolutePath
151
+ commandLine 'node', '../lib/commonjs/scripts/getFonts.js', "${rootDir.parentFile.absolutePath}/package.json"
118
152
  def fonts = new ByteArrayOutputStream()
119
153
  standardOutput = fonts
120
154
 
@@ -0,0 +1,42 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJavaSpec.js
9
+ *
10
+ * @nolint
11
+ */
12
+
13
+ package com.reactnativevectoricons.common;
14
+
15
+ import com.facebook.proguard.annotations.DoNotStrip;
16
+ import com.facebook.react.bridge.Promise;
17
+ import com.facebook.react.bridge.ReactApplicationContext;
18
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
19
+ import com.facebook.react.bridge.ReactMethod;
20
+ import com.facebook.react.turbomodule.core.interfaces.TurboModule;
21
+ import javax.annotation.Nonnull;
22
+
23
+ public abstract class NativeVectorIconsSpec extends ReactContextBaseJavaModule implements TurboModule {
24
+ public static final String NAME = "VectorIcons";
25
+
26
+ public NativeVectorIconsSpec(ReactApplicationContext reactContext) {
27
+ super(reactContext);
28
+ }
29
+
30
+ @Override
31
+ public @Nonnull String getName() {
32
+ return NAME;
33
+ }
34
+
35
+ @ReactMethod
36
+ @DoNotStrip
37
+ public abstract void getImageForFont(String fontFamilyName, String glyph, double fontSize, double color, Promise promise);
38
+
39
+ @ReactMethod(isBlockingSynchronousMethod = true)
40
+ @DoNotStrip
41
+ public abstract String getImageForFontSync(String fontFamilyName, String glyph, double fontSize, double color);
42
+ }
@@ -0,0 +1,49 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNVectorIconsSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_RNVectorIconsSpec
13
+ SHARED
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_RNVectorIconsSpec PUBLIC . react/renderer/components/RNVectorIconsSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_RNVectorIconsSpec
21
+ fbjni
22
+ folly_runtime
23
+ glog
24
+ jsi
25
+ react_codegen_rncore
26
+ react_debug
27
+ react_nativemodule_core
28
+ react_render_componentregistry
29
+ react_render_core
30
+ react_render_debug
31
+ react_render_graphics
32
+ react_render_imagemanager
33
+ react_render_mapbuffer
34
+ react_utils
35
+ rrc_image
36
+ rrc_view
37
+ turbomodulejsijni
38
+ yoga
39
+ )
40
+
41
+ target_compile_options(
42
+ react_codegen_RNVectorIconsSpec
43
+ PRIVATE
44
+ -DLOG_TAG=\"ReactNative\"
45
+ -fexceptions
46
+ -frtti
47
+ -std=c++20
48
+ -Wall
49
+ )
@@ -0,0 +1,38 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNVectorIconsSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativeVectorIconsSpecJSI_getImageForFont(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getImageForFont", "(Ljava/lang/String;Ljava/lang/String;DDLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
18
+ }
19
+
20
+ static facebook::jsi::Value __hostFunction_NativeVectorIconsSpecJSI_getImageForFontSync(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21
+ static jmethodID cachedMethodId = nullptr;
22
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, StringKind, "getImageForFontSync", "(Ljava/lang/String;Ljava/lang/String;DD)Ljava/lang/String;", args, count, cachedMethodId);
23
+ }
24
+
25
+ NativeVectorIconsSpecJSI::NativeVectorIconsSpecJSI(const JavaTurboModule::InitParams &params)
26
+ : JavaTurboModule(params) {
27
+ methodMap_["getImageForFont"] = MethodMetadata {4, __hostFunction_NativeVectorIconsSpecJSI_getImageForFont};
28
+ methodMap_["getImageForFontSync"] = MethodMetadata {4, __hostFunction_NativeVectorIconsSpecJSI_getImageForFontSync};
29
+ }
30
+
31
+ std::shared_ptr<TurboModule> RNVectorIconsSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
32
+ if (moduleName == "VectorIcons") {
33
+ return std::make_shared<NativeVectorIconsSpecJSI>(params);
34
+ }
35
+ return nullptr;
36
+ }
37
+
38
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativeVectorIcons'
21
+ */
22
+ class JSI_EXPORT NativeVectorIconsSpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativeVectorIconsSpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> RNVectorIconsSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
+ */
10
+
11
+ #include "ComponentDescriptors.h"
12
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ void RNVectorIconsSpec_registerComponentDescriptorsFromCodegen(
18
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
19
+
20
+ }
21
+
22
+ } // namespace facebook::react
@@ -0,0 +1,24 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "ShadowNodes.h"
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
+
17
+ namespace facebook::react {
18
+
19
+
20
+
21
+ void RNVectorIconsSpec_registerComponentDescriptorsFromCodegen(
22
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
23
+
24
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterCpp.js
9
+ */
10
+
11
+ #include "EventEmitters.h"
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterH.js
9
+ */
10
+ #pragma once
11
+
12
+ #include <react/renderer/components/view/ViewEventEmitter.h>
13
+
14
+
15
+ namespace facebook::react {
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsCpp.js
9
+ */
10
+
11
+ #include "Props.h"
12
+ #include <react/renderer/core/PropsParserContext.h>
13
+ #include <react/renderer/core/propsConversions.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+
19
+ } // namespace facebook::react
@@ -0,0 +1,18 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsH.js
9
+ */
10
+ #pragma once
11
+
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+
17
+
18
+ } // namespace facebook::react
@@ -0,0 +1,40 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNVectorIconsSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFont(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeVectorIconsCxxSpecJSI *>(&turboModule)->getImageForFont(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
19
+ count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asNumber(),
20
+ count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asNumber()
21
+ );
22
+ }
23
+ static jsi::Value __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFontSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
24
+ return static_cast<NativeVectorIconsCxxSpecJSI *>(&turboModule)->getImageForFontSync(
25
+ rt,
26
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
27
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
28
+ count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asNumber(),
29
+ count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asNumber()
30
+ );
31
+ }
32
+
33
+ NativeVectorIconsCxxSpecJSI::NativeVectorIconsCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
34
+ : TurboModule("VectorIcons", jsInvoker) {
35
+ methodMap_["getImageForFont"] = MethodMetadata {4, __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFont};
36
+ methodMap_["getImageForFontSync"] = MethodMetadata {4, __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFontSync};
37
+ }
38
+
39
+
40
+ } // namespace facebook::react