Skip to content

Commit 280c3a3

Browse files
troZeekrozniataPiotr Trockiokwasniewskiintergalacticspacehighway
authored
merge next to master (#817)
* feat(iOS): change Fabric implementation to UIScrollView (#672) * feat(iOS): change Fabric implementation to UIScrollView * fix: fix offset values in vertical orientation * feat: add initialPage props support * feat: add RTL language support * feat: add pageMargin prop support * fix: fix typescript error * feat: remove React.cloneElement * feat(ios): add getPageOffset method * fix: fix styles in old example * fix: behavior on page remove * chore: add GH actions (#680) Co-authored-by: Piotr Trocki <[email protected]> * feat(iOS): rewrite old arch to use UIScrollView (#681) * feat: rewrite old arch to use UIScrollView * feat: update example styles * fix: sending event on scrollViewDidEndDecelerating * feat: properly calculate width using orientation * fix: change way of disabing scroll * feat: rename to RNCPagerView * fix: removing last page * fix: remove unused properties, set animated * chore: update release script * Release 7.0.0-rc.0 * wip * wip * fabric example * nit: comment * make init consistent * fix: multiple updates of frame and contentSize * feat: add button to quickly switch layout direction * sync with master (#756) Co-authored-by: Piotr Trocki <[email protected]> * chore: upgrade RN (paper example) * chore: upgrade rn & fix issues (fabric example) * chore: bump versions in package.json * chore: fix eslint issue * chore: exclude example from tsc * feat(next): remove fabric example * chore: update README * fix broken overdrag on notch (#787) Co-authored-by: Kuba Juszczyk <[email protected]> * feat(iOS): Add a `useLegacy` flag to switch between the old/new iOS implementation (#783) * wip: unsuspicious changes * wip: unsuspicious changes v2 * FABRIC NEW IMPL -> OLD IMPL * wip: bring back useLegacy on the RN side * wip: bring back duplicate types to fix codegen issues * wip: remove #705 related code for now * wip: old/new impl division first draft * wip: old/new impl division continued * wip: old/new impl v3 * wip: add a `LEGACY_` prefix to all legacy implementation-related symbols * wip: fix styles for new implementation on Fabric * wip: move old/new impl into separate folders * wip: fix old impl fabric symbol names * wip: xcode changes * wip: clean up & unify the naming convention * wip: fix linter issues * wip: fix styles for new implementation on Paper * wip: make Fabric example run on another port by default to make it possible to run both examples in parallel * wip: implement an abstraction over native commands invocations to reduce branching * refactor: remove the unnecessary value for boolean props * fix: bump react-native-safe-area-context to a Fabric-enabled version * feat: bring back & adjust the `bootstrap-fabric` script * feat: adjust the home screen title depending on the used architecture * chore: update example/Podfile.lock * chore: update an Xcode project file after building * ci: make next branch events trigger ios/android build workflows * chore: remove commented-out code related to #705 for now * chore: add legacy implementation explanation comment * wip: Android fixes * fix: unnecessary comma in MainActivity.java * feat: readme makeover * chore: bump react-native-screens & react-native-gesture-handler in example * refactor(android): extract module name to shared variable, add comment for context * chore: remove unnecessary yarn.lock deps * chore(ios): bring back removed build flags * chore(ios): remove unnecessary concurrentRootEnabled method According to React Native Upgrade Helper, this method is to be removed when updating to RN 0.72: https://react-native-community.github.io/upgrade-helper/?from=0.71.14&to=0.72.0#RnDiffApp-ios-RnDiffApp-AppDelegate.mm * fix(android): adjust incorrect param type on Fabric * chore: remove unnecessary tsconfig.json comment * chore(ios): bring back (currently unused) code related to #712 and #705 * Release 7.0.0-rc.1 * fix(ios): fix freezing when navigating to same index (#804) * Release 7.0.0-rc.2 * fix iOS issue * Change Legacy basic example into the next basic example * revert documentatation --------- Co-authored-by: Kacper Rożniata <[email protected]> Co-authored-by: Piotr Trocki <[email protected]> Co-authored-by: Oskar Kwaśniewski <[email protected]> Co-authored-by: Nishan <[email protected]> Co-authored-by: Kuba Juszczyk <[email protected]> Co-authored-by: Kuba Juszczyk <[email protected]> Co-authored-by: Igor Bejnarowicz <[email protected]>
1 parent 0662c31 commit 280c3a3

Some content is hidden

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

48 files changed

+1943
-1774
lines changed

.github/workflows/android.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ on:
44
pull_request:
55
branches:
66
- master
7+
- next
78
paths:
89
- '.github/workflows/android.yml'
910
- 'android/**'
1011
- 'example/android/**'
1112
push:
1213
branches:
1314
- master
15+
- next
1416

1517
concurrency:
1618
group: ${{ github.ref }}-android

.github/workflows/ios.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ on:
44
pull_request:
55
branches:
66
- master
7+
- next
78
paths:
89
- '.github/workflows/ios.yml'
910
- 'ios/**'
1011
- 'example/ios/**'
1112
push:
1213
branches:
1314
- master
15+
- next
1416

1517
concurrency:
1618
group: ${{ github.ref }}-ios

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
pull_request:
55
branches:
66
- master
7+
- next
78
push:
89
branches:
910
- master
11+
- next
1012

1113
concurrency:
1214
group: ${{ github.ref }}-js

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ npm-debug.log
4747
yarn-debug.log
4848
yarn-error.log
4949

50-
# BUCK
51-
buck-out/
52-
\.buckd/
53-
android/app/libs
54-
android/keystores/debug.keystore
55-
5650
# Expo
5751
.expo/*
5852

@@ -76,3 +70,4 @@ lefthook.yml
7670
# testing
7771
/coverage
7872
.cxx
73+
example/ios/PagerViewExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ For advanced usage please take a look into our [example project](https://github.
147147
| `pageMargin: number` | Blank space to be shown between pages | both |
148148
| `keyboardDismissMode: ('none' / 'on-drag')` | Determines whether the keyboard gets dismissed in response to a drag | both |
149149
| `orientation: Orientation` | Set `horizontal` or `vertical` scrolling orientation (it does **not** work dynamically) | both |
150-
| `overScrollMode: OverScrollMode` | Used to override default value of overScroll mode. Can be `auto`, `always` or `never`. Defaults to `auto` | Android |
150+
| `overScrollMode: OverScrollMode` | Used to override default value of overScroll mode. Can be `auto`, `always` or `never`. Defaults to `auto` | Android |
151151
| `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 |
152152
| `overdrag: boolean` | Allows for overscrolling after reaching the end or very beginning or pages. Defaults to `false` | iOS |
153153
| `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 |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.reactnativepagerview
2+
3+
import com.facebook.react.uimanager.ViewGroupManager
4+
import android.widget.FrameLayout
5+
import com.facebook.react.module.annotations.ReactModule
6+
import com.facebook.react.uimanager.ThemedReactContext
7+
8+
// Note: The LEGACY_ variant is an iOS-only feature and the related Android files
9+
// are only included because of and relevant to auxiliary processes, like Codegen.
10+
@ReactModule(name = LEGACY_PagerViewViewManagerImpl.NAME)
11+
class LEGACY_PagerViewViewManager : ViewGroupManager<FrameLayout>() {
12+
override fun getName() = LEGACY_PagerViewViewManagerImpl.NAME
13+
14+
override fun createViewInstance(context: ThemedReactContext): FrameLayout {
15+
throw Error("LEGACY_RNCViewPager is an iOS-only feature")
16+
}
17+
}

android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ class PagerViewViewManager : ViewGroupManager<NestedScrollableHost>(), RNCViewPa
173173
return
174174
}
175175

176+
@ReactProp(name = "useLegacy")
177+
override fun setUseLegacy(view: NestedScrollableHost?, value: Boolean) {
178+
return
179+
}
180+
176181
fun goTo(root: NestedScrollableHost?, selectedPage: Int, scrollWithAnimation: Boolean) {
177182
if (root == null) {
178183
return
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.reactnativepagerview
2+
3+
// Note: The LEGACY_ variant is an iOS-only feature and the related Android files
4+
// are only included because of and relevant to auxiliary processes, like Codegen.
5+
object LEGACY_PagerViewViewManagerImpl {
6+
const val NAME = "LEGACY_RNCViewPager"
7+
}

android/src/main/java/com/reactnativepagerview/PagerViewViewPackage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class PagerViewPackage : ReactPackage {
1212
}
1313

1414
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15-
return listOf(PagerViewViewManager())
15+
return listOf(PagerViewViewManager(), LEGACY_PagerViewViewManager())
1616
}
1717
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.reactnativepagerview
2+
3+
import com.facebook.react.uimanager.ViewGroupManager
4+
import android.widget.FrameLayout
5+
import com.facebook.react.module.annotations.ReactModule
6+
import com.facebook.react.uimanager.ThemedReactContext
7+
8+
// Note: The LEGACY_ variant is an iOS-only feature and the related Android files
9+
// are only included because of and relevant to auxiliary processes, like Codegen.
10+
@ReactModule(name = LEGACY_PagerViewViewManagerImpl.NAME)
11+
class LEGACY_PagerViewViewManager : ViewGroupManager<FrameLayout>() {
12+
override fun getName() = LEGACY_PagerViewViewManagerImpl.NAME
13+
14+
override fun createViewInstance(context: ThemedReactContext): FrameLayout {
15+
throw Error("LEGACY_RNCViewPager is an iOS-only feature")
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include "RNCViewPagerShadowNode.h"
4+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
5+
6+
namespace facebook {
7+
namespace react {
8+
9+
using RNCViewPagerComponentDescriptor = ConcreteComponentDescriptor<RNCViewPagerShadowNode>;
10+
11+
}
12+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "RNCViewPagerShadowNode.h"
2+
3+
#include <react/debug/react_native_assert.h>
4+
#include <react/renderer/core/LayoutMetrics.h>
5+
6+
namespace facebook {
7+
namespace react {
8+
9+
const char RNCViewPagerComponentName[] = "RNCViewPager";
10+
11+
void RNCViewPagerShadowNode::updateStateIfNeeded() {
12+
ensureUnsealed();
13+
14+
auto contentBoundingRect = Rect{};
15+
for (const auto &childNode : getLayoutableChildNodes()) {
16+
contentBoundingRect.unionInPlace(childNode->getLayoutMetrics().frame);
17+
}
18+
19+
auto state = getStateData();
20+
21+
if (state.contentBoundingRect != contentBoundingRect) {
22+
state.contentBoundingRect = contentBoundingRect;
23+
setStateData(std::move(state));
24+
}
25+
}
26+
27+
#pragma mark - LayoutableShadowNode
28+
29+
void RNCViewPagerShadowNode::layout(LayoutContext layoutContext) {
30+
ConcreteViewShadowNode::layout(layoutContext);
31+
updateStateIfNeeded();
32+
}
33+
34+
}
35+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
#include <react/renderer/components/RNCViewPager/EventEmitters.h>
4+
#include <react/renderer/components/RNCViewPager/Props.h>
5+
#include <react/renderer/components/RNCViewPager/RNCViewPagerState.h>
6+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
7+
#include <react/renderer/core/LayoutContext.h>
8+
9+
namespace facebook {
10+
namespace react {
11+
12+
extern const char RNCViewPagerComponentName[];
13+
14+
class RNCViewPagerShadowNode final : public ConcreteViewShadowNode<
15+
RNCViewPagerComponentName,
16+
RNCViewPagerProps,
17+
RNCViewPagerEventEmitter,
18+
RNCViewPagerState> {
19+
public:
20+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
21+
22+
#pragma mark - LayoutableShadowNode
23+
24+
void layout(LayoutContext layoutContext) override;
25+
26+
private:
27+
void updateStateIfNeeded();
28+
};
29+
30+
}
31+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "RNCViewPagerState.h"
2+
3+
namespace facebook {
4+
namespace react {
5+
6+
Size RNCViewPagerState::getContentSize() const {
7+
return contentBoundingRect.size;
8+
}
9+
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include <react/renderer/graphics/Geometry.h>
4+
5+
namespace facebook {
6+
namespace react {
7+
8+
class RNCViewPagerState final {
9+
public:
10+
Point contentOffset;
11+
Rect contentBoundingRect;
12+
13+
Size getContentSize() const;
14+
15+
};
16+
17+
}
18+
}

example/.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package com.pagerviewexample;
22

3+
import com.facebook.react.ReactActivity;
4+
import com.facebook.react.ReactActivityDelegate;
5+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
6+
import com.facebook.react.defaults.DefaultReactActivityDelegate;
7+
8+
39
import com.facebook.react.ReactActivity;
410
import com.facebook.react.ReactActivityDelegate;
511
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;

example/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ buildscript {
1010
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
1111
ndkVersion = "23.1.7779620"
1212
}
13+
1314
repositories {
1415
google()
1516
mavenCentral()
17+
maven { url 'https://www.jitpack.io' }
1618
}
19+
1720
dependencies {
1821
classpath("com.android.tools.build:gradle")
1922
classpath("com.facebook.react:react-native-gradle-plugin")
2023
}
21-
}
24+
}

example/ios/PagerViewExample.xcodeproj/project.pbxproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@
570570
GCC_PREPROCESSOR_DEFINITIONS = (
571571
"DEBUG=1",
572572
"$(inherited)",
573+
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION,
573574
);
574575
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
575576
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -597,6 +598,13 @@
597598
"-DFOLLY_MOBILE=1",
598599
"-DFOLLY_USE_LIBCPP=1",
599600
);
601+
OTHER_LDFLAGS = (
602+
"$(inherited)",
603+
"-Wl",
604+
"-ld_classic",
605+
" ",
606+
"-Wl -ld_classic ",
607+
);
600608
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
601609
SDKROOT = iphoneos;
602610
};
@@ -638,6 +646,10 @@
638646
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
639647
GCC_C_LANGUAGE_STANDARD = gnu99;
640648
GCC_NO_COMMON_BLOCKS = YES;
649+
GCC_PREPROCESSOR_DEFINITIONS = (
650+
"$(inherited)",
651+
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION,
652+
);
641653
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
642654
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
643655
GCC_WARN_UNDECLARED_SELECTOR = YES;
@@ -662,6 +674,13 @@
662674
"-DFOLLY_MOBILE=1",
663675
"-DFOLLY_USE_LIBCPP=1",
664676
);
677+
OTHER_LDFLAGS = (
678+
"$(inherited)",
679+
"-Wl",
680+
"-ld_classic",
681+
" ",
682+
"-Wl -ld_classic ",
683+
);
665684
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
666685
SDKROOT = iphoneos;
667686
VALIDATE_PRODUCT = YES;

example/ios/Podfile.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ PODS:
375375
- React-jsinspector (0.72.6)
376376
- React-logger (0.72.6):
377377
- glog
378-
- react-native-pager-view (6.2.1):
378+
- react-native-pager-view (6.3.0):
379+
- RCT-Folly (= 2021.07.22.00)
379380
- React-Core
380381
- react-native-safe-area-context (4.5.2):
381382
- RCT-Folly
@@ -754,7 +755,7 @@ SPEC CHECKSUMS:
754755
React-jsiexecutor: 3bf18ff7cb03cd8dfdce08fbbc0d15058c1d71ae
755756
React-jsinspector: 194e32c6aab382d88713ad3dd0025c5f5c4ee072
756757
React-logger: cebf22b6cf43434e471dc561e5911b40ac01d289
757-
react-native-pager-view: d211379f61895b6349bd7e571b44a26d005c2975
758+
react-native-pager-view: 40d9ec4a63ed74f8aa2f1e1bba7c1e0b4080d8a6
758759
react-native-safe-area-context: 1d596539b05a78f2b346e954e7c577f6f9be7544
759760
React-NativeModulesApple: 02e35e9a51e10c6422f04f5e4076a7c02243fff2
760761
React-perflogger: e3596db7e753f51766bceadc061936ef1472edc3
@@ -784,4 +785,4 @@ SPEC CHECKSUMS:
784785

785786
PODFILE CHECKSUM: 4c96e1cc59fd0774de51faf6e28ddf171307d5ed
786787

787-
COCOAPODS: 1.11.3
788+
COCOAPODS: 1.12.1

example/metro.config.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ const config = {
3131
return acc;
3232
}, {}),
3333
},
34-
35-
transformer: {
36-
getTransformOptions: async () => ({
37-
transform: {
38-
experimentalImportSupport: false,
39-
inlineRequires: true,
40-
},
41-
}),
42-
},
4334
};
4435

4536
module.exports = mergeConfig(getDefaultConfig(__dirname), config);

0 commit comments

Comments
 (0)