Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Add fix for iOS layout shadow wrapper #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jalbatross
Copy link

@jalbatross jalbatross commented Dec 2, 2019

For layouts which use the position of the child element in the layout structure as the element's position (StackLayout, for example), the plugin works fine. However, for layouts where child node position may not have any correlation to the element's rendered UI (GridLayout, AbsoluteLayout, etc.), you end up running into problems.

For example, take the following layout on iOS:

<GridLayout rows="auto auto auto">
  <Label text="0" row="0"></Label>
  <Label text="1" row="1" shadow="10"></Label>
  <Label text="2" row="2"></Label>
</GridLayout>

Under the hood, this happens:

<GridLayout rows="auto auto auto">
  <Label text="0" row="0"></Label>
  <StackLayout>
    <Label text="1" row="1" shadow="10"></Label>
  </StackLayout>
  <Label text="2" row="2"></Label>
</GridLayout>

So the second label does not render correctly.

Currently this PR just applies the row, column, rowSpan, and colSpan attributes to the wrapping StackLayout if the original element is wrapped in a GridLayout.

More work needs to be done so that the wrapping StackLayout gets the correct attributes from the original element in order to render in the view correctly for all layouts - I believe #17 was caused by a similar issue for AbsoluteLayouts.

As-is, this is mergeable but does not account for all possible use cases.

@edusperoni
Copy link

Please change your array to a Set and also bind property change event (remember to clean them up afterward!)

parent.on(Observable.propertyChangeEvent, (propertyChangeData: PropertyChangeData) => {
    if(propertySet.has(propertyChangeData.propertyName)) {
        this.wrapper[propertyChangeData.propertyName] = propertyChangeData.value;
    }
});

To clean it up you should probably move that anonymous function to a named function and call:
parent.on(Observable.propertyChangeEvent, this.myfunction, this);

and clean up with:
parent.off(Observable.propertyChangeEvent, this.myfunction,this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants