yuzhilin
... ... @@ -28,7 +28,7 @@ struct PeopleShipHomePage {
// 总滑动空间
scroller: Scroller = new Scroller()
// 顶部透明度
@State topOpacity: number = 0
@Watch('topOpacityChange') @State topOpacity: number = 0
//发布数量
@State publishCount: number = 0
// 是否关注
... ... @@ -42,6 +42,22 @@ struct PeopleShipHomePage {
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
onPageShow(): void {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
}
onPageHide(): void {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
topOpacityChange(){
if(this.topOpacity > 0.8){
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}else{
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
}
}
build() {
if(this.isConnectNetwork){
Stack({ alignContent: Alignment.TopStart }) {
... ... @@ -50,7 +66,8 @@ struct PeopleShipHomePage {
Image($r('app.media.home_page_bg'))
.width('100%')
.height('120vp')
.objectFit(ImageFit.Fill)
.objectFit(ImageFit.Auto)
.objectRepeat(ImageRepeat.NoRepeat)
.backgroundColor(Color.White)
.visibility(this.isLoading ? Visibility.None : Visibility.Visible)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
... ...
... ... @@ -40,7 +40,9 @@ export struct PeopleShipHomePageTopComponent {
Image($r('app.media.home_page_bg'))
.width('100%')
.height('48vp')
.objectFit(ImageFit.Fill)
.objectFit(ImageFit.Auto)
.objectRepeat(ImageRepeat.NoRepeat)
.objectFit(ImageFit.Auto)
.backgroundColor(Color.White)
// 头像和名称
Row() {
... ...
... ... @@ -27,32 +27,60 @@ export class SearchShowRed {
res.push(content);
}
SearchShowRed.formatTitle(html, res, 0, textArr);
console.log('SearchShowRed-res', JSON.stringify(res))
SearchShowRed.formatTitle(
html.replaceAll('<em>', '').replaceAll('</em>', ''),
res,
0,
textArr
);
}
const titleInitRes: titleInitRes = {
titleMarked,
textArr
}
console.log('SearchShowRed-titleInitRes', JSON.stringify(titleInitRes))
return titleInitRes
}
private static formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) {
const item: string = matchArr[index];
const arr = textStr.split(item);
arr.forEach((str: string, ind: number) => {
if (!item) {
textArr.push({
content: textStr,
isRed: false
})
return;
}
const ind = textStr.indexOf(item);
const len = item.length;
if (ind === 0) {
textArr.push({
content: str.replaceAll('<em>', '').replaceAll('</em>', ''),
content: item,
isRed: true
})
SearchShowRed.formatTitle(textStr.slice(len), matchArr, index + 1, textArr);
} else if (ind + len === textStr.length) {
textArr.push({
content: textStr.slice(0, ind),
isRed: false
} as textItem)
})
textArr.push({
content: item,
isRed: true
})
} else if (ind === 1) {
SearchShowRed.formatTitle(str, matchArr, index + 1, textArr)
}
} else {
textArr.push({
content: textStr.slice(0, ind),
isRed: false
})
textArr.push({
content: item,
isRed: true
})
SearchShowRed.formatTitle(textStr.slice(ind + len), matchArr, index + 1, textArr);
}
}
}
\ No newline at end of file
... ...