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_col_model_impl.h" 17 18 #include "core/components_v2/grid_layout/grid_col_component.h" 19 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h" 20 21 namespace OHOS::Ace::Framework { 22 Create()23void GridColModelImpl::Create() 24 { 25 auto component = AceType::MakeRefPtr<V2::GridColComponent>(); 26 ViewStackProcessor::GetInstance()->Push(component); 27 } 28 Create(const V2::GridContainerSize & span,const V2::GridContainerSize & offset,const V2::GridContainerSize & order)29void GridColModelImpl::Create(const V2::GridContainerSize& span, const V2::GridContainerSize& offset, 30 const V2::GridContainerSize& order) 31 { 32 auto component = AceType::MakeRefPtr<V2::GridColComponent>(); 33 ViewStackProcessor::GetInstance()->Push(component); 34 component->SetSpan(span); 35 component->SetOffset(offset); 36 component->SetOrder(order); 37 } 38 SetSpan(const V2::GridContainerSize & span)39void GridColModelImpl::SetSpan(const V2::GridContainerSize& span) 40 { 41 auto component = ViewStackProcessor::GetInstance()->GetMainComponent(); 42 auto gridCol = AceType::DynamicCast<V2::GridColComponent>(component); 43 if (gridCol) { 44 gridCol->SetSpan(span); 45 } 46 } 47 SetOffset(const V2::GridContainerSize & offset)48void GridColModelImpl::SetOffset(const V2::GridContainerSize& offset) 49 { 50 auto component = ViewStackProcessor::GetInstance()->GetMainComponent(); 51 auto gridCol = AceType::DynamicCast<V2::GridColComponent>(component); 52 if (gridCol) { 53 gridCol->SetOffset(offset); 54 } 55 } 56 SetOrder(const V2::GridContainerSize & order)57void GridColModelImpl::SetOrder(const V2::GridContainerSize& order) 58 { 59 auto component = ViewStackProcessor::GetInstance()->GetMainComponent(); 60 auto gridCol = AceType::DynamicCast<V2::GridColComponent>(component); 61 if (gridCol) { 62 gridCol->SetOrder(order); 63 } 64 } 65 66 } // namespace OHOS::Ace::Framework 67