From c01b4aa989125107ef3cfc73422a3981d494ea9e Mon Sep 17 00:00:00 2001 From: sfchu Date: Tue, 25 Mar 2025 15:26:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E4=B8=8E=E6=81=A2=E5=A4=8D:CodeLinter?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/BindSheet.ets | 2 +- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/view/AddPassengers.ets | 2 +- entry/src/main/ets/view/CustomCalendarPickerDialog.ets | 6 +++--- entry/src/main/ets/view/DefaultList.ets | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/entry/src/main/ets/pages/BindSheet.ets b/entry/src/main/ets/pages/BindSheet.ets index 510a7f7..4aa6b97 100644 --- a/entry/src/main/ets/pages/BindSheet.ets +++ b/entry/src/main/ets/pages/BindSheet.ets @@ -51,7 +51,7 @@ struct BindSheetDemo { bottom: $r('sys.float.corner_radius_level4'), left: $r('sys.float.corner_radius_level6') }) - }) + }, (item: string, index: number) => (item + index).toString()) } .borderRadius($r('sys.float.corner_radius_level8')) .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index ac8fb9f..d391142 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -89,7 +89,7 @@ struct Index { GridItem() { this.Options(item.title, item.url, index, this.titleList.length) } - }, (item: titleModel, index: number) => index + JSON.stringify(item)) + }, (item: titleModel) => item.title.id.toString()) } .padding($r('sys.float.padding_level8')) .height(CommonConstants.FULL_PERCENT) diff --git a/entry/src/main/ets/view/AddPassengers.ets b/entry/src/main/ets/view/AddPassengers.ets index ada1756..7422b6d 100644 --- a/entry/src/main/ets/view/AddPassengers.ets +++ b/entry/src/main/ets/view/AddPassengers.ets @@ -131,7 +131,7 @@ export struct AddPassengers { left: $r('sys.float.padding_level8'), right: $r('sys.float.padding_level8') }) - }, (item: PersonList, index: number) => index + JSON.stringify(item)) + }, (item: PersonList) => (item.name).toString()) } .height($r('app.integer.button_height')) .width(CommonConstants.FULL_PERCENT) diff --git a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets index 91d6416..d3731ac 100644 --- a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -111,7 +111,7 @@ export struct CustomCalendarPickerDialog { CommonConstants.SATURDAY ? $r('sys.color.font_emphasize') : $r('sys.color.font_primary')) } .width($r('app.string.week_width')) - }) + }, (weekInformation: string, index: number) => (weekInformation + index).toString()) } .width(CommonConstants.FULL_PERCENT) .height($r('sys.float.Subtitle_M')) @@ -192,7 +192,7 @@ export struct CustomCalendarPickerDialog { this.controller.close(); } }) - }, (day: number) => JSON.stringify(day)) + }, (day: number) => day.toString()) } .columnsTemplate(CommonConstants.GRID_SEVEN) .rowsTemplate(monthItem.days.length > CommonConstants.MONTH_NUMBER ? @@ -201,7 +201,7 @@ export struct CustomCalendarPickerDialog { CommonConstants.GRID_HEIGHT_M) } } - }, (monthItem: Month) => JSON.stringify(monthItem)) + }, (monthItem: Month) => monthItem.month.toString()) } .width(CommonConstants.FULL_PERCENT) .edgeEffect(EdgeEffect.None) diff --git a/entry/src/main/ets/view/DefaultList.ets b/entry/src/main/ets/view/DefaultList.ets index dd9ad9b..5224d3d 100644 --- a/entry/src/main/ets/view/DefaultList.ets +++ b/entry/src/main/ets/view/DefaultList.ets @@ -58,7 +58,7 @@ export struct DefaultList { Column() { ForEach(this.defaultListData, () => { this.defaultListPage() - }, (item: number, index: number) => index + JSON.stringify(item)) + }, (item: number, index: number) => (index + item).toString()) } .margin({ right: $r('sys.float.padding_level8'), -- Gitee From 3d75880c6a56ade44cedb77d4823c4a94ff5ad0a Mon Sep 17 00:00:00 2001 From: sfchu Date: Wed, 26 Mar 2025 09:54:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E5=AE=9E=E7=8E=B0=E5=A4=9A?= =?UTF-8?q?=E7=A7=8D=E8=87=AA=E5=AE=9A=E4=B9=89=E5=BC=B9=E7=AA=97=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E3=80=91HMOS=E4=B8=96=E7=95=8C=E9=9B=86?= =?UTF-8?q?=E6=88=90sample=E6=95=B4=E6=94=B9=20CodeCheck+CodeLinter?= =?UTF-8?q?=E6=89=AB=E6=8F=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 2 +- .../main/ets/entryability/EntryAbility.ets | 28 +-- entry/src/main/ets/pages/CustomCalendar.ets | 4 +- .../ets/view/CustomCalendarPickerDialog.ets | 4 +- entry/src/main/ets/viewmodel/DataManager.ets | 14 +- entry/src/main/ets/viewmodel/DateModel.ets | 2 +- entry/src/main/ets/viewmodel/GetDate.ets | 6 +- entry/src/main/module.json5 | 2 +- .../main/resources/base/element/color.json | 56 ------ .../main/resources/base/element/float.json | 176 ------------------ .../main/resources/base/element/string.json | 12 -- .../base/media/train_transport_icon.png | Bin 716 -> 0 bytes .../main/resources/en_US/element/string.json | 12 -- .../main/resources/zh_CN/element/string.json | 12 -- 14 files changed, 33 insertions(+), 297 deletions(-) delete mode 100644 entry/src/main/resources/base/media/train_transport_icon.png diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index a1a34c7..b2a3151 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -182,7 +182,7 @@ export class CommonConstants { /** * 0.3. */ - public static readonly ZERO_Three: number = 0.3; + public static readonly ZERO_THREE: number = 0.3; /** * 1.0. diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 579b04b..f717c78 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -24,18 +24,22 @@ export default class EntryAbility extends UIAbility { private curBp: string = ''; private updateBreakpoint(windowWidth: number): void { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let newBp: string = ''; - if (windowWidthVp < 600) { - newBp = 'sm'; - } else if (windowWidthVp < 840) { - newBp = 'md'; - } else { - newBp = 'lg'; - } - if (this.curBp !== newBp) { - this.curBp = newBp; - AppStorage.setOrCreate('currentBreakpoint', this.curBp); + try { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let newBp: string = ''; + if (windowWidthVp < 600) { + newBp = 'sm'; + } else if (windowWidthVp < 840) { + newBp = 'md'; + } else { + newBp = 'lg'; + } + if (this.curBp !== newBp) { + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakpoint', this.curBp); + } + } catch (error) { + hilog.error(0x0000, 'EntryAbility', 'updateBreakpoint catch err:', JSON.stringify(error) ?? ''); } } diff --git a/entry/src/main/ets/pages/CustomCalendar.ets b/entry/src/main/ets/pages/CustomCalendar.ets index 6fdad84..7e66090 100644 --- a/entry/src/main/ets/pages/CustomCalendar.ets +++ b/entry/src/main/ets/pages/CustomCalendar.ets @@ -16,7 +16,7 @@ import { CustomCalendarPickerDialog } from '../view/CustomCalendarPickerDialog'; import { CommonConstants } from '../common/constants/CommonConstants'; import { getRealTimeDate } from '../viewmodel/GetDate'; -import { DateModel } from '../viewmodel/DateModel'; +import { dateModel } from '../viewmodel/DateModel'; @Entry @Component @@ -31,7 +31,7 @@ export struct CalendarView { @State currentMonth: number = 1; @State currentDay: number = 1; @State currentYear: number = 1; - @StorageLink('selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); + @StorageLink('selectedDate') dateModel: dateModel = new dateModel(0, 0, 0, 0); aboutToAppear(): void { this.dateModel = getRealTimeDate(); diff --git a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets index d3731ac..53e1c2e 100644 --- a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -18,7 +18,7 @@ import { MonthDataSource, Month } from '../viewmodel/MonthDataSource'; import { CommonConstants } from '../common/constants/CommonConstants'; import { DataManager } from '../viewmodel/DataManager'; import { getMonthDate } from '../viewmodel/GetDate'; -import { DateModel } from '../viewmodel/DateModel'; +import { dateModel } from '../viewmodel/DateModel'; @CustomDialog export struct CustomCalendarPickerDialog { @@ -36,7 +36,7 @@ export struct CustomCalendarPickerDialog { @Link currentMonth: number; @Link currentDay: number; @Link currentYear: number; - @StorageLink('selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); + @StorageLink('selectedDate') dateModel: dateModel = new dateModel(0, 0, 0, 0); controller: CustomDialogController; cancel: () => void = () => { }; diff --git a/entry/src/main/ets/viewmodel/DataManager.ets b/entry/src/main/ets/viewmodel/DataManager.ets index 65091d6..e582719 100644 --- a/entry/src/main/ets/viewmodel/DataManager.ets +++ b/entry/src/main/ets/viewmodel/DataManager.ets @@ -13,12 +13,12 @@ * limitations under the License. */ import dataPreferences from '@ohos.data.preferences'; -import { DateModel } from './DateModel'; +import { dateModel } from './DateModel'; import { getRealTimeDate } from './GetDate'; export class DataManager { - static getDate(context: Context, callback: (dateModel: DateModel) => void) { - let dateModel: DateModel = getRealTimeDate(); + static getDate(context: Context, callback: (dateModel: dateModel) => void) { + let dateModel: dateModel = getRealTimeDate(); try { let promise = dataPreferences.getPreferences(context, 'date'); promise.then((object: dataPreferences.Preferences) => { @@ -27,7 +27,7 @@ export class DataManager { getPromise.then((data: dataPreferences.ValueType) => { let dateSting = data as string; if (dateSting.length > 0) { - dateModel = JSON.parse(dateSting) as DateModel; + dateModel = JSON.parse(dateSting) as dateModel; callback(dateModel); } else { callback(dateModel); @@ -46,7 +46,7 @@ export class DataManager { } } - static setDate(context: Context, dateModel: DateModel, callback: () => void) { + static setDate(context: Context, dateModel: dateModel, callback: () => void) { try { let promise = dataPreferences.getPreferences(context, 'date'); promise.then((object: dataPreferences.Preferences) => { @@ -55,7 +55,7 @@ export class DataManager { setPromise.then(() => { let flushPromise = object.flush(); flushPromise.then(() => { - AppStorage.setOrCreate('selectedDate', dateModel); + AppStorage.setOrCreate('selectedDate', dateModel); callback(); }).catch(() => { callback(); @@ -83,7 +83,7 @@ export class DataManager { deletePromise.then(() => { let flushPromise = object.flush(); flushPromise.then(() => { - AppStorage.setOrCreate('selectedDate', undefined); + AppStorage.setOrCreate('selectedDate', undefined); callback(); }).catch(() => { }) diff --git a/entry/src/main/ets/viewmodel/DateModel.ets b/entry/src/main/ets/viewmodel/DateModel.ets index 016166e..5fa1b7c 100644 --- a/entry/src/main/ets/viewmodel/DateModel.ets +++ b/entry/src/main/ets/viewmodel/DateModel.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -export class DateModel { +export class dateModel { public day: number; public week: number; public month: number; diff --git a/entry/src/main/ets/viewmodel/GetDate.ets b/entry/src/main/ets/viewmodel/GetDate.ets index dbd1c43..613e28d 100644 --- a/entry/src/main/ets/viewmodel/GetDate.ets +++ b/entry/src/main/ets/viewmodel/GetDate.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { DateModel } from './DateModel'; +import { dateModel } from './DateModel'; export function getMonthDate(specifiedMonth: number, specifiedYear: number): number[] { let currentFirstWeekDay: number = 0; @@ -34,13 +34,13 @@ export function getMonthDate(specifiedMonth: number, specifiedYear: number): num return currentAllDay; } -export function getRealTimeDate(): DateModel { +export function getRealTimeDate(): dateModel { const nowDate = new Date(); let currentMonth = nowDate.getMonth() + 1; let currentDay = nowDate.getDate(); let currentYear = nowDate.getFullYear(); let currentWeekDay = new Date(currentYear, currentMonth - 1, currentDay).getDay(); - let nowDateModel = new DateModel(0, 0, 0, 0); + let nowDateModel = new dateModel(0, 0, 0, 0); nowDateModel.day = currentDay; nowDateModel.week = currentWeekDay; nowDateModel.month = currentMonth; diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 087bc8f..dcae23d 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -22,7 +22,7 @@ "label": "$string:EntryAbility_label", "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", - "exported": true, + "exported": false, "skills": [ { "entities": [ diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json index 3d6aa28..3c71296 100644 --- a/entry/src/main/resources/base/element/color.json +++ b/entry/src/main/resources/base/element/color.json @@ -3,62 +3,6 @@ { "name": "start_window_background", "value": "#FFFFFF" - }, - { - "name": "color_sub_background", - "value": "#f2f3f5" - }, - { - "name": "color_warning", - "value": "#0A59F7" - }, - { - "name": "color_text_primary", - "value": "#323435" - }, - { - "name": "color_text_secondary", - "value": "#afb0b1" - }, - { - "name": "color_background", - "value": "#e4e4e4" - }, - { - "name": "shadow_color", - "value": "#ededed" - }, - { - "name": "color_border", - "value": "#cccccc" - }, - { - "name": "dialog_background", - "value": "#f5f5f5" - }, - { - "name": "color_shadow", - "value": "#aaaaaa" - }, - { - "name": "color_bind_sheet", - "value": "#333333" - }, - { - "name": "color_background_bind", - "value": "#f1f1f1" - }, - { - "name": "color_linear1", - "value": "#3366FF" - }, - { - "name": "color_linear2", - "value": "#3366CC" - }, - { - "name": "color_linear3", - "value": "#336699" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index f432c39..b5e2fd8 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -1,117 +1,9 @@ { "float": [ - { - "name": "train_image_size", - "value": "20vp" - }, - { - "name": "check_button_height", - "value": "40vp" - }, - { - "name": "card_padding", - "value": "16vp" - }, { "name": "text_height", "value": "40vp" }, - { - "name": "month_text", - "value": "240vp" - }, - { - "name": "text_size_headline", - "value": "16vp" - }, - { - "name": "text_size_body1", - "value": "14vp" - }, - { - "name": "corner_radius_default_m", - "value": "20vp" - }, - { - "name": "corner_radius_default_l", - "value": "25vp" - }, - { - "name": "button_margin", - "value": "12vp" - }, - { - "name": "column_padding", - "value": "15vp" - }, - { - "name": "border", - "value": "2vp" - }, - { - "name": "row_height", - "value": "60vp" - }, - { - "name": "shadow_radius", - "value": "100vp" - }, - { - "name": "font_size", - "value": "20fp" - }, - { - "name": "font_size1", - "value": "16fp" - }, - { - "name": "text_margin", - "value": "10vp" - }, - { - "name": "row_padding", - "value": "30vp" - }, - { - "name": "column_margin", - "value": "-30vp" - }, - { - "name": "font_size3", - "value": "18fp" - }, - { - "name": "font_size4", - "value": "35fp" - }, - { - "name": "border_radius1", - "value": "8vp" - }, - { - "name": "font_size5", - "value": "28fp" - }, - { - "name": "bind_sheet_height", - "value": "300vp" - }, - { - "name": "builder_height", - "value": "35vp" - }, - { - "name": "corner_radius", - "value": "24vp" - }, - { - "name": "button_height1", - "value": "56vp" - }, - { - "name": "dialog_height", - "value": "110vp" - }, { "name": "toast_height", "value": "36vp" @@ -120,77 +12,9 @@ "name": "calendar_height", "value": "32vp" }, - { - "name": "blank_height", - "value": "38vp" - }, - { - "name": "margin_large", - "value": "275vp" - }, - { - "name": "border_radius2", - "value": "18vp" - }, - { - "name": "toast_width", - "value": "150vp" - }, - { - "name": "bottom_margin", - "value": "90vp" - }, { "name": "offset_dy", "value": "-80vp" - }, - { - "name": "margin_top", - "value": "74vp" - }, - { - "name": "border_radius3", - "value": "32vp" - }, - { - "name": "offset_x", - "value": "-50vp" - }, - { - "name": "offset_x_l", - "value": "-150vp" - }, - { - "name": "offset_y", - "value": "-180vp" - }, - { - "name": "border_radius5", - "value": "5vp" - }, - { - "name": "width_l", - "value": "320vp" - }, - { - "name": "offset_x_m", - "value": "-160vp" - }, - { - "name": "offset_y_l", - "value": "-100vp" - }, - { - "name": "offset_20", - "value": "-20vp" - }, - { - "name": "station_card_height", - "value": "97vp" - }, - { - "name": "nav_bar_width", - "value": "97vp" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 2503107..5529991 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -28,18 +28,10 @@ "name": "departure_date", "value": "出发日期" }, - { - "name": "button_text", - "value": "仅演示,可自行实现业务功能" - }, { "name": "week_width", "value": "14.3%" }, - { - "name": "calendar_height", - "value": "90%" - }, { "name": "button_scroll_option1", "value": "TimePickerDialog 12小时制" @@ -64,10 +56,6 @@ "name": "add_person", "value": "添加乘车人" }, - { - "name": "edit", - "value": "编辑" - }, { "name": "confirmed", "value": "确认" diff --git a/entry/src/main/resources/base/media/train_transport_icon.png b/entry/src/main/resources/base/media/train_transport_icon.png deleted file mode 100644 index 44ed5a9bdbbda8701231fb067643a2f9451d03d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 716 zcmV;-0yF)IP)} zflD9*d|D*q*TwqNKz)SXrKtusEX#0N1FEu->jWMg5Rvf&^r*;n3;WA3o8{XTMGlwc zqXUgc0ascjS8&sThE-VQ$Td39s45?Vadn*`CP@P=KrZL6r7^jF-89kP6gAPIWN_L* z<0_F!?o)#=C4-yI^cy+&O@{S&K@FB|4YrqMSg?<<9y8Qn+4^=V%6%q+jwBJ(KG1R! zLG1%AClS;>&~g$%m4QWunvI%bVMwswOuvycAPfoK0j)+_=BL%~!-yb)ck5fgBrs-? zNxv@VAS^4vIFJa&okTG1B!VWu)2>Be4p{O({|iCfw{Rc(c_N3O$Ay^}JXQqMG5X}EQTBb1tGNxfn&|}b}7Lr%>@y>Yr!jJx$rjl6fi2}?;=&1pakoL_pV!a zVH>;yHIyJ`&4FfBSmDTFN`PAj8jb=UM3r#`F}V4@InX$VSHZuj_!b;=?|=aH&9$q@ z1;Kp^e{Ja6g$Mgt7v8^agqjR7_aell=oD%cz0Qt%W zl9-kY@+XqE#l|mf|nUo8X60{_Buoap% y;O3VJ@tG0NHp3o+bO-A!i{GDB@%gVQY~UB5P`|YCR^2fG0000 Date: Wed, 26 Mar 2025 13:51:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E5=AE=9E=E7=8E=B0=E5=A4=9A?= =?UTF-8?q?=E7=A7=8D=E8=87=AA=E5=AE=9A=E4=B9=89=E5=BC=B9=E7=AA=97=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E3=80=91HMOS=E4=B8=96=E7=95=8C=E9=9B=86?= =?UTF-8?q?=E6=88=90sample=E6=95=B4=E6=94=B9=20CodeCheck+CodeLinter?= =?UTF-8?q?=E6=89=AB=E6=8F=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/view/CustomCalendarPickerDialog.ets | 98 ++++++++++--------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets index 53e1c2e..caf4377 100644 --- a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -119,6 +119,58 @@ export struct CustomCalendarPickerDialog { .scrollBar(BarState.Off) } + @Builder + itemCard(monthItem: Month) { + Column() { + this.itemHead(monthItem.month) + this.itemWeek() + } + } + + @Builder + gridCard(monthItem: Month) { + Grid() { + ForEach(monthItem.days, (day: number) => { + GridItem() { + if (day === this.dateModel.day && monthItem.num === this.dateModel.month) { + Text(day.toString()) + .fontSize($r('sys.float.Subtitle_M')) + .fontColor($r('sys.color.background_primary')) + } else { + Text(day.toString()) + .fontSize($r('sys.float.Subtitle_M')) + .fontColor(day < this.currentDay && monthItem.num === + this.currentMonth ? $r('sys.color.font_tertiary') : $r('sys.color.font_primary')) + } + } + .height($r('app.float.calendar_height')) + .width($r('app.float.calendar_height')) + .borderRadius($r('sys.float.corner_radius_level2')) + .backgroundColor(day === this.dateModel.day && monthItem.num === + this.dateModel.month ? $r('sys.color.font_emphasize') : + (this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? + $r('sys.color.background_primary') : $r('sys.color.background_fourth'))) + .opacity(day === CommonConstants.ZERO ? CommonConstants.ZERO : CommonConstants.JANUARY) + .onClick(() => { + if (day >= this.currentDay || monthItem.num > this.currentMonth) { + let weekIndex = monthItem.days.indexOf(day) % CommonConstants.WEEK_NUMBER; + this.dateModel.day = day; + this.dateModel.week = weekIndex; + this.dateModel.month = monthItem.num; + DataManager.setDate(getContext(this), this.dateModel, () => { + }); + this.controller.close(); + } + }) + }, (day: number) => day.toString()) + } + .columnsTemplate(CommonConstants.GRID_SEVEN) + .rowsTemplate(monthItem.days.length > CommonConstants.MONTH_NUMBER ? + CommonConstants.GRID_SIX : CommonConstants.GRID_FIVE) + .height(monthItem.days.length > CommonConstants.MONTH_NUMBER ? CommonConstants.GRID_HEIGHT_L : + CommonConstants.GRID_HEIGHT_M) + } + build() { Column({ space: CommonConstants.ELEMENTS_MARGIN }) { Row() { @@ -151,54 +203,12 @@ export struct CustomCalendarPickerDialog { LazyForEach(this.contentData, (monthItem: Month) => { ListItemGroup() { ListItem() { - Column() { - this.itemHead(monthItem.month) - this.itemWeek() - } + this.itemCard(monthItem) } .width(CommonConstants.FULL_PERCENT) ListItem() { - Grid() { - ForEach(monthItem.days, (day: number) => { - GridItem() { - if (day === this.dateModel.day && monthItem.num === this.dateModel.month) { - Text(day.toString()) - .fontSize($r('sys.float.Subtitle_M')) - .fontColor($r('sys.color.background_primary')) - } else { - Text(day.toString()) - .fontSize($r('sys.float.Subtitle_M')) - .fontColor(day < this.currentDay && monthItem.num === - this.currentMonth ? $r('sys.color.font_tertiary') : $r('sys.color.font_primary')) - } - } - .height($r('app.float.calendar_height')) - .width($r('app.float.calendar_height')) - .borderRadius($r('sys.float.corner_radius_level2')) - .backgroundColor(day === this.dateModel.day && monthItem.num === - this.dateModel.month ? $r('sys.color.font_emphasize') : - (this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_primary') : $r('sys.color.background_fourth'))) - .opacity(day === CommonConstants.ZERO ? CommonConstants.ZERO : CommonConstants.JANUARY) - .onClick(() => { - if (day >= this.currentDay || monthItem.num > this.currentMonth) { - let weekIndex = monthItem.days.indexOf(day) % CommonConstants.WEEK_NUMBER; - this.dateModel.day = day; - this.dateModel.week = weekIndex; - this.dateModel.month = monthItem.num; - DataManager.setDate(getContext(this), this.dateModel, () => { - }); - this.controller.close(); - } - }) - }, (day: number) => day.toString()) - } - .columnsTemplate(CommonConstants.GRID_SEVEN) - .rowsTemplate(monthItem.days.length > CommonConstants.MONTH_NUMBER ? - CommonConstants.GRID_SIX : CommonConstants.GRID_FIVE) - .height(monthItem.days.length > CommonConstants.MONTH_NUMBER ? CommonConstants.GRID_HEIGHT_L : - CommonConstants.GRID_HEIGHT_M) + this.gridCard(monthItem) } } }, (monthItem: Month) => monthItem.month.toString()) -- Gitee