当前位置: 首页 > news >正文

移动版网站开发软文推广网站

移动版网站开发,软文推广网站,做网站用的软件是什么了,施工企业会计心得体会鸿蒙开发融云demo消息未读数 跟着我一步步搭建带界面的融云demo,这次是要显示未读数,未读数有两个,一个是消息列表的未读数,一个是主页消息tab上的未读数。 一、消息列表的未读数 先看下效果图: 关键代码如下&#…
鸿蒙开发融云demo消息未读数

跟着我一步步搭建带界面的融云demo,这次是要显示未读数,未读数有两个,一个是消息列表的未读数,一个是主页消息tab上的未读数。

一、消息列表的未读数

先看下效果图:

在这里插入图片描述
关键代码如下:

if (this.chatItem.unreadMessageCount > 0 || this.customUnReadCount > 0) { // 红点消息大于0条时渲染红点Row() {Text(this.chatItem.unreadMessageCount > 0?`${this.chatItem.unreadMessageCount}`:`${this.customUnReadCount}`).borderRadius($r('app.integer.layout_8')).constraintSize({minWidth: $r('app.integer.opt_layout_chat_view_red_dot_width')}).height($r('app.integer.opt_layout_chat_view_red_dot_height')).backgroundColor($r('app.color.color_red')).fontSize($r('app.integer.text_font_10')).textAlign(TextAlign.Center).fontColor(Color.White)}.alignItems(VerticalAlign.Center).justifyContent(FlexAlign.Center).borderRadius($r('app.integer.layout_10')).margin({ top: $r('app.integer.layout_minus_8'), left: $r('app.integer.layout_24') }).constraintSize({minWidth: $r('app.integer.opt_layout_chat_view_red_dot_container_width')}).height($r('app.integer.opt_layout_chat_view_red_dot_container_height')).backgroundColor(Color.White).alignRules({top: { anchor: '__container__', align: VerticalAlign.Top },left: { anchor: '__container__', align: HorizontalAlign.Start }}).opacity((this.chatItem.unreadMessageCount > 0 || this.customUnReadCount > 0) ? 1 : 0).id('badge')}
二、主页消息tab的未读数:

先看下效果图:
在这里插入图片描述
关键代码如下:

public static getPrivateUnReadCount(unreadCountCallback: (unreadCount: number) => void) {let unreadCount = 0let conTypeList = new List<ConversationType>();conTypeList.add(ConversationType.Private);let isContainBlocked = false;IMEngine.getInstance().getUnreadCountByTypes(conTypeList, isContainBlocked).then(result => {if (EngineError.Success !== result.code) {// 获取未读数失败return;}if (!result.data) {// 未读数为 nullreturn;}unreadCount = result.data as number;unreadCountCallback(unreadCount )});}
@BuilderTabBottom(item: TabItem, index: number) {Column() {// 发现在TabBottom传值改变不了,就用要显示未读数加上位置判断,用if else显示组件,这样不用算badge的size// 规则:字符串’-1‘代表的是红点,其他字符串数字为数字红点if ((isNotEmptyString(this.unreadNumHome) && index === 0) ||(isNotEmptyString(this.unreadNumMsg) && index === 1) ||(isNotEmptyString(this.unreadNumMine) && index === 2)) {Badge({value: index === 0 ? (this.unreadNumHome === '-1' ? '' : this.unreadNumHome) :index === 1 ? (this.unreadNumMsg === '-1' ? '' : this.unreadNumMsg) :(this.unreadNumMine === '-1' ? '' : this.unreadNumMine), // 设置 badge 的显示文本position: BadgePosition.RightTop, // 设置 badge 显示在右上角style: index === 0 || index === 1 ? { badgeColor: $r('app.color.color_red') } :{ badgeSize: 9, badgeColor: $r('app.color.color_red') }// 设置 badge 的显示样式,首页和消息不用限制大小,让它自适应}) {Column() {Image(this.selectedIndex === index ? item.imageActivated : item.imageOriginal).height($r('app.float.tab_image_size')).width($r('app.float.tab_image_size'))}.padding({ left: 10, right: 10, })}.margin({ top: 5, bottom: 5 })} else {Column() {Image(this.selectedIndex === index ? item.imageActivated : item.imageOriginal).height($r('app.float.tab_image_size')).width($r('app.float.tab_image_size'))}.padding({ left: 10, right: 10, }).margin({ top: 5, bottom: 5 })}Text(item.title).fontSize($r('app.float.tab_text_font_size')).fontWeight(500).fontColor(this.selectedIndex === index ? $r('app.color.color_main') : Color.White).textAlign(TextAlign.Center).margin({bottom: $r('app.float.tab_text_margin_bottom')})}.justifyContent(FlexAlign.Center).height('100%').width('100%').backgroundColor($r("app.color.color_black")).onClick(() => {this.selectedIndex = index})}
整个鸿蒙融云demo项目结构图:

在这里插入图片描述
有问题或者需要完整源码的私信我

http://www.mmbaike.com/news/36097.html

相关文章:

  • 建设网站的重要性百度地图轨迹导航
  • 湖南网站设计公司外贸网站建站
  • 淘宝网站小视频怎么做的微信推广平台自己可以做
  • 一般做企业网站需要什么资料怎么做关键词排名靠前
  • 电商网站上信息资源的特点包括哪些山西百度查关键词排名
  • 大连疫情最新情况最新消息seo网站优化怎么做
  • 建筑搜索网站推广关键词排名查询
  • 酒店网站建设策划书百度的链接
  • nginx网站301重定向怎么做chrome浏览器下载安卓手机
  • 政府网站建设 报价简述提升关键词排名的方法
  • 免费微网站怎么做聚名网官网
  • 杭州清风室内设计学校搜索引擎优化实验报告
  • 桂电做网站的毕设容易过嘛如何给企业做网络推广
  • 武汉做网站定价免费seo排名优化
  • 北京模板建站哪家好西安网站公司推广
  • 深圳短视频推广收费seo优化的作用
  • 香港网站备案号seo关键词软件
  • 苏州网站建设设计制作公司广州新一期lpr
  • 南昌专业制作网站设计谷歌账号注册入口官网
  • 怎么用WordPress搜索别人宁波优化关键词首页排名
  • 做化工的外贸网站都有什么网站seo诊断技巧
  • 佛山建设外贸网站公司吗苏州网站维护
  • 中山seo网站优化公司甘肃新站优化
  • 广州专业网站建设后台管理便捷短视频营销
  • 西樵做网站最新新闻热点事件2022
  • 网站建设技术工具网络营销整合营销
  • 在自己网站做blog全国新冠疫情最新消息
  • 珠海网站建设网络公司怎么样整站seo优化
  • 济宁网站建设招聘百度推广外推联系方式
  • 建网站卖虚拟资源需要怎么做百度推广怎么做免费