Skip to content

Commit

Permalink
merge next to master (#817)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
8 people authored Mar 31, 2024
1 parent 0662c31 commit 280c3a3
Show file tree
Hide file tree
Showing 48 changed files with 1,943 additions and 1,774 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
pull_request:
branches:
- master
- next
paths:
- '.github/workflows/android.yml'
- 'android/**'
- 'example/android/**'
push:
branches:
- master
- next

concurrency:
group: ${{ github.ref }}-android
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
pull_request:
branches:
- master
- next
paths:
- '.github/workflows/ios.yml'
- 'ios/**'
- 'example/ios/**'
push:
branches:
- master
- next

concurrency:
group: ${{ github.ref }}-ios
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
pull_request:
branches:
- master
- next
push:
branches:
- master
- next

concurrency:
group: ${{ github.ref }}-js
Expand Down
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ npm-debug.log
yarn-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Expo
.expo/*

Expand All @@ -76,3 +70,4 @@ lefthook.yml
# testing
/coverage
.cxx
example/ios/PagerViewExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ For advanced usage please take a look into our [example project](https://github.
| `pageMargin: number` | Blank space to be shown between pages | both |
| `keyboardDismissMode: ('none' / 'on-drag')` | Determines whether the keyboard gets dismissed in response to a drag | both |
| `orientation: Orientation` | Set `horizontal` or `vertical` scrolling orientation (it does **not** work dynamically) | both |
| `overScrollMode: OverScrollMode` | Used to override default value of overScroll mode. Can be `auto`, `always` or `never`. Defaults to `auto` | Android |
| `overScrollMode: OverScrollMode` | Used to override default value of overScroll mode. Can be `auto`, `always` or `never`. Defaults to `auto` | Android |
| `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 |
| `overdrag: boolean` | Allows for overscrolling after reaching the end or very beginning or pages. Defaults to `false` | iOS |
| `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 |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.reactnativepagerview

import com.facebook.react.uimanager.ViewGroupManager
import android.widget.FrameLayout
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.ThemedReactContext

// Note: The LEGACY_ variant is an iOS-only feature and the related Android files
// are only included because of and relevant to auxiliary processes, like Codegen.
@ReactModule(name = LEGACY_PagerViewViewManagerImpl.NAME)
class LEGACY_PagerViewViewManager : ViewGroupManager<FrameLayout>() {
override fun getName() = LEGACY_PagerViewViewManagerImpl.NAME

override fun createViewInstance(context: ThemedReactContext): FrameLayout {
throw Error("LEGACY_RNCViewPager is an iOS-only feature")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ class PagerViewViewManager : ViewGroupManager<NestedScrollableHost>(), RNCViewPa
return
}

@ReactProp(name = "useLegacy")
override fun setUseLegacy(view: NestedScrollableHost?, value: Boolean) {
return
}

fun goTo(root: NestedScrollableHost?, selectedPage: Int, scrollWithAnimation: Boolean) {
if (root == null) {
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.reactnativepagerview

// Note: The LEGACY_ variant is an iOS-only feature and the related Android files
// are only included because of and relevant to auxiliary processes, like Codegen.
object LEGACY_PagerViewViewManagerImpl {
const val NAME = "LEGACY_RNCViewPager"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class PagerViewPackage : ReactPackage {
}

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return listOf(PagerViewViewManager())
return listOf(PagerViewViewManager(), LEGACY_PagerViewViewManager())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.reactnativepagerview

import com.facebook.react.uimanager.ViewGroupManager
import android.widget.FrameLayout
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.ThemedReactContext

// Note: The LEGACY_ variant is an iOS-only feature and the related Android files
// are only included because of and relevant to auxiliary processes, like Codegen.
@ReactModule(name = LEGACY_PagerViewViewManagerImpl.NAME)
class LEGACY_PagerViewViewManager : ViewGroupManager<FrameLayout>() {
override fun getName() = LEGACY_PagerViewViewManagerImpl.NAME

override fun createViewInstance(context: ThemedReactContext): FrameLayout {
throw Error("LEGACY_RNCViewPager is an iOS-only feature")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include "RNCViewPagerShadowNode.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>

namespace facebook {
namespace react {

using RNCViewPagerComponentDescriptor = ConcreteComponentDescriptor<RNCViewPagerShadowNode>;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "RNCViewPagerShadowNode.h"

#include <react/debug/react_native_assert.h>
#include <react/renderer/core/LayoutMetrics.h>

namespace facebook {
namespace react {

const char RNCViewPagerComponentName[] = "RNCViewPager";

void RNCViewPagerShadowNode::updateStateIfNeeded() {
ensureUnsealed();

auto contentBoundingRect = Rect{};
for (const auto &childNode : getLayoutableChildNodes()) {
contentBoundingRect.unionInPlace(childNode->getLayoutMetrics().frame);
}

auto state = getStateData();

if (state.contentBoundingRect != contentBoundingRect) {
state.contentBoundingRect = contentBoundingRect;
setStateData(std::move(state));
}
}

#pragma mark - LayoutableShadowNode

void RNCViewPagerShadowNode::layout(LayoutContext layoutContext) {
ConcreteViewShadowNode::layout(layoutContext);
updateStateIfNeeded();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <react/renderer/components/RNCViewPager/EventEmitters.h>
#include <react/renderer/components/RNCViewPager/Props.h>
#include <react/renderer/components/RNCViewPager/RNCViewPagerState.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/core/LayoutContext.h>

namespace facebook {
namespace react {

extern const char RNCViewPagerComponentName[];

class RNCViewPagerShadowNode final : public ConcreteViewShadowNode<
RNCViewPagerComponentName,
RNCViewPagerProps,
RNCViewPagerEventEmitter,
RNCViewPagerState> {
public:
using ConcreteViewShadowNode::ConcreteViewShadowNode;

#pragma mark - LayoutableShadowNode

void layout(LayoutContext layoutContext) override;

private:
void updateStateIfNeeded();
};

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "RNCViewPagerState.h"

namespace facebook {
namespace react {

Size RNCViewPagerState::getContentSize() const {
return contentBoundingRect.size;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <react/renderer/graphics/Geometry.h>

namespace facebook {
namespace react {

class RNCViewPagerState final {
public:
Point contentOffset;
Rect contentBoundingRect;

Size getContentSize() const;

};

}
}
1 change: 1 addition & 0 deletions example/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.pagerviewexample;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactActivityDelegate;


import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
Expand Down
5 changes: 4 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ buildscript {
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}

repositories {
google()
mavenCentral()
maven { url 'https://www.jitpack.io' }
}

dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
}
19 changes: 19 additions & 0 deletions example/ios/PagerViewExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -597,6 +598,13 @@
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
" ",
"-Wl -ld_classic ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
};
Expand Down Expand Up @@ -638,6 +646,10 @@
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -662,6 +674,13 @@
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
" ",
"-Wl -ld_classic ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
7 changes: 4 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ PODS:
- React-jsinspector (0.72.6)
- React-logger (0.72.6):
- glog
- react-native-pager-view (6.2.1):
- react-native-pager-view (6.3.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- react-native-safe-area-context (4.5.2):
- RCT-Folly
Expand Down Expand Up @@ -754,7 +755,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 3bf18ff7cb03cd8dfdce08fbbc0d15058c1d71ae
React-jsinspector: 194e32c6aab382d88713ad3dd0025c5f5c4ee072
React-logger: cebf22b6cf43434e471dc561e5911b40ac01d289
react-native-pager-view: d211379f61895b6349bd7e571b44a26d005c2975
react-native-pager-view: 40d9ec4a63ed74f8aa2f1e1bba7c1e0b4080d8a6
react-native-safe-area-context: 1d596539b05a78f2b346e954e7c577f6f9be7544
React-NativeModulesApple: 02e35e9a51e10c6422f04f5e4076a7c02243fff2
React-perflogger: e3596db7e753f51766bceadc061936ef1472edc3
Expand Down Expand Up @@ -784,4 +785,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 4c96e1cc59fd0774de51faf6e28ddf171307d5ed

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
9 changes: 0 additions & 9 deletions example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ const config = {
return acc;
}, {}),
},

transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};

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

0 comments on commit 280c3a3

Please sign in to comment.