• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_DATEPICKER_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_DATEPICKER_H
18 
19 #include "bridge/declarative_frontend/jsview/js_interactable_view.h"
20 #include "bridge/declarative_frontend/jsview/js_view_abstract.h"
21 #include "core/components/picker/picker_base_component.h"
22 #include "core/components_ng/pattern/picker/datepicker_event_hub.h"
23 #include "frameworks/bridge/declarative_frontend/jsview/dialog/js_alert_dialog.h"
24 
25 namespace OHOS::Ace::Framework {
26 class JSDatePicker : public JSViewAbstract {
27 public:
28     static void Create(const JSCallbackInfo& info);
29 
30     static void JSBind(BindingTarget globalObj);
31     static void SetLunar(bool isLunar);
32     static void OnChange(const JSCallbackInfo& info);
33     static void PickerBackgroundColor(const JSCallbackInfo& info);
34     // keep compatible, need remove after
35     static void UseMilitaryTime(bool isUseMilitaryTime);
36 
37 private:
38     static void CreateDatePicker(const JSRef<JSObject>& paramObj);
39     // keep compatible, need remove after
40     static void CreateTimePicker(const JSRef<JSObject>& paramObj);
41     static PickerDate ParseDate(const JSRef<JSVal>& dateVal);
42     // keep compatible, need remove after
43     static PickerTime ParseTime(const JSRef<JSVal>& timeVal);
44 };
45 
46 class JSDatePickerDialog : JSAlertDialog {
47 public:
48     static void JSBind(BindingTarget globalObj);
49     static void Show(const JSCallbackInfo& info);
50     static void DatePickerDialogShow(const JSRef<JSObject>& paramObj,
51         const std::map<std::string, NG::DialogEvent>& dialogEvent,
52         const std::map<std::string, NG::DialogGestureEvent>& dialogCancelEvent);
53 
54 private:
55     static void CreateDatePicker(RefPtr<Component>& component, const JSRef<JSObject>& paramObj);
56     // keep compatible, need remove after
57     static void CreateTimePicker(RefPtr<Component>& component, const JSRef<JSObject>& paramObj);
58     static PickerDate ParseDate(const JSRef<JSVal>& dateVal);
59     // keep compatible, need remove after
60     static PickerTime ParseTime(const JSRef<JSVal>& timeVal);
61 };
62 
63 class JSTimePicker : public JSViewAbstract {
64 public:
65     static void Create(const JSCallbackInfo& info);
66 
67     static void JSBind(BindingTarget globalObj);
68     static void OnChange(const JSCallbackInfo& info);
69     static void UseMilitaryTime(bool isUseMilitaryTime);
70 
71 private:
72     static void CreateTimePicker(const JSRef<JSObject>& paramObj);
73     static PickerTime ParseTime(const JSRef<JSVal>& timeVal);
74 };
75 
76 class JSTimePickerDialog {
77 public:
78     static void JSBind(BindingTarget globalObj);
79     static void Show(const JSCallbackInfo& info);
80     static void TimePickerDialogShow(const JSRef<JSObject>& paramObj,
81         const std::map<std::string, NG::DialogEvent>& dialogEvent,
82         const std::map<std::string, NG::DialogGestureEvent>& dialogCancelEvent);
83 
84 private:
85     static void CreateTimePicker(RefPtr<Component>& component, const JSRef<JSObject>& paramObj);
86     static PickerTime ParseTime(const JSRef<JSVal>& timeVal);
87     static PickerDate ParseDate(const JSRef<JSVal>& dateVal);
88 };
89 } // namespace OHOS::Ace::Framework
90 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_DATEPICKER_H
91