Skip to content

Commit ecb77e6

Browse files
troZeePiotr Trocki
andauthored
chore: remove fabric example and migrate to 72 (#730)
* chore: remove fabric example and add old arch support for the example * Apply fixes * use JS stack instead of the native one * change to false * migrate to 72 * fix lint * change maestro version * change android workflow * Revert "change android workflow" This reverts commit d42ccec. * upload artifacts * record a video * just a basic example * turn off new architecture * update podflie.lock --------- Co-authored-by: Piotr Trocki <[email protected]>
1 parent 25aa3fc commit ecb77e6

File tree

155 files changed

+3473
-13864
lines changed

Some content is hidden

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

155 files changed

+3473
-13864
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
globals: {
55
expect: true,
66
element: true,

.github/workflows/android.yml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,62 @@ jobs:
5555
~/.gradle/wrapper
5656
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
5757

58+
- name: AVD cache
59+
uses: actions/cache@v3
60+
id: avd-cache
61+
with:
62+
path: |
63+
~/.android/avd/*
64+
~/.android/adb*
65+
key: avd-cache
66+
5867
- name: Install Maestro CLI
59-
run: export MAESTRO_VERSION=1.21.3; curl -Ls "https://get.maestro.mobile.dev" | bash
68+
run: export MAESTRO_VERSION=1.31.0; curl -Ls "https://get.maestro.mobile.dev" | bash
6069

6170
- name: Add Maestro to path
6271
run: echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
6372

73+
- name: create AVD and generate snapshot for caching
74+
if: steps.avd-cache.outputs.cache-hit != 'true'
75+
uses: reactivecircus/android-emulator-runner@v2
76+
with:
77+
api-level: 29
78+
force-avd-creation: false
79+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
80+
disable-animations: false
81+
cores: 2
82+
ram-size: 4096M
83+
profile: Nexus 6
84+
script: echo "Generated AVD snapshot for caching."
85+
6486
- name: Run Android Emulator and app
6587
uses: reactivecircus/android-emulator-runner@v2
6688
with:
6789
api-level: 29
68-
arch: x86_64
69-
target: google_apis
7090
force-avd-creation: false
7191
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
72-
disable-animations: true
92+
disable-animations: false
93+
cores: 2
94+
ram-size: 4096M
95+
profile: Nexus 6
7396
script: |
7497
yarn run-example-android
7598
yarn test:e2e:android
99+
100+
- name: Upload report
101+
if: always()
102+
uses: actions/upload-artifact@v3
103+
with:
104+
name: E2E Report
105+
path: |
106+
${{ github.workspace }}/*.mp4
107+
${{ github.workspace }}/*.png
108+
${{ github.workspace }}/report*.xml
109+
~/.maestro/tests/**/*
110+
111+
- name: Store tests result
112+
uses: actions/upload-artifact@v3
113+
with:
114+
name: e2e_android_report
115+
path: |
116+
report.xml

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ test-butler-app.apk
6464
example/vendor
6565

6666
#Example
67-
fabricexample/ios/Pods
68-
fabricexample/vendor
69-
fabricexample/android/app/.cxx
67+
example/ios/Pods
68+
example/vendor
7069
.lefthookrc
7170
lefthook.yml
7271

7372

7473
# Temporary files created by Metro to check the health of the file watcher
7574
.metro-health-check*
75+
76+
# testing
77+
/coverage
7678
.cxx

README.md

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This component allows the user to swipe left and right through pages of data. Un
2020
## Versions
2121

2222
| 4.x | 5.x and above |
23-
| ---------- | ----------- |
23+
| ---------- | ------------- |
2424
| iOS | iOS support |
2525
| ViewPager1 | ViewPager2 |
2626

@@ -34,29 +34,6 @@ In version **6.x** support for `transitionStyle` property has been dropped. More
3434

3535
`yarn add react-native-pager-view`
3636

37-
## New architecture setup (Fabric)
38-
39-
This library supports new architecture! We have two example folders one for each architecture. If you are using this library in your own project there some extra steps needed.
40-
### iOS
41-
Install pods with this flag inside `ios` folder:
42-
```sh
43-
RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
44-
```
45-
(Inside of `fabricexample` the `RCT_NEW_ARCH_ENABLED` is already set to true by default inside `Podfile`)
46-
47-
### Android
48-
Set `newArchEnabled` to `true` inside `android/gradle.properties` (this flag is already set to true in `fabricexample`) and then run:
49-
```sh
50-
yarn android
51-
```
52-
53-
If you have issues with running android build you can try to generate codegen before the build using this command:
54-
55-
```sh
56-
cd android && ./gradlew generateCodegenArtifactsFromSchema
57-
```
58-
59-
6037
## Linking
6138

6239
### >= 0.60
@@ -172,8 +149,8 @@ For advanced usage please take a look into our [example project](https://github.
172149
| `orientation: Orientation` | Set `horizontal` or `vertical` scrolling orientation (it does **not** work dynamically) | both |
173150
| `overScrollMode: OverScollMode` | Used to override default value of overScroll mode. Can be `auto`, `always` or `never`. Defaults to `auto` | Android |
174151
| `offscreenPageLimit: number` | Set the number of pages that should be retained to either side of the currently visible page(s). Pages beyond this limit will be recreated from the adapter when needed. Defaults to RecyclerView's caching strategy. The given value must either be larger than 0. | Android |
175-
| `overdrag: boolean` | Allows for overscrolling after reaching the end or very beginning or pages. Defaults to `false` | iOS |
176-
| `layoutDirection: ('ltr' / 'rtl' / 'locale')` | Specifies layout direction. Use `ltr` or `rtl` to set explicitly or `locale` to deduce from the default language script of a locale. Defaults to `locale` | both |
152+
| `overdrag: boolean` | Allows for overscrolling after reaching the end or very beginning or pages. Defaults to `false` | iOS |
153+
| `layoutDirection: ('ltr' / 'rtl' / 'locale')` | Specifies layout direction. Use `ltr` or `rtl` to set explicitly or `locale` to deduce from the default language script of a locale. Defaults to `locale` | both |
177154

178155
| Method | Description | Platform |
179156
| ------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------: |
@@ -205,7 +182,7 @@ requestAnimationFrame(() => refPagerView.current?.setPage(index));
205182

206183
### iOS
207184

208-
| horizontal | vertical |
185+
| horizontal | vertical |
209186
| :------------------------------------------------------------------: | :--------------------------------------------------------------------: |
210187
| <img src="img/ios-viewpager-scroll.gif" alt="ViewPager" width="325"> | <img src="img/ios-viewpager-vertical.gif" alt="ViewPager" width="325"> |
211188

@@ -220,37 +197,38 @@ To attach reanimated handler with `onPageScroll` follow the below steps.
220197
```jsx
221198
// 1. Define the handler
222199
function usePageScrollHandler(handlers, dependencies) {
223-
const {context, doDependenciesDiffer} = useHandler(handlers, dependencies);
200+
const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);
224201
const subscribeForEvents = ['onPageScroll'];
225202

226203
return useEvent(
227-
event => {
204+
(event) => {
228205
'worklet';
229-
const {onPageScroll} = handlers;
206+
const { onPageScroll } = handlers;
230207
if (onPageScroll && event.eventName.endsWith('onPageScroll')) {
231208
onPageScroll(event, context);
232209
}
233210
},
234211
subscribeForEvents,
235-
doDependenciesDiffer,
212+
doDependenciesDiffer
236213
);
237214
}
238-
215+
239216
// 2. Attach the event handler
240-
import PagerView from "react-native-pager-view";
241-
import Animated from "react-native-reanimated";
217+
import PagerView from 'react-native-pager-view';
218+
import Animated from 'react-native-reanimated';
242219
const AnimatedPagerView = Animated.createAnimatedComponent(PagerView);
243220

244221
const pageScrollHandler = usePageScrollHandler({
245-
onPageScroll: e => {
246-
'worklet';
247-
offset.value = e.offset;
248-
console.log(e.offset, e.position);
249-
},
222+
onPageScroll: (e) => {
223+
'worklet';
224+
offset.value = e.offset;
225+
console.log(e.offset, e.position);
226+
},
250227
});
251228

252-
<AnimatedPagerView onPageScroll={pageScrollHandler}/>
229+
<AnimatedPagerView onPageScroll={pageScrollHandler} />;
253230
```
231+
254232
## License
255233

256234
MIT

example/.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source 'https://rubygems.org'
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-
ruby '>= 2.6.10'
5-
gem 'cocoapods', '>= 1.11.3'
4+
ruby ">= 2.6.10"
5+
gem 'cocoapods', '~> 1.12'

example/Gemfile.lock

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.5)
4+
CFPropertyList (3.0.6)
55
rexml
6-
activesupport (6.1.7.6)
6+
activesupport (7.0.7.2)
77
concurrent-ruby (~> 1.0, >= 1.0.2)
88
i18n (>= 1.6, < 2)
99
minitest (>= 5.1)
1010
tzinfo (~> 2.0)
11-
zeitwerk (~> 2.3)
12-
addressable (2.8.1)
11+
addressable (2.8.5)
1312
public_suffix (>= 2.0.2, < 6.0)
1413
algoliasearch (1.27.5)
1514
httpclient (~> 2.8, >= 2.8.3)
1615
json (>= 1.5.1)
1716
atomos (0.1.3)
1817
claide (1.1.0)
19-
cocoapods (1.11.3)
18+
cocoapods (1.12.1)
2019
addressable (~> 2.8)
2120
claide (>= 1.0.2, < 2.0)
22-
cocoapods-core (= 1.11.3)
21+
cocoapods-core (= 1.12.1)
2322
cocoapods-deintegrate (>= 1.0.3, < 2.0)
24-
cocoapods-downloader (>= 1.4.0, < 2.0)
23+
cocoapods-downloader (>= 1.6.0, < 2.0)
2524
cocoapods-plugins (>= 1.0.0, < 2.0)
2625
cocoapods-search (>= 1.0.0, < 2.0)
27-
cocoapods-trunk (>= 1.4.0, < 2.0)
26+
cocoapods-trunk (>= 1.6.0, < 2.0)
2827
cocoapods-try (>= 1.1.0, < 2.0)
2928
colored2 (~> 3.1)
3029
escape (~> 0.0.4)
3130
fourflusher (>= 2.3.0, < 3.0)
3231
gh_inspector (~> 1.0)
3332
molinillo (~> 0.8.0)
3433
nap (~> 1.0)
35-
ruby-macho (>= 1.0, < 3.0)
34+
ruby-macho (>= 2.3.0, < 3.0)
3635
xcodeproj (>= 1.21.0, < 2.0)
37-
cocoapods-core (1.11.3)
38-
activesupport (>= 5.0, < 7)
36+
cocoapods-core (1.12.1)
37+
activesupport (>= 5.0, < 8)
3938
addressable (~> 2.8)
4039
algoliasearch (~> 1.0)
4140
concurrent-ruby (~> 1.1)
@@ -56,7 +55,7 @@ GEM
5655
colored2 (3.1.2)
5756
concurrent-ruby (1.2.2)
5857
escape (0.0.4)
59-
ethon (0.15.0)
58+
ethon (0.16.0)
6059
ffi (>= 1.15.0)
6160
ffi (1.15.5)
6261
fourflusher (2.3.1)
@@ -65,14 +64,14 @@ GEM
6564
httpclient (2.8.3)
6665
i18n (1.14.1)
6766
concurrent-ruby (~> 1.0)
68-
json (2.6.2)
67+
json (2.6.3)
6968
minitest (5.19.0)
7069
molinillo (0.8.0)
7170
nanaimo (0.3.0)
7271
nap (1.1.0)
7372
netrc (0.11.0)
7473
public_suffix (4.0.7)
75-
rexml (3.2.5)
74+
rexml (3.2.6)
7675
ruby-macho (2.5.1)
7776
typhoeus (1.4.0)
7877
ethon (>= 0.9.0)
@@ -85,13 +84,12 @@ GEM
8584
colored2 (~> 3.1)
8685
nanaimo (~> 0.3.0)
8786
rexml (~> 3.2.4)
88-
zeitwerk (2.6.11)
8987

9088
PLATFORMS
9189
ruby
9290

9391
DEPENDENCIES
94-
cocoapods (>= 1.11.3)
92+
cocoapods (~> 1.12)
9593

9694
RUBY VERSION
9795
ruby 2.7.5p203

example/android/app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ dependencies {
153153
implementation("com.facebook.react:react-android")
154154

155155
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
156+
implementation 'androidx.appcompat:appcompat:1.6.1'
157+
implementation 'com.google.android.material:material:1.4.+'
158+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
156159

157160
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
158161
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
23

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

56
<application
6-
android:name=".MainApplication"
7-
android:label="@string/app_name"
8-
android:icon="@mipmap/ic_launcher"
9-
android:roundIcon="@mipmap/ic_launcher_round"
10-
android:allowBackup="false"
11-
android:theme="@style/AppTheme">
12-
<activity
13-
android:name=".MainActivity"
7+
android:name=".MainApplication"
8+
android:allowBackup="false"
9+
android:icon="@mipmap/ic_launcher"
1410
android:label="@string/app_name"
15-
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
16-
android:launchMode="singleTask"
17-
android:windowSoftInputMode="adjustResize"
18-
android:exported="true">
19-
<intent-filter>
20-
<action android:name="android.intent.action.MAIN" />
21-
<category android:name="android.intent.category.LAUNCHER" />
22-
</intent-filter>
23-
</activity>
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:theme="@style/AppTheme">
13+
<activity
14+
android:name=".MainActivity"
15+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
16+
android:exported="true"
17+
android:label="@string/app_name"
18+
android:launchMode="singleTask"
19+
android:windowSoftInputMode="adjustResize">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
2426
</application>
25-
</manifest>
27+
28+
</manifest>

example/android/app/src/main/java/com/pagerviewexample/MainActivity.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
package com.pagerviewexample;
22

3-
import com.facebook.react.ReactActivity;
4-
import com.facebook.react.ReactActivityDelegate;
5-
import com.facebook.react.ReactRootView;
6-
7-
83
import com.facebook.react.ReactActivity;
94
import com.facebook.react.ReactActivityDelegate;
105
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
@@ -32,9 +27,6 @@ protected ReactActivityDelegate createReactActivityDelegate() {
3227
this,
3328
getMainComponentName(),
3429
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
35-
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
36-
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
37-
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
38-
);
30+
DefaultNewArchitectureEntryPoint.getFabricEnabled());
3931
}
4032
}

0 commit comments

Comments
 (0)