Skip to content

Commit 447bde6

Browse files
Merge pull request #45 from douglasjunior/new-arch
Add new arch
2 parents b25b5bb + 9cc4605 commit 447bde6

58 files changed

Lines changed: 7929 additions & 8387 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ node_modules/
99
__tests__/
1010
screenshots/
1111
Sample/
12-
/src/
1312
scripts/
1413
android/build/
1514
android/.idea/

.prettierrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
arrowParens: 'avoid',
3-
bracketSameLine: true,
4-
bracketSpacing: false,
53
singleQuote: true,
64
trailingComma: 'all',
75
};

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ npm i -S react-native-pdf-renderer
3939

4040
Go to the folder **your-project/ios** and run `pod install`, and you're done.
4141

42-
### New Architecture
43-
44-
See https://github.com/douglasjunior/react-native-pdf-renderer/issues/31#issuecomment-2564782735
45-
4642
### Android specific (optional)
4743

4844
Customize the [`androidx.recyclerview:recyclerview`](https://developer.android.com/jetpack/androidx/releases/recyclerview) version by setting `ext` in your `android/build.gradle` file.
@@ -98,7 +94,7 @@ For more details, see the [Sample Project](https://github.com/douglasjunior/reac
9894
|distanceBetweenPages|`number`|`16`|Distance in `DPI` between pages.|
9995
|maxZoom|`number`|`5`|Max zoom scale.|
10096
|maxPageResolution|`number`|`2048`|(Android only) Max page resolution (width/height) in pixels when zooming. Defined to prevent Android crash when zooming too much: https://github.com/douglasjunior/react-native-pdf-renderer/issues/26 . |
101-
|singlePage|`boolean`|`false`|(Experimental) Renders only the first page without scroll. (useful for display thumbnail)|
97+
|singlePage|`boolean`|`false`|Renders only the first page without scroll. (useful for display thumbnail)|
10298
|onPageChange|`(current: number, total: number) => void`||Invoked on pages scroll.|
10399
|style|`StyleProp<ViewStyle>`||Styles to be applied to the native [view](https://reactnative.dev/docs/view-style-props).|
104100

ReactNativePdfRenderer.podspec

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ require 'json'
33
packageJson = JSON.parse(File.read('package.json'))
44
version = packageJson["version"]
55
repository = packageJson["repository"]["url"]
6+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
67

78
Pod::Spec.new do |s|
89
s.name = "ReactNativePdfRenderer"
@@ -15,7 +16,13 @@ Pod::Spec.new do |s|
1516
s.source = { :git => repository, :tag => version }
1617
s.platform = :ios, "11.0"
1718
s.preserve_paths = 'README.md', 'package.json', '*.js'
18-
s.source_files = 'ios/ReactNativePdfRendererLibrary/**/*.{h,m}'
19+
s.source_files = 'ios/ReactNativePdfRendererLibrary/**/*.{h,m,mm,swift}'
1920

20-
s.dependency 'React-Core'
21+
s.frameworks = 'PDFKit'
22+
23+
if fabric_enabled
24+
install_modules_dependencies(s)
25+
else
26+
s.dependency "React-Core"
27+
end
2128
end

Sample/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

Sample/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ DerivedData
2121
*.ipa
2222
*.xcuserstate
2323
**/.xcode.env.local
24+
*.xcworkspace
2425

2526
# Android/IntelliJ
2627
#
@@ -33,6 +34,7 @@ local.properties
3334
.cxx/
3435
*.keystore
3536
!debug.keystore
37+
.kotlin/
3638

3739
# node.js
3840
#

Sample/.prettierrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
arrowParens: 'avoid',
3-
bracketSameLine: true,
4-
bracketSpacing: false,
53
singleQuote: true,
64
trailingComma: 'all',
75
};

Sample/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const PDF_URL =
88
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a11/a11final-fltpln.pdf'; // 618 pages
99
// const PDF_URL = 'https://www.africau.edu/images/default/sample.pdf'; // 2 pages
1010

11-
function App(): JSX.Element {
11+
function App() {
1212
const [totalPages, setTotalPages] = useState(0);
1313
const [currentPage, setCurrentPage] = useState(0);
1414
const [downloading, setDownloading] = useState(false);

Sample/Gemfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby ">= 2.6.10"
5+
6+
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
7+
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8+
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'
10+
gem 'concurrent-ruby', '< 1.3.4'
11+
12+
# Ruby 3.4.0 has removed some libraries from the standard library.
13+
gem 'bigdecimal'
14+
gem 'logger'
15+
gem 'benchmark'
16+
gem 'mutex_m'

Sample/README.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,76 @@ 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.
62+
63+
This is one way to run your app — you can also build it directly from Android Studio or Xcode.
4664

47-
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
65+
## Step 3: Modify your app
4866

49-
## Step 3: Modifying your App
67+
Now that you have successfully run the app, let's make changes!
5068

51-
Now that you have successfully run the app, let's modify it.
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).
5270

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!
71+
When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:
5572

56-
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
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.
5775

5876
## Congratulations! :tada:
5977

@@ -62,11 +80,11 @@ You've successfully run and modified your React Native App. :partying_face:
6280
### Now what?
6381

6482
- 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).
83+
- If you're curious to learn more about React Native, check out the [docs](https://reactnative.dev/docs/getting-started).
6684

6785
# Troubleshooting
6886

69-
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
87+
If you're having issues getting the above steps to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
7088

7189
# Learn More
7290

0 commit comments

Comments
 (0)