!113 Gitee Review - dev

Merge pull request !113 from tsj_2020/dev
This commit is contained in:
openharmony_ci
2021-03-27 09:39:33 +08:00
committed by Gitee
4 changed files with 24 additions and 0 deletions
@@ -200,6 +200,18 @@ public:
*/
const Dimension &GetDimension(uint16_t keyNameId) const;
void SetWidth(const int16_t width)
{
width_.type = DimensionType::TYPE_PIXEL;
width_.value.pixel = width;
}
void SetHeight(const int16_t height)
{
height_.type = DimensionType::TYPE_PIXEL;
height_.value.pixel = height;
}
protected:
void SetComponentName(uint16_t name)
{
@@ -286,6 +286,11 @@ void ListAdapter::BuildItemViewTree(const JSValue element) const
return;
}
ConstrainedParameter parentParam = uiListContentParam_;
if (direction_ == UIList::VERTICAL) {
component->SetWidth(uiListContentParam_.maxWidth);
} else {
component->SetHeight(uiListContentParam_.maxHeight);
}
Component::BuildViewTree(component, nullptr, parentParam);
component->OnViewAttached();
}
@@ -66,6 +66,11 @@ public:
void UpdateContentAlignParam(ConstrainedParameter param);
void SetDirection(uint8_t direction)
{
direction_ = direction;
}
private:
bool GenerateListItems(const JSValue descriptors, int16_t size);
int16_t CalculateItemIndex(int16_t itemIndex) const;
@@ -81,6 +86,7 @@ private:
int16_t listItemsCount_;
// the content area
ConstrainedParameter uiListContentParam_;
uint8_t direction_ = UIList::VERTICAL;
};
} // namespace ACELite
} // namespace OHOS
@@ -136,6 +136,7 @@ void ListComponent::OnViewAttached()
ConstrainedParameter listParameter;
GetConstrainedParam(listParameter);
adapter_.UpdateContentAlignParam(listParameter);
adapter_.SetDirection(list_.GetDirection());
// Step4. add children to list dynamically.
list_.SetAdapter(&adapter_);
}