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_RADIO_RADIO_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RADIO_RADIO_MODEL_H 18 19 #include <functional> 20 #include <mutex> 21 22 #include "core/components_ng/pattern/radio/radio_event_hub.h" 23 24 namespace OHOS::Ace { 25 26 class ACE_FORCE_EXPORT RadioModel { 27 public: 28 static RadioModel* GetInstance(); 29 virtual ~RadioModel() = default; 30 31 virtual void Create(const std::optional<std::string>& value, const std::optional<std::string>& group, 32 const std::optional<int32_t>& indicator); 33 virtual void SetChecked(bool isChecked); 34 virtual void SetOnChange(NG::ChangeEvent&& onChange); SetBuilder(std::function<void ()> && buildFunc)35 virtual void SetBuilder(std::function<void()>&& buildFunc) {}; 36 virtual void SetWidth(const Dimension& width); 37 virtual void SetHeight(const Dimension& height); 38 virtual void SetPadding(const NG::PaddingPropertyF& args, const NG::PaddingProperty& newArgs); SetCheckedBackgroundColor(const Color & color)39 virtual void SetCheckedBackgroundColor(const Color& color) {} SetUncheckedBorderColor(const Color & color)40 virtual void SetUncheckedBorderColor(const Color& color) {} SetIndicatorColor(const Color & color)41 virtual void SetIndicatorColor(const Color& color) {} SetOnChangeEvent(NG::ChangeEvent && onChangeEvent)42 virtual void SetOnChangeEvent(NG::ChangeEvent&& onChangeEvent) {}; SetOnClickEvent(std::function<void ()> && onClick)43 virtual void SetOnClickEvent(std::function<void()>&& onClick) {}; SetResponseRegion(const std::vector<DimensionRect> & responseRegion)44 virtual void SetResponseRegion(const std::vector<DimensionRect>& responseRegion) {}; SetHoverEffect(HoverEffectType hoverEffect)45 virtual void SetHoverEffect(HoverEffectType hoverEffect) {}; 46 47 private: 48 static std::unique_ptr<RadioModel> instance_; 49 static std::mutex mutex_; 50 }; 51 } // namespace OHOS::Ace 52 53 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RADIO_RADIO_MODEL_H 54