Delete terminalAPP/.../ets/pages/color_setting.ets

This commit is contained in:
linweijian 2024-10-20 16:09:30 +08:00
parent c72ca2f39d
commit 9f0065767b
1 changed files with 0 additions and 136 deletions

View File

@ -1,136 +0,0 @@
import promptAction from '@ohos.promptAction';
import router from '@ohos.router';
import { AppUtils } from '../common/AppUtils'
@Entry
@Component
struct Index {
fontColor: string[] = ['黑','白','黄','绿','红','橙','蓝','灰',]
@State select: number = 0
@State fontsize: number = 0;
@State themeColor: Color = AppUtils.getInstance().getThemeColor();
@State fontWeight: number = AppUtils.getInstance().getFontWeight();
onPageShow() {
// 页面显示时,获取 AppUtils 中的当前字体大小
this.fontsize = AppUtils.getInstance().getFontSize();
this.themeColor = AppUtils.getInstance().getThemeColor();
this.fontWeight = AppUtils.getInstance().getFontWeight();
}
getColor(index:number):Color{
switch (index){
case 0:
return Color.Black;
case 1:
return Color.White;
case 2:
return Color.Yellow;
case 3:
return Color.Green;
case 4:
return Color.Red;
case 5:
return Color.Orange;
case 6:
return Color.Blue;
case 7:
return Color.Grey;
default:
return Color.Black;
}
}
changeFontColor(index: number): void {
const newColor = this.getColor(index);
AppUtils.getInstance().setFontColor(newColor); // 更新 AppUtils 中的字体颜色
promptAction.showToast({
message: '您已经成功选择',
duration: 2000,
bottom: 50
});
}
build() {
Column() {
Row() {
Image($r('app.media.two'))
.width(this.fontsize)
.margin({left:'2%'})
.onClick(() => {
router.back()
promptAction.showToast({
message: '已成功返回',
duration: 2000,
bottom: 50
});
})
Text('字体颜色')
.fontWeight(this.fontWeight)
.fontSize(this.fontsize)
.fontColor(AppUtils.getInstance().getFontColor())
.onClick(() => {
router.back()
promptAction.showToast({
message: '已成功返回',
duration: 2000,
bottom: 50
});
})
}.width('100%')
.height('90')
// .justifyContent(FlexAlign.Start)
.margin({top: 20,left:40})
Row() {
Text(this.fontColor[this.select])
.fontWeight(FontWeight.Bold)
.fontSize(this.fontsize)
.fontColor(AppUtils.getInstance().getFontColor())
Button('选择样式')
.fontWeight(this.fontWeight)
.fontSize(this.fontsize)
.backgroundColor(Color.Orange)
.fontColor(Color.White)
.margin(20)
.onClick(()=>{
TextPickerDialog.show({
range:this.fontColor,
selected: this.select,
onAccept: ( value :TextPickerResult)=> {
this.select = value.index;
this.changeFontColor(this.select);
promptAction.showToast({
message:'您已经成功选择',
duration:2000,
bottom:50
})
},
onCancel:( )=>{
console.info('取消选择')
},
onChange :() => {
console.info('')
}
})
})
}.width('100%')
.height('30%')
.justifyContent(FlexAlign.Center)
}.width('100%')
.height('100%')
.backgroundColor(this.themeColor);
}
}