Harmony开发 eTs公共样式抽取

  Harmony系统开发使用eTs开发过程中对于样式相同且重复使用的样式可以抽取成公共样式循环利用,类似于android的style样式。

import router from '@ohos.router'
import cryptoFramework from '@ohos.security.cryptoFramework';
import prompt from '@system.prompt'
class LoginBean {phone: string;pwd: string;name: string;
}
//标题
@Extend(Text) function extendTitle() {.fontSize(22).fontColor($r('app.color.primary_orange')).maxLines(1).fontWeight(FontWeight.Bold).margin({ top: 10, bottom: 40 })
}
//底部文字
@Extend(Text) function extendRight() {.fontSize(20).fontColor($r('app.color.white')).maxLines(1).fontWeight(FontWeight.Bold).margin({ bottom: 40 })
}
//item布局
@Extend(Row) function extendItemLayout() {.margin({ top: 4, bottom: 4 }).padding({ top: 4, bottom: 10 }).border({width: { bottom: 1 },color: { bottom: $r('app.color.primary_line') },// radius: { bottomRight: 80 },style: {bottom: BorderStyle.Solid} })
}@Extend(Image) function extendItemImg() {.objectFit(ImageFit.Contain).width(30).height(30)
}@Extend(TextInput) function extendItemInput(type) {.width('80%').fontSize(15).type(type).placeholderFont({ size: 15 }).placeholderColor($r('app.color.primary_gray')).caretColor($r('app.color.primary_green')).backgroundColor(Color.White)
}
// 字节流以16进制输出
function uint8ArrayToShowStr(uint8Array) {return Array.prototype.map.call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)).join('');
}function testGenerateAesKey() {// 创建对称密钥生成器let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256');// 通过密钥生成器随机生成对称密钥let promiseSymKey = symKeyGenerator.generateSymKey();promiseSymKey.then(key => {// 获取对称密钥的二进制数据,输出长度为256bit的字节流let encodedKey = key.getEncoded();console.log("213==uint8ArrayToShowStr:"+ uint8ArrayToShowStr(encodedKey.data));})
}@Entry
@Component
struct Login {@State loginBean: LoginBean = new LoginBean();private loginClick() {console.log("213==phone:" + this.loginBean.phone)console.log("213==pwd:" + this.loginBean.pwd)testGenerateAesKey()if (!this.loginBean.phone) {prompt.showToast({message: '请输入手机号'})return} else if (!this.loginBean.pwd) {prompt.showToast({message: '请输入密码'})return}// router.pushUrl({//   url: 'pages/Main'// }, router.RouterMode.Standard,//   (err) => {//   });}build() {Column() {Column() {Image($r('app.media.icon_app_label')).objectFit(ImageFit.Contain).width(60).height(60)Text($r('app.string.app_name')).extendTitle()}.width('100%').height(0).layoutWeight(1).alignItems(HorizontalAlign.Center).justifyContent(FlexAlign.End)Column() {//手机号Row() {Image($r('app.media.icon_login_phone')).objectFit(ImageFit.Contain).width(30).height(30)TextInput({ placeholder: '请输入手机号', text: 'xcxxcc1' }).extendItemInput(InputType.Normal).onChange((value: string) => {this.loginBean.phone = value})}.extendItemLayout()//密码Row() {Image($r('app.media.icon_login_pwd')).extendItemImg()TextInput({ placeholder: '请输入密码', text: ';lywg@2023' }).extendItemInput(InputType.Password).placeholderFont({ size: 14, weight: 400 }).onChange((value: string) => {this.loginBean.pwd = value})}.extendItemLayout()Row() {//登陆按钮Text('登录').backgroundColor($r("app.color.primary_green")).fontSize(18).fontColor($r("app.color.white")).borderRadius(8).margin({ top: 30 }).padding({ top: 5, bottom: 5, left: 40, right: 40 }).onClick(this.loginClick.bind(this))// .onClick(() => {})}}.borderRadius(10).margin({ left: 20, right: 20 }).padding({ top: 20, bottom: 20, left: 20, right: 20 }).backgroundColor($r('app.color.white'))Column() {Text('深化治理建设  打造数字山东').extendRight()}.width('100%').height(0).layoutWeight(1).alignItems(HorizontalAlign.Center).justifyContent(FlexAlign.End)}.width('100%').height('100%').backgroundImage($r('app.media.login_bg')).backgroundImageSize({ width: '100%', height: '100%' })}
}

在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/219264.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2018年2月16日 Go生态洞察:Go 1.10版本发布分析

🌷🍁 博主猫头虎(🐅🐾)带您 Go to New World✨🍁 🦄 博客首页——🐅🐾猫头虎的博客🎐 🐳 《面试题大全专栏》 🦕 文章图文…

【教学类-06-12】20231126 (一)如何让加减乘除题目从小到大排序(以1-20之间加法为例,做正序排列用)

结果展示 优化后 优化前 背景需求: 生成列表 单独抽取显示题目排序方法 存在问题: 我希望 00 01 02……这样排序,但是实际上,除了第一个加数会从小到大排序,第二个被加数的第十位数和个位数都会从小到大排序,也就是…

express中间件

1.中间件的格式 Express的中间件,本质上就是一个 function 处理函数,Express中间件的格式如下: 注意:中间件函数的形参列表中,必须包合 next 参数。而路由处理函数中只包含 req 和 res。 // 常量 mw 所指向的,就是一个中间件函数…

WorkPlus稳定服务助力行业千万用户,打造无界沟通协作平台

在企业移动数字化领域,WorkPlus以其十年如一日的研发实力和千万级用户案例,成为众多企业首选的移动数字化平台。究竟是什么样的力量支撑着WorkPlus在市场上占据如此重要的地位呢?接下来,让我们一起揭开WorkPlus的神秘面纱&#xf…

【精选】框架初探篇之——MyBatis的CRUD及配置文件

MyBatis增删改查 MyBatis新增 新增用户 持久层接口添加方法 void add(User user);映射文件添加标签 <insert id"add" parameterType"com.mybatis.pojo.User">insert into user(username,sex,address) values(# {username},# {sex},# {address}) <…

如何找出excel中两列数据中不同的值(IF函数的用法)

第一部分&#xff0c;举例&#xff1a; 例1&#xff1a; 如下图所示&#xff0c;A列和B列是需要比较的数据&#xff0c;C列为对比规则&#xff1a;IF(A2B2,"是","否") 示例图 例2&#xff1a;给B列的成绩评等级 C列的规则&#xff1a; IF(B2>85,&qu…

京东数据采集(京东数据运营):怎样快速获取京东市场大数据?

相信京东平台的很多品牌方们都有做数据分析的需求&#xff0c;但面对多而杂的市场数据&#xff0c;很多运营者都没有思路。单依靠肉眼来看&#xff0c;很多商品的类目、销售成绩、价格分布等运营者也未必清楚。 其实对于京东平台上市场数据的获取&#xff0c;品牌可以直接借助一…

服务号和订阅号哪个好

服务号和订阅号有什么区别&#xff1f;服务号转为订阅号有哪些作用&#xff1f;在推送频率上来看&#xff0c;服务号每月能推送四条消息&#xff0c;而订阅号可以每天&#xff08;24小时&#xff09;推送一条消息。如果企业开通公众号的目的是提供服务&#xff0c;例如售前资讯…

【从浅识到熟知Linux】基本指定之cat、more和less

&#x1f388;归属专栏&#xff1a;从浅学到熟知Linux &#x1f697;个人主页&#xff1a;Jammingpro &#x1f41f;每日一句&#xff1a;写完这篇我要去吃晚饭啦&#xff01;&#xff01; 文章前言&#xff1a;本文介绍cat、more和less指令三种查看文件的用法并给出示例和截图…

HCIA-Datacom跟官方路线学习第二部分

接着前面第六章&#xff0c;通过VLAN技术&#xff0c; 可以将物理的局域网划分成多个广播域&#xff0c; 实现同一VLAN内的网络设备可以直接进行二层通信&#xff0c; 不同VLAN内的设备不可以直接进行二层通信。 第七章 生成树 在以太网交换网络会使用冗余链路&#xff0c; 但…

为什么网上大量程序员卡35岁年龄招聘,而从来不报道测试、技术支持、售前售后工程师呢?

其实&#xff0c;网上只报道程序员卡35岁&#xff0c;这个说法并不成立。 而是普遍卡35岁&#xff0c;但并没有明确的一个职业类别。 随便搜一下&#xff0c;一眼望过去&#xff0c;其实已经波及很多行业了。 但如果你把IT从业人员合并报道&#xff0c;确实容易给人一种“程序…

【全网首发】2023年NOIP T1词典详解

目录 前言 题目详解 AC代码 结尾 前言 NOIP的第一题我终于终于过了&#xff01; 还是很激动的&#xff0c;所以想把自己的思路和想法写下来供大家参考。 题目详解 首先还没看过题的小伙伴&#xff0c;请看题&#xff1a; 一道题拿来还是得先理解题目。而这道题简单来说…