Skip to content

Commit

Permalink
modify modify viewpager and textinput, fix scrollview (Tencent#16)
Browse files Browse the repository at this point in the history
* complete webview

Signed-off-by: shitijun <[email protected]>

* add textinput

Signed-off-by: shitijun <[email protected]>

* modify viewpager and textinput

Signed-off-by: shitijun <[email protected]>

* fix cannot scroll

Signed-off-by: shitijun <[email protected]>

---------

Signed-off-by: shitijun <[email protected]>
  • Loading branch information
skhrogers authored and sohotz committed May 14, 2024
1 parent 0303e50 commit 2f5642f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class HRViewPagerView extends HippyRenderBaseView {
private readonly TAG = "HRViewPagerView"
public initialPage: number = 0
public index: number = 0
public disableSwipe:boolean = false
public vertical:boolean = false
public controller: SwiperController = new SwiperController()

constructor(ctx: NativeRenderContext) {
super(ctx)
}
Expand All @@ -40,6 +44,14 @@ export class HRViewPagerView extends HippyRenderBaseView {
if (propKey === 'initialPage') {
this.initialPage = propValue as number
this.index = this.initialPage
} else if (propKey === 'scrollEnabled') {
let enable = propValue as boolean
this.disableSwipe = !enable
} else if (propKey === 'direction') {
//todo: android has branch: props.containsKey("vertical")
if (propValue as string === 'vertical') {
this.vertical = true
}
}
return super.setProp(propKey, propValue as HippyAny)
}
Expand All @@ -50,6 +62,17 @@ export class HRViewPagerView extends HippyRenderBaseView {
case "setPage":
this.index = params[0] as number
break;
case "next":
this.controller.showNext()
break;
case "prev":
this.controller.showPrevious()
break;
case "setIndex":
//todo: not support para 'animated'
let map = params[0] as HippyMap
this.index = map.get('index') as number
break;
default:
break;
}
Expand All @@ -62,7 +85,7 @@ export struct HRViewPager {
@ObjectLink renderView: HRViewPagerView
@ObjectLink children: HippyObservedArray<HippyRenderBaseView>
@BuilderParam buildRenderView: ($$: HippyRenderBaseView, parent: HRComponent) => void
private controller: SwiperController = new SwiperController()

private PAGE_ITEM_POSITION: string = "position";

handleChangeEvent(index: number) {
Expand Down Expand Up @@ -104,13 +127,16 @@ export struct HRViewPager {
}

build() {
Swiper(this.controller) {
Swiper(this.renderView.controller) {
ForEach(this.children, (item: HippyRenderBaseView) => {
this.buildRenderView(item, null)
}, (item: HippyRenderBaseView) => item.tag + '')
}
.indicator(false)
.index(this.renderView.index)
.applyRenderViewBaseAttr(this.renderView)
.disableSwipe(this.renderView.disableSwipe)
.vertical(this.renderView.vertical)
.onChange((event) => this.handleChangeEvent(event))
.onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) =>
this.handleGestureSwipeEvent(index, extraInfo))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ export struct HRScroll {

build() {
Scroll(this.renderView.scroller) {
if (this.children.length > 0) {
this.buildRenderView(this.children[0], this)
Stack() {
if (this.children.length > 0) {
this.buildRenderView(this.children[0], this)
}
}
}
.applyRenderViewBaseAttr(this.renderView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export class HRTextInputView extends HippyRenderBaseView {

blurTextInput(params: Array<HippyAny>) {
//todo
this.multiline = !this.multiline
}

hideInputMethod(params: Array<HippyAny>) {
Expand Down

0 comments on commit 2f5642f

Please sign in to comment.