Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-09-20 17:06:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd2379a25a26e9f9c01a75b66ad2e7dcab739a32
bd2379a2
1 parent
4ed7d5b8
fix: 19347 卡片来源显示规则-来源过长时,不符合省略优先级
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
3 deletions
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
View file @
bd2379a
...
...
@@ -3,6 +3,8 @@ import { CommonConstants, CompStyle } from 'wdConstant/Index';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import router from '@ohos.router'
import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed';
import measure from '@ohos.measure'
import display from '@ohos.display';
@Reusable
@Component
...
...
@@ -20,10 +22,13 @@ export struct CardSourceInfo {
@State authorMarked: boolean = false;
@State authorArr: textItem[] = []
@State onlyShowCornerAndSource: boolean = false;
aboutToAppear(): void {
this.processText();
this.titleInit();
this.calcContentSpace();
}
titleInit() {
...
...
@@ -171,6 +176,48 @@ export struct CardSourceInfo {
return flag;
}
getContentSize(textContent: string, fontSize: number ) {
return px2vp(Number(measure.measureTextSize({
textContent,
fontSize
}).width))
}
calcContentSpace() {
if (this.isLimited()) return;
const screenWidth = px2vp(display.getDefaultDisplaySync().width)
let leftSpace = screenWidth;
const souceSize = this.getContentSize(this.displayText, 12);
const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12);
const dotSize = 11;
const timeSize = this.getContentSize(this.handleTimeStr(), 12);
const commentNum = this.getContentDtoBean()?.interactData?.commentNum
let commentSize = 0;
if (commentNum) {
commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12);
}
if (this.contentDTO.cornerMark || this.contentDTO.corner) {
leftSpace = leftSpace - cornerSize
}
if (this.showTime()) {
leftSpace = leftSpace - dotSize - timeSize
}
if (!this.isEllipsisActive) {
leftSpace = leftSpace - dotSize - commentSize
}
if (leftSpace < souceSize) {
this.onlyShowCornerAndSource = true;
}
}
build() {
Column(){
Flex({ justifyContent: FlexAlign.Start, direction: FlexDirection.Row }) {
...
...
@@ -192,6 +239,7 @@ export struct CardSourceInfo {
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
if (!this.onlyShowCornerAndSource) {
// 点
if (this.showDot()) {
...
...
@@ -232,6 +280,8 @@ export struct CardSourceInfo {
}
}
}
}
.width(CommonConstants.FULL_WIDTH)
...
...
@@ -260,6 +310,7 @@ export struct CardSourceInfo {
}
.width(CommonConstants.FULL_WIDTH)
.margin({ top: this.viewShowData ? 8 : 0 })
.clip(true)
}
...
...
@@ -268,13 +319,17 @@ export struct CardSourceInfo {
* @returns
*/
private getContentDtoBean(): ContentDTO {
let content = new ContentDTO
if (this.compDTO == undefined) {
return
this.contentDTO
content =
this.contentDTO
}
if (this.compDTO.operDataList.length == 0) {
return this.contentDTO
content = this.contentDTO
}
if (!content) {
content = this.compDTO.operDataList[0]
}
return
this.compDTO.operDataList[0]
return
content;
}
/**
...
...
Please
register
or
login
to post a comment