diff --git a/harmony/datetimepicker.har b/harmony/datetimepicker.har
new file mode 100644
index 00000000..3ffad823
Binary files /dev/null and b/harmony/datetimepicker.har differ
diff --git a/harmony/datetimepicker/.gitignore b/harmony/datetimepicker/.gitignore
new file mode 100644
index 00000000..e2713a27
--- /dev/null
+++ b/harmony/datetimepicker/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/harmony/datetimepicker/LICENSE b/harmony/datetimepicker/LICENSE
new file mode 100644
index 00000000..c5c85db4
--- /dev/null
+++ b/harmony/datetimepicker/LICENSE
@@ -0,0 +1,21 @@
+ MIT License
+
+ Copyright (C) 2023 Huawei Device Co., Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
diff --git a/harmony/datetimepicker/OAT.xml b/harmony/datetimepicker/OAT.xml
new file mode 100644
index 00000000..bf636592
--- /dev/null
+++ b/harmony/datetimepicker/OAT.xml
@@ -0,0 +1,38 @@
+
+
+
+ LICENSE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/harmony/datetimepicker/README.OpenSource b/harmony/datetimepicker/README.OpenSource
new file mode 100644
index 00000000..6a6dfa0b
--- /dev/null
+++ b/harmony/datetimepicker/README.OpenSource
@@ -0,0 +1,11 @@
+[
+ {
+ "Name": "datetimepicker",
+ "License": "MIT License",
+ "License File": "https://github.com/react-native-datetimepicker/datetimepicker/blob/master/LICENSE.md",
+ "Version Number": "7.6.2",
+ "Owner" : "Martijn Swaagman "
+ "Upstream URL": "https://github.com/react-native-datetimepicker/datetimepicker",
+ "Description": "datetimepicker, React Native date & time picker component."
+ }
+]
\ No newline at end of file
diff --git a/harmony/datetimepicker/README.md b/harmony/datetimepicker/README.md
new file mode 100644
index 00000000..a7db105d
--- /dev/null
+++ b/harmony/datetimepicker/README.md
@@ -0,0 +1,262 @@
+> 模板版本:v0.0.1
+
+
+
+## 安装与使用
+
+进入到工程目录并输入以下命令:
+
+
+
+**正在 npm 发布中,当前请先从仓库[Release](https://github.com/react-native-oh-library/datetimepicker/releases)中获取库 tgz,通过使用本地依赖来安装本库。**
+
+#### **yarn**
+
+```bash
+yarn add xxx
+```
+
+#### **npm**
+
+```bash
+npm install xxx
+```
+
+
+
+下面的代码展示了这个库的基本使用场景:
+
+```js
+import DateTimePicker from '@react-native-community/datetimepicker';
+
+export const App = () => {
+ const [date, setDate] = useState(new Date(1598051730000));
+ const [mode, setMode] = useState('date');
+ const [show, setShow] = useState(false);
+
+ const onChange = (event, selectedDate) => {
+ const currentDate = selectedDate;
+ setShow(false);
+ setDate(currentDate);
+ };
+
+ const showMode = (currentMode) => {
+ setShow(true);
+ setMode(currentMode);
+ };
+
+ const showDatepicker = () => {
+ showMode('date');
+ };
+
+ const showTimepicker = () => {
+ showMode('time');
+ };
+
+ return (
+
+
+
+ selected: {date.toLocaleString()}
+ {show && (
+
+ )}
+
+ );
+};
+```
+
+## Link
+
+目前鸿蒙暂不支持 AutoLink,所以 Link 步骤需要手动配置。
+
+首先需要使用 DevEco Studio 打开项目里的鸿蒙工程 `harmony`
+
+### 引入原生端代码
+
+目前有两种方法:
+
+1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
+2. 直接链接源码。
+
+方法一:通过 har 包引入
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "rnoh": "file:../rnoh",
+ "rnoh-datetimepicker": "file:../../node_modules/@react-native-community/datetimepicker/harmony/datetimepicker.har"
+ }
+```
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+方法二:直接链接源码
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "rnoh": "file:../rnoh",
+ "rnoh-datetimepicker": "file:../../node_modules/@react-native-community/datetimepicker/harmony/datetimepicker"
+ }
+```
+
+打开终端,执行:
+
+```bash
+cd entry
+ohpm install --no-link
+```
+
+### 配置 CMakeLists 和引入 datetimepicker
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
+
+```diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
+
+# RNOH_BEGIN: add_package_subdirectories
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
++ add_subdirectory("${OH_MODULE_DIR}/rnoh-datetimepicker/src/main/cpp" ./datetimepicker)
+# RNOH_END: add_package_subdirectories
+
+add_library(rnoh_app SHARED
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
+
+# RNOH_BEGIN: link_packages
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
++ target_link_libraries(rnoh_app PUBLIC rnoh_datetime_picker)
+# RNOH_END: link_packages
+```
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "SamplePackage.h"
++ #include "DateTimePickerPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+}
+```
+
+### 在 ArkTs 侧引入 DateTimePicker 组件
+
+打开 `entry/src/main/ets/pages/index.ets`,添加:
+
+```diff
+import {
+ RNApp,
+ ComponentBuilderContext,
+ RNAbility,
+ AnyJSBundleProvider,
+ MetroJSBundleProvider,
+ ResourceJSBundleProvider,
+} from 'rnoh'
+import { SampleView, SAMPLE_VIEW_TYPE, PropsDisplayer } from "rnoh-sample-package"
+import { createRNPackages } from '../RNPackagesFactory'
++ import { RNDateTimePicker, DATETIME_PICKER_VIEW_TYPE } from "rnoh-datetimepicker"
+
+@Builder
+function CustomComponentBuilder(ctx: ComponentBuilderContext) {
+ if (ctx.descriptor.type === SAMPLE_VIEW_TYPE) {
+ SampleView({
+ ctx: ctx.rnohContext,
+ tag: ctx.descriptor.tag,
+ buildCustomComponent: CustomComponentBuilder
+ })
+ }
++ else if (ctx.descriptor.type === DATETIME_PICKER_VIEW_TYPE) {
++ RNDateTimePicker({
++ ctx: ctx.rnohContext,
++ tag: ctx.descriptor.tag,
++ buildCustomComponent: CustomComponentBuilder
++ })
++ }
+ ...
+}
+...
+```
+
+### 运行
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+然后编译、运行即可。
+
+## 兼容性
+
+要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
+
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[<@react-native-oh-library/datetimepicker> Releases](https://github.com/react-native-oh-library/datetimepicker/releases/tag/7.6.2-0.0.2)
+
+## 属性
+
+| 名称 | 说明 | 类型 | 是否必填 | 原库平台 | 鸿蒙支持 |
+| ----------- | ------------------------------------------------------------------------- | -------- | -------- | ------------------------ | ---------------------------------------------------------- |
+| mode | Defines the type of the picker | string | 否 | All | partially (仅支持 date/time 模式) |
+| style | Sets style directly on picker component. | object | 否 | IOS only | yes |
+| display | Defines the visual display of the picker. The default value is "default". | string | 否 | All | partially (支持"default","spinner","compact","inline") |
+| onChange | Date change handler. | function | 否 | All | partially (仅支持 type 为 set 类型) |
+| value | Defines the date or time value used in the component. | Date | 是 | All | partially (仅 mode=date 且 display=spinner 时支持动态设置) |
+| is24Hour | Allows changing of the time picker to a 24-hour format. | bool | 否 | Windows and Android only | yes |
+| maximumDate | Defines the maximum date that can be selected | Date | 否 | All | partially (仅支持在 mode=date 且 display=spinner 时设置) |
+| minimumDate | Defines the minimum date that can be selected. | Date | 否 | All | partially (仅支持在 mode=date 且 display=spinner 时设置) |
+| disabled | If true, the user won't be able to interact with the view. | bool | 否 | IOS only | yes |
+| textColor | Allows changing of the textColor of the date picker. | string | 否 | IOS only | partially (仅支持在 mode=date 且 display=compact 时设置) |
+
+## 遗留问题
+
+- [ ] 部分接口,未适配
+
+## 其他
+
+## 开源协议
+
+本项目基于 [The MIT License (MIT)](https://github.com/react-native-oh-library/datetimepicker/blob/harmony/LICENSE) ,请自由地享受和参与开源。
diff --git a/harmony/datetimepicker/build-profile.json5 b/harmony/datetimepicker/build-profile.json5
new file mode 100644
index 00000000..eae947d4
--- /dev/null
+++ b/harmony/datetimepicker/build-profile.json5
@@ -0,0 +1,10 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "targets": [
+ {
+ "name": "default",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/harmony/datetimepicker/hvigorfile.ts b/harmony/datetimepicker/hvigorfile.ts
new file mode 100644
index 00000000..b4b93187
--- /dev/null
+++ b/harmony/datetimepicker/hvigorfile.ts
@@ -0,0 +1,25 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANT KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+export { harTasks } from '@ohos/hvigor-ohos-plugin';
diff --git a/harmony/datetimepicker/index.ets b/harmony/datetimepicker/index.ets
new file mode 100644
index 00000000..e8972514
--- /dev/null
+++ b/harmony/datetimepicker/index.ets
@@ -0,0 +1,24 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+export * from './src/main/ets/RNDateTimePicker'
\ No newline at end of file
diff --git a/harmony/datetimepicker/oh-package.json5 b/harmony/datetimepicker/oh-package.json5
new file mode 100644
index 00000000..aac50786
--- /dev/null
+++ b/harmony/datetimepicker/oh-package.json5
@@ -0,0 +1,13 @@
+{
+ "license": "ISC",
+ "types": "",
+ "devDependencies": {
+ "rnoh": "file:../rnoh"
+ },
+ "name": "rnoh-date-time-picker",
+ "description": "date-time-picker in harmony",
+ "main": "index.ets",
+ "version": "0.0.1",
+ "dependencies": {}
+}
+
diff --git a/harmony/datetimepicker/src/main/cpp/CMakeLists.txt b/harmony/datetimepicker/src/main/cpp/CMakeLists.txt
new file mode 100644
index 00000000..6a06095a
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.13)
+set(CMAKE_VERBOSE_MAKEFILE on)
+
+file(GLOB rnoh_datetime_picker_SRC CONFIGURE_DEPENDS *.cpp)
+add_library(rnoh_datetime_picker SHARED ${rnoh_datetime_picker_SRC})
+target_include_directories(rnoh_datetime_picker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(rnoh_datetime_picker PUBLIC rnoh)
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/ComponentDescriptors.h b/harmony/datetimepicker/src/main/cpp/ComponentDescriptors.h
new file mode 100644
index 00000000..b1f77594
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/ComponentDescriptors.h
@@ -0,0 +1,37 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_C_TRS_H
+#define HEADER_FILE_CPP_C_TRS_H
+
+#include "ShadowNodes.h"
+#include
+
+namespace facebook{
+namespace react{
+using RNDateTimePickerComponentDescriptor = ConcreteComponentDescriptor;
+
+} //namespace react
+} //namespace facebook
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/DateTimePickerEventEmitRequestHandler.h b/harmony/datetimepicker/src/main/cpp/DateTimePickerEventEmitRequestHandler.h
new file mode 100644
index 00000000..af1a0ef6
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/DateTimePickerEventEmitRequestHandler.h
@@ -0,0 +1,86 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_D_LER_H
+#define HEADER_FILE_CPP_D_LER_H
+
+#include
+#include
+#include "RNOH/ArkJS.h"
+#include "RNOH/EventEmitRequestHandler.h"
+#include "EventEmitters.h"
+
+using namespace facebook;
+namespace rnoh {
+
+enum DateEventType {
+ DATETIME_CHANGE = 0,
+ DATETIME_PICKERDISMISS = 1
+};
+
+DateEventType getDateEventType(ArkJS &arkJs,napi_value eventObject)
+{
+ auto eventType = arkJs.getString(arkJs.getObjectProperty(eventObject,"type"));
+ if(eventType == "onChange"){
+ return DateEventType::DATETIME_CHANGE;
+ }else if(eventType == "onPickerDismiss"){
+ return DateEventType::DATETIME_PICKERDISMISS;
+ }else {
+ throw std::runtime_error("Unknown Page event type");
+ }
+}
+
+class DateTimePickerEventEmitRequestHandler : public EventEmitRequestHandler{
+ public:
+ void handleEvent(EventEmitRequestHandler::Context const &ctx) override
+ {
+ if(ctx.eventName != "RNDateTimePicker"){
+ return;
+ }
+ ArkJS arkJs(ctx.env);
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter(ctx.tag);
+ if(eventEmitter == nullptr){
+ return;
+ }
+ switch (getDateEventType(arkJs,ctx.payload)){
+ case DateEventType::DATETIME_CHANGE:{
+ double positionIn = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload,"timestamp"));
+ double offsetIn = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload,"utcOffset"));
+ react::RNDateTimePickerEventEmitter::OnChange event = {.timestamp=positionIn, .utcOffset=(int)offsetIn};
+ eventEmitter->onChange(event);
+ break;
+ }
+ case DateEventType::DATETIME_PICKERDISMISS:{
+ react::RNDateTimePickerEventEmitter::OnPickerDismiss event={};
+ eventEmitter->onPickerDismiss(event);
+ break;
+ }
+ default:
+ break;
+ }
+ };
+};
+} // namespace rnoh
+#endif
+
diff --git a/harmony/datetimepicker/src/main/cpp/DateTimePickerJSIBinder.h b/harmony/datetimepicker/src/main/cpp/DateTimePickerJSIBinder.h
new file mode 100644
index 00000000..567fc2e9
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/DateTimePickerJSIBinder.h
@@ -0,0 +1,73 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_D_J_DER_H
+#define HEADER_FILE_D_J_DER_H
+
+#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
+
+namespace rnoh{
+class DateTimePickerJSIBinder : public ViewComponentJSIBinder {
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
+ {
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
+ object.setProperty(rt,"maximumDate","string");
+ object.setProperty(rt,"minimumDate","string");
+// object.setProperty(rt,"date","double"); ////luoxf
+ object.setProperty(rt,"date","string");////luoxf
+ object.setProperty(rt,"locale","string");
+ object.setProperty(rt,"minuteInterval","number");
+
+ object.setProperty(rt,"mode","string");//枚举
+ object.setProperty(rt,"timeZoneOffsetInMinutes","number");
+ object.setProperty(rt,"timeZoneName","string");
+ object.setProperty(rt,"textColor","string");//SharedColor
+ object.setProperty(rt,"accentColor","string");//SharedColor
+
+ object.setProperty(rt,"themeVariant","string");//枚举
+ object.setProperty(rt,"displayIOS","string");//枚举
+ object.setProperty(rt,"enabled","boolean");
+ object.setProperty(rt,"is24Hour","boolean");
+
+ return object;
+ }
+
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
+ {
+ // LOG(INFO) << "RNOH datetimepicker:createBubblingEventTypes";
+ facebook::jsi::Object events(rt);
+ events.setProperty(rt,"topChange",createBubblingCapturedEvent(rt,"onChange"));
+ events.setProperty(rt,"topPickerDismiss",createBubblingCapturedEvent(rt,"onPickerDismiss"));
+ return events;
+ }
+
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
+ {
+ facebook::jsi::Object events(rt);
+ //createDirectEvent
+ return events;
+ }
+};
+}// namespace rnoh
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/DateTimePickerNapiBinder.h b/harmony/datetimepicker/src/main/cpp/DateTimePickerNapiBinder.h
new file mode 100644
index 00000000..e648f058
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/DateTimePickerNapiBinder.h
@@ -0,0 +1,73 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_D_N_DER_H
+#define HEADER_FILE_CPP_D_N_DER_H
+
+#include "RNOHCorePackage/ComponentBinders/ViewComponentNapiBinder.h"
+#include "Props.h"
+#include "States.h"
+#include
+namespace rnoh{
+
+class DateTimePickerNapiBinder : public ViewComponentNapiBinder {
+public:
+ std::string toDateStr(int64_t date){
+ std::stringstream ss;
+ std::string strRes;
+ ss << date;
+ ss >> strRes;
+ return strRes;
+ }
+ napi_value createProps(napi_env env, facebook::react::ShadowView const shadowView) override
+ {
+ napi_value napiViewProps = ViewComponentNapiBinder::createProps(env,shadowView);
+ if(auto props = std::dynamic_pointer_cast(shadowView.props) ){
+
+ return ArkJS(env)
+ .getObjectBuilder(napiViewProps)
+ .addProperty("maximumDate", toDateStr(props->maximumDate))
+ .addProperty("minimumDate", toDateStr(props->minimumDate))
+// .addProperty("date", props->date)
+// .addProperty("date", "stringluoxf:100000")
+ .addProperty("date", toDateStr(props->date))
+ .addProperty("locale",props->locale)
+ .addProperty("minuteInterval",props->minuteInterval)
+ .addProperty("mode",props->mode)
+ .addProperty("timeZoneOffsetInMinutes",props->timeZoneOffsetInMinutes)
+ .addProperty("textColor",props->textColor)
+ .addProperty("accentColor",props->accentColor)
+
+ .addProperty("themeVariant",props->themeVariant)
+ .addProperty("displayIOS",props->displayIOS)
+ .addProperty("enabled",props->enabled)
+ .addProperty("is24Hour",props->is24Hour)
+ .build();
+ }
+ return napiViewProps;
+ };
+};
+
+}// namespace rnoh
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/DateTimePickerPackage.h b/harmony/datetimepicker/src/main/cpp/DateTimePickerPackage.h
new file mode 100644
index 00000000..8da28eb2
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/DateTimePickerPackage.h
@@ -0,0 +1,66 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HARMONY_DATETIME_SRC_MAIN_CPP_D_P_AGE_H
+#define HARMONY_DATETIME_SRC_MAIN_CPP_D_P_AGE_H
+
+#include "RNOH/Package.h"
+#include "ComponentDescriptors.h"
+#include "DateTimePickerJSIBinder.h"
+#include "DateTimePickerNapiBinder.h"
+#include "DateTimePickerEventEmitRequestHandler.h"
+
+
+using namespace rnoh;
+using namespace facebook;
+namespace rnoh {
+
+class DateTimePickerPackage : public Package {
+ public:
+ DateTimePickerPackage(Package::Context ctx) : Package(ctx){}
+
+ std::vector createComponentDescriptorProviders() override
+ {
+ return {
+ facebook::react::concreteComponentDescriptorProvider(),
+ };
+ }
+
+ ComponentJSIBinderByString createComponentJSIBinderByName() override
+ {
+ return {{"RNDateTimePicker", std::make_shared()}};
+ };
+
+ ComponentNapiBinderByString createComponentNapiBinderByName() override
+ {
+ return {{"RNDateTimePicker", std::make_shared()}};
+ };
+
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override
+ {
+ return {std::make_shared()};
+ }
+};
+} //namespace rnoh
+#endif
diff --git a/harmony/datetimepicker/src/main/cpp/EventEmitters.cpp b/harmony/datetimepicker/src/main/cpp/EventEmitters.cpp
new file mode 100644
index 00000000..e461d0f5
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/EventEmitters.cpp
@@ -0,0 +1,46 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "EventEmitters.h"
+
+namespace facebook{
+ namespace react {
+
+void RNDateTimePickerEventEmitter::onChange(OnChange event) const {
+ dispatchEvent("change",[event=std::move(event)](jsi::Runtime &runtime){
+ auto payload = jsi::Object(runtime);
+ payload.setProperty(runtime,"timestamp",event.timestamp);
+ payload.setProperty(runtime,"utcOffset",event.utcOffset);
+ return payload;
+ });
+}
+void RNDateTimePickerEventEmitter::onPickerDismiss(OnPickerDismiss event) const{
+ dispatchEvent("pickerDismiss",[event=std::move(event)](jsi::Runtime &runtime) {
+ auto payload = jsi::Object(runtime);
+ return payload;
+ });
+}
+
+ } //namespace react
+} //namespace facebook
diff --git a/harmony/datetimepicker/src/main/cpp/EventEmitters.h b/harmony/datetimepicker/src/main/cpp/EventEmitters.h
new file mode 100644
index 00000000..1c725b82
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/EventEmitters.h
@@ -0,0 +1,54 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_E_E_ERS_H
+#define HEADER_FILE_CPP_E_E_ERS_H
+
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+class JSI_EXPORT RNDateTimePickerEventEmitter : public ViewEventEmitter {
+public:
+ using ViewEventEmitter::ViewEventEmitter;
+
+ struct OnChange {
+ double timestamp;
+ int utcOffset;
+ };
+
+ struct OnPickerDismiss {
+
+ };
+
+ void onChange(OnChange value) const;
+
+ void onPickerDismiss(OnPickerDismiss value) const;
+};
+
+} // namespace react
+} // namespace facebook
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/Props.cpp b/harmony/datetimepicker/src/main/cpp/Props.cpp
new file mode 100644
index 00000000..9c51c79f
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/Props.cpp
@@ -0,0 +1,54 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "Props.h"
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+RNDateTimePickerProps::RNDateTimePickerProps(
+ const PropsParserContext &context,
+ const RNDateTimePickerProps &sourceProps,
+ const RawProps &rawProps): ViewProps(context,sourceProps,rawProps),
+
+ maximumDate(convertRawProp(context,rawProps,"maximumDate",sourceProps.maximumDate,{0})),
+ minimumDate(convertRawProp(context,rawProps,"minimumDate",sourceProps.minimumDate,{0})),
+ date(convertRawProp(context,rawProps,"date",sourceProps.date, {0})),
+ locale(convertRawProp(context,rawProps,"locale",sourceProps.locale,{})),
+ minuteInterval(convertRawProp(context,rawProps,"minuteInterval",sourceProps.minuteInterval,{0})),
+ mode(convertRawProp(context,rawProps,"mode",sourceProps.mode,{"date"})),
+ timeZoneOffsetInMinutes(convertRawProp(context,rawProps,"timeZoneOffsetInMinutes",sourceProps.timeZoneOffsetInMinutes,{0.0})),
+ timeZoneName(convertRawProp(context,rawProps,"timeZoneName",sourceProps.timeZoneName,{})),
+ textColor(convertRawProp(context,rawProps,"textColor",sourceProps.textColor,{})),
+ accentColor(convertRawProp(context,rawProps,"accentColor",sourceProps.accentColor,{})),
+ themeVariant(convertRawProp(context,rawProps,"themeVariant",sourceProps.themeVariant,{"unspecified"})),
+ displayIOS(convertRawProp(context,rawProps,"displayIOS",sourceProps.displayIOS,{"default"})),
+ is24Hour(convertRawProp(context,rawProps,"is24Hour",sourceProps.is24Hour,{true})),
+ enabled(convertRawProp(context,rawProps,"enabled",sourceProps.enabled,{true}))
+ {}
+
+} // namespace react
+} // namespace facebook
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/Props.h b/harmony/datetimepicker/src/main/cpp/Props.h
new file mode 100644
index 00000000..8b5f6422
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/Props.h
@@ -0,0 +1,118 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_P_OPS_H
+#define HEADER_FILE_CPP_P_OPS_H
+
+#include
+#include
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+enum class RNDateTimePickerMode { Date, Time, Datetime, Countdown};
+
+static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNDateTimePickerMode &result) {
+ auto string = (std::string)value;
+ if(string == "date") { result = RNDateTimePickerMode::Date; return;}
+ if(string == "time") { result = RNDateTimePickerMode::Time; return;}
+ if(string == "datetime") { result = RNDateTimePickerMode::Datetime; return;}
+ if(string == "countdown") { result = RNDateTimePickerMode::Countdown; return; }
+ abort();
+}
+
+static inline std::string toString(const RNDateTimePickerMode &value){
+ switch (value) {
+ case RNDateTimePickerMode::Date: return "date";
+ case RNDateTimePickerMode::Time: return "time";
+ case RNDateTimePickerMode::Datetime: return "datetime";
+ case RNDateTimePickerMode::Countdown: return "countdown";
+ }
+}
+
+enum class RNDateTimePickerThemeVariant { Dark, Light, Unspecified};
+
+static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNDateTimePickerThemeVariant &result) {
+ auto string = (std::string)value;
+ if(string == "dark") { result = RNDateTimePickerThemeVariant::Dark; return;}
+ if(string == "light") { result = RNDateTimePickerThemeVariant::Light; return;}
+ if(string == "unspecified") { result = RNDateTimePickerThemeVariant::Unspecified; return; }
+ abort();
+}
+
+static inline std::string toString(const RNDateTimePickerThemeVariant &value){
+ switch (value) {
+ case RNDateTimePickerThemeVariant::Dark: return "dark";
+ case RNDateTimePickerThemeVariant::Light: return "light";
+ case RNDateTimePickerThemeVariant::Unspecified: return "unspecified";
+ }
+}
+enum class RNDateTimePickerDisplayIOS { Default, Spinner, Compact, Inline};
+
+static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNDateTimePickerDisplayIOS &result) {
+ auto string = (std::string)value;
+ if(string == "default") { result = RNDateTimePickerDisplayIOS::Default; return;}
+ if(string == "spinner") { result = RNDateTimePickerDisplayIOS::Spinner; return;}
+ if(string == "compact") { result = RNDateTimePickerDisplayIOS::Compact; return; }
+ if(string == "inline") { result = RNDateTimePickerDisplayIOS::Inline; return; }
+ abort();
+}
+
+static inline std::string toString(const RNDateTimePickerDisplayIOS &value){
+ switch (value) {
+ case RNDateTimePickerDisplayIOS::Default: return "default";
+ case RNDateTimePickerDisplayIOS::Spinner: return "spinner";
+ case RNDateTimePickerDisplayIOS::Compact: return "compact";
+ case RNDateTimePickerDisplayIOS::Inline: return "inline";
+ }
+}
+
+class JSI_EXPORT RNDateTimePickerProps final : public ViewProps {
+ public:
+ RNDateTimePickerProps() = default;
+ RNDateTimePickerProps(const PropsParserContext& context, const RNDateTimePickerProps &sourceProps, const RawProps &rawProps);
+
+#pragma mark - Props
+
+ int64_t maximumDate{0};
+ int64_t minimumDate{0};
+ int64_t date{0};
+ std::string locale{};
+ int minuteInterval{0};
+ std::string mode{ toString(RNDateTimePickerMode::Date)};
+ facebook::react::Float timeZoneOffsetInMinutes{0.0};
+ std::string timeZoneName{};
+ std::string textColor{};
+ std::string accentColor{};
+ std::string themeVariant{toString(RNDateTimePickerThemeVariant::Unspecified)};
+ std::string displayIOS{toString(RNDateTimePickerDisplayIOS::Default)};
+ bool enabled{true};
+ bool is24Hour{true};
+};
+
+} // namespace react
+} // namespace facebook
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/ShadowNodes.cpp b/harmony/datetimepicker/src/main/cpp/ShadowNodes.cpp
new file mode 100644
index 00000000..684c4940
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/ShadowNodes.cpp
@@ -0,0 +1,33 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "ShadowNodes.h"
+
+namespace facebook {
+namespace react {
+
+ extern const char RNDateTimePickerComponentName[] = "RNDateTimePicker";
+
+} // namespace react
+} // namespace facebook
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/ShadowNodes.h b/harmony/datetimepicker/src/main/cpp/ShadowNodes.h
new file mode 100644
index 00000000..6ff154dd
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/ShadowNodes.h
@@ -0,0 +1,51 @@
+
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_S_DES_H
+#define HEADER_FILE_CPP_S_DES_H
+
+#include "EventEmitters.h"
+#include "Props.h"
+#include "States.h"
+
+#include
+#include
+
+namespace facebook {
+namespace react {
+
+JSI_EXPORT extern const char RNDateTimePickerComponentName[];
+
+/*
+ * `ShadowNode` for component.
+ */
+using RNDateTimePickerShadowNode = ConcreteViewShadowNode<
+ RNDateTimePickerComponentName,
+ RNDateTimePickerProps,
+ RNDateTimePickerEventEmitter,
+ RNDateTimePickerState>;
+} // namespace react
+} // namespace facebook
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/States.cpp b/harmony/datetimepicker/src/main/cpp/States.cpp
new file mode 100644
index 00000000..d5746f6c
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/States.cpp
@@ -0,0 +1,32 @@
+
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "States.h"
+
+namespace facebook {
+namespace react {
+
+
+} // namespace react
+} // namespace facebook
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/cpp/States.h b/harmony/datetimepicker/src/main/cpp/States.h
new file mode 100644
index 00000000..eead7c94
--- /dev/null
+++ b/harmony/datetimepicker/src/main/cpp/States.h
@@ -0,0 +1,53 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef HEADER_FILE_CPP_S_TES_H
+#define HEADER_FILE_CPP_S_TES_H
+
+#ifdef ANDROID
+#include
+#include
+#include
+#endif
+
+namespace facebook {
+namespace react {
+
+class RNDateTimePickerState {
+ public:
+ RNDateTimePickerState() = default;
+
+#ifdef ANDROID
+ RNDateTimePickerState(RNDateTimePickerState const &previousState, folly::dynamic data){};
+ folly::dynamic getDynamic() const {
+ return {};
+ };
+ MapBuffer getMapBuffer() const {
+ return MapBufferBuilder::EMPTY();
+ };
+#endif
+};
+} // namespace react
+} // namespace facebook
+#endif
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/ets/Logger.ts b/harmony/datetimepicker/src/main/ets/Logger.ts
new file mode 100644
index 00000000..4d5f5151
--- /dev/null
+++ b/harmony/datetimepicker/src/main/ets/Logger.ts
@@ -0,0 +1,63 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+import hilog from '@ohos.hilog';
+
+class Logger {
+ private domain: number;
+ private prefix: string;
+ private format: string = '%{public}s, %{public}s';
+ private isDebug: boolean;
+
+ /**
+ * constructor.
+ *
+ * @param Prefix Identifies the log tag.
+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
+ */
+ constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
+ this.prefix = prefix;
+ this.domain = domain;
+ this.isDebug = isDebug;
+ }
+
+ debug(...args: string[]):void{
+ if(this.isDebug){
+ hilog.debug(this.domain,this.prefix,this.format,args);
+ }
+ }
+
+ info(...args: string[]): void{
+ hilog.info(this.domain,this.prefix,this.format,args);
+ }
+
+ warn(...args: string[]): void{
+ hilog.warn(this.domain,this.prefix,this.format,args);
+ }
+
+ error(...args: string[]): void{
+ hilog.error(this.domain,this.prefix,this.format,args);
+ }
+}
+
+export default new Logger('datetimepicker', 0xFF00, false)
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/ets/RNDateTimePicker.ets b/harmony/datetimepicker/src/main/ets/RNDateTimePicker.ets
new file mode 100644
index 00000000..18cad21a
--- /dev/null
+++ b/harmony/datetimepicker/src/main/ets/RNDateTimePicker.ets
@@ -0,0 +1,189 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+import {
+ Descriptor,
+ RNOHContext,
+ ViewBaseProps,
+ RNViewBase,
+ ComponentBuilderContext,
+ RNComponentFactory
+} from 'rnoh'
+import inputMethod from '@ohos.inputMethod';
+import Logger from './Logger';
+
+export const DATETIME_PICKER_VIEW_TYPE = "RNDateTimePicker"
+
+export interface ViewPagerProps extends ViewBaseProps {
+ maximumDate: string
+ minimumDate: string
+ date: string
+ locale: string
+ minuteInterval: number //
+ mode: string
+ timeZoneOffsetInMinutes: number //
+ timeZoneName: string //
+ textColor: string //
+ accentColor: string //
+ themeVariant: string //
+ displayIOS: string
+ enabled: boolean //
+ is24Hour: boolean //add 0926
+}
+
+export type PickerDescriptor = Descriptor<"RNDateTimePicker", ViewPagerProps>
+
+const TAG:string = "RNDateTimePicker"
+
+@Component
+export struct RNDateTimePicker {
+ ctx!: RNOHContext
+ tag: number = 0
+ @BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
+ @State descriptor: PickerDescriptor = {} as PickerDescriptor
+ private unregisterDescriptorChangesListener?: () => void = undefined
+
+ @State selectDate: Date = new Date()
+ @State isMilitaryTime: boolean = false //true=24h制
+ @State isLunar: boolean = false //true=显示农历
+
+ aboutToAppear() {
+
+ this.descriptor = this.ctx.descriptorRegistry.getDescriptor(this.tag)
+ this.unregisterDescriptorChangesListener = this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag,
+ (newDescriptor) => {
+ this.descriptor = (newDescriptor as PickerDescriptor)
+ Logger.debug(TAG,`[RNOH]: in RNDateTimePicker,descriptor change :${JSON.stringify(this.descriptor.props)}`)
+ this.isMilitaryTime = this.descriptor.props.is24Hour
+ this.selectDate = new Date(Number.parseInt(this.descriptor.props.date));
+ }
+ )
+ Logger.info(TAG,`[RNOH]: in RNDateTimePicker,propsout :${JSON.stringify(this.descriptor.props)}`)
+ this.selectDate = new Date(Number.parseInt(this.descriptor.props.date));
+ Logger.debug(TAG,`[RNOH]: RNDateTimePicker,out selectDate :${this.selectDate}`)
+ this.isMilitaryTime = this.descriptor.props.is24Hour
+
+ }
+ onPageHide() {
+ Logger.debug(TAG,`[RNOH]: in RNDateTimePicker,onPageHide`)
+
+ }
+
+ aboutToDisappear() {
+ Logger.debug(TAG,`[RNOH]: in RNDateTimePicker,aboutToDisappear`)
+ this.onPickerDismiss()
+ this.unregisterDescriptorChangesListener?.()
+ }
+
+ onDateChange(dateIn: Date) {
+ Logger.debug(TAG,`RNOH in PickerView onChange,${JSON.stringify(dateIn)}`)
+ let unit = 1000 * 60
+ let time = dateIn.getTime()
+
+ //It is the offset in minutes between the selected date and UTC time.
+ let offset = time / unit;
+ this.ctx.rnInstanceManager.emitComponentEvent(
+ this.descriptor.tag,
+ DATETIME_PICKER_VIEW_TYPE,
+ {
+ type: "onChange",
+ utcOffset: offset,
+ timestamp: time
+ }
+ );
+ }
+
+ onPickerDismiss() {
+ Logger.debug(TAG,`RNOH in PickerView onPickerDismiss`)
+ this.ctx.rnInstanceManager.emitComponentEvent(
+ this.descriptor.tag,
+ DATETIME_PICKER_VIEW_TYPE,
+ {
+ type: "onPickerDismiss"
+ }
+ );
+ }
+ //"default" - Automatically pick the best style available for the current platform & mode.
+ //"spinner" - the usual pre-iOS 14 appearance with a wheel from which you choose values
+ //"compact" - Affects only iOS 14 and later. Will fall back to "spinner" if not supported.
+ //"inline"
+ build() {
+ RNViewBase({ ctx: this.ctx, tag: this.tag }) {
+ // RNComponentFactory({ctx:this.ctx,tag:this.tag,buildCustomComponent:this.buildCustomComponent})
+ if (this.descriptor.props.mode === "date" || this.descriptor.props.mode === "default") {
+ if (this.descriptor.props.displayIOS === "compact" || this.descriptor.props.displayIOS === "inline") {
+
+ CalendarPicker({ hintRadius: 17, selected: this.selectDate })
+
+ .edgeAlign(CalendarAlign.END)
+ // .textStyle({color:this.descriptor.props.textColor,font:{size:16,weight:FontWeight.Normal}})
+ .textStyle({ color: this.descriptor.props.textColor })
+ .enabled(this.descriptor.props.enabled)
+ .width("100%").height("100%")
+ .onChange((newDate:Date) => {
+ Logger.debug(TAG,"CalendarPicker onChange:" + JSON.stringify(newDate))
+ //0927验证发现 没有执行回调
+ // this.selectDate.setFullYear(newDate.getFullYear(), newDate.getMonth(), newDate.getDay())
+ this.selectDate = newDate
+ this.onDateChange(this.selectDate)
+ })
+ } else if (this.descriptor.props.displayIOS === "spinner" || this.descriptor.props.displayIOS === "default") {
+ DatePicker({
+ start: Number.parseInt(this.descriptor.props.minimumDate) != 0 ? new Date(Number.parseInt(this.descriptor.props.minimumDate)) : new Date(1970, 0, 0),
+ end: Number.parseInt(this.descriptor.props.maximumDate) != 0 ? new Date(Number.parseInt(this.descriptor.props.maximumDate)) : new Date(2100, 0, 0),
+ selected: this.selectDate
+ })
+ // .disappearTextStyle({color:Color.Gray,font:{size:'16fp',weight:FontWeight.Bold}})
+ // .textStyle({color:'#ff182431',font:{size:'18fp',weight:FontWeight.Normal}})
+ // .selectedTextStyle({color:'#ff0000FF',font:{size:'26fp',weight:FontWeight.Regular}})
+ .lunar(this.isLunar)
+ .enabled(this.descriptor.props.enabled)
+ .width("100%").height("100%")
+ .onDateChange((value: Date) => {
+ // this.selectDate.setFullYear(value.year, value.month, value.day)
+ this.selectDate = value
+ Logger.debug(TAG,"DatePicker,select current date is: "+ JSON.stringify(value))
+ this.onDateChange(this.selectDate)
+ })
+ }
+ } else if (this.descriptor.props.mode === "time") {
+ TimePicker({
+ selected: this.selectDate,
+ })
+ .useMilitaryTime(this.isMilitaryTime)
+ .enabled(this.descriptor.props.enabled)
+ .onChange((value: TimePickerResult) => {
+ this.selectDate.setHours(value.hour, value.minute)
+ Logger.debug(TAG,'TimePicker,select current date is: ' + JSON.stringify(value))
+ this.onDateChange(this.selectDate)
+ })
+ // .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}})
+ .width("100%").height("100%")
+ }
+ // .position({y:this.descriptor.layoutMetrics.frame.origin.y, x:this.descriptor.layoutMetrics.frame.origin.x})
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/module.json5 b/harmony/datetimepicker/src/main/module.json5
new file mode 100644
index 00000000..59f10ece
--- /dev/null
+++ b/harmony/datetimepicker/src/main/module.json5
@@ -0,0 +1,9 @@
+{
+ "module": {
+ "name": "datetimepicker",
+ "type": "har",
+ "deviceTypes": [
+ "default"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/resources/base/element/color.json b/harmony/datetimepicker/src/main/resources/base/element/color.json
new file mode 100644
index 00000000..3c712962
--- /dev/null
+++ b/harmony/datetimepicker/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/resources/base/element/string.json b/harmony/datetimepicker/src/main/resources/base/element/string.json
new file mode 100644
index 00000000..247ebf72
--- /dev/null
+++ b/harmony/datetimepicker/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Pager_viewAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "Pager_viewAbility_label",
+ "value": "label"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/resources/base/media/icon.png b/harmony/datetimepicker/src/main/resources/base/media/icon.png
new file mode 100644
index 00000000..ce307a88
Binary files /dev/null and b/harmony/datetimepicker/src/main/resources/base/media/icon.png differ
diff --git a/harmony/datetimepicker/src/main/resources/base/profile/main_pages.json b/harmony/datetimepicker/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 00000000..1898d94f
--- /dev/null
+++ b/harmony/datetimepicker/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/harmony/datetimepicker/src/main/resources/en_US/element/string.json b/harmony/datetimepicker/src/main/resources/en_US/element/string.json
new file mode 100644
index 00000000..247ebf72
--- /dev/null
+++ b/harmony/datetimepicker/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Pager_viewAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "Pager_viewAbility_label",
+ "value": "label"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/harmony/datetimepicker/src/main/resources/zh_CN/element/string.json b/harmony/datetimepicker/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 00000000..4913f880
--- /dev/null
+++ b/harmony/datetimepicker/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "Pager_viewAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "Pager_viewAbility_label",
+ "value": "label"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index f3d8eab1..25f381e0 100644
--- a/package.json
+++ b/package.json
@@ -1,12 +1,16 @@
{
- "name": "@react-native-community/datetimepicker",
- "version": "7.6.2",
+ "name": "@react-native-oh-tpl/datetimepicker",
+ "version": "7.6.2-0.0.2",
"description": "DateTimePicker component for React Native",
+ "harmony": {
+ "alias": "@react-native-community/datetimepicker"
+ },
"main": "./src/index.js",
"types": "src/index.d.ts",
"files": [
"ios",
"android",
+ "harmony",
"src",
"jest",
"flow-typed",
@@ -14,11 +18,15 @@
"RNDateTimePicker.podspec",
"!android/build",
"!ios/build",
+ "!harmony/oh_modules",
+ "!harmony/**/build",
+ "!harmony/**/oh_modules",
"!**/__tests__",
"!**/__fixtures__",
"!**/__mocks__"
],
"publishConfig": {
+ "registry": "https://registry.npmjs.org/",
"access": "public"
},
"scripts": {
@@ -43,7 +51,7 @@
},
"repository": {
"type": "git",
- "url": "git+https://github.com/react-native-community/datetimepicker.git"
+ "url": "https://github.com/react-native-oh-library/datetimepicker.git"
},
"keywords": [
"react-native-component",
@@ -89,6 +97,7 @@
"react-native": "^0.72.7",
"react-native-localize": "^3.0.3",
"react-native-test-app": "^2.5.32",
+
"react-native-windows": "^0.71.3",
"react-test-renderer": "18.2.0",
"semantic-release": "^19.0.3"
@@ -104,4 +113,4 @@
"javaPackageName": "com.reactcommunity.rndatetimepicker"
}
}
-}
+}
\ No newline at end of file
diff --git a/src/datetimepicker.harmony.js b/src/datetimepicker.harmony.js
new file mode 100644
index 00000000..b1d94397
--- /dev/null
+++ b/src/datetimepicker.harmony.js
@@ -0,0 +1,131 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+import RNDateTimePicker from './picker';
+import {dateToMilliseconds, sharedPropsValidation} from './utils';
+import {
+ IOS_DISPLAY,
+ EVENT_TYPE_SET,
+ EVENT_TYPE_DISMISSED,
+ IOS_MODE,
+} from './constants';
+import * as React from 'react';
+//import {Platform} from 'react-native';
+
+import type {
+ DateTimePickerEvent,
+ NativeEventIOS,
+ IOSNativeProps,
+ IOSDisplay,
+} from './types';
+
+// const getDisplaySafe = (display: IOSDisplay): IOSDisplay=>{
+// const majorVersionIOS = parseInt(Platfrom.Version, 10);
+// if(display === IOS_DISPLAY.inline && majorVersionIOS < 14){
+// // inline is available since 14.0
+// return IOS_DISPLAY.spinner;
+// }
+// if(majorVersionIOS < 14){
+// // NOTE this should compare against 13.4, not 14 according to https://developer.apple.com/documentation/uikit/uidatepickerstyle/uidatepickerstylecompact?changes=latest_minor&language=objc
+// // but UIDatePickerStyleCompact does not seem to work prior to 14
+// // only the spinner display (UIDatePickerStyleWheels) is thus available below 14
+// return IOS_DISPLAY.spinner;
+// }
+//
+// return display
+// }
+
+export default function Picker({
+ value,
+ locale,
+ maximumDate,
+ minimumDate,
+ minuteInterval,
+ timeZoneOffsetInMinutes,
+ timeZoneName,
+ textColor,
+ accentColor,
+ themeVariant,
+ onChange,
+ mode = IOS_MODE.date,
+ display: providedDisplay = IOS_DISPLAY.default,
+ disabled = false,
+ is24Hour = true,
+ ...other
+}: IOSNativeProps): React.Node {
+ sharedPropsValidation({value, timeZoneOffsetInMinutes, timeZoneName});
+
+ // const display = getDisplaySafe(providedDisplay)
+ const display = providedDisplay;
+
+ const _onChange = (event: NativeEventIOS) => {
+ const timestamp = event.nativeEvent.timestamp;
+ const unifiedEvent: DateTimePickerEvent = {
+ ...event,
+ type: EVENT_TYPE_SET,
+ };
+
+ const date = timestamp !== undefined ? new Date(timestamp) : undefined;
+
+ onChange && onChange(unifiedEvent, date);
+ };
+
+ const onDismiss = () => {
+ // TODO introduce separate onDismissed event listener
+ onChange &&
+ onChange(
+ {
+ type: EVENT_TYPE_DISMISSED,
+ nativeEvent: {
+ timestamp: value.getTime(),
+ utcOffset: 0, // TODO vonovak - the dismiss event should not carry any date information
+ },
+ },
+ value,
+ );
+ };
+
+ return (
+ true}
+ onResponderTerminationRequest={() => false}
+ displayIOS={display}
+ enabled={disabled !== true}
+ is24Hour={is24Hour}
+ />
+ );
+}
diff --git a/src/picker.harmony.js b/src/picker.harmony.js
new file mode 100644
index 00000000..1a98704b
--- /dev/null
+++ b/src/picker.harmony.js
@@ -0,0 +1,26 @@
+/**
+ * MIT License
+ *
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+import RNDateTimePicker from './specs/NativeComponentDateTimePicker';
+
+export default RNDateTimePicker;
diff --git a/src/specs/NativeComponentDateTimePicker.js b/src/specs/NativeComponentDateTimePicker.js
index 526dbc8f..c24c1733 100644
--- a/src/specs/NativeComponentDateTimePicker.js
+++ b/src/specs/NativeComponentDateTimePicker.js
@@ -35,6 +35,7 @@ type NativeProps = $ReadOnly<{|
'default' | 'spinner' | 'compact' | 'inline',
'default',
>,
+ is24Hour?: WithDefault,
enabled?: WithDefault,
|}>;