mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-19 21:33:33 -04:00
@@ -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_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user