|
|
@@ -18,11 +18,17 @@ import { hilog } from '@kit.PerformanceAnalysisKit'
|
|
|
import { SelectItem } from './SelectItem'
|
|
|
import { FastForwardSecondInterface } from './FastForwardSecondInterface'
|
|
|
import { ButtonFancyModifier, ShadowModifier, SymbolGlyphFancyModifier } from '../common/util/AttributeModifierUtil'
|
|
|
+import { CustomizeICON, Icon } from '../view/CustomizeICON'
|
|
|
+import { appInfoManager } from '@kit.StoreKit'
|
|
|
|
|
|
@Preview
|
|
|
// @Entry
|
|
|
@Component
|
|
|
export struct SettingPage {
|
|
|
+ @State iconCurrentID: string = 'default';//图标的id
|
|
|
+ @State iconArray: Array<Icon> = []
|
|
|
+ @StorageProp('isLandscape') isLandscape: boolean = false;
|
|
|
+ @State isCustomizeICONSheet: boolean = false //自定义背景界面
|
|
|
@StorageProp('topSafeHeight') topSafeHeight: number = 0;
|
|
|
@State isCopyFileToDownLoad: boolean = false
|
|
|
static readonly IS_COPYFILE_TO_DOWNLOAD: string = 'isCopyFileToDownLoad';
|
|
|
@@ -272,8 +278,33 @@ export struct SettingPage {
|
|
|
let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
|
|
|
AppStorage.setOrCreate('themeColor', themeColor);
|
|
|
this.themeColor = themeColor;
|
|
|
+ this.initIcon()
|
|
|
}
|
|
|
|
|
|
+ initIcon(){
|
|
|
+ this.iconCurrentID = PreferencesUtil.getStringSync('iconCurrentID', 'default')
|
|
|
+ const iconItem:Icon = {
|
|
|
+ iconUrl: 'default',
|
|
|
+ iconId: 'default',
|
|
|
+ enabled: false
|
|
|
+ }
|
|
|
+ this.iconArray.push(iconItem)
|
|
|
+ try {
|
|
|
+ appInfoManager.queryDynamicIcons()
|
|
|
+ .then((queryResult: appInfoManager.DynamicIconInfo[]) => {
|
|
|
+ hilog.info(0, 'TAG', "Succeeded in getting queryResult= " + JSON.stringify(queryResult));
|
|
|
+ const iconList = JSON.parse(JSON.stringify(queryResult)) as Array<Icon>;
|
|
|
+ this.iconArray = this.iconArray.concat(iconList)
|
|
|
+ }).catch((error: BusinessError) => {
|
|
|
+ hilog.error(0, 'TAG', "queryDynamicIcons failed, code: " + error.code + ", exception message: " + error.message);
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ hilog.error(0, 'TAG', "queryDynamicIcons exception code: " + error.code + ", exception message: " + error.message);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 监听颜色模式变化
|
|
|
onColorModeChange(): void {
|
|
|
this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK;
|
|
|
@@ -730,6 +761,52 @@ export struct SettingPage {
|
|
|
|
|
|
Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
|
|
|
|
|
|
+
|
|
|
+ Button({ type: ButtonType.Normal, stateEffect: true }) {
|
|
|
+ Row() {
|
|
|
+ SymbolGlyph($r('sys.symbol.satellite_map'))
|
|
|
+ .fontSize(20)
|
|
|
+ .fontColor([this.themeColor])
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
+ .margin({ left: 15 })
|
|
|
+ Text('自定义图标')
|
|
|
+ .margin({ left: 8 })
|
|
|
+ .fontSize(15)
|
|
|
+ .fontColor(Color.Gray)
|
|
|
+ .fontWeight(480)
|
|
|
+ .layoutWeight(1)
|
|
|
+ .bindSheet($$this.isCustomizeICONSheet, this.customizeICONSheet(), {
|
|
|
+ height: this.isLandscape ? '95%' : '85%',
|
|
|
+ dragBar: true,
|
|
|
+ preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
|
|
|
+ showClose: true,
|
|
|
+ blurStyle: BlurStyle.Thin,
|
|
|
+ backgroundColor: Color.Transparent,
|
|
|
+ title: { title: '自定义图标' }
|
|
|
+ })
|
|
|
+
|
|
|
+ Blank()
|
|
|
+ // 右侧箭头
|
|
|
+ Image($r('app.media.arrow_right'))
|
|
|
+ .width(22)
|
|
|
+ .height(22)
|
|
|
+ .margin({ left: 20, right: 20 })
|
|
|
+ .align(Alignment.Center)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .clickEffect({level:ClickEffectLevel.HEAVY})
|
|
|
+ .height(55)
|
|
|
+ .onClick(() => {
|
|
|
+ if (!Utility.isNoble()) {
|
|
|
+ this.showVipDialog();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.isCustomizeICONSheet = !this.isCustomizeICONSheet;
|
|
|
+ })
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+
|
|
|
+ Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
|
|
|
+
|
|
|
// 滚动隐藏'
|
|
|
// Row() {
|
|
|
// Text('滚动隐藏')
|
|
|
@@ -2101,6 +2178,26 @@ export struct SettingPage {
|
|
|
.padding(0)
|
|
|
}
|
|
|
|
|
|
+ @Builder
|
|
|
+ customizeICONSheet() {
|
|
|
+ Scroll() {
|
|
|
+ Column() {
|
|
|
+ CustomizeICON({
|
|
|
+ iconIndex:this.iconCurrentID,
|
|
|
+ iconArray:this.iconArray,
|
|
|
+ onIconChange:(iconId:string,iconUrl:string)=>{
|
|
|
+ this.iconCurrentID = iconId
|
|
|
+ PreferencesUtil.put('iconCurrentID', this.iconCurrentID)
|
|
|
+ PreferencesUtil.put('iconCurrentUrl', iconUrl)
|
|
|
+ this.sendChangeEvent()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('100%')
|
|
|
+ }
|
|
|
+
|
|
|
//发送广播通知更新UI
|
|
|
sendChangeEvent() {
|
|
|
const eventData: emitter.EventData = {};
|