Skip to content

Conversation

@seanoshea
Copy link
Contributor

A replacement for #670.

@seanoshea
Copy link
Contributor Author

With seanoshea/BostonFreedomTrail@7185af9, seanoshea/BostonFreedomTrail#190 and bd88915, I seemed to be able to style the snack bar message background color and text color.

cc @ianegordon @ajsecord

@codecov-io
Copy link

codecov-io commented Jan 4, 2017

Current coverage is 28.84% (diff: 14.28%)

No coverage report found for develop at 89e007b.

Powered by Codecov. Last update 89e007b...4833c77

@ianegordon ianegordon self-assigned this Jan 4, 2017
@seanoshea
Copy link
Contributor Author

Did a little investigation into how other view-based libraries manage this and found:

https://github.com/Instagram/IGListKit/blob/master/Source/IGListCollectionView.m#L17
https://github.com/Instagram/IGListKit/issues/294
https://github.com/jessesquires/BButton/blob/develop/BButton/Classes/BButton.m#L188-L201

I like the idea of overriding the getter and defaulting to the appearance setting in https://github.com/jessesquires/BButton/blob/develop/BButton/Classes/BButton.m#L193.

What do you think?

@ianegordon
Copy link
Contributor

I think there is a workaround where we don't have to check against nil. (Your concern above)

I've pulled out my demo code to try and lock down the magic order / combination.

[C&P some old notes on UIAppearance]

Initial Thinking:

Default values for properties annotated with UI_APPEARANCE_SELECTOR must be set in +initialize on the UIAppearance proxy..

Default values for properties annotated with IBInspectable should be set on the _ivar in -commonClassInit. If you have explicitly set a value to the property in your Storyboard, it will get set by the OS after this method.

Default values for properties that are neither UI_APPEARANCE_SELECTOR nor IBInspectable should be set in -commonClassInit on the _ivar if they are non-zero.

UIView subclasses should be annotated IBDesignable.

UIView subclasses should have a -commonClassnameInit method that is called from both -initWithFrame and -initWithCoder.

@seanoshea
Copy link
Contributor Author

OK - I think all those nil checks were unnecessary.

Unsure of whether it makes sense to make these new properties IBDesignable per your notes above, but willing to be convinced otherwise.

I guess one other thing we could do in this PR would be to override initWithCoder: and initWithFrame: and use a commonSnackbarMessageViewInit method?

@ajsecord
Copy link
Contributor

ajsecord commented Jan 9, 2017

@seanoshea, @ianegordon don't worry about the Travis CI—I'll fix it later.

@seanoshea
Copy link
Contributor Author

@ajsecord - ok. Didn't realize that the travis-ci boxes came pre-packaged with swiftlint. There must be a way to only try a brew install if the min version of swiftlint is not already installed on the machine.

Will fix my unit tests and revert that small change to the travis script.

@ajsecord
Copy link
Contributor

ajsecord commented Jan 9, 2017

Yeah...it also looks like different versions of brew consider the "already installed" case to be error vs warning. Sorry for the confusion!

@seanoshea
Copy link
Contributor Author

Frustrated by the inability to fully unit test this out, but as there's no host window to add the MDCSnackbarMessageView to, the UIAppearance additions are never triggered in a unit test environment.

I'm not exactly psyched about not having the PR have any unit tests associated with it - open to suggestions if you have any for testing out this kind of functionality.

@ianegordon ianegordon self-requested a review January 10, 2017 16:44
Copy link
Contributor

@ianegordon ianegordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
We will revisit adding UITests when technology allows.

@ianegordon ianegordon merged commit 95891e1 into material-components:develop Jan 11, 2017
kul3r4 pushed a commit to kul3r4/material-components-ios-1 that referenced this pull request Jan 18, 2017
* Snackbar Message View Styling.

* Small alteration to how colors are generated for the unit tests.

* Not styling the snack bar in the init method.

* Default styling for background views.

* Remove overriding the styling in init.

* Looks like swiftlint is already installed by default on travis-ci
boxes. Trying this as an experiment.

* Trying this?

* Cant get unit tests to pass as there’s no window to add the message
view to with logic tests.
jgunaratne pushed a commit that referenced this pull request Jan 18, 2017
* Extracts header code into method removing repetition

* [AppBar] Header stack view in AppBarController (#1121)

Since the header stack view is going to be laid out with auto layout, it should be inited with a CGRectZero. Doing it with self.view.bounds creates a tiny loop since the view is not loaded yet.

* [ThumbTrack] Remove extra UIColor categories (#1122)

* Pull the functionality of UIColor+MDC into MDCThumbTrack.

MDCThumbTrack is now the only class using this behaviour, so three extra files have been removed now that they are no longer necessary.

* Fixed colon alignment.

* [Ink] Add nonnull to the MDCInkTouchController initializer (#1123)

* Specify `nonnull` on the MDCInkTouchController initializer.

This is a quick change since the initializer was never returning nil to begin with.

* Update Shrine to use the nonnull MDCInkTouchController initializer.

* Formatted all Objective-C sources with clang-format. (#1133)

* [Scripts] Add scripts for "prepping" and cleaning the library/catalog/demo apps. (#1130)

* Changed build_all to echo the xcodebuild command it is executing.

* Added a clean_all script.

* Added a prep_all script.

* Updated README.md with new scripts.

* Change Travis CI to use the new `prep_all` script.

* Added a script to format Objective-C sources with clang-format. (#1132)

* Added comment about Travis CI's 10.1 device bug. (#1135)

* Removed the private/Color subspec. (#1128)

* [Catalog] Center views in the Buttons (Swift and Storyboard) demo (#1126)

* Center the Storyboard button demo.

This uses an outer container to set up a view which is 50% the screen width (to allow for the other half of the button demo), and then an inner container to vertically and horizontally center the buttons.

* Center the buttons added programatically.

* Weakify strongify asynchronously dispatched snackbar view dismissal (#1136)

* Update the button’s custom title color when the tint color changes. (#1134)

* Add travis_wait prefixes on long-running commands.

* Render Snackbar labels correctly for RTL (#1137)

* Change the MDCInteractionTest deployment target to 8.0. (#1131)

* Turn `inkController` into a lazy var. (#1139)

This removes the need for storing it as an optional.

* [ProgressView] Backward animation support (#1138)

* Add backward progress animation mode support.

This allows users to animate the progress view backward if they are giving it progress which is lesser than the current value.

* Demonstrate the backward progress animation support.

* Update the assets for the progress view.

* Change ProgressViewExample with new enum name.

* Updated enum names.

* Update with new enum names.

* Added script to install SwiftLint. (#1143)

* Ran scripts/format_all. (#1141)

* [Scripts] SwiftLint integration (#1129)

* Integrate SwiftLint in the Catalog.

* Update the disabled SwiftLint rules.

* Reference a local swiftlint.yml symlink.

This prevents us from getting warnings about code style violations from the other demos.

* Fix SwiftLint violations in the Catalog and Components.

* Ignore the `third_party` directory when running the linter.

We should not have to deal with warnings in code we may not be able to fix easily.

* Integrate SwiftLint into Shrine.

Additionally, fix a number of warnings introduced.

* Run SwiftLint on Travis.

* Enable many of the previously disabled rules and correct them.

* Fix control statement violations from SwiftLint.

* Update README.md

* Ignore "error" from already-installed brew packages.

* [FlexibleHeader] - Update tests so as not to have 0 in contentSize (#1146)

* Fixed broken links to versions.md.

* Added component changes to CHANGELOG.md.

* Added API diff, determined new version number is 20.0.0.

* Bumped version number to 20.0.0.

* Tell `brew install` to stop failing if swiftlint is already installed.

* Changed clean script to force-clean Xcode projects. (#1144)

* Fix SwiftLint warnings (#1149)

* Exclude catalog/third_party from SwiftLint.

* Added line length to .swiftlint.yml

* Fixed SwiftLint warnings with some minor refactors.

* Install SwiftLint via the install_contributor_tools script. (#1145)

* Install SwiftLint via the install_contributor_tools script.

* Exclude catalog/third_party from SwiftLint.

* Added line length to .swiftlint.yml

* Fixed SwiftLint warnings with some minor refactors.

* Revert "Fixed SwiftLint warnings with some minor refactors."

This reverts commit 2c19802.

* Revert "Added line length to .swiftlint.yml"

This reverts commit 12a6781.

* Revert "Exclude catalog/third_party from SwiftLint."

This reverts commit 8a00ad8.

* [Collections] Added custom Storyboard cell to the Storyboard example. (#1152)

* [Feature highlight] Dynamically size inner highlight (#1151)

* Use instance based inner radius

* Warning re ios sim

* Scale outer highlight to encircle inner highlight

* Dont scale innerhighlight pulsing with inner highlight size

* Reset highlight example supplemental:

* Build fix: CGFloat casts missing from MDCFeatureHighlightView.m.

* More SwiftLint fixes for unit tests and example apps. (#1154)

* ClangFormat changes.

* Added swiftlint to scripts/format_all.`

* Fix scripts/lint_all to work from any directory.

* Fixed swiftlint invocation.

* Remove the checks for force casting (! operator).

* Some fixes.

* More Swift fixes.

* [Snackbar] Message View Styling. (#1120)

* Snackbar Message View Styling.

* Small alteration to how colors are generated for the unit tests.

* Not styling the snack bar in the init method.

* Default styling for background views.

* Remove overriding the styling in init.

* Looks like swiftlint is already installed by default on travis-ci
boxes. Trying this as an experiment.

* Trying this?

* Cant get unit tests to pass as there’s no window to add the message
view to with logic tests.

* Fixed Shrine compilation.

* [AppBar] - Added Modal Presentation App Bar Example (#1153)

* ModalAppBar - Added additional AppBar example to display modal AppBar vc example

* ModalAppBar - Added swift modal example

* ModalAppBar - Updated naming

* ModalAppBar - Updated swift example

* ModalAppBar - Indentions and removed setting nil to title property

* Moves the initialization of the header page into separate file

* Moves the initialization of the header page into separate file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants