Skip to content

Commit

Permalink
Feature/ohos:modify Modal/PullFooter/PullHeader (Tencent#26)
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]>

* modify ViewPager/RefreshWrapper/ScrollView/WaterFlow

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

* modify Modal/PullFooter/PullHeader

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 1a98131 commit c57e209
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export class HRModalView extends HippyRenderBaseView {
immersionStatusBar: boolean = false;
darkStatusBarText: boolean = false;

handleClose() {
HRGestureDispatcher.handleClickEvent(this.ctx, this.tag, HREventUtils.EVENT_MODAL_REQUEST_CLOSE)
}

constructor(ctx: NativeRenderContext) {
super(ctx)
}
Expand Down Expand Up @@ -81,14 +77,8 @@ struct HippyDialog {
this.buildRenderView(item, null)
}, (item: HippyRenderBaseView) => item.tag + '')
}
.opacity(this.renderView.transparent == true ? 0.4 : 1)
.size({width:this.renderView.cssWidth, height: this.renderView.cssHeight})
.backgroundColor(0x55ffffff).backdropBlur(5)
.onClick((e:ClickEvent) => {
LogUtils.i(TAG, `HRModal cssWidth: ${this.renderView.cssWidth}, cssHeight: ${this.renderView.cssHeight}`);
this.renderView.handleClose()
})

.applyRenderViewBaseAttr(this.renderView)
.backgroundColor(this.renderView.transparent ? Color.Transparent : this.renderView.cssBackgroundColor)
}
}

Expand All @@ -98,9 +88,12 @@ export struct HRModal {
@ObjectLink children: HippyObservedArray<HippyRenderBaseView>
@BuilderParam buildRenderView: ($$: HippyRenderBaseView, parent: HRComponent) => void
private dialogController: CustomDialogController = {} as CustomDialogController

handleCancel(): void {
HRGestureDispatcher.handleClickEvent(this.renderView.ctx, this.renderView.tag, HREventUtils.EVENT_MODAL_REQUEST_CLOSE)
LogUtils.d(TAG, `handleCancel EVENT_MODAL_REQUEST_CLOSE`)
HREventUtils.sendComponentEvent(this.renderView.ctx, this.renderView.tag, HREventUtils.EVENT_MODAL_REQUEST_CLOSE, null)
}

aboutToAppear() {
this.dialogController = new CustomDialogController({
builder: HippyDialog({
Expand All @@ -116,15 +109,32 @@ export struct HRModal {
cancel: this.handleCancel,
});
this.dialogController.open();
HRGestureDispatcher.handleClickEvent(this.renderView.ctx, this.renderView.tag, HREventUtils.EVENT_MODAL_SHOW)

HREventUtils.sendComponentEvent(this.renderView.ctx, this.renderView.tag, HREventUtils.EVENT_MODAL_SHOW, null)
}

aboutToDisappear() {
LogUtils.d(TAG, `aboutToDisappear`)
this.dialogController.close()
}

build() {

}
}

// base props for all components
@Extend(Stack)
function applyRenderViewBaseAttr($$: HippyRenderBaseView) {
//.backgroundColor($$.cssBackgroundColor)
//.position({ x: $$.cssPositionX, y: $$.cssPositionY })
//.size({ width: $$.cssWidth, height: $$.cssHeight })
.opacity($$.cssOpacity)
.clip($$.cssOverflow)
.visibility(($$ as HippyRenderBaseView).cssVisibility) // must add as, otherwise the compiler has error
.zIndex($$.cssZIndex)
.border($$.cssBorder)
.rotate($$.cssRotate)
.scale($$.cssScale)
.translate($$.cssTranslate)
//.onClick($$.eventClick)
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export struct HRViewPager {
.vertical(this.renderView.vertical)
.prevMargin(this.renderView.prevMargin)
.nextMargin(this.renderView.nextMargin)
.loop(false)
.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 @@ -30,7 +30,7 @@ import { HRRect } from '../../utils/HRTypes';
@Observed
export class HRPullFooterView extends HippyRenderBaseView {
private readonly TAG = "HRPullFooterView"
public collapseTime: number = 1000
//public collapseTime: number = 1000
constructor(ctx: NativeRenderContext) {
super(ctx)
this.cssVisibility = Visibility.None
Expand All @@ -57,15 +57,15 @@ export class HRPullFooterView extends HippyRenderBaseView {
switch (method) {
case "collapsePullFooter":
{
setTimeout(() => {
LogUtils.d(this.TAG, "delay : " + this.collapseTime)
this.cssVisibility = Visibility.Hidden
//setTimeout(() => {
// LogUtils.d(this.TAG, "delay : " + this.collapseTime)
this.cssVisibility = Visibility.None
if (this.parentView) {
this.parentView.setProp("cssPositionX", 0);
this.parentView.setProp("cssPositionY", 0);
this.parentView.setProp("cssHeight", this.parentView.cssHeight+this.cssHeight)
}
}, this.collapseTime);
//}, this.collapseTime);
}
break;
default:
Expand Down Expand Up @@ -107,7 +107,7 @@ export struct HRPullFooter {
}, (item: HippyRenderBaseView) => item.tag + '')
}
.applyRenderViewBaseAttr(this.renderView)
.visibility(this.renderView.cssVisibility)
//.visibility(this.renderView.cssVisibility)
// .zIndex(2)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { LogUtils } from '../../../support/utils/LogUtils';
@Observed
export class HRPullHeaderView extends HippyRenderBaseView {
private readonly TAG = "HRPullHeaderView"
public collapseTime: number = 1000
private CURRENT_OFFSET: string = "contentOffset";

constructor(ctx: NativeRenderContext) {
Expand Down Expand Up @@ -61,29 +60,35 @@ export class HRPullHeaderView extends HippyRenderBaseView {
call(method: string, params: Array<HippyAny>, callback: HippyRenderCallback | null): void {
LogUtils.d(this.TAG, "call: method " + method + ", params: " + params)
switch (method) {
case "collapsePullHeader":
this.onHeadRefreshFinish()
break
case "collapsePullHeaderWithOptions":
{
let map = params[0] as HippyMap
this.collapseTime = map.get('time') as number;
let collapseTime = map.get('time') as number;
setTimeout(() => {
LogUtils.d(this.TAG, "delay : " + this.collapseTime)
this.cssVisibility = Visibility.Hidden
let params = new Map<string, Number>() as HippyMap;
params.set(this.CURRENT_OFFSET, this.cssHeight);
HREventUtils.sendComponentEvent(this.ctx, this.tag,
HREventUtils.EVENT_LIST_HEADER_PULLING, params);
if (this.parentView) {
this.parentView.setProp("cssPositionX", 0);
this.parentView.setProp("cssPositionY", 0);
}
}, this.collapseTime);
LogUtils.d(this.TAG, "delay : " + collapseTime)
// let params = new Map<string, Number>() as HippyMap;
// params.set(this.CURRENT_OFFSET, this.cssHeight);
//HREventUtils.sendComponentEvent(this.ctx, this.tag, HREventUtils.EVENT_LIST_HEADER_PULLING, params);
this.onHeadRefreshFinish()
}, collapseTime);
}
break;
default:
break;
}
}

onHeadRefreshFinish() {
this.cssVisibility = Visibility.None
if (this.parentView) {
this.parentView.setProp("cssPositionX", 0);
this.parentView.setProp("cssPositionY", 0);
}
}

setRenderViewFrame(frame: HRRect): void {
frame.x = this.cssPositionX;
frame.y = this.cssPositionY;
Expand Down

0 comments on commit c57e209

Please sign in to comment.