Skip to content

Commit 12d212c

Browse files
authored
Improve Documentation for RNN Installation (#8042)
* Converted a MainActivity and MainApplication to kotlin. Refined installation documentation * Added swift documentation * Fixes after PR
1 parent ad65cf9 commit 12d212c

File tree

8 files changed

+169
-285
lines changed

8 files changed

+169
-285
lines changed

lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.facebook.react.ReactApplication;
66
import com.facebook.react.ReactNativeHost;
7+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
78
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
89
import com.facebook.soloader.SoLoader;
910
import com.reactnativenavigation.react.ReactGateway;
@@ -40,6 +41,9 @@ public void onCreate() {
4041
} catch (IOException e) {
4142
throw new RuntimeException(e);
4243
}
44+
45+
DefaultNewArchitectureEntryPoint.load();
46+
4347
reactGateway = createReactGateway();
4448
}
4549

playground/android/app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: "com.android.application"
22
apply plugin: "com.facebook.react"
3+
apply plugin: 'org.jetbrains.kotlin.android'
34

45
react {
56
root = file("../../../")
@@ -48,6 +49,9 @@ android {
4849
signingConfig signingConfigs.release
4950
}
5051
}
52+
kotlinOptions {
53+
jvmTarget = '17'
54+
}
5155
}
5256

5357
dependencies {
@@ -59,6 +63,7 @@ dependencies {
5963
implementation project(':react-native-fast-image')
6064

6165
implementation project(':react-native-navigation')
66+
implementation 'androidx.core:core-ktx:1.16.0'
6267

6368
androidTestImplementation('com.wix:detox:+') { transitive = true }
6469
androidTestImplementation 'junit:junit:4.12'

playground/android/app/src/main/java/com/reactnativenavigation/playground/MainActivity.java

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.reactnativenavigation.playground
2+
3+
import android.os.Bundle
4+
import android.widget.ImageView
5+
import com.reactnativenavigation.NavigationActivity
6+
7+
class MainActivity : NavigationActivity() {
8+
override fun onCreate(savedInstanceState: Bundle?) {
9+
super.onCreate(savedInstanceState)
10+
setSplashLayout()
11+
}
12+
13+
private fun setSplashLayout() {
14+
val img = ImageView(this)
15+
img.setImageDrawable(getDrawable(R.drawable.ic_android))
16+
setContentView(img)
17+
}
18+
}

playground/android/app/src/main/java/com/reactnativenavigation/playground/MainApplication.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.reactnativenavigation.playground
2+
3+
import com.facebook.react.PackageList
4+
import com.facebook.react.ReactHost
5+
import com.facebook.react.ReactNativeHost
6+
import com.facebook.react.ReactPackage
7+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
8+
import com.reactnativenavigation.NavigationApplication
9+
import com.reactnativenavigation.RNNToggles
10+
import com.reactnativenavigation.react.NavigationPackage
11+
import com.reactnativenavigation.react.NavigationReactNativeHost
12+
13+
class MainApplication : NavigationApplication(mapOf(
14+
RNNToggles.TOP_BAR_COLOR_ANIMATION__PUSH to true,
15+
RNNToggles.TOP_BAR_COLOR_ANIMATION__TABS to true
16+
)) {
17+
override val reactNativeHost: ReactNativeHost = object : NavigationReactNativeHost(this) {
18+
override fun getJSMainModuleName(): String {
19+
return "index"
20+
}
21+
22+
override fun getUseDeveloperSupport(): Boolean {
23+
return BuildConfig.DEBUG
24+
}
25+
26+
public override fun getPackages(): List<ReactPackage> {
27+
val packages = PackageList(this).packages
28+
packages.add(NavigationPackage())
29+
return packages
30+
}
31+
32+
override val isHermesEnabled: Boolean
33+
get() = BuildConfig.IS_HERMES_ENABLED
34+
35+
override val isNewArchEnabled: Boolean
36+
get() = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
37+
}
38+
39+
override fun onCreate() {
40+
super.onCreate()
41+
registerExternalComponent("RNNCustomComponent", FragmentCreator())
42+
}
43+
44+
override val reactHost: ReactHost
45+
get() = getDefaultReactHost(this, reactNativeHost)
46+
}

playground/android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ allprojects {
3333
flatDir {
3434
dirs "$rootProject.projectDir/libs"
3535
}
36+
mavenCentral()
3637
}
3738
}
3839

0 commit comments

Comments
 (0)