Skip to content

格式化代码,解决双指滚动bug #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified harmony/smart_refresh_layout.har
Binary file not shown.
3 changes: 3 additions & 0 deletions harmony/smart_refresh_layout/src/main/ets/PullToRefresh.ets
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ export struct PullToRefresh {
})
.onActionUpdate((event?: GestureEvent) => {
if (event !== undefined) {
if (event.fingerList.length !== 1){
this.touchYOld = event.offsetY;
}
this.onActionUpdate(event);
}
})
Expand Down
2 changes: 1 addition & 1 deletion harmony/smart_refresh_layout/src/main/ets/RNCAnyHeader.ets
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from 'rnoh'
import Logger from './Logger'

const TAG: string = "[RNOH] SmartRefreshLayout"
const TAG: string = "[RNOH] RNCAnyHeader"
export const ANY_HEADER_TYPE = "RNCAnyHeader"

export interface AnyHeaderProps extends ViewBaseProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from 'rnoh'
import Logger from './Logger'

const TAG: string = "[RNOH] SmartRefreshLayout"
const TAG: string = "[RNOH] RNCDefaultHeader"
export const DEFAULT_HEADER_TYPE = "RNCDefaultHeader"

export interface DefaultHeaderProps extends ViewBaseProps {
Expand All @@ -42,7 +42,7 @@ export struct RNCDefaultHeader {

aboutToAppear() {
this.descriptor = this.ctx.descriptorRegistry.getDescriptor<DefaultHeaderDescriptor>(this.tag)
Logger.info(TAG," RNCDefaultHeader: props = " + JSON.stringify(this.descriptor.props))
Logger.info(TAG,"RNCDefaultHeader: props = " + JSON.stringify(this.descriptor.props))
this.unregisterDescriptorChangesListener = this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag,
(newDescriptor) => {
this.descriptor = (newDescriptor as DefaultHeaderDescriptor)
Expand Down
19 changes: 17 additions & 2 deletions harmony/smart_refresh_layout/src/main/ets/SmartRefreshControl.ets
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Tag,
ColorSegments,
convertColorSegmentsToString,
RNScrollViewManager
RNScrollViewManager,
} from 'rnoh'
import { PullToRefresh } from './PullToRefresh'
import { PullToRefreshConfigurator } from './PullToRefreshConfigurator'
Expand Down Expand Up @@ -58,6 +58,7 @@ export struct SmartRefreshControl {
@State descriptor: SmartRefreshControlDescriptor = {} as SmartRefreshControlDescriptor
private unregisterDescriptorChangesListener?: () => void = undefined
private cleanupCommandCallback?: () => void = undefined
private unlockScrollingCallback?: () => void = undefined
private scroller: Scroller = new Scroller();
private pullToRefreshConfigurator:PullToRefreshConfigurator = new PullToRefreshConfigurator();
private finishRefresh:(value: string | PromiseLike<string>) => void = ()=>{}
Expand Down Expand Up @@ -168,6 +169,14 @@ export struct SmartRefreshControl {
}

checkHeaderMove(displayedHeaderHeight:number){
if (this.unlockScrollingCallback === undefined && displayedHeaderHeight != 0){
this.getScroller().scrollEdge(Edge.Top)
this.unlockScrollingCallback = this.getChildScrollViewComponentManager()?.lockScrolling()
}
if (this.unlockScrollingCallback !== undefined && displayedHeaderHeight == 0){
this.unlockScrollingCallback()
this.unlockScrollingCallback = undefined
}
// 下拉中
if (this.displayedHeaderHeight < displayedHeaderHeight) {
this.onHeaderPulling(displayedHeaderHeight)
Expand All @@ -177,8 +186,14 @@ export struct SmartRefreshControl {
this.displayedHeaderHeight = displayedHeaderHeight
}

// 因为子节点还没创建出来,需要延迟获取RNScrollViewManager
getChildScrollViewComponentManager():RNScrollViewManager{
let scrollViewComponentManager = this.ctx.componentManagerRegistry.getComponentManager(this.scrollViewTag) as RNScrollViewManager
return scrollViewComponentManager
}

getScroller():Scroller{
let scroller = (this.ctx.componentManagerRegistry.getComponentManager(this.scrollViewTag) as RNScrollViewManager).getScroller() as Scroller
let scroller = this.getChildScrollViewComponentManager()?.getScroller() as Scroller
if (scroller) {
return scroller
}else {
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-smartrefreshlayout",
"version": "0.6.7-0.0.8",
"name": "@react-native-oh-tpl/react-native-smartrefreshlayout",
"version": "0.6.7-0.0.9",
"description": "基于android SmartRefreshLayout的封装",
"main": "lib/commonjs/index.js",
"react-native": "src/index.tsx",
Expand All @@ -9,11 +9,16 @@
"types": "lib/typescript/src/index.d.ts",
"scripts": {
"test": "npm test",
"prepare": "bob build"
"prepare": "bob build",
"prettier": "prettier --write src"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/react-native-studio/react-native-SmartRefreshLayout.git"
"url": "https://github.com/react-native-oh-library/react-native-SmartRefreshLayout.git"
},
"keywords": [
"react",
Expand Down
26 changes: 12 additions & 14 deletions src/AnyHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import RCTAnyHeader,{NativeProps as AnyHeaderProps} from './fabric/AnyHeaderNativeComponent';
import React from 'react';
import RCTAnyHeader, {
NativeProps as AnyHeaderProps,
} from "./fabric/AnyHeaderNativeComponent";
import React from "react";

export class AnyHeader extends React.Component<AnyHeaderProps> {

render() {
return (
<RCTAnyHeader
{...this.props}
style={{height:0}}
>
{this.props.children}
</RCTAnyHeader>
)
}
render() {
return (
<RCTAnyHeader {...this.props} style={{ height: 0 }}>
{this.props.children}
</RCTAnyHeader>
);
}
}

export default AnyHeader;
export default AnyHeader;
Loading