Skip to content

Commit 9083ffe

Browse files
authored
fix:修复SpringScrollView在302框架上无法正常注册Fabric组件问题 (#19)
Signed-off-by: wupingyuan <wupingyuan2@h-partners.com>
1 parent 0d58315 commit 9083ffe

File tree

2 files changed

+128
-6
lines changed

2 files changed

+128
-6
lines changed

src/SpringScrollView.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ import type { HeaderStatus } from "./RefreshHeader";
2828
import { idx } from "./idx";
2929
import type { Offset, SpringScrollViewPropType } from "./Types";
3030
import { styles } from "./styles";
31+
import type { NativeProps as SpringScrollViewViewProps } from './SpringScrollViewNativeComponent';
32+
import SpringScrollViewNative from './SpringScrollViewNativeComponent';
3133

32-
export class SpringScrollView extends React.PureComponent<SpringScrollViewPropType> {
34+
export class SpringScrollView extends React.PureComponent<SpringScrollViewViewProps> {
3335
_offsetY: Animated.Value;
3436
_offsetX: Animated.Value;
3537
_offsetYValue: number = 0;
@@ -106,7 +108,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
106108
{...this.props}
107109
ref={ref => (this._scrollView = ref)}
108110
style={(Platform.OS === "android" || Platform.OS === "harmony") ? wStyle : { flex: 1 }}
109-
onScroll={this._event}
111+
onScroll={this._onScroll}
110112
refreshHeaderHeight={onRefresh ? Refresh.height : 0}
111113
loadingFooterHeight={onLoading ? Loading.height : 0}
112114
onLayout={this._onWrapperLayoutChange}
@@ -558,9 +560,5 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
558560
};
559561
}
560562

561-
const SpringScrollViewNative = Animated.createAnimatedComponent(
562-
requireNativeComponent("SpringScrollView", SpringScrollView)
563-
);
564-
565563
const SpringScrollContentViewNative =
566564
Platform.OS === "ios" ? requireNativeComponent("SpringScrollContentView") : View;
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import * as React from "react";
2+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3+
import type { HostComponent, ViewProps,Animated,ViewStyle } from 'react-native';
4+
5+
export interface Offset {
6+
x: number;
7+
y: number;
8+
}
9+
10+
export interface Size {
11+
width:number;
12+
height:number;
13+
}
14+
15+
export interface NativeContentOffset {
16+
x?: Animated.Value;
17+
y?: Animated.Value;
18+
}
19+
20+
export type RefreshStyle = "topping" | "stickyScrollView" | "stickyContent";
21+
22+
export type LoadingStyle = "bottoming" | "stickyScrollView" | "stickyContent";
23+
24+
export interface ScrollEvent {
25+
nativeEvent: {
26+
contentOffset: {
27+
x: number;
28+
y: number;
29+
};
30+
};
31+
}
32+
33+
export type HeaderStatus =
34+
| "waiting"
35+
| "pulling"
36+
| "pullingEnough"
37+
| "pullingCancel"
38+
| "refreshing"
39+
| "rebound";
40+
41+
export interface RefreshHeaderPropType {
42+
maxHeight: number;
43+
offset: Animated.Value;
44+
}
45+
export interface RefreshHeaderStateType {
46+
status: HeaderStatus;
47+
}
48+
export class RefreshHeader extends React.Component<
49+
RefreshHeaderPropType,
50+
RefreshHeaderStateType
51+
> {}
52+
53+
export class NormalHeader extends RefreshHeader {}
54+
55+
export type FooterStatus =
56+
| "waiting"
57+
| "dragging"
58+
| "draggingEnough"
59+
| "draggingCancel"
60+
| "releaseRebound"
61+
| "loading"
62+
| "rebound"
63+
| "allLoaded";
64+
65+
export interface LoadingFooterPropType {
66+
maxHeight: number;
67+
offset: Animated.Value;
68+
bottomOffset: number;
69+
}
70+
71+
export interface LoadingFooterStateType {
72+
status: FooterStatus;
73+
}
74+
75+
export class LoadingFooter extends React.Component<
76+
LoadingFooterPropType,
77+
LoadingFooterStateType
78+
> {}
79+
80+
export class NormalFooter extends LoadingFooter {}
81+
82+
export interface NativeProps extends ViewProps {
83+
contentStyle?: ViewStyle;
84+
bounces?: boolean;
85+
scrollEnabled?: boolean;
86+
directionalLockEnabled?: boolean;
87+
initialContentOffset?: Offset;
88+
showsVerticalScrollIndicator?: boolean;
89+
showsHorizontalScrollIndicator?: boolean;
90+
refreshHeader?: React.ComponentClass<RefreshHeaderPropType, RefreshHeaderStateType>;
91+
loadingFooter?: React.ComponentClass<LoadingFooterPropType, LoadingFooterStateType>;
92+
onRefresh?: () => any;
93+
onLoading?: () => any;
94+
allLoaded?: boolean;
95+
textInputRefs?: any[];
96+
inputToolBarHeight?: number;
97+
tapToHideKeyboard?: boolean;
98+
pagingEnabled?: boolean;
99+
pageSize?: Size;
100+
dragToHideKeyboard?: boolean;
101+
onTouchBegin?: () => any;
102+
onTouchEnd?: () => any;
103+
onTouchFinish?: () => any;
104+
inverted?: boolean;
105+
onMomentumScrollBegin?: () => any;
106+
onMomentumScrollEnd?: () => any;
107+
onScroll?: (evt: ScrollEvent) => any;
108+
onNativeContentOffsetExtract?: NativeContentOffset;
109+
onSizeChange?: (size:Size) => any;
110+
onContentSizeChange?: (size: Size) => any;
111+
onScrollBeginDrag?: () => any;
112+
scrollTo(offset: Offset, animated?: boolean): Promise<void>;
113+
scroll(offset: Offset, animated?: boolean): Promise<void>;
114+
scrollToBegin(animated?: boolean): Promise<void>;
115+
scrollToEnd(animated?: boolean): Promise<void>;
116+
endRefresh(): void;
117+
endLoading(): void;
118+
beginRefresh(): Promise<any>;
119+
}
120+
121+
122+
export default codegenNativeComponent<NativeProps>(
123+
'SpringScrollView'
124+
) as HostComponent<NativeProps>;

0 commit comments

Comments
 (0)