GithubHelp home page GithubHelp logo

Comments (5)

harlanhaskins avatar harlanhaskins commented on August 16, 2024

I guess I think this would be simpler as an extension with static functions on Banner

Like:

extension Banner {
    class func warning(text: String) {
        return Banner(title: "Warning", subtitle: text, image: UIImage(named: "Caution"), backgroundColor: UIColor.bryxYellowColor())
    }
}

from bryxbanner.

AnthonyMDev avatar AnthonyMDev commented on August 16, 2024

Hmm, that's a fair point @harlanhaskins . I hadn't even considered that. It probably would be easier. I like the idea of being able to pass around BannerTemplateType objects though. For instance, an ErrorType enum could conform to BannerTemplateType so you could show the right error message for any given error.

This also allows me to pass a BannerTemplateType into a function to display the banner at run-time, when I may not know what banner I want to use at compile time.

Chances are using an extension, I could always get the same functionality, but I feel like it would create cleaner code in many situations using a protocol, and much more flexible.

Additionally, a user can easily create extensions as you have above on their own right now if they need them, so adding the protocol does not stop you from doing so.

Thoughts?

from bryxbanner.

AnthonyMDev avatar AnthonyMDev commented on August 16, 2024

@harlanhaskins If you aren't interested in this feature, just let me know and we can close this.
Using extensions is something that users can probably just implement on their own very easily, so I don't think we need to add anything to the library in that case.

I still think that have a protocol for this would be really helpful, and I'm willing to take the time to make a PR, but I understand if this is a feature you aren't interested in including.

from bryxbanner.

harlanhaskins avatar harlanhaskins commented on August 16, 2024

Yeah, I'm just not really convinced it's worth the extra coverage in the library. The Banner API is fairly simple on purpose.

Thanks for the proposal though!

from bryxbanner.

AnthonyMDev avatar AnthonyMDev commented on August 16, 2024

You got it. Thanks

from bryxbanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.