[TIMOB-24080] iOS: Add paragraph styles to AttributedString
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-09-19T19:00:24.000+0000 |
| Affected Version/s | Release 6.3.0, Release 7.1.0 |
| Fix Version/s | Release 7.5.0 |
| Components | Android, iOS |
| Labels | attributedString |
| Reporter | Flavio De Stefano |
| Assignee | Vijay Singh |
| Created | 2016-10-27T14:58:39.000+0000 |
| Updated | 2018-09-19T20:58:01.000+0000 |
Description
Add LineHeight property for AttributedString
PR: https://github.com/appcelerator/titanium_mobile/pull/8558
Hey Flavio, thanks for the PR! Please add Android parity, docs, unit-tests and example-code for your PR, thx!
I'll address today. But, there's no Android parity, cause AttributedString are missing on Android. Right?
Ti.UI.AttributedStringis cross-platform.Oh, I didn't notices that, sorry :) I'll indagate on how to implement in Android. Thank you.
Demo:
var win = Titanium.UI.createWindow({ backgroundColor: '#ddd', }); win.open(); var text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.'; var attr = Titanium.UI.createAttributedString({ text: text, attributes: [ // Sets the line height { type: Titanium.UI.ATTRIBUTE_LINE_HEIGHT, range: [0, text.length], value: 20.0 }, ] }); var label = Titanium.UI.createLabel({ width: 200, height: Titanium.UI.SIZE, attributedString: attr }); win.add(label);Moving out of 6.2.0, since we are trying to finalize the version the upcoming weeks and the PR has outstanding code-review adjustments.
PR - https://github.com/appcelerator/titanium_mobile/pull/10032 Test Case -
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var label = Ti.UI.createLabel(); var str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent quis dolor consequat turpis pharetra laoreet vitae a sapien. Aliquam erat volutpat. Nulla sit amet tellus sapien, a pulvinar metus. Suspendisse risus elit, dictum id molestie ac, ullamcorper id dui. Vivamus dapibus, eros nec sodales semper, sem dui semper eros, id condimentum quam tellus at ligula. Ut justo magna, tempor et vestibulum id, tincidunt sit amet quam. Maecenas dictum metus vel diam blandit facilisis. Ut tincidunt nibh non ligula sagittis nec tincidunt augue vehicula. Suspendisse sem dui, ornare in condimentum ut, convallis ut quam. Proin pharetra augue sed tortor aliquam iaculis. Etiam non erat lectus. In ac metus massa, quis dictum metus. Quisque faucibus quam non leo fringilla sit amet mattis mauris dictum. Duis viverra ipsum blandit dolor congue sed adipiscing tortor porta. Nullam malesuada felis ut dolor dignissim faucibus."; label.attributedString = Ti.UI.createAttributedString({ text: str, attributes: [{ type: Ti.UI.ATTRIBUTE_PARAGRAPH_STYLE, value: { alignment: Ti.UI.TEXT_ALIGNMENT_JUSTIFY, minimumLineHeight: 3, headIndent: 5, lineSpacing: 5, lineBreakMode: Ti.UI.ATTRIBUTE_LINE_BREAK_BY_WORD_WRAPPING, }, range: [0,str.length] }] }); win.add(label); win.open();FR passed.
Verified the fix on SDK 7.5.0.v20180919120117. Works fine.Closing
Operating System Name = Mac OS X Version = 10.13.6 Architecture = 64bit # CPUs = 8 Memory = 17179869184 Node.js Node.js Version = 8.9.1 npm Version = 5.5.1 Titanium CLI CLI Version = 5.1.1 SDK =7.5.0.v20180919120117 iPhone 6s -IOS 12