15 Commits

Author SHA1 Message Date
Alyssa Weiss
924c49e43b Remove all iOS 10 availability checks from material_components_ios now that only iOS 10+ is supported.
PiperOrigin-RevId: 366437050
2021-04-02 06:33:16 -07:00
Randall Li
fa62718bc5
add deps on availability for a bunch of components (#9679)
* add Availability build file

* add Button deps on availability

* added elevation

* corrected include statements to use import of the umbrella files

* revert unwanted changes

* spaces

* clangformat

* add availability dep

* added buttom nav deps on availibility

* Add FeatureHighlight build dep for Availability

* Add Availability build dep to FeatureHighlight private

* Add missing =

* fixed tabs spacing

Co-authored-by: Bryan Oltman <bryanoltman@gmail.com>
2020-02-11 13:14:09 -05:00
Nobody
98f8968ebe [Material][Availability] Migrates elevation to MDCAvailability.
PiperOrigin-RevId: 293812421
2020-02-07 07:49:46 -08:00
Wenyu Zhang
ba2336c38e
[Color+Elevation] Add a convenience method to resolve dynamic color only when traitCollection's color appearance has changed. (#8315)
Add this convenience method would help supporting theming extension in an easier way that we don't need to check color difference on traitCollection every time like https://github.com/material-components/material-components-ios/pull/8285/files#diff-48ca693ee2870d02b06a42900a1dc69dR73.
2019-08-15 10:59:48 -04:00
Yarden Eitan
3f121b7014
[Elevation] Update mdc_resolvedColorWithTraitCollection:elevation: to support pre-iOS 13 (#8217)
By having mdc_resolvedColorWithTraitCollection:elevation be an iOS13 only API, it forces the client using this API to have iOS13 checks surrounding this method, when in fact we are already adding those checks inside the method itself, making clients have to do additional work that is unneeded.

Secondly, having the method return nil if it isn't iOS13 and not just return the original color causes clients (and our theming extensions) to add additional checks if its nil and apply the original color otherwise:
```
self.backgroundColor = [self.backgroundColor resolvedColorForTraitCollection:self.traitCollection elevation:elevation] ?: self.backgroundColor;
```

Instead of just doing:
```
self.backgroundColor = [self.backgroundColor resolvedColorForTraitCollection:self.traitCollection elevation:elevation];
```

Lastly, I don't believe it makes sense to make the method an iOS13 API only as in fact UITraitCollections exist since iOS8, and is legitimate to pass it to the function even though userInterfaceStyle is not there yet.

Closes: #8216
2019-08-04 19:22:34 -07:00
Yarden Eitan
7d6164356f
[Elevation] Add smooth continuous formula for values between 0 and 1 (#8212)
In the UIColor+MaterialElevation category the formula to convert elevation to alpha has a jump for elevations that are 0 to anything bigger than 0.

This means that elevation 0 returns an alpha that is 0, but any elevation that is above 0, even 0.000000001 will return an alpha of 2 or bigger. This causes 2 problems:

Some of our components return elevations that are very close to 0, like 0.0000000000005 (AppBar in particular). If we don't fix this, it will cause constant flickering of the background color of the AppBar as it transitions between 0 and something closer to 0.
There is a big jump when component elevations between 0 and anything larger than 0 occurs which makes it seem like a jump and not smooth to the observer.
The change provide a smooth function that occurs between values of 0 and 1. This formula has been thought out in collaboration with design.

Closes: #8213
2019-08-02 21:01:32 -07:00
Robert Moore
9ea5f99c12
[Elevation] Fix spelling typos. (#8114) 2019-07-30 12:41:33 -04:00
Wenyu Zhang
c3f8c6adeb
[Elevation] Add a UIColor category to support resolving color with elevation. (#8085)
This PR provides two methods to allow users resolving color with elevation.

closes https://github.com/material-components/material-components-ios/issues/8086.
2019-07-26 16:48:56 -04:00
Wenyu Zhang
95047be49d Merge branch 'release-candidate' into develop 2019-07-24 16:50:27 -04:00
Yarden Eitan
c980a95d54
[Elevation] Add absoluteElevation property and clarify the elevationDidChange block param (#8071)
As clients will initialize their material components and want to provide a background color that fits the component's elevation, they will need to get its absolute elevation value. Therefore, currently they need to add mdc_currentElevation + mdc_baseElevation themselves to get that.

In this PR I am adding an mdc_absoluteElevation getter where clients can get that and not have to do unneeded calculation in their code. Furthermore, because elevationDidChangeBlock effectively returns the absolute elevation, it would be easier for clients to understand that concept by also providing an absoluteElevation property.

Added easier to understand description of what exactly the elevationDidChangeBlock elevation param it provides.
2019-07-24 14:30:08 -04:00
Yarden Eitan
0a270c3842 [Elevation] passing self to the elevationDidChangeBlock (#8058)
Similarly to `traitCollectionDidChangeBlock`, we want to pass `self` here in cases where the object is being injected, and also to remove the need from clients to weakify self and possibly cause retain cycles.

When our components conform to this block, they should be more type specific to what self is. As an example in the MDCCard header, I would expect conforming to this block would be declared like:
```
@property(nonatomic, copy, nullable) void (^mdc_elevationDidChangeBlock)
(MDCCard * elevatableSelf, CGFloat elevation);
```
2019-07-24 12:13:13 -04:00
Cody Weaver
96a2a60934 [Elevation] Add category to UIView (#7969)
Adds a category to UIView to get a mdc_baseElevation for a given view. This new property will allow views to know the elevation of everything below them.

Related to #7964
2019-07-24 12:12:29 -04:00
Cody Weaver
e312d88119
[Elevation] Add elevationDidChange method to UIView category (#8067)
This change adds a method to UIView elevationDidChange to inform all UIViews and their subviews that one of their _superview_s changed elevation and they may need to be re-themed.

Closes #8005
2019-07-24 08:26:26 -07:00
Yarden Eitan
0643370347
[Elevation] passing self to the elevationDidChangeBlock (#8058)
Similarly to `traitCollectionDidChangeBlock`, we want to pass `self` here in cases where the object is being injected, and also to remove the need from clients to weakify self and possibly cause retain cycles.

When our components conform to this block, they should be more type specific to what self is. As an example in the MDCCard header, I would expect conforming to this block would be declared like:
```
@property(nonatomic, copy, nullable) void (^mdc_elevationDidChangeBlock)
(MDCCard * elevatableSelf, CGFloat elevation);
```
2019-07-24 10:59:16 -04:00
Cody Weaver
f335b96277
[Elevation] Add category to UIView (#7969)
Adds a category to UIView to get a mdc_baseElevation for a given view. This new property will allow views to know the elevation of everything below them.

Related to #7964
2019-07-23 15:32:54 -07:00