1 /* 2 * Copyright (c) 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TOGGLE_TOGGLE_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TOGGLE_TOGGLE_MODEL_H 18 19 #include <memory> 20 21 #include "base/geometry/dimension.h" 22 #include "core/components/common/properties/color.h" 23 #include "core/components_ng/pattern/toggle/switch_event_hub.h" 24 #include "frameworks/core/components_ng/property/measure_property.h" 25 26 namespace OHOS::Ace::NG { 27 28 enum class ToggleType { 29 CHECKBOX = 0, 30 SWITCH, 31 BUTTON, 32 }; 33 34 } // namespace OHOS::Ace::NG 35 36 namespace OHOS::Ace { 37 38 class ToggleModel { 39 public: 40 static ToggleModel* GetInstance(); 41 virtual ~ToggleModel() = default; 42 43 virtual void Create(NG::ToggleType toggleType, bool isOn) = 0; 44 virtual void SetSelectedColor(const Color& selectedColor) = 0; 45 virtual void SetSwitchPointColor(const Color& switchPointColor) = 0; 46 virtual void OnChange(NG::ChangeEvent&& onChange) = 0; 47 virtual void SetWidth(const Dimension& width) = 0; 48 virtual void SetHeight(const Dimension& height) = 0; 49 virtual void SetBackgroundColor(const Color& color) = 0; 50 virtual bool IsToggle() = 0; 51 virtual void SetPadding(const NG::PaddingPropertyF& args) = 0; 52 53 private: 54 static std::unique_ptr<ToggleModel> instance_; 55 }; 56 57 } // namespace OHOS::Ace 58 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TOGGLE_TOGGLE_MODEL_H