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

Tc 1698 #3647

Closed
wants to merge 5 commits into from
Closed

Tc 1698 #3647

wants to merge 5 commits into from

Conversation

farfromrefug
Copy link
Contributor

jira ticket

So it s a big one.
It s a completely new label to support html and more.
It s based on DTCoreText and TTTAttributeLabel

Actually for DTCoreText it s based on my fork of it as i needed to modify it

I need DTCoreText for the "html string to NSAttributeString" and i use TTTAttributeLabel as the label it self (because the one from DTCoreText wasn't good enough).

As for the integration of DTCoreText(and DTFoundation as it comes with) into Titanium, i did what i could and i am willing to modify anything necessary.

Now about the label itself it behaves even better than the original one.
To show that and mostly to test the new label i actually let the old one in as TiUILabelOld. It will allow to compare the two.

I did some heavy testing and everything seems to be working.
Only one thing is bugging me and it was already present in the old one: The label doesnt behave correctly while animating. Especially the view is animated but the label view (the subview added in TiUILabel) is not and resize immediately. You can see the behavior in the example below.

Here is the example i use to test compare

var win = Titanium.UI.createWindow();
win.backgroundColor = 'white';

function merge_options(obj1,obj2){
    var obj3 = {};
    for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
    for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
    return obj3;
}

var  holder = Ti.UI.createView({
    width:Ti.UI.SIZE,
    height:Ti.UI.SIZE,
    layout:'vertical'
})

var args = {
    top:5,
    width: 200,
    height: Ti.UI.SIZE,
    textAlign:'center',
    verticalAlign:'center',
    font:{fontSize:12, fontWeight:'normal'},
    shadowOffset:{x:0, y:1},
    shadowColor:'#ff000000',
    shadowRadius:4,
    textPaddingRight:15,
    textPaddingTop:5,
    wordWrap:false,
    borderRadius:4,
    autoLink : Ti.UI.AUTOLINK_MAP_ADDRESSES|Ti.UI.AUTOLINK_PHONE_NUMBERS|Ti.UI.AUTOLINK_URLS
}
var viewOld = Titanium.UI.createLabelOld(merge_options(args, {
  backgroundColor:'green',
  text: "hello, world! I'm really happy to see you. And now this test needs to be longer"
}));
holder.add(viewOld);

var viewNew1 = Titanium.UI.createLabel(merge_options(args, {
  backgroundColor:'green',
  text: "hello 0679113383, world! http://google.com ok. now an address 2 rue edouard branly grenoble france"
}));
holder.add(viewNew1);

viewNew1.addEventListener('touchstart', function(e){
    if (e.source.height === Ti.UI.SIZE)
        e.source.animate({height:30, duration:500});
    else
        e.source.animate({height:Ti.UI.SIZE, duration:500});
});

var viewNew2 = Titanium.UI.createLabel(merge_options(args, {
  backgroundColor:'green',
  html: '<b>Nevada Hotel</b><br><small><font color="#E0E0E0">Floor</font> <b><font color="#FD2500">1F</font></b></small>',
}));
holder.add(viewNew2);

viewNew2.addEventListener('touchstart', function(e){
    if (e.source.textAlign === 'left')
        e.source.textAlign = 'center';
    else if (e.source.textAlign === 'center')
        e.source.textAlign = 'right';
    else
        e.source.textAlign = 'left';

    if (e.source.verticalAlign === 'top')
        e.source.verticalAlign = 'center';
    else if (e.source.verticalAlign === 'center')
        e.source.verticalAlign = 'bottom';
    else
        e.source.verticalAlign = 'top';

    if (e.source.backgroundColor === 'green')
        e.source.backgroundColor = 'red';
    else
        e.source.backgroundColor = 'green';
});

win.add(holder);
win.open();

Its based on TTTAttributeLabel and DTCoreText

Conflicts:
	iphone/Classes/TiUILabel.h
	iphone/Classes/TiUILabel.m
	iphone/iphone/Titanium.xcodeproj/project.pbxproj
For now only tel/url/maps are opened directly
added support for multiLineEllipsize

Conflicts:
	android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUILabel.java
@farfromrefug
Copy link
Contributor Author

Seeing there is no follow up on this one and since maintaining my github branch is getting really hard, i decided to discard that pull request. Sorry
May be one day we ll be able to work closer

@hdogan
Copy link
Contributor

hdogan commented Feb 27, 2013

What a pity :/

@ndastur
Copy link

ndastur commented May 31, 2013

It is a shame and a much needed feature. Is it possible to transform this into a module instead?

@farfromrefug
Copy link
Contributor Author

Sorry it simplemented in my private branch and working perfectly (even if a improved tableview), and i cant take the time to turn in into a module.

Very sorry!

@DrMoriarty
Copy link

I've found a module with rich text labels https://github.com/pegli/RichText it based on DTCoreText
iOS only

@farfromrefug farfromrefug deleted the TC-1698 branch October 18, 2013 06:43
@farfromrefug
Copy link
Contributor Author

Yes @DrMoriarty that s where i started if i remember correctly

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.

None yet

4 participants