Skip to content

Commit

Permalink
React native UI and SDK packages (#1174)
Browse files Browse the repository at this point in the history
* feat: init rn ui package

* chore: link rn packages to reflect changes in example app

* chore: remove irrelevant patch

* chore: additional setup and assets

* chore: add hooks and helper fns

* feat: label and loader components

* feat: notification item component

* feat: add uireactnative to example app

* chore: add uirn as dependency in app

* chore: update podfile

* style: beautify example app

* style: beautify example app

* chore: support class based sdk

* chore: reset rn sdk version

* chore: merge branch 'main'

* fix: build error

* fix: build error

* refactor: improve log messages
  • Loading branch information
kalashshah authored Mar 22, 2024
1 parent fefdf91 commit 395ded2
Show file tree
Hide file tree
Showing 71 changed files with 3,860 additions and 646 deletions.
5 changes: 5 additions & 0 deletions packages/examples/sdk-react-native/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ yarn-error.log

# testing
/coverage

# Expo
.expo
dist/
web-build/
5 changes: 5 additions & 0 deletions packages/examples/sdk-react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
//
// Added by install-expo-modules
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

<uses-permission android:name="android.permission.INTERNET" />

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>

<application
android:name=".MainApplication"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.rnsdktest;
import expo.modules.ReactActivityDelegateWrapper;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
Expand All @@ -23,10 +24,10 @@ protected String getMainComponentName() {
*/
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new DefaultReactActivityDelegate(
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
this,
getMainComponentName(),
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
DefaultNewArchitectureEntryPoint.getFabricEnabled());
DefaultNewArchitectureEntryPoint.getFabricEnabled()));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.rnsdktest;
import android.content.res.Configuration;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;

import android.app.Application;
import com.facebook.react.PackageList;
Expand All @@ -13,7 +16,7 @@
public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
new DefaultReactNativeHost(this) {
new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
Expand All @@ -30,7 +33,7 @@ protected List<ReactPackage> getPackages() {

@Override
protected String getJSMainModuleName() {
return "index";
return ".expo/.virtual-metro-entry";
}

@Override
Expand All @@ -42,7 +45,7 @@ protected boolean isNewArchEnabled() {
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};
});

@Override
public ReactNativeHost getReactNativeHost() {
Expand All @@ -58,5 +61,12 @@ public void onCreate() {
DefaultNewArchitectureEntryPoint.load();
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
}
3 changes: 3 additions & 0 deletions packages/examples/sdk-react-native/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ rootProject.name = 'rnsdktest'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
2 changes: 1 addition & 1 deletion packages/examples/sdk-react-native/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
presets: ['babel-preset-expo'],
};
11 changes: 10 additions & 1 deletion packages/examples/sdk-react-native/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip

platform :ios, min_ios_version_supported
platform :ios, '13.0'
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
Expand All @@ -26,6 +27,14 @@ if linkage != nil
end

target 'rnsdktest' do
use_expo_modules!
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
config = use_native_modules!

# Flags change depending on the env values.
Expand Down
Loading

0 comments on commit 395ded2

Please sign in to comment.