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

[TIMOB-24080] : iOS - Paragraph style support in attributed string #10032

Merged
merged 31 commits into from
Sep 19, 2018

Conversation

vijaysingh-axway
Copy link
Contributor

@vijaysingh-axway vijaysingh-axway commented May 9, 2018

Copy link
Collaborator

@hansemannn hansemannn left a comment

Choose a reason for hiding this comment

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

Some minor issues.

@@ -594,6 +594,26 @@ - (NSNumber *)ATTRIBUTE_LINE_BREAK_BY_TRUNCATING_MIDDLE
{
return NUMINTEGER(NSLineBreakByTruncatingMiddle);
}
- (NSNumber *)ATTRIBUTE_TEXT_ALIGNMENT_LEFT
{
return NUMINTEGER(NSTextAlignmentLeft);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already support these on the UIModule class via Ti.UI.TEXT_ALIGNMENT_*

@@ -504,7 +504,7 @@ - (NSNumber *)convertUnits:(id)args
MAKE_SYSTEM_PROP(ATTRIBUTE_STRIKETHROUGH_COLOR, AttributeNameStrikethroughColor);
MAKE_SYSTEM_PROP(ATTRIBUTE_OBLIQUENESS, AttributeNameObliqueness);
MAKE_SYSTEM_PROP(ATTRIBUTE_EXPANSION, AttributeNameExpansion);
MAKE_SYSTEM_PROP(ATTRIBUTE_LINE_BREAK, AttributeNameLineBreak);
MAKE_SYSTEM_PROP(ATTRIBUTE_LINE_BREAK, AttributeNameLineBreak); // deprecated
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like we only warn the user via code so far, not via docs. Please add.

description: |
This property contains the line break mode to be used laying out the text of paragraph.
type: Number
constants: [ Titanium.UI.ATTRIBUTE_LINE_BREAK_* ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought this is deprecated?

If positive, this value is the distance from the leading margin
(for example, the left margin in left-to-right text). If 0 or negative,
it is the distance from the trailing margin. This is a float value.
type: Number
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to document what units tailIndex uses, such as points.

description: |
This value is always nonnegative. This value is included in the line fragment heights
in the layout manager.
type: Number
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to document the lineSpacing units, such as points.

would not otherwise fit in the available space. The maximum amount of tightening performed
by the system is dependent on the font, line width, and other factors. The default value of
this property is NO.
type: Number
Copy link
Contributor

Choose a reason for hiding this comment

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

The allowsDefaultTighteningForTruncation type should be boolean, not number.

And the description should use true and false instead of the Objective-C YES and NO.

to separate it from the following paragraph. This value must be nonnegative. The space
between paragraphs is determined by adding the paragraphSpacing of previous paragraph and
the paragraphSpacingBefore of current paragraph.
type: Number
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should rename property paragraphSpacing to paragraphSpacingAfter. This makes it clear that it's only applied after the paragraph (assuming this is actually how it works). And it clearly separates it from the paragraphSpacingBefore property.

@jquick-axway
Copy link
Contributor

@vijaysingh-axway, @hansemannn, it's kind of a bummer that we're hard-coding properties such as lineSpacing to points/dips instead of respecting the default units set for the app. This can make view layout/alignment with text a pain.

To be fair, I've noticed that our existing ATTRIBUTE_BASELINE_OFFSET is hard-coded to pixels and ATTRIBUTE_KERN is hard-coded to points. So, it appears to be a pre-existing issue with attributed strings, but do we really want to continue this trend? Perhaps allowing these properties to be set to a string where the dev can set the units might be better? (If you feel that it's too late, then fair enough.)

The natural line height of the receiver is multiplied by this factor (if positive)
before being constrained by minimum and maximum line height. The default value of
this property is 0.0.
type: Number
Copy link
Contributor

@jquick-axway jquick-axway May 9, 2018

Choose a reason for hiding this comment

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

The docs here don't do a good job describing what lineHeightMultiple, maximumLineHeight, and minimumLineHeight do. Nor why you would want to use them.
(Not trying to be rude. Just looking at this from a Titanium dev's perspective.) 😄

I assume you would want to use minimumLineHeight in case you use mixed font sizes and you want all lines to have the same height as the largest font size. That's the only use-case I can think of.

But why would you want to use maximumLineHeight? Would it clip text that exceed this height? If there is answer to this, then we should document it.

Also, I have no clue what lineHeightMultiple is supposed to do from reading the description... nor why I would want to use it. If there is a valid use-case, then let's document it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I assume a value of zero for maximumLineHeight means do not apply a max, right? Otherwise text would always be clipped. We should document that.

I assume the same is true for lineHeightMultiple? A value of zero means don't multiply?

@hansemannn
Copy link
Collaborator

I agree! There is a helper for convertig values to dimensions. Vijay, can you address that?

@hansemannn
Copy link
Collaborator

@vijaysingh-axway Can you check the review comments? Moving to 7.3.0 for now, due to lower priority.

@hansemannn hansemannn added this to the 7.3.0 milestone May 15, 2018
@jquick-axway
Copy link
Contributor

Note that I'm not trying to picky. These details matter when we implement this on Android for parity. Documenting these details not only benefits Titanium devs, but it also serves as a specification when implementing this feature on other platforms. Thanks!

@sgtcoolguy sgtcoolguy modified the milestones: 7.3.0, 7.4.0 May 16, 2018
@tidev tidev deleted a comment from build Aug 15, 2018
@tidev tidev deleted a comment from build Aug 15, 2018
@@ -178,11 +213,12 @@ - (void)addAttribute:(id)args
break;

case AttributeNameLineBreak:
DEPRECATED_REPLACED(@"UI.ATTRIBUTE_LINE_BREAK", @"UI.ATTRIBUTE_PARAGRAPH_STYLE.lineBreakMode", @"7.3.0");
Copy link
Collaborator

Choose a reason for hiding this comment

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

7.4.0

@hansemannn hansemannn removed the hold for parity ✋ This PR should not be merged until an equivalent PR is ready for the other platform(s) label Aug 21, 2018
@hansemannn hansemannn modified the milestones: 7.4.0, 7.5.0 Aug 21, 2018
@vijaysingh-axway
Copy link
Contributor Author

@hansemannn Fixed the dimension conversion. Now you can review. Thanks!

@hansemannn
Copy link
Collaborator

@vijaysingh-axway You still should update the docs to reflect that developers can also use non-Number types.

@build
Copy link
Contributor

build commented Aug 22, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

Copy link
Collaborator

@hansemannn hansemannn left a comment

Choose a reason for hiding this comment

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

CR passed!

@hansemannn
Copy link
Collaborator

@jquick-axway Can you re-review / approve this?

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

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

CR: Pass

@keerthi1032
Copy link
Contributor

keerthi1032 commented Sep 19, 2018

FR passed. Attributed string Works fine on IOS. PR merged
Test Environment:
Name = Mac OS X
Version = 10.13.6
Architecture = 64bit
Memory = 17179869184
Node.js
Node.js Version = 8.9.1
npm Version = 5.5.1
Titanium CLI
CLI Version = 5.1.1
Titanium SDK
SDK Version = 7.5.0 local sdk
iPhone 6s -ios 12
iPhone 5 -ios 11 simulator

@keerthi1032 keerthi1032 merged commit 7561912 into tidev:master Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants