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

[ALOY-1703] Add several XML attribute aliases #953

Closed
wants to merge 6 commits into from

Conversation

brentonhouse
Copy link
Contributor

No description provided.

Copy link
Contributor

@ewanharris ewanharris left a comment

Choose a reason for hiding this comment

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

I think the verticalAlign is technically a change of behaviour, so I'm not too keen on that.

What's the desire for adding the src alias, is it purely because it's less characters than image? I'm not really a fan of adding an undocumented alias purely to avoid typing 2 characters.

}

if ( node.getAttribute('verticalAlign') === 'center' ) {
node.setAttribute('verticalAlign', 'Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER');
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on Josh's comment, this is a change in behaviour correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, I am not talking about changing anything with the SDK. This is simply an intuitive way to be able to center text and it mirrors what you can do with textAlign. I think NOT doing this is actually more harmful as most developers are going to assume that "center" can be used and won't find out until their build breaks.

Copy link
Contributor

@ewanharris ewanharris Jan 24, 2020

Choose a reason for hiding this comment

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

But there is a behaviour change here, verticalAlign: 'center' currently does one thing (which I agree doesn't do what I would expect) and here we're changing it do something completely different.

Alloy has no special handling for textAlign, I think it "just works" due to TEXT_ALIGNMENT_CENTER having a value of center, whereas TEXT_VERTICAL_ALIGNMENT_CENTER has a value (on Android) of middle so it doesn't work.

If we're adding special handling for center, why not add the other variants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, no one knows about "middle" unless you dig into the source code. "center" makes sense because it is part of the name TEXT_VERTICAL_ALIGNMENT_CENTER and the fact that TEXT_ALIGNMENT_CENTER can be aliased by using "center". If we want to change the value to TEXT_VERTICAL_ALIGNMENT_MIDDLE, then "middle" would make sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't saying people should know about middle, it was just an explanation of why this weird behaviour happens.

I tried testing this change, and it looks like it only works when used in views and not in styles?

@@ -44,6 +44,10 @@ function parse(node, state, args) {
}
}

if ( node.getAttribute('verticalAlign') === 'center' ) {
node.setAttribute('verticalAlign', 'Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER');
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar change in behaviour comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the desire for adding the src alias, is it purely because it's less characters than image? I'm not really a fan of adding an undocumented alias purely to avoid typing 2 characters.

I think src or source makes much more sense. That would align us more with HTML, NativeScript, ReactNative, Xamarin, etc

Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to use src that change should come in the SDK imo

@@ -86,6 +86,10 @@ function parse(node, state, args) {
postCode += '<%= parentSymbol %>.add(' + parentSymbol + ');';
}

if ( node.getAttribute('verticalAlign') === 'center' ) {
node.setAttribute('verticalAlign', 'Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER');
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar change in behaviour comment

@@ -136,6 +136,10 @@ function parse(node, state, args) {
}
}

if ( node.getAttribute('verticalAlign') === 'center' ) {
node.setAttribute('verticalAlign', 'Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER');
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar change in behaviour comment

@build
Copy link

build commented Jan 24, 2020

Warnings
⚠️

Please ensure to add a changelog entry for your changes. Edit the CHANGELOG.md file and add your change under the Unreleased items header

Messages
📖

✅ All tests are passing
Nice one! All 3490 tests are passing.

Generated by 🚫 dangerJS against 07225aa

@ewanharris
Copy link
Contributor

@brentonhouse I like the idea of making this simpler. But I think as it stands, IMO the potential confusion from verticalAlign: 'center' not working everywhere (styles we could fix, js code we could try with a babel plugin but maybe at the cost of performance?) would outweigh the benefits

@Topener
Copy link
Contributor

Topener commented Jan 30, 2020

To me it would be better to integrate these aliases into the SDK instead of Alloy. It is hard to explain in documentation some things exist in alloy only. I also think introducing things like a src property on an ImageView will cause more confusion than it solves. There already is confusion with html, we shouldn't want to confirm that.

@brentonhouse
Copy link
Contributor Author

understood.

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.

4 participants