Files
mattermost-mobile/patches/react-native+0.68.2.patch
2022-07-26 11:37:59 -04:00

344 lines
12 KiB
Diff

diff --git a/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js b/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js
index 7cee521..e490d09 100644
--- a/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js
+++ b/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js
@@ -1784,9 +1784,15 @@ class ScrollView extends React.Component<Props, State> {
// Note: we should split props.style on the inner and outer props
// however, the ScrollView still needs the baseStyle to be scrollable
const {outer, inner} = splitLayoutProps(flattenStyle(props.style));
+ let inverted;
+ if (inner.scaleY) {
+ inverted = {scaleY: -1};
+ delete inner['scaleY']
+ }
+
return React.cloneElement(
refreshControl,
- {style: StyleSheet.compose(baseStyle, outer)},
+ {style: [baseStyle, outer, inverted]},
<NativeDirectionalScrollView
{...props}
style={StyleSheet.compose(baseStyle, inner)}
diff --git a/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js
index a6826f3..a7b904b 100644
--- a/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js
+++ b/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js
@@ -170,7 +170,9 @@ class ScrollViewStickyHeader extends React.Component<Props, State> {
this.props.onLayout(event);
const child = React.Children.only(this.props.children);
- if (child.props.onLayout) {
+ if (child.props.onCellLayout) {
+ child.props.onCellLayout(event, child.props.cellKey, child.props.index);
+ } else if (child.props.onLayout) {
child.props.onLayout(event);
}
};
diff --git a/node_modules/react-native/Libraries/Lists/VirtualizedList.js b/node_modules/react-native/Libraries/Lists/VirtualizedList.js
index 6de43b7..2c18c92 100644
--- a/node_modules/react-native/Libraries/Lists/VirtualizedList.js
+++ b/node_modules/react-native/Libraries/Lists/VirtualizedList.js
@@ -16,6 +16,7 @@ const ScrollView = require('../Components/ScrollView/ScrollView');
const StyleSheet = require('../StyleSheet/StyleSheet');
const View = require('../Components/View/View');
const ViewabilityHelper = require('./ViewabilityHelper');
+const Platform = require('../Utilities/Platform');
const flattenStyle = require('../StyleSheet/flattenStyle');
const infoLog = require('../Utilities/infoLog');
@@ -34,6 +35,7 @@ import type {
ViewToken,
ViewabilityConfigCallbackPair,
} from './ViewabilityHelper';
+import type {LayoutEvent} from '../Types/CoreEventTypes';
import {
VirtualizedListCellContextProvider,
VirtualizedListContext,
@@ -796,12 +798,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
const {
CellRendererComponent,
ItemSeparatorComponent,
+ ListHeaderComponent,
+ ListItemComponent,
data,
+ debug,
getItem,
getItemCount,
+ getItemLayout,
horizontal,
+ renderItem,
} = this.props;
- const stickyOffset = this.props.ListHeaderComponent ? 1 : 0;
+ const stickyOffset = ListHeaderComponent ? 1 : 0;
const end = getItemCount(data) - 1;
let prevCellKey;
last = Math.min(end, last);
@@ -816,27 +823,30 @@ class VirtualizedList extends React.PureComponent<Props, State> {
<CellRenderer
CellRendererComponent={CellRendererComponent}
ItemSeparatorComponent={ii < end ? ItemSeparatorComponent : undefined}
+ ListItemComponent={ListItemComponent}
cellKey={key}
+ debug={debug}
fillRateHelper={this._fillRateHelper}
+ getItemLayout={getItemLayout}
horizontal={horizontal}
index={ii}
inversionStyle={inversionStyle}
item={item}
key={key}
prevCellKey={prevCellKey}
+ onCellLayout={this._onCellLayout}
onUpdateSeparators={this._onUpdateSeparators}
- onLayout={e => this._onCellLayout(e, key, ii)}
onUnmount={this._onCellUnmount}
- parentProps={this.props}
ref={ref => {
this._cellRefs[key] = ref;
}}
+ renderItem={renderItem}
/>,
);
prevCellKey = key;
}
}
-
+1
_onUpdateSeparators = (keys: Array<?string>, newProps: Object) => {
keys.forEach(key => {
const ref = key != null && this._cellRefs[key];
@@ -1268,7 +1278,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
}
};
- _onCellLayout(e, cellKey, index) {
+ _onCellLayout = (e: LayoutEvent, cellKey: string, index: number): void => {
const layout = e.nativeEvent.layout;
const next = {
offset: this._selectOffset(layout),
@@ -1301,7 +1311,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
this._computeBlankness();
this._updateViewableItems(this.props.data);
- }
+ };
_onCellUnmount = (cellKey: string) => {
const curr = this._frames[cellKey];
@@ -1380,7 +1390,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
}
}
- _onLayout = (e: Object) => {
+ _onLayout = (e: LayoutEvent) => {
if (this._isNestedWithSameOrientation()) {
// Need to adjust our scroll metrics to be relative to our containing
// VirtualizedList before we can make claims about list item viewability
@@ -1395,7 +1405,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
this._maybeCallOnEndReached();
};
- _onLayoutEmpty = e => {
+ _onLayoutEmpty = (e: LayoutEvent) => {
this.props.onLayout && this.props.onLayout(e);
};
@@ -1403,12 +1413,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
return this._getCellKey() + '-footer';
}
- _onLayoutFooter = e => {
+ _onLayoutFooter = (e: LayoutEvent) => {
this._triggerRemeasureForChildListsInCell(this._getFooterCellKey());
this._footerLength = this._selectLength(e.nativeEvent.layout);
};
- _onLayoutHeader = e => {
+ _onLayoutHeader = (e: LayoutEvent) => {
this._headerLength = this._selectLength(e.nativeEvent.layout);
};
@@ -1888,32 +1898,29 @@ type CellRendererProps = {
ItemSeparatorComponent: ?React.ComponentType<
any | {highlighted: boolean, leadingItem: ?Item},
>,
+ ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
cellKey: string,
+ debug?: ?boolean,
fillRateHelper: FillRateHelper,
+ getItemLayout?: (
+ data: any,
+ index: number,
+ ) => {
+ length: number,
+ offset: number,
+ index: number,
+ ...
+ },
horizontal: ?boolean,
index: number,
inversionStyle: ViewStyleProp,
item: Item,
// This is extracted by ScrollViewStickyHeader
- onLayout: (event: Object) => void,
+ onCellLayout: (event: Object, cellKey: string, index: number) => void,
onUnmount: (cellKey: string) => void,
onUpdateSeparators: (cellKeys: Array<?string>, props: Object) => void,
- parentProps: {
- // e.g. height, y,
- getItemLayout?: (
- data: any,
- index: number,
- ) => {
- length: number,
- offset: number,
- index: number,
- ...
- },
- renderItem?: ?RenderItemType<Item>,
- ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
- ...
- },
prevCellKey: ?string,
+ renderItem?: ?RenderItemType<Item>,
...
};
@@ -1925,7 +1932,7 @@ type CellRendererState = {
...
};
-class CellRenderer extends React.Component<
+class CellRenderer extends React.PureComponent<
CellRendererProps,
CellRendererState,
> {
@@ -1940,12 +1947,16 @@ class CellRenderer extends React.Component<
props: CellRendererProps,
prevState: CellRendererState,
): ?CellRendererState {
- return {
- separatorProps: {
- ...prevState.separatorProps,
- leadingItem: props.item,
- },
- };
+ if (prevState.separatorProps.leadingItem !== props.item) {
+ return {
+ separatorProps: {
+ ...prevState.separatorProps,
+ leadingItem: props.item,
+ },
+ };
+ } else {
+ return prevState;
+ }
}
// TODO: consider factoring separator stuff out of VirtualizedList into FlatList since it's not
@@ -1982,6 +1993,15 @@ class CellRenderer extends React.Component<
this.props.onUnmount(this.props.cellKey);
}
+ _onLayout = (nativeEvent: LayoutEvent): void => {
+ this.props.onCellLayout &&
+ this.props.onCellLayout(
+ nativeEvent,
+ this.props.cellKey,
+ this.props.index,
+ );
+ };
+
_renderElement(renderItem, ListItemComponent, item, index) {
if (renderItem && ListItemComponent) {
console.warn(
@@ -2022,14 +2042,16 @@ class CellRenderer extends React.Component<
const {
CellRendererComponent,
ItemSeparatorComponent,
+ ListItemComponent,
+ debug,
fillRateHelper,
+ getItemLayout,
horizontal,
item,
index,
inversionStyle,
- parentProps,
+ renderItem,
} = this.props;
- const {renderItem, getItemLayout, ListItemComponent} = parentProps;
const element = this._renderElement(
renderItem,
ListItemComponent,
@@ -2038,12 +2060,10 @@ class CellRenderer extends React.Component<
);
const onLayout =
- /* $FlowFixMe[prop-missing] (>=0.68.0 site=react_native_fb) This comment
- * suppresses an error found when Flow v0.68 was deployed. To see the
- * error delete this comment and run Flow. */
- getItemLayout && !parentProps.debug && !fillRateHelper.enabled()
+ (getItemLayout && !debug && !fillRateHelper.enabled()) ||
+ !this.props.onCellLayout
? undefined
- : this.props.onLayout;
+ : this._onLayout;
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
// called explicitly by `ScrollViewStickyHeader`.
const itemSeparator = ItemSeparatorComponent && (
@@ -2109,7 +2129,14 @@ function describeNestedLists(childList: {
const styles = StyleSheet.create({
verticallyInverted: {
- transform: [{scaleY: -1}],
+ ...Platform.select({
+ android: {
+ scaleY: -1,
+ },
+ ios: {
+ transform: [{scaleY: -1}],
+ },
+ }),
},
horizontallyInverted: {
transform: [{scaleX: -1}],
diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index d876b13..142c59b 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -112,7 +112,7 @@ def enableHermesForVariant = config.enableHermesForVariant ?: {
def hermesFlagsForVariant = config.hermesFlagsForVariant ?: {
def variant ->
def hermesFlags;
- if (variant.name.toLowerCase().contains("release")) {
+ if (variant.name.toLowerCase().contains("release") || variant.name.toLowerCase().contains("unsigned")) {
// Can't use ?: since that will also substitute valid empty lists
hermesFlags = config.hermesFlagsRelease
if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"]
@@ -128,7 +128,7 @@ def hermesFlagsForVariant = config.hermesFlagsForVariant ?: {
def disableDevForVariant = config.disableDevForVariant ?: {
def variant ->
config."devDisabledIn${variant.name.capitalize()}" ||
- variant.name.toLowerCase().contains("release")
+ variant.name.toLowerCase().contains("release") || variant.name.toLowerCase().contains("unsigned")
}
// Set bundleForVariant to a function to configure per variant,
@@ -137,13 +137,13 @@ def bundleForVariant = config.bundleForVariant ?: {
def variant ->
config."bundleIn${variant.name.capitalize()}" ||
config."bundleIn${variant.buildType.name.capitalize()}" ||
- variant.name.toLowerCase().contains("release")
+ variant.name.toLowerCase().contains("release") || variant.name.toLowerCase().contains("unsigned")
}
// Set deleteDebugFilesForVariant to a function to configure per variant,
// defaults to True for Release variants and False for debug variants
def deleteDebugFilesForVariant = config.deleteDebugFilesForVariant ?: {
- def variant -> variant.name.toLowerCase().contains("release")
+ def variant -> variant.name.toLowerCase().contains("release") || variant.name.toLowerCase().contains("unsigned")
}
android {