Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

[Layout] Add extensibility support to ASLayoutElementStyle#2975

Merged
maicki merged 2 commits intofacebookarchive:masterfrom
maicki:MSASLayoutElementStyleExtensibilityTakeTwo
Feb 7, 2017
Merged

[Layout] Add extensibility support to ASLayoutElementStyle#2975
maicki merged 2 commits intofacebookarchive:masterfrom
maicki:MSASLayoutElementStyleExtensibilityTakeTwo

Conversation

@maicki
Copy link
Copy Markdown
Contributor

@maicki maicki commented Feb 3, 2017

With the introduction of ASLayoutElementStyle that combines all style related properties for a ASLayoutElement we need to provide some kind of extensibility support. This is important as it should be possible to add custom layout specs and extend the ASLayoutElementStyle for usage within the custom layout specs.

The general idea is outline in this gist via examples: https://gist.github.com/maicki/2630b51f62cbedc0cb34e0bcac96d6c9

Original diff #2294 and replaces #2943

@maicki
Copy link
Copy Markdown
Contributor Author

maicki commented Feb 3, 2017

cc @appleguy

Copy link
Copy Markdown
Contributor

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@end

/*
* Let the ASLayoutableStyle conform to the MSLayoutable protocol and add properties implementation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revisit this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nguyenhuy. Addressed the comment.

Copy link
Copy Markdown
Contributor

@garrettmoon garrettmoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be handy!

/**
* Unbox NSNumber based on the type
*/
#define ASDK_UNBOX_NUMBER(NUMBER, PROPERTY_TYPE) \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any concern that this doesn't support other values that NSNumber does? I.e. long, longlong, char, etc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now this will be fine and we can re-consider if we ran into issues. If a not supported data type is set we will assert for now.

- (void)doUseSomeStyleValuesFromChildren
{
for (id<ASLayoutElement> child in self.children) {
__unused CGFloat extendedWidht = child.style.extendedWidth;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in width

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Should be fixed.

@maicki maicki merged commit f212545 into facebookarchive:master Feb 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants