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 #include "bridge/declarative_frontend/jsview/models/grid_row_model_impl.h"
17
18 #include "bridge/declarative_frontend/view_stack_processor.h"
19 #include "core/components_v2/grid_layout/grid_row_component.h"
20
21 namespace OHOS::Ace::Framework {
22
Create()23 void GridRowModelImpl::Create()
24 {
25 auto component = AceType::MakeRefPtr<V2::GridRowComponent>();
26 ViewStackProcessor::GetInstance()->Push(component);
27 }
28
Create(const RefPtr<V2::GridContainerSize> & col,const RefPtr<V2::Gutter> & gutter,const RefPtr<V2::BreakPoints> & breakpoints,V2::GridRowDirection direction)29 void GridRowModelImpl::Create(const RefPtr<V2::GridContainerSize>& col, const RefPtr<V2::Gutter>& gutter,
30 const RefPtr<V2::BreakPoints>& breakpoints, V2::GridRowDirection direction)
31 {
32 auto component = AceType::MakeRefPtr<V2::GridRowComponent>();
33 component->SetTotalCol(col);
34 component->SetGutter(gutter);
35 component->SetBreakPoints(breakpoints);
36 component->SetDirection(direction);
37 ViewStackProcessor::GetInstance()->Push(component);
38 }
39
SetOnBreakPointChange(std::function<void (const std::string)> && onChange)40 void GridRowModelImpl::SetOnBreakPointChange(std::function<void(const std::string)>&& onChange)
41 {
42 auto component = AceType::DynamicCast<V2::GridRowComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
43 if (component) {
44 component->SetbreakPointChange(std::move(onChange));
45 }
46 }
47
SetHeight()48 void GridRowModelImpl::SetHeight()
49 {
50 auto component = AceType::DynamicCast<V2::GridRowComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
51 if (component) {
52 component->SetHasContainerHeight(true);
53 }
54 }
55
56 } // namespace OHOS::Ace::Framework
57