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

Better customization through use of a specific stylesheet protocol #18

Merged
merged 1 commit into from
Dec 17, 2013

Conversation

grantjk
Copy link
Contributor

@grantjk grantjk commented Dec 16, 2013

Hi,
I just came across the lib recently and was playing around with customizing the colors a bit more. Because I like using Cocoapods, I like having the ability to customize the message views without directly altering the original libraries.

This pull request specifies a stylesheet protocol so anyone can pass in an object that conforms to the protocol and change the attributes they want. It also makes it really easy to subclass the default TWMessageBarStyleSheet and only override some of the properties. Trying to change the background color of only one of the message types is as easy as subclassing the TWMessageBarStyleSheet and just calling super for the non-modified types.

I'd be interested to hear what you think, I threw this together pretty quick this afternoon, but it appears to work for me.

I'd be happy to make more changes too.

  • JG

@terryworona
Copy link
Owner

I was meaning to do something like this. To be honest, I have no idea why I architected the customization component (ie. stylesheet) the way I did; it's less than ideal.

I'll take a look at this PR this week and likely pull it in.

@grantjk
Copy link
Contributor Author

grantjk commented Dec 17, 2013

Great! Let me know if you see something to change. I'm happy to figure something out.

On Dec 16, 2013, at 5:02 PM, terryworona notifications@github.com wrote:

I was meaning to do something like this. To be honest, I have no idea why I architected the customization component (ie. stylesheet) the way I did; it's less than ideal.

I'll take a look at this PR this week and likely pull it in.


Reply to this email directly or view it on GitHub.

@terryworona terryworona merged commit 8321fe6 into terryworona:master Dec 17, 2013
@terryworona
Copy link
Owner

Alright I merged it all in. Changed just a few things and created a demo style sheet. This provides a much better solution going forward for adding further customization options.

@grantjk grantjk deleted the customization branch December 17, 2013 13:58
@grantjk
Copy link
Contributor Author

grantjk commented Dec 17, 2013

Great!
Only thing I can see is that it might be a good idea to expose the interface for TWDefaultMessageBarStyleSheet in the header file so that basic customization like the following is still possible:

@interface HMSCMessageBarStyleSheet : TWDefaultMessageBarStyleSheet

@end

@implementation HMSCMessageBarStyleSheet

- (UIColor *)backgroundColorForMessageType:(TWMessageBarMessageType)type
{
    switch (type) {
        case TWMessageBarMessageTypeError:
            return [UIColor redColor];
            break;
        case TWMessageBarMessageTypeInfo:
        case TWMessageBarMessageTypeSuccess:
            return [super backgroundColorForMessageType:type];
        default:
            break;
    }
}

@end

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.

2 participants