@react-native-vector-icons/common 0.0.1-alpha.2 → 0.0.1-alpha.22

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 (172) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +268 -0
  3. package/android/build.gradle +40 -6
  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/NativeVectorIcons.web.js.map +1 -1
  44. package/lib/commonjs/create-icon-set.js +52 -35
  45. package/lib/commonjs/create-icon-set.js.map +1 -1
  46. package/lib/commonjs/create-icon-source-cache.js.map +1 -1
  47. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +92 -0
  48. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -0
  49. package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js +20 -0
  50. package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
  51. package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +50 -0
  52. package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -0
  53. package/lib/commonjs/dynamicLoading/types.js +2 -0
  54. package/lib/commonjs/dynamicLoading/types.js.map +1 -0
  55. package/lib/commonjs/ensure-native-module-available.js +1 -1
  56. package/lib/commonjs/ensure-native-module-available.js.map +1 -1
  57. package/lib/commonjs/index.js +57 -1
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/scripts/common.js +49 -0
  60. package/lib/commonjs/scripts/common.js.map +1 -0
  61. package/lib/commonjs/scripts/getFonts.js +6 -40
  62. package/lib/commonjs/scripts/getFonts.js.map +1 -1
  63. package/lib/commonjs/scripts/updatePlist.js +54 -0
  64. package/lib/commonjs/scripts/updatePlist.js.map +1 -0
  65. package/lib/module/NativeVectorIcons.js +2 -0
  66. package/lib/module/NativeVectorIcons.js.map +1 -1
  67. package/lib/module/NativeVectorIcons.web.js +2 -0
  68. package/lib/module/NativeVectorIcons.web.js.map +1 -1
  69. package/lib/module/create-icon-set.js +52 -33
  70. package/lib/module/create-icon-set.js.map +1 -1
  71. package/lib/module/create-icon-source-cache.js +2 -0
  72. package/lib/module/create-icon-source-cache.js.map +1 -1
  73. package/lib/module/dynamicLoading/dynamic-font-loading.js +85 -0
  74. package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -0
  75. package/lib/module/dynamicLoading/dynamic-font-loading.web.js +16 -0
  76. package/lib/module/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
  77. package/lib/module/dynamicLoading/dynamic-loading-setting.js +41 -0
  78. package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -0
  79. package/lib/module/dynamicLoading/types.js +2 -0
  80. package/lib/module/dynamicLoading/types.js.map +1 -0
  81. package/lib/module/ensure-native-module-available.js +2 -0
  82. package/lib/module/ensure-native-module-available.js.map +1 -1
  83. package/lib/module/index.js +33 -1
  84. package/lib/module/index.js.map +1 -1
  85. package/lib/module/scripts/common.js +43 -0
  86. package/lib/module/scripts/common.js.map +1 -0
  87. package/lib/module/scripts/getFonts.js +8 -39
  88. package/lib/module/scripts/getFonts.js.map +1 -1
  89. package/lib/module/scripts/updatePlist.js +51 -0
  90. package/lib/module/scripts/updatePlist.js.map +1 -0
  91. package/lib/typescript/commonjs/package.json +1 -0
  92. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts +8 -0
  93. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/NativeVectorIcons.web.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/src/create-icon-set.d.ts +36 -0
  96. package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
  99. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
  101. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
  103. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts +9 -0
  105. package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/ensure-native-module-available.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/index.d.ts +6 -0
  108. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/scripts/common.d.ts +2 -0
  110. package/lib/typescript/commonjs/src/scripts/common.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/src/scripts/getFonts.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts +3 -0
  113. package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts.map +1 -0
  114. package/lib/typescript/module/package.json +1 -0
  115. package/lib/typescript/module/src/NativeVectorIcons.d.ts +8 -0
  116. package/lib/typescript/module/src/NativeVectorIcons.d.ts.map +1 -0
  117. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts +3 -0
  118. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts.map +1 -0
  119. package/lib/typescript/module/src/create-icon-set.d.ts +36 -0
  120. package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -0
  121. package/lib/typescript/module/src/create-icon-source-cache.d.ts +21 -0
  122. package/lib/typescript/module/src/create-icon-source-cache.d.ts.map +1 -0
  123. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
  124. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
  125. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
  126. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
  127. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
  128. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
  129. package/lib/typescript/module/src/dynamicLoading/types.d.ts +9 -0
  130. package/lib/typescript/module/src/dynamicLoading/types.d.ts.map +1 -0
  131. package/lib/typescript/module/src/ensure-native-module-available.d.ts +2 -0
  132. package/lib/typescript/module/src/ensure-native-module-available.d.ts.map +1 -0
  133. package/lib/typescript/module/src/index.d.ts +6 -0
  134. package/lib/typescript/module/src/index.d.ts.map +1 -0
  135. package/lib/typescript/module/src/scripts/common.d.ts +2 -0
  136. package/lib/typescript/module/src/scripts/common.d.ts.map +1 -0
  137. package/lib/typescript/module/src/scripts/getFonts.d.ts +3 -0
  138. package/lib/typescript/module/src/scripts/getFonts.d.ts.map +1 -0
  139. package/lib/typescript/module/src/scripts/updatePlist.d.ts +3 -0
  140. package/lib/typescript/module/src/scripts/updatePlist.d.ts.map +1 -0
  141. package/package.json +72 -81
  142. package/react-native-vector-icons.podspec +79 -35
  143. package/src/NativeVectorIcons.ts +2 -14
  144. package/src/create-icon-set.tsx +97 -54
  145. package/src/create-icon-source-cache.ts +3 -7
  146. package/src/dynamicLoading/dynamic-font-loading.ts +97 -0
  147. package/src/dynamicLoading/dynamic-font-loading.web.ts +15 -0
  148. package/src/dynamicLoading/dynamic-loading-setting.ts +77 -0
  149. package/src/dynamicLoading/types.ts +10 -0
  150. package/src/ensure-native-module-available.ts +1 -1
  151. package/src/index.ts +48 -1
  152. package/src/scripts/common.ts +52 -0
  153. package/src/scripts/getFonts.ts +6 -47
  154. package/src/scripts/updatePlist.ts +58 -0
  155. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.java +0 -121
  156. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.java +0 -45
  157. package/android/src/newarch/VectorIconsSpec.java +0 -9
  158. package/android/src/oldarch/VectorIconsSpec.java +0 -18
  159. package/lib/typescript/src/NativeVectorIcons.d.ts +0 -9
  160. package/lib/typescript/src/NativeVectorIcons.d.ts.map +0 -1
  161. package/lib/typescript/src/NativeVectorIcons.web.d.ts.map +0 -1
  162. package/lib/typescript/src/create-icon-set.d.ts +0 -26
  163. package/lib/typescript/src/create-icon-set.d.ts.map +0 -1
  164. package/lib/typescript/src/create-icon-source-cache.d.ts.map +0 -1
  165. package/lib/typescript/src/ensure-native-module-available.d.ts.map +0 -1
  166. package/lib/typescript/src/index.d.ts +0 -3
  167. package/lib/typescript/src/index.d.ts.map +0 -1
  168. package/lib/typescript/src/scripts/getFonts.d.ts.map +0 -1
  169. /package/lib/typescript/{src → commonjs/src}/NativeVectorIcons.web.d.ts +0 -0
  170. /package/lib/typescript/{src → commonjs/src}/create-icon-source-cache.d.ts +0 -0
  171. /package/lib/typescript/{src → commonjs/src}/ensure-native-module-available.d.ts +0 -0
  172. /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 ADDED
@@ -0,0 +1,268 @@
1
+ ![Vector Icons for React Native](https://cloud.githubusercontent.com/assets/378279/12009887/33f4ae1c-ac8d-11e5-8666-7a87458753ee.png)
2
+
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
+
5
+ # React Native Vector Icons
6
+
7
+ Elevate your React Native applications with the power of customizable vector
8
+ icons. Ideal for embellishing buttons, logos, and navigation or tab bars, these
9
+ icons seamlessly integrate into your projects. Their versatility makes
10
+ extension and styling effortless.
11
+
12
+ For the integration of `.svg` files natively, you can explore [`react-native-vector-image`](https://github.com/oblador/react-native-vector-image).
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
+
17
+ ## Table of Contents
18
+
19
+ - [Sponsorship](#sponsorship)
20
+ - [Available Icon Sets](#available-icon-sets)
21
+ - [Installation](#installation)
22
+ - [Setup](#setup)
23
+ - [Icon Component](#icon-component)
24
+ - [Usage as PNG Image/Source Object](#usage-as-png-imagesource-object)
25
+ - [Multi-Style Fonts](#multi-style-fonts)
26
+ - [Custom Fonts](#custom-fonts)
27
+ - [Animation](#animation)
28
+ - [Dynamic icon font loading](#dynamic-icon-font-loading)
29
+ - [Usage Examples](#usage-examples)
30
+ - [Changelog](https://github.com/react-native-vector-icons/react-native-vector-icons/releases)
31
+ - [License](#license)
32
+
33
+ ## Sponsorship
34
+
35
+ Should you find this library beneficial, kindly contemplate the option of
36
+ [sponsoring](https://github.com/sponsors/oblador).
37
+
38
+ ## Available Icon Sets
39
+
40
+ [Explore all icons](https://react-native-vector-icons.github.io/react-native-vector-icons/).
41
+
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
+
44
+ ### Actively maintained
45
+ - [`AntDesign`](https://ant.design/components/icon) from Ant Group (v4.4.2 with _449_ icons)
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.6.0 featuring _2050_ free and _30213_ pro icons)
48
+ - [`Foundation`](http://zurb.com/playground/foundation-icon-fonts-3) by ZURB, Inc. (v3.0 with _283_ icons)
49
+ - [`Ionicons`](https://ionic.io/ionicons) crafted by Ionic (v7.4.0 containing _1356_ icons)
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.11.0 with _331_ icons)
52
+
53
+ ### No longer maintained upstream
54
+ - [`Entypo`](http://entypo.com) by Daniel Bruce (v1.0.1 with _411_ icons)
55
+ - [`EvilIcons`](http://evil-icons.io) designed by Alexander Madyankin & Roman Shamin (v1.10.1 with _70_ icons)
56
+ - [`FontAwesome`](https://fontawesome.com/v4/icons) by Fonticons, Inc. (v4.7.0 containing _785_ icons)
57
+ - [`FontAwesome 5`](https://fontawesome.com/v5/search) from Fonticons, Inc. (v5.15.4 offering _1611_ free and _7869_ pro icons)
58
+ - [`Fontisto`](https://github.com/kenangundogan/fontisto) created by Kenan Gündoğan (v3.0.4 featuring _617_ icons)
59
+ - [`MaterialIcons`](https://fonts.google.com/icons?icon.set=Material+Icons) by Google, Inc. (v4.0.0 featuring _2234_ icons)
60
+ - [`SimpleLineIcons`](https://simplelineicons.github.io/) crafted by Sabbir & Contributors (v2.5.5 with _189_ icons)
61
+ - [`Zocial`](https://smcllns.github.io/css-social-buttons) by Sam Collins (v1.1.1 with _100_ icons)
62
+
63
+ ## Migration
64
+
65
+ See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-icons` to the package-per-icon-set approach.
66
+
67
+ ## Installation
68
+
69
+ 1. Install the common package
70
+ ```sh
71
+ npm install --save @react-native-vector-icons/common
72
+ ```
73
+ 2. Install the packages for the icons you want use
74
+ ```sh
75
+ npm install --save @react-native-vector-icons/fontawesome6 @react-native-vector-icons/evilicons
76
+ ```
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
79
+ * [FontAwesome 6](packages/fontawesome6/README.md)
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
+ * [Fontello](packages/fontello/README.md)
84
+ * [Icomoon](packages/icomoon/README.md)
85
+
86
+ ## Setup
87
+
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.
89
+
90
+ ## `Icon` Component
91
+
92
+ You can either use one of the bundled icons above or roll your own custom font.
93
+
94
+ ```js
95
+ import Icon from '@react-native-vector-icons/fontawesome';
96
+ const myIcon = <Icon name="rocket" size={30} color="#900" />;
97
+ ```
98
+
99
+ ### Props
100
+
101
+ Any [Text props](https://reactnative.dev/docs/text.html#props) and the following:
102
+
103
+ | Prop | Description | Default |
104
+ | ----------- | ----------------------------------------------------------------------- | ----------- |
105
+ | **`size`** | Size of the icon, can also be passed as `fontSize` in the style object. | `12` |
106
+ | **`name`** | What icon to show, see Icon Explorer app or one of the links above. | _None_ |
107
+ | **`color`** | Color of the icon. | _Inherited_ |
108
+
109
+ ### Static Methods
110
+
111
+ | Prop | Description |
112
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
113
+ | **`getImageSource`** | Returns a promise that resolving to the source of a bitmap version of the icon for use with `Image` component et al. Usage: `const source = await Icon.getImageSource(name, size, color)` |
114
+ | **`getImageSourceSync`** | Same as `getImageSource` but synchronous. Usage: `const source = Icon.getImageSourceSync(name, size, color)` |
115
+
116
+ ### Styling
117
+
118
+ Since `Icon` builds on top of the `Text` component, most [style properties](https://reactnative.dev/docs/style.html) will work as expected, you might find it useful to play around with these:
119
+
120
+ - `backgroundColor`
121
+ - `borderWidth`
122
+ - `borderColor`
123
+ - `borderRadius`
124
+ - `padding`
125
+ - `margin`
126
+ - `color`
127
+ - `fontSize`
128
+
129
+ By combining some of these you can create for example :
130
+
131
+ ![type](https://cloud.githubusercontent.com/assets/378279/7667570/33817554-fc0d-11e4-9ad7-4eb60139cfb7.png)
132
+ ![star](https://cloud.githubusercontent.com/assets/378279/7667569/3010dd7e-fc0d-11e4-9696-cb721fe8e98d.png)
133
+
134
+ ## Usage as PNG Image/Source Object
135
+
136
+ Convenient way to plug this in into other components that rely on bitmap images rather than scalable vector icons. Takes the arguments `name`, `size` and `color` as described above.
137
+
138
+ ```jsx
139
+ const source = Icon.getImageSourceSync('user', 20, 'red');
140
+ return <Image source={source} />;
141
+ );
142
+ ```
143
+
144
+ Alternatively you may use the async method `Icon.getImageSource`.
145
+
146
+ Keep in mind that `Icon.getImageSourceSync` is blocking and might incur performance penalties. Subsequent calls will use cache however.
147
+
148
+ ## Multi-Style Fonts
149
+
150
+ Some fonts today use multiple styles, FontAwesome 5 for example, which is supported by this library. The usage is pretty much the same as the standard `Icon` component:
151
+
152
+ ```jsx
153
+ import Icon from '@react-native-vector-icons/fontawesome5';
154
+
155
+ const myIcon1 = <Icon name="comments" size={30} color="#900" />; // Defaults to solid
156
+ const myIcon2 = <Icon name="comments" size={30} color="#900" iconType="solid" />;
157
+ const myIcon3 = <Icon name="comments" size={30} color="#900" iconType="light" />; // Only in FA5 Pro
158
+ ```
159
+
160
+ ### Static methods
161
+
162
+ All static methods from `Icon` is supported by multi-styled fonts.
163
+
164
+ | Prop | Description |
165
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
166
+ | **`getImageSource`** | Returns a promise that resolving to the source of a bitmap version of the icon for use with `Image` component et al. Usage: `const source = await Icon.getImageSource(name, size, color)` |
167
+ | **`getImageSourceSync`** | Same as `getImageSource` but synchronous. Usage: `const source = Icon.getImageSourceSync(name, size, color)` |
168
+
169
+ ## Custom Fonts
170
+
171
+ The best approach is to use our icon generator to create your own icon package.
172
+
173
+ See [CREATE_FONT_PACKAGE.md](./docs/CREATE_FONT_PACKAGE.md) to learn how to create your own font packages.
174
+
175
+ You can also use `createIconSet()` directly in your project. This
176
+ returns your own custom font based on the `glyphMap` where the key is the icon
177
+ name and the value is either a UTF-8 character or it's character code.
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.
180
+
181
+ ```js
182
+ import { createIconSet } from '@react-native-vector-icons/common';
183
+ const glyphMap = { 'icon-name': 1234, test: '∆' };
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
+ })
192
+ ```
193
+
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
195
+ ```json
196
+ {
197
+ "reactNativeVectorIcons": {
198
+ "fontDir": "src/assets/fonts"
199
+ }
200
+ }
201
+ ```
202
+
203
+ ## Animation
204
+
205
+ React Native comes with an amazing animation library called
206
+ [`Animated`](https://reactnative.dev/docs/animated.html). To use it with an
207
+ icon, simply create an animated component with this line: `const AnimatedIcon =
208
+ Animated.createAnimatedComponent(Icon)`. You can also use the higher level
209
+ animation library
210
+ [react-native-animatable](https://github.com/oblador/react-native-animatable).
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
+
229
+ ## Usage Examples
230
+
231
+ ### Icon Explorer
232
+
233
+ Try the `IconExplorer` project in `Examples/IconExplorer` folder, there you can also search for any icon.
234
+
235
+ ![Screenshot of IconExplorer](https://cloud.githubusercontent.com/assets/378279/8903470/a9fe6b46-3458-11e5-901f-98b7b676d0d3.png)
236
+
237
+ ### Basic Example
238
+
239
+ ```js
240
+ import Icon from '@react-native-vector-icons/ionicons';
241
+
242
+ function ExampleView(props) {
243
+ return <Icon name="ios-person" size={30} color="#4F8EF7" />;
244
+ }
245
+ ```
246
+
247
+ ### Inline Icons
248
+
249
+ ```js
250
+ import { Text } from 'react-native';
251
+ import Icon from '@react-native-vector-icons/ionicons';
252
+
253
+ function ExampleView(props) {
254
+ return (
255
+ <Text>
256
+ Lorem <Icon name="ios-book" color="#4F8EF7" /> Ipsum
257
+ </Text>
258
+ );
259
+ }
260
+ ```
261
+
262
+ ## [Changelog](https://github.com/react-native-vector-icons/react-native-vector-icons/releases)
263
+
264
+ ## License
265
+
266
+ This project is licenced under the [MIT License](http://opensource.org/licenses/mit-license.html).
267
+
268
+ Any bundled fonts are copyright to their respective authors and mostly under MIT or [SIL OFL](http://scripts.sil.org/OFL).
@@ -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"
@@ -79,12 +102,21 @@ android {
79
102
  main {
80
103
  if (isNewArchitectureEnabled()) {
81
104
  java.srcDirs += [
82
- 'src/newarch',
83
- // This is needed to build Kotlin project with NewArch enabled
84
- "${project.buildDir}/generated/source/codegen/java"
105
+ "src/newarch",
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
- java.srcDirs += ['src/oldarch']
119
+ java.srcDirs += ["src/oldarch"]
88
120
  }
89
121
  }
90
122
  }
@@ -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,12 +148,12 @@ 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
 
121
155
  doLast {
122
- def files = fonts.toString().trim().split('\n')
156
+ def files = fonts.toString().trim().split('\n').findAll { it }
123
157
  copy {
124
158
  from files
125
159
 
@@ -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