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, bool hasSecond = false) = 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 SetWheelModeEnabled(bool wheelModeEnabled) = 0; 38 virtual void SetDisappearTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) = 0; 39 virtual void SetNormalTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) = 0; 40 virtual void SetSelectedTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) = 0; 41 virtual void SetBackgroundColor(const Color& color) = 0; 42 virtual void SetChangeEvent(ChangeEvent&& onChange) = 0; 43 44 private: 45 static std::unique_ptr<TimePickerModel> timePickerInstance_; 46 static std::mutex mutex_; 47 }; 48 49 class TimePickerDialogModel { 50 public: 51 static TimePickerDialogModel* GetInstance(); 52 virtual ~TimePickerDialogModel() = default; 53 54 virtual void SetTimePickerDialogShow(PickerDialogInfo& pickerDialog, NG::TimePickerSettingData& settingData, 55 std::function<void()>&& onCancel, std::function<void(const std::string&)>&& onAccept, 56 std::function<void(const std::string&)>&& onChange) = 0; 57 58 private: 59 static std::unique_ptr<TimePickerDialogModel> timePickerDialogInstance_; 60 static std::mutex mutex_; 61 }; 62 } // namespace OHOS::Ace 63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TIME_PICKER_TIME_PICKER_MODEL_H 64