wangliang_wd

feat:解决冲突

... ... @@ -42,7 +42,7 @@ export struct FeedBackActivity {
@State toastText:ResourceStr = ""
// @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
dialogToast: CustomDialogController = new CustomDialogController({
... ... @@ -291,7 +291,7 @@ export struct FeedBackActivity {
.height(CommonConstants.FULL_HEIGHT)
.scrollBar(BarState.Off)
.alignSelf(ItemAlign.Start)
.padding({ bottom: 64+64 })
.padding({ bottom: 64+64+15 })
Column(){
Text($r('app.string.submit'))
.textAlign(TextAlign.Center)
... ... @@ -307,7 +307,7 @@ export struct FeedBackActivity {
}
this.reportCommit()
})
.margin({bottom:64+64})
.margin({ bottom: 64+64+15 })
}
}
}
... ...
... ... @@ -5,6 +5,7 @@ import {
EmitterUtils,
EmitterEventId,
NetworkUtil,
DisplayUtils
} from 'wdKit';
import {
Action,
... ... @@ -65,6 +66,9 @@ export struct ImageAndTextPageComponent {
@State isScrollTop: boolean = true
@State offsetY: number = 0
@State executedStartTime: number = new Date().getTime()
private screenHeight: number = 0
private topHeight: number = 32
private bottomHeight: number = 150
pageShowTime:number = 0;
pageHideTime:number = 0;
lastTimeoutId?: number
... ... @@ -160,7 +164,7 @@ export struct ImageAndTextPageComponent {
.onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
this.checkToScrollCommentArea()
})
// .onMeasureSize()
... ... @@ -206,7 +210,7 @@ export struct ImageAndTextPageComponent {
styleType: 1,
onCommentIconClick: () => {
const info = componentUtils.getRectangleById('comment');
console.log(JSON.stringify(info))
console.log(TAG, "点击滑动页面", JSON.stringify(info))
if (!this.offsetY) {
this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y
... ... @@ -229,7 +233,7 @@ export struct ImageAndTextPageComponent {
.position({y:'85%'})
.width(CommonConstants.FULL_WIDTH)
.backgroundColor(Color.White)
.height(150)
.height(this.bottomHeight)
// 发布时间
Column() {
... ... @@ -244,7 +248,7 @@ export struct ImageAndTextPageComponent {
}
}
.width(CommonConstants.FULL_WIDTH)
.height(32)
.height(this.topHeight)
.padding({ left: 15, right: 15, })
.justifyContent(FlexAlign.SpaceBetween)
.alignItems(VerticalAlign.Bottom)
... ... @@ -444,6 +448,7 @@ export struct ImageAndTextPageComponent {
aboutToAppear() {
this.getDetail()
this.screenHeight = DisplayUtils.getDeviceHeight()
//注册通知,来自别的组件的评论成功通知
EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => {
if (targetId) {
... ... @@ -451,11 +456,22 @@ export struct ImageAndTextPageComponent {
// 滚动到评论列表
if (this.info) {
// let height = DisplayUtils.getDeviceHeight() / 2
let offSetY = this.info?.globalPosition.y as number
Logger.debug(TAG, "滚动至yOffset: " + (offSetY - 100))
//评论区当前位置
let currentCommonentOffSetY = this.info?.globalPosition.y as number
//当前页面滚动的位置
let currentScrollOffSetY = this.scroller.currentOffset().yOffset
if (currentCommonentOffSetY > 0 && currentCommonentOffSetY < (this.screenHeight-this.bottomHeight)){
return
}
let offSetY = currentScrollOffSetY
if (currentCommonentOffSetY > (this.screenHeight-this.bottomHeight) ) {
offSetY = currentCommonentOffSetY-200
}else {
offSetY = currentScrollOffSetY + currentCommonentOffSetY-100
}
//头部距离48
this.scroller.scrollTo({
yOffset: offSetY - 100,
yOffset: offSetY,
xOffset: 0,
animation: { duration: 1000, curve: Curve.Ease }
})
... ...
import { CompDTO, ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { CommonConstants, CompStyle } from 'wdConstant/Index';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import router from '@ohos.router'
import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed';
... ... @@ -34,10 +34,16 @@ export struct CardSourceInfo {
}
}
private isLimited(): boolean {
return this.compDTO.compStyle === CompStyle.Card_13
|| this.compDTO.compStyle === CompStyle.Card_14
|| this.compDTO.compStyle === CompStyle.Card_06
|| this.compDTO.compStyle === CompStyle.Card_21;
}
processText() {
const sourceText = this.contentDTO?.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO?.source;
if (sourceText && (sourceText.length > this.maxLength)) {
const sourceText = this.contentDTO.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO.source;
if (this.isLimited() && sourceText.length > this.maxLength) {
this.displayText = sourceText.substring(0, this.maxLength) + '...';
this.isEllipsisActive = true;
} else {
... ...
... ... @@ -132,6 +132,9 @@ struct CommentListDialog {
inDialog: true,
dialogBeforeJumpOtherPageAction: () => {
// PublicDialogManager.shareInstance().closeLastDialog()
if (this.onClose) {
this.onClose()
}
}
})
}
... ...
... ... @@ -35,6 +35,7 @@ export struct LikeComponent {
pageParam: ParamType = {}
@Consume pageName: string
@Consume pageId: string
private dialogBeforeJumpOtherPageAction: () => void = () => {}
//上层传值 样例
// this.data['contentId'] = '30035444649' //必须
... ... @@ -403,6 +404,7 @@ export struct LikeComponent {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
console.log(TAG, '点赞点击,未登录')
if (this.dialogBeforeJumpOtherPageAction) { this.dialogBeforeJumpOtherPageAction() }
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
... ...
... ... @@ -326,7 +326,8 @@ export struct OperRowListView {
data: this.likeBean,
styleType: this.styleType,
componentType: 6,
pageComponentType: this.pageComponentType
pageComponentType: this.pageComponentType,
dialogBeforeJumpOtherPageAction: this.dialogBeforeJumpOtherPageAction
})
}
.width(48)
... ... @@ -491,6 +492,7 @@ export struct OperRowListView {
console.log(TAG, '收藏点击,登录', user_id)
if (!user_id) {
console.log(TAG, '收藏点击,用户未登录')
if (this.dialogBeforeJumpOtherPageAction) { this.dialogBeforeJumpOtherPageAction() }
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
... ... @@ -550,4 +552,4 @@ export struct OperRowListView {
console.log(TAG, 'this.publishCommentModel', JSON.stringify(this.publishCommentModel))
})
}
}
\ No newline at end of file
}
... ...
... ... @@ -19,6 +19,10 @@ export struct PlayerFullScreenView {
private timer: number = -1
@State upProVal: string = ''
@State duration: string = DateTimeUtils.secondToTime(this.videoDuration)
@State startX:number = 0
@State endX:number = 0
@State panDirection:number = 1 //1左滑 2右滑
private panDistance:number = 0
getTitle() {
return this.contentDetailData?.newsTitle
... ... @@ -65,6 +69,7 @@ export struct PlayerFullScreenView {
this.headerBuilder()
this.middleSlideBuilder()
// this.middleContainerBuilder()
this.bottomBuilder()
}
.zIndex(99999)
... ... @@ -116,7 +121,6 @@ export struct PlayerFullScreenView {
})
}
@Builder
bottomBuilder() {
... ... @@ -189,12 +193,88 @@ export struct PlayerFullScreenView {
}
@Builder
middleContainerBuilder() {
Row() {
}
.width('100%')
.height('100%')
.margin({ top: 73, bottom: 73 })
// .backgroundColor('#FF0000')
.onClick(() => {
Logger.warn(`cj2024 onClick showOperator=${this.showOperator}`)
if (!this.isDragging) {
if (this.showOperator == false) {
this.restartTimer();
} else {
this.showOperator = false
}
}
})
.gesture(
// 以下组合手势为顺序识别,当长按手势事件未正常触发时则不会触发拖动手势事件
GestureGroup(GestureMode.Sequence,
// TapGesture()
// .onAction((event?:GestureEvent) => {
// Logger.warn(`cj2024 TapGesture showOperator=${this.showOperator}`)
// if (this.showOperator == false) {
// this.restartTimer();
// } else {
// this.showOperator = false
// }
// }),
PanGesture()
.onActionStart((event?: GestureEvent) => {
if (event) {
this.startX = event.offsetX
}
Logger.warn(`cj2024 pan start`)
})
.onActionUpdate((event?: GestureEvent) => {
if (event) {
}
Logger.warn(`cj2024 pan update`)
})
.onActionEnd((event?: GestureEvent) => {
if (event) {
this.endX = event.offsetX
}
this.panDirection = this.endX - this.startX > 0 ? 2 : 1
Logger.warn(`cj2024 pan end panDirection = ${this.panDirection} this.progressVal = ${this.progressVal} dir=${this.endX - this.startX}`)
if (Math.abs(this.endX - this.startX) < 100) {
this.panDistance = 1
} else {
this.panDistance = Math.abs(this.endX - this.startX) / 100
}
if (this.panDirection == 1) { //左滑
if (this.progressVal > 5) {
this.progressVal -= this.panDistance
} else {
this.progressVal = 0
}
} else {
if (this.progressVal <100) {
this.progressVal += this.panDistance
} else {
this.progressVal = 100
}
}
Logger.warn(`cj2024 pan end panDistance = ${this.panDistance} this.progressVal = ${this.progressVal}`)
this.playerController?.setSeekTime(this.progressVal, SliderChangeMode.End);
})
)
)
}
@Builder
middleSlideBuilder() {
Column() {
Slider({
value: this.progressVal,
step: 0.01,
style: SliderStyle.OutSet
style: SliderStyle.NONE
})
.trackColor(Color.Transparent)// 设置轨道为透明
.selectedColor(Color.Transparent)// 设置已选择部分为透明
... ... @@ -211,6 +291,7 @@ export struct PlayerFullScreenView {
}
if (mode === SliderChangeMode.End) {
this.isDragging = false
this.playerController?.setSeekTime(this.progressVal, SliderChangeMode.End);
}
console.log('Transparent slider value:', value)
... ... @@ -222,8 +303,11 @@ export struct PlayerFullScreenView {
clearInterval(this.timer)
}
if (event.type === TouchType.Up) {
this.restartTimer();
this.playerController?.setSeekTime(this.progressVal, SliderChangeMode.End);
if (this.showOperator == false) {
this.restartTimer();
} else {
this.showOperator = false
}
}
}
})
... ...
... ... @@ -15,6 +15,7 @@ export struct PlayerTitleView {
@State titleHeight: number = 0
@State rmhPlatform: number = 0 // 1是人民号
@State isOverLines: boolean = false
@State isTitleOverLines: boolean = false
@State summary: string = ''
@State private titleLines: number = 0
... ... @@ -92,6 +93,41 @@ export struct PlayerTitleView {
console.log(TAG, 'clipStr:', clipStr)
return clipStr
}
/**
* 截断文本
* @param {string} str 要截断的文本 '啊啊啊啊啊'
* @param {number} fontSize 字体大小(px)
* @param {number} maxLines 最大行数 3
* @param {number} textWidth 文本宽度(px) vp 需要转换vp2px()
* @returns {string} clipStr 截断后的文本 '啊啊'
*/
clipTitleText(str: string, fontSize: number, maxLines: number, textWidth: number): string {
let strArr: string[] = str.split("")
let truncateContent: string = '啊啊啊啊啊啊' // ...比正常文字宽度更小,这里使用啊啊啊(任意三个文字)代替计算
let measureTruncateWidth: number = measure.measureText({
textContent: truncateContent,
fontSize: fontSize,
fontWeight: 600,
lineHeight: 20,
wordBreak:WordBreak.BREAK_ALL
})
let clipStr: string = ''
for (let i = 0; i < strArr.length; i++) {
if (measure.measureText({
textContent: clipStr,
fontSize: fontSize,
fontWeight: 600,
lineHeight: 20,
wordBreak:WordBreak.BREAK_ALL
}) >= textWidth * maxLines - measureTruncateWidth) {
this.isTitleOverLines = true
break;
}
clipStr += strArr[i]
}
console.log(TAG, 'clipTitleText clipStr:', clipStr)
return clipStr
}
aboutToAppear(): void {
this.rmhPlatform = this.contentDetailData?.rmhPlatform || 0
... ... @@ -136,19 +172,20 @@ export struct PlayerTitleView {
}
Text(this.getTitle())
.fontColor(Color.White)
.fontSize(15)
.maxLines(3)
.lineHeight(20)
.fontWeight(600)
.fontFamily('PingFang SC-Regular')
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ bottom: 2 }) //8
.onAreaChange((oldArea: Area, newArea: Area) => {
this.titleLines = Math.ceil((newArea.height as number) / 20) // 20是行高
this.updateSummaryLines()
})
// Text(this.getTitle())
// .fontColor(Color.White)
// .fontSize(15)
// .maxLines(4)
// .lineHeight(20)
// .fontWeight(600)
// .fontFamily('PingFang SC-Regular')
// .textOverflow({ overflow: TextOverflow.Ellipsis })
// .margin({ bottom: 2 }) //8
// .onAreaChange((oldArea: Area, newArea: Area) => {
// this.titleLines = Math.ceil((newArea.height as number) / 20) // 20是行高
// this.updateSummaryLines()
// })
this.titleBuilder()
/**
* 标题大于三行或存在简介显示查看详情按钮
*/
... ... @@ -174,7 +211,7 @@ export struct PlayerTitleView {
// })
// }
// } else {
if(this.summary) {
if(this.summary && this.titleLines < 4) {
Text() {
Span(this.clipText(this.summary, 14, this.summaryLines, this.windowWidth - 150 - vp2px(50)))
.fontSize(14)
... ... @@ -232,4 +269,51 @@ export struct PlayerTitleView {
.alignItems(HorizontalAlign.Start)
.visibility(this.isOpenDetail || this.isDragging ? Visibility.None : Visibility.Visible)
}
@Builder
titleBuilder() {
Text() {
Span(this.clipTitleText(this.getTitle(), 14, 4, this.windowWidth - 230 - vp2px(50)))
.fontSize(15)
.fontColor(Color.White)
.lineHeight(20)
.fontWeight(600)
.fontFamily('PingFang SC-Regular')
if (this.isTitleOverLines) {
Span('... 全文')
.fontColor('#888888')
.fontWeight(600)
.fontFamily('PingFang SC-Regular')
.fontSize(12)
.onClick(() => {
this.isOpenDetail = true
this.dialogController?.open()
})
ImageSpan($r('app.media.comment_unfold_svg'))
.width(14)
.height(14)
.objectFit(ImageFit.Fill)
.verticalAlign(ImageSpanAlignment.BOTTOM)
.margin({bottom:1})
// .padding({
// bottom: 4
// })
.onClick(() => {
this.isOpenDetail = true
this.dialogController?.open()
})
}
}
.onAreaChange((oldArea: Area, newArea: Area) => {
this.titleLines = Math.ceil((newArea.height as number) / 20) // 20是行高
this.updateSummaryLines()
})
.padding({
left: 0,//6
right: 6,
top: 0,//4
bottom: 4
})
}
}
... ...