diff --git a/function/arkui/inspector_test/entry/src/main/ets/pages/DatePickerDialog/DatePickerDialog01.ets b/function/arkui/inspector_test/entry/src/main/ets/pages/DatePickerDialog/DatePickerDialog01.ets new file mode 100644 index 0000000000000000000000000000000000000000..08f1c549e507b05a2feb13eaab5e57a8037a20c7 --- /dev/null +++ b/function/arkui/inspector_test/entry/src/main/ets/pages/DatePickerDialog/DatePickerDialog01.ets @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@ohos.router' +@Entry +@Component +struct DatePickerDialog01 { + @State selectedDate :Date=new Date("2000-1-1") + @State isShowTimed:boolean=false + @State isUseMilitaryTime:boolean=false + @State lunarswitch:boolean=false + @State idOrKeyArray: Array> = [ + ['', ''], + ['qzq_DatePickerDialog_id', ''], + ['', 'qzq_DatePickerDialog_key'], + ['qzq_DatePickerDialog_id', 'qzq_DatePickerDialog_key'], + ]; + + build() { + Scroll(){ + Column() { + Text("DatePickerDialog") + .fontSize(18) + .margin({ top: 24 }) + Button("DatePickerDialog") + .margin(20) + .onClick(() => { + this.getUIContext().showDatePickerDialog({ + start: new Date("2000-1-1"), + end: new Date("2100-12-31"), + selected: this.selectedDate , + showTime:this.isShowTimed, + lunarSwitch:this.lunarswitch, + useMilitaryTime:this.isUseMilitaryTime, + disappearTextStyle: {color: Color.Pink, font: {size: '22fp', weight: FontWeight.Bold}}, + textStyle: {color: '#ff00ff00', font: {size: '18fp', weight: FontWeight.Normal}}, + selectedTextStyle: {color: '#ff182431', font: {size: '14fp', weight: FontWeight.Regular}}, + onDateAccept: (value: Date) => { + this.selectedDate = value + console.info("DatePickerDialog:onDateAccept()" + value.toString()) + }, + + }) + + }) + + Button('change isshowtimed') + .onClick(()=>{ + this.isShowTimed=!this.isShowTimed + }) + + Button('change isUseMilitaryTime') + .onClick(()=>{ + this.isUseMilitaryTime=!this.isUseMilitaryTime + }) + + Button('change lunarswitch') + .onClick(()=>{ + this.lunarswitch=!this.lunarswitch + }) + + Button('Back') + .onClick(()=> { + router.pushUrl({ + url: 'pages/IndexQ', + params: '' + }) + }) + + }.width('100%').height('100%').backgroundColor('#F1F3F5') + } + } +} \ No newline at end of file diff --git a/function/arkui/inspector_test/entry/src/main/ets/pages/IndexQ.ets b/function/arkui/inspector_test/entry/src/main/ets/pages/IndexQ.ets index 6152959673cde70910d170a4d767e2f9d275b296..4999676b36fc472d1aabd1f7f17b123867251bfa 100644 --- a/function/arkui/inspector_test/entry/src/main/ets/pages/IndexQ.ets +++ b/function/arkui/inspector_test/entry/src/main/ets/pages/IndexQ.ets @@ -28,7 +28,8 @@ struct IndexQ { 'Stepper/stepper03', 'Stepper/stepper04', 'Video/video01', - 'DatePickerDialog/DatePickerDialog01' + 'DatePickerDialog/DatePickerDialog01', + 'TimePickerDialog/TimePickerDialog01', ]; @State arrRight: Array = [ diff --git a/function/arkui/inspector_test/entry/src/main/ets/pages/TimePickerDialog/TimePickerDialog01.ets b/function/arkui/inspector_test/entry/src/main/ets/pages/TimePickerDialog/TimePickerDialog01.ets new file mode 100644 index 0000000000000000000000000000000000000000..b92a452dd5815328880f4811ed7091c0e9b8d425 --- /dev/null +++ b/function/arkui/inspector_test/entry/src/main/ets/pages/TimePickerDialog/TimePickerDialog01.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@ohos.router' +@Entry +@Component +struct TimePickerDialog01 { + @State selectedTime :Date=new Date("2001-12-24T08:30:00") + @State isUseMilitaryTime:boolean=false + @State idOrKeyArray: Array> = [ + ['', ''], + ['qzq_TimePickerDialog_id', ''], + ['', 'qzq_TimePickerDialog_key'], + ['qzq_TimePickerDialog_id', 'qzq_TimePickerDialog_key'], + ]; + + build() { + Scroll(){ + Column() { + Text("TimePickerDialog") + .fontSize(18) + .margin({ top: 24 }) + + Button("TimePickerDialog") + .margin(20) + .onClick(() => { + this.getUIContext().showTimePickerDialog({ + selected: this.selectedTime, + useMilitaryTime:this.isUseMilitaryTime, + disappearTextStyle: { color: Color.Red, font: { size: 15, weight: FontWeight.Lighter } }, + textStyle: { color: Color.Black, font: { size: 20, weight: FontWeight.Normal } }, + selectedTextStyle: { color: Color.Blue, font: { size: 30, weight: FontWeight.Bolder } }, + onAccept: (value: TimePickerResult) => { + if (value.hour != undefined && value.minute != undefined) { + this.selectedTime.setHours(value.hour, value.minute) + console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) + } + }, + }) + }) + Button('change isUseMilitaryTime') + .onClick(()=>{ + this.isUseMilitaryTime=!this.isUseMilitaryTime + }) + Button('Back') + .onClick(()=> { + router.pushUrl({ + url: 'pages/IndexQ', + params: '' + }) + }) + }.width('100%').height('100%').backgroundColor('#F1F3F5') + } + } +} \ No newline at end of file diff --git a/function/arkui/inspector_test/entry/src/main/resources/base/profile/main_pages.json b/function/arkui/inspector_test/entry/src/main/resources/base/profile/main_pages.json index cad8eda3b80ca7f2ef8eb988c1909786ccfd9ad8..72cd59a54b2e92414634b84063a905b9e24d53ec 100644 --- a/function/arkui/inspector_test/entry/src/main/resources/base/profile/main_pages.json +++ b/function/arkui/inspector_test/entry/src/main/resources/base/profile/main_pages.json @@ -35,6 +35,8 @@ "pages/AlertDialog/alertDialog03", "pages/AlertDialog/alertDialog04", "pages/CalendarPickerDialog/calendarPickerDialog", + "pages/DatePickerDialog/DatePickerDialog01", + "pages/TimePickerDialog/TimePickerDialog01", "pages/TextPickerDialog/textPickerDialog01", "pages/promptAction/promptAction01", "pages/promptAction/promptAction02", @@ -42,4 +44,4 @@ "pages/promptAction/promptAction04", "pages/bindMenu/bindMenu01" ] -} +} \ No newline at end of file