Skip to content

Banner Configuration Struct initialization - #2

Closed
ahartwel wants to merge 2 commits into
Daltron:masterfrom
ahartwel:feature/style_struct
Closed

Banner Configuration Struct initialization#2
ahartwel wants to merge 2 commits into
Daltron:masterfrom
ahartwel:feature/style_struct

Conversation

@ahartwel

Copy link
Copy Markdown

No description provided.

ahartwel added 2 commits April 3, 2017 22:25
no change to the existing api, but added init(config: BannerConfiguration)
@ahartwel

ahartwel commented Apr 15, 2017

Copy link
Copy Markdown
Author

Hey Daltron,
I implemented the creation of the banner with a configuration struct. I kept the original api in place but switched them over to using the struct under the hood and added an initializer init(config: BannerConfiguration)

The configurations have two inits, one long one with all the properties (with some default values) and a builder init.

//long init
let config = BannerConfiguration(color: UIColor.green, title: "Custom Notification from a struct", attributedTitle: nil, subtitle: "Extremely Customizable", attributedSubtitle: nil, leftView: nil, rightView: nil, customView: nil, bannerHeight: 100, duration: 2)


//builder 
let config = BannerConfiguration(builder: { banner in
                banner.color = UIColor.green
                banner.title = "Custom notification from a struct"
                banner.subtitle = "Extremely Customizable"
                banner.bannerHeight = 100
                banner.duration = 2
    })

I also did some reorganizing throughout the NotificationBanner subclasses and split out the adding of subviews and applying of constraints out into separate functions so that it would be easier to understand the set up when applying the BannerConfiguration. I didn't change any functionality there just moved stuff around.

@Daltron

Daltron commented Apr 15, 2017

Copy link
Copy Markdown
Owner

@ahartwel First off, thanks a lot for taking a stab at this. It looks like a lot of time was put into it and that is greatly appreciated. However, after carefully reviewing, I'm still not sure this is in NotificationBanner's best interest quite yet. It doesn't really seem to add any new significant functionality that NotificationBanner doesn't already have. I'd love to hear any opposition you may have. I encourage you to use your forked version if it truly suits your needs better.

@ahartwel

Copy link
Copy Markdown
Author

It didn't add any functionality but it allows users to customize the banner without needing to know about the internals of the banner. The best example of this is the duration and height. In master you have to read through the code to find out they are publicly modifiable. With a config object you get all the properties abstracted away from their implementation and you can set what you want and just ignore the inner workings of the banner. You don't need to read through any docs or code to know what you can do.

@Daltron

Daltron commented Apr 15, 2017

Copy link
Copy Markdown
Owner

@ahartwel I understand the point you are trying to bring across but I still don't think this configuration option makes setting the duration and bannerHeight and other properties for that matter easier. The chances are very high (but you may disagree) that someone who wants to modify these properties are simply going to:

  1. Type banner.dur and banner.hei and see from xCode's auto-complete that the duration and bannerHeight properties are available. This option is how I and a lot of other developers I know quickly see if properties are available within a library.

or

  1. If they can't find what they are looking for via xCode's auto complete, then quickly glance over the source code to see if the property they are looking for can be modified.

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