3 分•作者: altilunium•7 个月前
返回首页
最新
2 分•作者: zhousg•7 个月前
HarmonyOS 5 新闻应用 - 新闻详情页实现案例
摘要
本文详细介绍了使用 ArkTS 语言在 HarmonyOS 5.0 新闻应用中实现新闻详情页的过程。通过定义 BarButton 和 NewDetailPage 组件,实现了新闻详情页的界面布局、状态栏颜色设置和页面导航。<p>@Component
struct BarButton {
icon: ResourceStr = ''<p><pre><code> build() {
Row() {
Image(this.icon)
.width(24)
.height(24)
.fillColor(Color.White)
}
.justifyContent(FlexAlign.Center)
.width(40)
.aspectRatio(1)
.borderRadius(22)
.backgroundColor('#45FFFFFF')
} </code></pre>
}<p>@Component
struct NewDetailPage {
news: NewsModel = {} as NewsModel<p><pre><code> async setStatusBarContentColor(color: string) {
const ctx = this.getUIContext()
.getHostContext()!
const win = await window.getLastWindow(ctx)
win.setWindowSystemBarProperties({
statusBarContentColor: color
})
}
@Builder
CustomBarBuilder() {
Row({ space: 10 }) {
BarButton({ icon: $r('sys.media.ohos_ic_public_arrow_left') })
.onClick(() => pathStack.pop())
Blank()
BarButton({ icon: $r('sys.media.ohos_ic_public_share') })
BarButton({ icon: $r('sys.media.ohos_ic_public_more') })
}
.padding(15)
.width('100%')
}
@Builder
TitleBuilder () {
Column({ space: 12 }){
Button(this.news.category)
.size({ height: 36 })
Text(this.news.title)
.fontSize(24)
.fontWeight(FontWeight.Medium)
.fontColor(Color.White)
Text() {
Span(this.news.author)
Span('·')
Span(this.news.time)
}
.fontSize(14)
.fontColor(Color.White)
}
.padding(15)
.height(300)
.width('100%')
.justifyContent(FlexAlign.End)
.alignItems(HorizontalAlign.Start)
}
@Builder
ContentBuilder () {
Column(){
Row({ space: 10 }){
Image(this.news.companyLogo)
.width(40)
.aspectRatio(1)
.borderRadius(20)
Text(this.news.company)
.fontSize(18)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height(60)
Text(`
At the newly expanded FIFA Club World Cup on
`)
.fontSize(16)
.lineHeight(24)
}
.borderRadius({ topLeft: 30, topRight: 30 })
.backgroundColor(Color.White)
.padding(15)
}
build() {
NavDestination() {
List(){
ListItem(){
this.CustomBarBuilder()
}
ListItem(){
this.TitleBuilder()
}
ListItem(){
this.ContentBuilder()
}
}
.width('100%')
.height('100%')
.layoutWeight(1)
}
.hideTitleBar(true)
.backgroundImage($r('app.media.news01'))
.backgroundImageSize({ height: '60%', width: 'auto' })
.backgroundImagePosition(Alignment.Top)
.onShown(() => this.setStatusBarContentColor('#FFFFFF'))
.onHidden(() => this.setStatusBarContentColor('#000000'))
.onReady((ctx) => {
this.news = ctx.pathInfo.param as NewsModel
})
}
}</code></pre>
2 分•作者: aatakansalar•7 个月前
这是一款工具,用于在执行前,通过启发式方法、回归分析和研究方法来估算大语言模型(LLM)API的令牌使用量和成本。它包括命令行界面(CLI)、Python API 和持续集成(CI)支持。
3 分•作者: Gys•7 个月前
5 分•作者: avatarluca•7 个月前
21 分•作者: dnetesn•7 个月前
11 分•作者: gripewater•7 个月前
2 分•作者: somafet•7 个月前
2 分•作者: mustache_kimono•7 个月前
1 分•作者: camel-cdr•7 个月前
2 分•作者: remus•7 个月前
1 分•作者: Bluestein•7 个月前
2 分•作者: ColinWright•7 个月前
2 分•作者: MxcAlex•7 个月前
1 分•作者: ColinWright•7 个月前
1 分•作者: altilunium•7 个月前
1 分•作者: bryanrasmussen•7 个月前
4 分•作者: theusus•7 个月前
我从上一家公司被裁员了,现在在一家平庸的公司。我的经理以前为所欲为,当我给他们反馈时,他们却生气了。在经历了几个月的沮丧之后,我向上一级主管报告了此事。但他们做的事情更糟。他们收集了所有人的反馈,把所有的负面评价都放在我身上。更糟糕的是,他们把这些反馈给了我的经理。
我每天都害怕被解雇。我已经找了三个月的,但还没有收到任何offer。我真的感到绝望,充满了焦虑。
非常感谢任何有用的建议。
我尝试过很多疗法,目前正在服用重药。但已经没有任何帮助了。
国家:印度
3 分•作者: Bluestein•7 个月前
1 分•作者: zspitzer•7 个月前