• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TOGGLE_TOGGLE_MODEL_NG_H
16 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TOGGLE_TOGGLE_MODEL_NG_H
17 
18 #include "core/components_ng/base/frame_node.h"
19 #include "core/components_ng/pattern/toggle/toggle_model.h"
20 
21 namespace OHOS::Ace::NG {
22 
23 class ACE_EXPORT ToggleModelNG : public OHOS::Ace::ToggleModel {
24 public:
25     void Create(ToggleType toggleType, bool isOn) override;
26     void SetSelectedColor(const Color& selectedColor) override;
27     void SetSwitchPointColor(const Color& switchPointColor) override;
28     void OnChange(ChangeEvent&& onChange) override;
29     void SetWidth(const Dimension& width) override;
30     void SetHeight(const Dimension& height) override;
31     void SetBackgroundColor(const Color& color) override;
32     bool IsToggle() override;
33     void SetPadding(const NG::PaddingPropertyF& args) override;
34 
35 private:
36     static void CreateCheckbox(int32_t nodeId);
37     static void CreateSwitch(int32_t nodeId);
38     static void CreateButton(int32_t nodeId);
39     static void AddNewChild(const RefPtr<UINode>& parentFrame, int32_t nodeId, int32_t index);
40     static int32_t RemoveNode(const RefPtr<FrameNode>& childFrameNode, int32_t nodeId);
41 };
42 
43 } // namespace OHOS::Ace::NG
44 
45 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TOGGLE_TOGGLE_MODEL_NG_H