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

When right aligning a text component and setting the truncation string , the truncation string doesn't show #75

Closed
avnerbarr opened this issue Apr 8, 2015 · 7 comments
Labels

Comments

@avnerbarr
Copy link
Contributor

I right aligned the text component, limited it to 1 line and set a truncation string. The truncation string doesn't display as expected

@ocrickard
Copy link
Contributor

Could you please provide sample code and a screenshot of your observed
behavior?
On Wed, Apr 8, 2015 at 7:47 AM avnerbarr notifications@github.com wrote:

I right aligned the text component, limited it to 1 line and set a
truncation string. The truncation string doesn't display as expected


Reply to this email directly or view it on GitHub
#75.

@avnerbarr
Copy link
Contributor Author

Sure:

+(instancetype)n {

    // the left label should fit and aligned to left side
    CKLabelComponent *leftLabel = [CKLabelComponent newWithLabelAttributes:{
        .string = @"Left label",
        .maximumNumberOfLines = 1,
        .color = [UIColor componentsLightGreyColor],
        .font = [UIFont componentsTitleFont]
    }viewAttributes:{
        {@selector(setBackgroundColor:),[UIColor clearColor]}
    }];

    // the right label should be aligned to the right of the container and truncated
    CKLabelComponent *right = [CKLabelComponent newWithLabelAttributes:{
       .string = @"This is a really long string that should be truncated",
        .truncationString = @"... more",
        .maximumNumberOfLines = 1,
        .alignment = NSTextAlignmentRight
    }viewAttributes:{
        {@selector(setBackgroundColor:),[UIColor clearColor]}
    }];
    CKStackLayoutComponent *stack = [CKStackLayoutComponent newWithView:{
        [UIView class],
        {
            {@selector(setBackgroundColor:),[UIColor clearColor]}
        }
    } size:{
        .minHeight = 44
    }style:{
        .alignItems = CKStackLayoutAlignItemsStretch,
        .direction = CKStackLayoutDirectionHorizontal,
    }children:{
        {
            .component = [CKCenterLayoutComponent newWithCenteringOptions:CKCenterLayoutComponentCenteringY sizingOptions:CKCenterLayoutComponentSizingOptionDefault child:leftLabel size:{.minHeight = 44}],
            .flexGrow = YES,
            .spacingBefore = 15
        },
        {
            .component = [CKCenterLayoutComponent newWithCenteringOptions:CKCenterLayoutComponentCenteringY sizingOptions:CKCenterLayoutComponentSizingOptionDefault child:right size:{.minHeight = 44}],
            .spacingBefore = 20,
            .spacingAfter = 15,
            .flexShrink = YES
        }
    }];

    return [super newWithComponent:stack];
}

screen shot 2015-04-08 at 3 08 21 pm

@avnerbarr
Copy link
Contributor Author

If i play with the . maximumNumberOfLines the behavior is as you would expect.

@ocrickard
Copy link
Contributor

Hmm, yeah, ideally it should consume all available space, not sure yet if this is a bug in text component's truncation or sizing behavior, or if it's an interaction between the stack layout component and the text component.

@ocrickard ocrickard added the bug label Apr 8, 2015
@ocrickard
Copy link
Contributor

Confirmed this is a bug in CKTextKitTailTruncater. I had assumed that right-aligned text was RTL writing direction and as a result the truncation location selected is incorrect. Will fix.

@ocrickard
Copy link
Contributor

This should be fixed now, let me know if you continue to have issues.

@DrChrispoper
Copy link

@ocrickard
I'm reopening this as the issue is similar.
Setting a max of 1 line breaks with
.lineBreakMode = NSLineBreakByCharWrapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants