• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TIME_PICKER_TIME_PICKER_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TIME_PICKER_TIME_PICKER_MODEL_H
18 
19 #include <mutex>
20 
21 #include "core/components/picker/picker_data.h"
22 #include "core/components/picker/picker_theme.h"
23 #include "core/components_ng/pattern/picker/picker_model.h"
24 #include "core/components_ng/pattern/picker/picker_type_define.h"
25 
26 namespace OHOS::Ace {
27 using ChangeEvent = std::function<void(const BaseEventInfo* info)>;
28 class TimePickerModel {
29 public:
30     static TimePickerModel* GetInstance();
31     virtual ~TimePickerModel() = default;
32 
33     virtual void CreateTimePicker(RefPtr<PickerTheme> pickerTheme) = 0;
34     virtual void SetSelectedTime(const PickerTime& value) = 0;
35     virtual void SetOnChange(ChangeEvent&& onChange) = 0;
36     virtual void SetHour24(bool isUseMilitaryTime) = 0;
37     virtual void SetDisappearTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) = 0;
38     virtual void SetNormalTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) = 0;
39     virtual void SetSelectedTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) = 0;
40     virtual void SetBackgroundColor(const Color& color) = 0;
41     virtual void SetChangeEvent(ChangeEvent&& onChange) = 0;
42 
43 private:
44     static std::unique_ptr<TimePickerModel> timePickerInstance_;
45     static std::mutex mutex_;
46 };
47 
48 class TimePickerDialogModel {
49 public:
50     static TimePickerDialogModel* GetInstance();
51     virtual ~TimePickerDialogModel() = default;
52 
53     virtual void SetTimePickerDialogShow(PickerDialogInfo& pickerDialog, NG::TimePickerSettingData& settingData,
54         std::function<void()>&& onCancel, std::function<void(const std::string&)>&& onAccept,
55         std::function<void(const std::string&)>&& onChange) = 0;
56 
57 private:
58     static std::unique_ptr<TimePickerDialogModel> timePickerDialogInstance_;
59     static std::mutex mutex_;
60 };
61 } // namespace OHOS::Ace
62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TIME_PICKER_TIME_PICKER_MODEL_H
63