• 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 #include "bridge/declarative_frontend/jsview/models/textpicker_model_impl.h"
17 
18 #include "bridge/declarative_frontend/jsview/js_view_common_def.h"
19 #include "core/components/picker/picker_text_component.h"
20 
21 namespace OHOS::Ace::Framework {
Create(RefPtr<PickerTheme> pickerTheme)22 void TextPickerModelImpl::Create(RefPtr<PickerTheme> pickerTheme)
23 {
24     auto textPicker = AceType::MakeRefPtr<PickerTextComponent>();
25     ViewStackProcessor::GetInstance()->ClaimElementId(textPicker);
26 
27     textPicker->SetIsDialog(false);
28     textPicker->SetHasButtons(false);
29     textPicker->SetTheme(pickerTheme);
30     ViewStackProcessor::GetInstance()->Push(textPicker);
31 }
32 
SetDefaultPickerItemHeight(const Dimension & value)33 void TextPickerModelImpl::SetDefaultPickerItemHeight(const Dimension& value)
34 {
35     auto textPicker = AceType::DynamicCast<PickerTextComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
36     textPicker->SetDefaultHeight(true);
37     JSViewSetProperty(&PickerTextComponent::SetColumnHeight, value);
38 }
39 
SetSelected(uint32_t value)40 void TextPickerModelImpl::SetSelected(uint32_t value)
41 {
42     JSViewSetProperty(&PickerTextComponent::SetSelected, value);
43 }
44 
SetRange(const std::vector<std::string> & value)45 void TextPickerModelImpl::SetRange(const std::vector<std::string>& value)
46 {
47     JSViewSetProperty(&PickerTextComponent::SetRange, value);
48 }
49 
SetOnChange(TextChangeEvent && onChange)50 void TextPickerModelImpl::SetOnChange(TextChangeEvent&& onChange)
51 {
52     JSViewSetProperty(&PickerBaseComponent::SetOnTextChange, std::move(onChange));
53 }
54 } // namespace OHOS::Ace::Framework
55