|
1 | | -exports[`Android/Java creates a TemplateManager.java 1`] = ` |
| 1 | +exports[`Android/Java: Combined creates a TemplateManager.java 1`] = ` |
2 | 2 | "// Created by react-native-create-bridge |
3 | 3 |
|
4 | 4 | package com.testapp.testmodule; |
@@ -29,14 +29,14 @@ public class TestModuleManager extends SimpleViewManager<View> { |
29 | 29 |
|
30 | 30 | @ReactProp(name = \"exampleProp\") |
31 | 31 | public void setExampleProp(View view, String prop) { |
32 | | - // Set properties from React onto your native component |
| 32 | + // Set properties from React onto your native component via a setter method |
33 | 33 | // https://facebook.github.io/react-native/docs/native-components-android.html#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation |
34 | 34 | } |
35 | 35 | } |
36 | 36 | " |
37 | 37 | `; |
38 | 38 |
|
39 | | -exports[`Android/Java creates a TemplateModule.java 1`] = ` |
| 39 | +exports[`Android/Java: Combined creates a TemplateModule.java 1`] = ` |
40 | 40 | "// Created by react-native-create-bridge |
41 | 41 |
|
42 | 42 | package com.testapp.testmodule; |
@@ -96,7 +96,7 @@ public class TestModuleModule extends ReactContextBaseJavaModule { |
96 | 96 | " |
97 | 97 | `; |
98 | 98 |
|
99 | | -exports[`Android/Java creates a TemplatePackage.java 1`] = ` |
| 99 | +exports[`Android/Java: Combined creates a TemplatePackage.java 1`] = ` |
100 | 100 | "// Created by react-native-create-bridge |
101 | 101 |
|
102 | 102 | package com.testapp.testmodule; |
@@ -136,3 +136,175 @@ public class TestModulePackage implements ReactPackage { |
136 | 136 | } |
137 | 137 | " |
138 | 138 | `; |
| 139 | +
|
| 140 | +exports[`Android/Java: Native Modules creates a TemplateModule.java 1`] = ` |
| 141 | +"// Created by react-native-create-bridge |
| 142 | +
|
| 143 | +package com.testapp.testmodule; |
| 144 | +
|
| 145 | +import android.support.annotation.Nullable; |
| 146 | +
|
| 147 | +import com.facebook.react.bridge.ReactApplicationContext; |
| 148 | +import com.facebook.react.bridge.ReactContextBaseJavaModule; |
| 149 | +import com.facebook.react.bridge.ReactMethod; |
| 150 | +import com.facebook.react.bridge.WritableMap; |
| 151 | +import com.facebook.react.modules.core.DeviceEventManagerModule; |
| 152 | +
|
| 153 | +import java.util.HashMap; |
| 154 | +import java.util.Map; |
| 155 | +
|
| 156 | +public class TestModuleModule extends ReactContextBaseJavaModule { |
| 157 | + public static final String REACT_CLASS = \"TestModule\"; |
| 158 | + private static ReactApplicationContext reactContext = null; |
| 159 | +
|
| 160 | + public TestModuleModule(ReactApplicationContext context) { |
| 161 | + // Pass in the context to the constructor and save it so you can emit events |
| 162 | + // https://facebook.github.io/react-native/docs/native-modules-android.html#the-toast-module |
| 163 | + super(context); |
| 164 | +
|
| 165 | + reactContext = context; |
| 166 | + } |
| 167 | +
|
| 168 | + @Override |
| 169 | + public String getName() { |
| 170 | + // Tell React the name of the module |
| 171 | + // https://facebook.github.io/react-native/docs/native-modules-android.html#the-toast-module |
| 172 | + return REACT_CLASS; |
| 173 | + } |
| 174 | +
|
| 175 | + @Override |
| 176 | + public Map<String, Object> getConstants() { |
| 177 | + // Export any constants to be used in your native module |
| 178 | + // https://facebook.github.io/react-native/docs/native-modules-android.html#the-toast-module |
| 179 | + final Map<String, Object> constants = new HashMap<>(); |
| 180 | + constants.put(\"EXAMPLE_CONSTANT\", \"example\"); |
| 181 | +
|
| 182 | + return constants; |
| 183 | + } |
| 184 | +
|
| 185 | + @ReactMethod |
| 186 | + public void exampleMethod () { |
| 187 | + // An example native method that you will expose to React |
| 188 | + // https://facebook.github.io/react-native/docs/native-modules-android.html#the-toast-module |
| 189 | + } |
| 190 | +
|
| 191 | + private static void emitDeviceEvent(String eventName, @Nullable WritableMap eventData) { |
| 192 | + // A method for emitting from the native side to JS |
| 193 | + // https://facebook.github.io/react-native/docs/native-modules-android.html#sending-events-to-javascript |
| 194 | + reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, eventData); |
| 195 | + } |
| 196 | +} |
| 197 | +" |
| 198 | +`; |
| 199 | +
|
| 200 | +exports[`Android/Java: Native Modules creates a TemplatePackage.java 1`] = ` |
| 201 | +"// Created by react-native-create-bridge |
| 202 | +
|
| 203 | +package com.testapp.testmodule; |
| 204 | +
|
| 205 | +import com.facebook.react.ReactPackage; |
| 206 | +import com.facebook.react.bridge.JavaScriptModule; |
| 207 | +import com.facebook.react.bridge.NativeModule; |
| 208 | +import com.facebook.react.bridge.ReactApplicationContext; |
| 209 | +import com.facebook.react.uimanager.ViewManager; |
| 210 | +
|
| 211 | +import java.util.Arrays; |
| 212 | +import java.util.Collections; |
| 213 | +import java.util.List; |
| 214 | +
|
| 215 | +public class TestModulePackage implements ReactPackage { |
| 216 | + @Override |
| 217 | + public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { |
| 218 | + // Register your native module |
| 219 | + // https://facebook.github.io/react-native/docs/native-modules-android.html#register-the-module |
| 220 | + return Arrays.<NativeModule>asList( |
| 221 | + new TestModuleModule(reactContext) |
| 222 | + ); |
| 223 | + } |
| 224 | +
|
| 225 | + @Override |
| 226 | + public List<Class<? extends JavaScriptModule>> createJSModules() { |
| 227 | + return Collections.emptyList(); |
| 228 | + } |
| 229 | +
|
| 230 | + public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { |
| 231 | + return Collections.emptyList(); |
| 232 | + } |
| 233 | +} |
| 234 | +" |
| 235 | +`; |
| 236 | +
|
| 237 | +exports[`Android/Java: UI Components creates a TemplateManager.java 1`] = ` |
| 238 | +"// Created by react-native-create-bridge |
| 239 | +
|
| 240 | +package com.testapp.testmodule; |
| 241 | +
|
| 242 | +import android.view.View; |
| 243 | +
|
| 244 | +import com.facebook.react.uimanager.SimpleViewManager; |
| 245 | +import com.facebook.react.uimanager.ThemedReactContext; |
| 246 | +
|
| 247 | +import com.facebook.react.uimanager.annotations.ReactProp; |
| 248 | +
|
| 249 | +public class TestModuleManager extends SimpleViewManager<View> { |
| 250 | + public static final String REACT_CLASS = \"TestModule\"; |
| 251 | +
|
| 252 | + @Override |
| 253 | + public String getName() { |
| 254 | + // Tell React the name of the module |
| 255 | + // https://facebook.github.io/react-native/docs/native-components-android.html#1-create-the-viewmanager-subclass |
| 256 | + return REACT_CLASS; |
| 257 | + } |
| 258 | +
|
| 259 | + @Override |
| 260 | + public View createViewInstance(ThemedReactContext context){ |
| 261 | + // Create a view here |
| 262 | + // https://facebook.github.io/react-native/docs/native-components-android.html#2-implement-method-createviewinstance |
| 263 | + return new View(context); |
| 264 | + } |
| 265 | +
|
| 266 | + @ReactProp(name = \"exampleProp\") |
| 267 | + public void setExampleProp(View view, String prop) { |
| 268 | + // Set properties from React onto your native component via a setter method |
| 269 | + // https://facebook.github.io/react-native/docs/native-components-android.html#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation |
| 270 | + } |
| 271 | +} |
| 272 | +" |
| 273 | +`; |
| 274 | +
|
| 275 | +exports[`Android/Java: UI Components creates a TemplatePackage.java 1`] = ` |
| 276 | +"// Created by react-native-create-bridge |
| 277 | +
|
| 278 | +package com.testapp.testmodule; |
| 279 | +
|
| 280 | +import com.facebook.react.ReactPackage; |
| 281 | +import com.facebook.react.bridge.JavaScriptModule; |
| 282 | +import com.facebook.react.bridge.NativeModule; |
| 283 | +import com.facebook.react.bridge.ReactApplicationContext; |
| 284 | +import com.facebook.react.uimanager.ViewManager; |
| 285 | +
|
| 286 | +import java.util.Arrays; |
| 287 | +import java.util.Collections; |
| 288 | +import java.util.List; |
| 289 | +
|
| 290 | +public class TestModulePackage implements ReactPackage { |
| 291 | + @Override |
| 292 | + public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { |
| 293 | + return Collections.emptyList(); |
| 294 | + } |
| 295 | +
|
| 296 | + @Override |
| 297 | + public List<Class<? extends JavaScriptModule>> createJSModules() { |
| 298 | + return Collections.emptyList(); |
| 299 | + } |
| 300 | +
|
| 301 | + public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { |
| 302 | + // Register your native component\'s view manager |
| 303 | + // https://facebook.github.io/react-native/docs/native-components-android.html#4-register-the-viewmanager |
| 304 | + return Arrays.<ViewManager>asList( |
| 305 | + new TestModuleManager() |
| 306 | + ); |
| 307 | + } |
| 308 | +} |
| 309 | +" |
| 310 | +`; |
0 commit comments