Skip to content

Instantly share code, notes, and snippets.

@janicduplessis
Created August 2, 2019 06:09
Show Gist options
  • Save janicduplessis/c87b074ba4824ed30edb31a4a2764292 to your computer and use it in GitHub Desktop.
Save janicduplessis/c87b074ba4824ed30edb31a4a2764292 to your computer and use it in GitHub Desktop.
package com.th3rdwave;
import com.aakashns.reactnativedialogs.modules.DialogAndroid;
import com.facebook.react.TurboReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.modules.statusbar.StatusBarModule;
import com.facebook.react.uimanager.ViewManager;
import com.gettipsi.stripe.CustomCardInputReactManager;
import com.gettipsi.stripe.StripeModule;
import com.github.reactnativecommunity.location.RNLocationModule;
import com.imagepicker.ImagePickerModule;
import com.learnium.RNDeviceInfo.RNDeviceModule;
import com.reactnativecommunity.asyncstorage.AsyncStorageModule;
import com.reactnativecommunity.netinfo.NetInfoModule;
import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager;
import com.swmansion.gesturehandler.react.RNGestureHandlerModule;
import com.swmansion.gesturehandler.react.RNGestureHandlerRootViewManager;
import com.swmansion.reanimated.ReanimatedModule;
import com.th3rdwave.views.GooglePayButtonViewManager;
import org.devio.rn.splashscreen.SplashScreenModule;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.branch.rnbranch.RNBranchModule;
import io.sentry.RNSentryModule;
public class TWTurboReactPackage extends TurboReactPackage {
@Override
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
switch (name) {
case ImagePickerModule.NAME:
return new ImagePickerModule(reactContext);
case RNLocationModule.NAME:
return new RNLocationModule(reactContext);
case RNDeviceModule.NAME:
return new RNDeviceModule(reactContext, false);
case StripeModule.NAME:
return new StripeModule(reactContext);
case DialogAndroid.NAME:
return new DialogAndroid(reactContext);
case RNBranchModule.NAME:
return new RNBranchModule(reactContext);
case ReanimatedModule.NAME:
return new ReanimatedModule(reactContext);
case NetInfoModule.NAME:
return new NetInfoModule(reactContext);
case StatusBarModule.NAME:
return new StatusBarModule(reactContext);
case AsyncStorageModule.NAME:
return new AsyncStorageModule(reactContext);
case RNSentryModule.NAME:
return new RNSentryModule(reactContext);
case RNGestureHandlerModule.MODULE_NAME:
return new RNGestureHandlerModule(reactContext);
case SplashScreenModule.NAME:
return new SplashScreenModule(reactContext);
default:
throw new IllegalArgumentException(
"In MainApplication, could not find Native module for " + name);
}
}
@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
Class<? extends NativeModule>[] moduleList =
new Class[] {
ImagePickerModule.class,
RNLocationModule.class,
RNDeviceModule.class,
StripeModule.class,
DialogAndroid.class,
RNBranchModule.class,
ReanimatedModule.class,
NetInfoModule.class,
StatusBarModule.class,
AsyncStorageModule.class,
RNSentryModule.class,
RNGestureHandlerModule.class,
SplashScreenModule.class,
};
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
for (Class<? extends NativeModule> moduleClass : moduleList) {
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);
reactModuleInfoMap.put(
reactModule.name(),
new ReactModuleInfo(
reactModule.name(),
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
false));
}
return new ReactModuleInfoProvider() {
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
return reactModuleInfoMap;
}
};
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Arrays.asList(
new GooglePayButtonViewManager(),
new CustomCardInputReactManager(),
new RNGestureHandlerRootViewManager(),
new RNGestureHandlerButtonViewManager());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment