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 "frameworks/bridge/declarative_frontend/jsview/models/blank_model_impl.h" 17 18 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h" 19 20 namespace OHOS::Ace::Framework { Create()21void BlankModelImpl::Create() 22 { 23 auto specializedBox = AceType::MakeRefPtr<OHOS::Ace::BoxComponent>(); 24 25 // specialized component should be firstly pushed. 26 ViewStackProcessor::GetInstance()->ClaimElementId(specializedBox); 27 ViewStackProcessor::GetInstance()->Push(specializedBox); 28 29 // Blank fill the remain space. 30 auto flexItem = ViewStackProcessor::GetInstance()->GetFlexItemComponent(); 31 flexItem->SetFlexGrow(1); 32 flexItem->SetFlexShrink(0); 33 flexItem->SetMustStretch(true); 34 } 35 SetBlankMin(const Dimension & blankMin)36void BlankModelImpl::SetBlankMin(const Dimension& blankMin) 37 { 38 auto flexItem = ViewStackProcessor::GetInstance()->GetFlexItemComponent(); 39 flexItem->SetFlexBasis(blankMin.IsValid() ? blankMin : Dimension()); 40 } 41 SetHeight(const Dimension & height)42void BlankModelImpl::SetHeight(const Dimension& height) 43 { 44 auto flexItem = ViewStackProcessor::GetInstance()->GetFlexItemComponent(); 45 if (height > flexItem->GetFlexBasis()) { 46 flexItem->SetFlexBasis(height); 47 } 48 } 49 SetColor(const Color & color)50void BlankModelImpl::SetColor(const Color& color) 51 { 52 auto blank = ViewStackProcessor::GetInstance()->GetBoxComponent(); 53 CHECK_NULL_VOID(blank); 54 blank->SetColor(color); 55 } 56 } // namespace OHOS::Ace::Framework 57