Skip to content

Commit 8a670f7

Browse files
committed
react native 82 file changes, testing required
1 parent 851d5d4 commit 8a670f7

File tree

11 files changed

+122
-90
lines changed

11 files changed

+122
-90
lines changed

example/README.md

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,84 @@ This is a new [**React Native**](https://reactnative.dev) project, bootstrapped
22

33
# Getting Started
44

5-
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
5+
> **Note**: Make sure you have completed the [Set Up Your Environment](https://reactnative.dev/docs/set-up-your-environment) guide before proceeding.
66
7-
## Step 1: Start the Metro Server
7+
## Step 1: Start Metro
88

9-
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
9+
First, you will need to run **Metro**, the JavaScript build tool for React Native.
1010

11-
To start Metro, run the following command from the _root_ of your React Native project:
11+
To start the Metro dev server, run the following command from the root of your React Native project:
1212

13-
```bash
14-
# using npm
13+
```sh
14+
# Using npm
1515
npm start
1616

1717
# OR using Yarn
1818
yarn start
1919
```
2020

21-
## Step 2: Start your Application
21+
## Step 2: Build and run your app
2222

23-
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
23+
With Metro running, open a new terminal window/pane from the root of your React Native project, and use one of the following commands to build and run your Android or iOS app:
2424

25-
### For Android
25+
### Android
2626

27-
```bash
28-
# using npm
27+
```sh
28+
# Using npm
2929
npm run android
3030

3131
# OR using Yarn
3232
yarn android
3333
```
3434

35-
### For iOS
35+
### iOS
3636

37-
```bash
38-
# using npm
37+
For iOS, remember to install CocoaPods dependencies (this only needs to be run on first clone or after updating native deps).
38+
39+
The first time you create a new project, run the Ruby bundler to install CocoaPods itself:
40+
41+
```sh
42+
bundle install
43+
```
44+
45+
Then, and every time you update your native dependencies, run:
46+
47+
```sh
48+
bundle exec pod install
49+
```
50+
51+
For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
52+
53+
```sh
54+
# Using npm
3955
npm run ios
4056

4157
# OR using Yarn
4258
yarn ios
4359
```
4460

45-
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
61+
If everything is set up correctly, you should see your new app running in the Android Emulator, iOS Simulator, or your connected device.
4662

47-
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
63+
This is one way to run your app — you can also build it directly from Android Studio or Xcode.
4864

49-
## Step 3: Modifying your App
65+
## Step 3: Modify your app
5066

51-
Now that you have successfully run the app, let's modify it.
67+
Now that you have successfully run the app, let's make changes!
5268

53-
1. Open `App.tsx` in your text editor of choice and edit some lines.
54-
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
69+
Open `App.tsx` in your text editor of choice and make some changes. When you save, your app will automatically update and reflect these changes — this is powered by [Fast Refresh](https://reactnative.dev/docs/fast-refresh).
5570

56-
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
71+
When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:
5772

58-
## Congratulations! :tada:
73+
- **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Dev Menu**, accessed via <kbd>Ctrl</kbd> + <kbd>M</kbd> (Windows/Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (macOS).
74+
- **iOS**: Press <kbd>R</kbd> in iOS Simulator.
5975

60-
You've successfully run and modified your React Native App. :partying_face:
76+
## Congratulations! :tada:
6177

6278
### Now what?
6379

6480
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65-
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
81+
- If you're curious to learn more about React Native, check out the [docs](https://reactnative.dev/docs/getting-started).
6682

6783
# Troubleshooting
6884

69-
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70-
71-
# Learn More
72-
73-
To learn more about React Native, take a look at the following resources:
74-
75-
- [React Native Website](https://reactnative.dev) - learn more about React Native.
76-
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77-
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78-
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79-
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
85+
If you're having issues getting the above steps to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:allowBackup="false"
1111
android:theme="@style/AppTheme"
12+
android:usesCleartextTraffic="${usesCleartextTraffic}"
1213
android:supportsRtl="true">
1314
<activity
1415
android:name=".MainActivity"

example/android/app/src/main/java/sourcetoad/reactnativesketchcanvas/example/MainApplication.kt

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,20 @@ import com.facebook.react.PackageList
55
import com.facebook.react.ReactApplication
66
import com.facebook.react.ReactHost
77
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
8-
import com.facebook.react.ReactNativeHost
9-
import com.facebook.react.ReactPackage
108
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11-
import com.facebook.react.defaults.DefaultReactNativeHost
129

1310
class MainApplication : Application(), ReactApplication {
1411

15-
override val reactNativeHost: ReactNativeHost =
16-
object : DefaultReactNativeHost(this) {
17-
override fun getPackages(): List<ReactPackage> =
18-
PackageList(this).packages.apply {
19-
// Packages that cannot be autolinked yet can be added manually here, for
20-
// example:
21-
// add(MyReactNativePackage())
22-
}
23-
24-
override fun getJSMainModuleName(): String = "index"
25-
26-
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
27-
28-
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
29-
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
30-
}
31-
32-
override val reactHost: ReactHost
33-
get() = getDefaultReactHost(applicationContext, reactNativeHost)
12+
override val reactHost: ReactHost by lazy {
13+
getDefaultReactHost(
14+
context = applicationContext,
15+
packageList =
16+
PackageList(this).packages.apply {
17+
// Packages that cannot be autolinked yet can be added manually here, for example:
18+
// add(MyReactNativePackage())
19+
},
20+
)
21+
}
3422

3523
override fun onCreate() {
3624
super.onCreate()

example/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
buildscript {
22
ext {
3-
buildToolsVersion = "35.0.0"
3+
buildToolsVersion = "36.0.0"
44
minSdkVersion = 24
5-
compileSdkVersion = 35
6-
targetSdkVersion = 35
5+
compileSdkVersion = 36
6+
targetSdkVersion = 36
77
ndkVersion = "27.1.12297006"
88
kotlinVersion = "2.1.20"
99
}

example/android/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ newArchEnabled=true
3737
# Use this property to enable or disable the Hermes JS engine.
3838
# If set to false, you will be using JSC instead.
3939
hermesEnabled=true
40+
41+
# Use this property to enable edge-to-edge display support.
42+
# This allows your app to draw behind system bars for an immersive UI.
43+
# Note: Only works with ReactActivity and should not be used with custom Activity.
44+
edgeToEdgeEnabled=false

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

example/ios/ReactNativeSketchCanvasExample/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>CADisableMinimumFrameDurationOnPhone</key>
6+
<true/>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>en</string>
79
<key>CFBundleDisplayName</key>

example/package.json

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,36 @@
55
"scripts": {
66
"android": "react-native run-android",
77
"ios": "react-native run-ios",
8-
"start": "react-native start"
8+
"start": "react-native start",
9+
"test": "jest"
910
},
1011
"dependencies": {
11-
"react": "19.1.0",
12-
"react-native": "0.80.0"
12+
"react": "19.1.1",
13+
"react-native": "0.82.0",
14+
"@react-native/new-app-screen": "0.82.0",
15+
"react-native-safe-area-context": "^5.5.2"
1316
},
1417
"devDependencies": {
1518
"@babel/core": "^7.25.2",
1619
"@babel/preset-env": "^7.25.3",
1720
"@babel/runtime": "^7.25.0",
18-
"@react-native-community/cli": "19.0.0",
19-
"@react-native-community/cli-platform-android": "19.0.0",
20-
"@react-native-community/cli-platform-ios": "19.0.0",
21-
"@react-native/babel-preset": "0.80.0",
22-
"@react-native/metro-config": "0.80.0",
23-
"@react-native/typescript-config": "0.80.0",
24-
"typescript": "5.0.4"
21+
"@react-native-community/cli": "20.0.0",
22+
"@react-native-community/cli-platform-android": "20.0.0",
23+
"@react-native-community/cli-platform-ios": "20.0.0",
24+
"@react-native/babel-preset": "0.82.0",
25+
"@react-native/eslint-config": "0.82.0",
26+
"@react-native/metro-config": "0.82.0",
27+
"@react-native/typescript-config": "0.82.0",
28+
"@types/jest": "^29.5.13",
29+
"@types/react": "^19.1.1",
30+
"@types/react-test-renderer": "^19.1.0",
31+
"eslint": "^8.19.0",
32+
"jest": "^29.6.3",
33+
"prettier": "2.8.8",
34+
"react-test-renderer": "19.1.1",
35+
"typescript": "^5.8.3"
2536
},
2637
"engines": {
27-
"node": ">=18"
38+
"node": ">=20"
2839
}
2940
}

example/src/App.tsx

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
/* eslint-disable @typescript-eslint/no-unused-vars */
2-
import React, { Component } from 'react';
1+
/**
2+
* @format
3+
*/
4+
5+
import React from 'react';
36
import {
47
AppRegistry,
5-
StyleSheet,
68
Text,
7-
View,
89
Alert,
910
TouchableOpacity,
1011
ScrollView,
1112
Platform,
12-
SafeAreaView,
13+
StatusBar,
14+
StyleSheet,
15+
useColorScheme,
16+
View,
1317
TextInput,
1418
} from 'react-native';
19+
import {
20+
SafeAreaProvider,
21+
useSafeAreaInsets,
22+
} from 'react-native-safe-area-context';
1523

1624
import RNSketchCanvas, {
1725
SketchCanvas,
@@ -28,7 +36,7 @@ type ExampleState = {
2836
scrollEnabled: boolean;
2937
};
3038

31-
export default class example extends Component<any, ExampleState> {
39+
class ExampleApp extends React.Component<any, ExampleState> {
3240
constructor(props: any) {
3341
super(props);
3442

@@ -70,7 +78,7 @@ export default class example extends Component<any, ExampleState> {
7078

7179
render() {
7280
return (
73-
<SafeAreaView style={styles.container}>
81+
<View style={styles.container}>
7482
{this.state.example === 0 && (
7583
<View
7684
style={{
@@ -1056,11 +1064,25 @@ export default class example extends Component<any, ExampleState> {
10561064
{this.state.example === 9 && (
10571065
<Example9 onClose={() => this.setState({ example: 0 })} />
10581066
)}
1059-
</SafeAreaView>
1067+
</View>
10601068
);
10611069
}
10621070
}
10631071

1072+
// Wrapper component to use hooks and provide SafeAreaProvider
1073+
function AppWrapper() {
1074+
const isDarkMode = useColorScheme() === 'dark';
1075+
1076+
return (
1077+
<SafeAreaProvider>
1078+
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
1079+
<ExampleApp />
1080+
</SafeAreaProvider>
1081+
);
1082+
}
1083+
1084+
export default AppWrapper;
1085+
10641086
const styles = StyleSheet.create({
10651087
container: {
10661088
flex: 1,
@@ -1126,4 +1148,4 @@ const styles = StyleSheet.create({
11261148
},
11271149
});
11281150

1129-
AppRegistry.registerComponent('example', () => example);
1151+
AppRegistry.registerComponent('example', () => AppWrapper);

0 commit comments

Comments
 (0)