39 Commits

Author SHA1 Message Date
Nobody
79b2c20369 Ignore strict warnings on unused functions in private/Math
PiperOrigin-RevId: 474968977
2022-09-16 22:42:14 -07:00
Jeff Verkoeyen
22861e3594 [Math] Delete unused MDCDegreesToRadians.
PiperOrigin-RevId: 462516724
2022-07-21 18:55:28 -07:00
Jeff Verkoeyen
9ecefd04e7 Delete deprecated math functions.
PiperOrigin-RevId: 404810846
2021-10-21 09:23:57 -07:00
Jeff Verkoeyen
a798879555 Add an MDCFloatIsApproximatelyZero method.
PiperOrigin-RevId: 404793427
2021-10-21 07:53:00 -07:00
Jeff Verkoeyen
c34de39e30 Internal change.
PiperOrigin-RevId: 397316843
2021-09-17 07:45:01 -07:00
Aron Budinszky
139d7f628e [Math] Remove use of deprecated methods.
This fixes a bug introduced by [e1afe22](e1afe22cfb) which caused failing builds on Xcode 12 due to use of deprecated methods.

Specifically: the related commit above deprecated the custom MDCMath-specific methods, but MDCMath.h itself continues to use those same deprecated methods. This causes builds to fail (v117, Xcode 12, included as a Pod); previous version with v116 or a custom version with my commit resolves the issue.

### Thanks for starting a pull request on Material Components!

#### Don't forget:
- [X] Identify the component the PR relates to in brackets in the title. ```[Buttons] Updated documentation```
- [ ] Link to GitHub issues it solves. ```closes #1234```
- [ ] Please add unit tests, snapshot tests, or manual testing steps depending on the change.
- [ ] Sign the CLA bot. You can do this once the pull request is opened.

[Contributing](https://github.com/material-components/material-components-ios/tree/develop/contributing) has more information and tips for a great
pull request.

Closes https://github.com/material-components/material-components-ios/pull/10091

COPYBARA_INTEGRATE_REVIEW=https://github.com/material-components/material-components-ios/pull/10091 from aronbudinszky:develop d8caae97a1777857dea959e34130b2af87ba4a61
PiperOrigin-RevId: 336098267
2020-10-08 09:19:54 -07:00
Jeff Verkoeyen
e1afe22cfb [Math] Deprecate all APIs that have a direct standard library equivalent.
Prefer using tgmath.h to get double/float-based APIs instead.

PiperOrigin-RevId: 333511426
2020-09-24 07:39:16 -07:00
Wenyu Zhang
98f43faf56 [Math] Delete MDCVisibleAreaInsetsForMinimumTappability.
PiperOrigin-RevId: 320656443
2020-07-10 12:48:33 -07:00
Wenyu Zhang
a95c7968c8 [Math] Mark MDCVisibleAreaInsetsForMinimumTappability deprecated.
PiperOrigin-RevId: 319291209
2020-07-01 13:59:45 -07:00
Yarden Eitan
6bd4757079 [HitAreaInsets] Add a convenience math method to calculate the correct visibleAreaInsets given a frame and a minimum touch target.
PiperOrigin-RevId: 315655291
2020-06-10 02:29:15 -07:00
Wenyu Zhang
a3381717f7
Fix the bazel BUILD files and snapshot that were restored unintentionally.(#9983) 2020-04-29 11:00:00 -04:00
Randall Li
0100cfe414 [MDC-iOS/BottomSheet] Fix dismissOnDraggingDownSheet behavior
The bottom sheet incorrectly allowed the sheet to be drag dismissed when `dismissOnDraggingDownSheet` was set to NO.

This change permits the gesture to dismiss to begin but prevents it from actually closing the sheet.

https://github.com/material-components/material-components-ios/issues/9723

Closes https://github.com/material-components/material-components-ios/pull/9885

PiperOrigin-RevId: 307802500
2020-04-22 06:21:26 -07:00
Jeff Verkoeyen
8abbb099a9 Delete all bazel support.
We no longer support bazel.

This PR deletes everything related to bazel support from our repo.

Closes https://github.com/material-components/material-components-ios/pull/9968

PiperOrigin-RevId: 306227127
2020-04-13 07:13:47 -07:00
Robert Moore
00c88d5317
[Math] Use Starlark macros. (#8204)
Use more Starlark macros to make releasing easier.

Part of #8150
2019-08-02 16:36:08 -04:00
Wenyu Zhang
46454f9f4b
[Math] Add MDCEdgeInsetsEqualToEdgeInsets to compare two UIEdgeInsets. (#7804)
Created to prepare for a fix for https://github.com/material-components/material-components-ios/issues/7752.

`UIEdgeInsetsEqualToEdgeInsets` directly compares `CGFloat` number within two . The `MDCEdgeInsetsEqualToEdgeInsets` added in this PR compares UIEdgeInsets using `MDCCGFloatEqual` to take epsilon into consideration.
2019-07-08 12:54:06 -04:00
Robert Moore
800188a649
{clang-format} Format the components. (#6347)
This is a follow-up to https://github.com/material-components/material-components-ios/pull/6027

```
find components \( -name "*.h" -or -name "*.m" \) | xargs clang-format -i
```
2019-01-23 11:08:43 -05:00
Wenyu Zhang
6ff913571e
[Math] Add Math tests to bazel (#6282)
closes #6231
2019-01-13 23:09:10 -05:00
Yarden Eitan
2803125b2c
ran clang-format (#6027) 2019-01-11 13:23:51 -05:00
Andrew Overton
056e4701f0
Make pod install work on Cocoapods 1.6.0.beta.2 (#5966)
# Original PR description:

On Cocoapods version 1.6.0 beta 2 we get an error on pod install because certain test targets don't have any sources to compile. This PR adds some skeleton unit test source files to get that working. Is everyone okay with these (for now) basically empty files?

Closes #5825

# FInal PR description:

The original aim of this PR was to get the project working with the Cocoapods 1.6 beta.

I initially didn't know where to begin getting it to work, so I used `pod lib lint` to get answers. `pod lib lint` had issues with the following things:

1. test_specs not having any sources to compile. This was due to our pattern of putting unit test test_specs inside of parent test_specs that didn't have anything else.

To address this I did two things. First, I moved away from the nested test_spec pattern. Now, instead of "Subspec/tests/unit_tests" it's "Subspec/UnitTests". This is more in line with the style Cocoapods uses [here](http://blog.cocoapods.org/CocoaPods-1.6.0-beta/). Secondly, I added some dummy files for things like UIMetrics and MaterialMath.

2. Importing headers across modules without using framework style imports.

I added framework style imports. This required some additional rewrite rules in the kokoro script.

3. Dependencies across subspecs being implicit.

I made them explicit by adding dependency statements to the podspecs where needed. 

`pod lib lint` didn't take issue with this, but I also saw that `MaterialComponents` was depending on `MaterialComponentsBeta` in various places. For example, all the theming extensions were in beta, but the tests for them weren't. I moved the tests to test_specs within the beta extensions. This required some directory structure changes. These changes then required some BUILD file changes. Making BUILD file changes made me realize that some swift unit tests weren't being accounted for by bazel. I took care of this too.

This PR also fixes some swift debugging stuff--"po" statements that weren't working before now do. I didn't rigorously verify this, but I also think this PR will lead to faster clean build times? It kinda seemed like it was while I was working on it.
2019-01-11 10:08:05 -05:00
Robert Moore
03f3351ad5
Global replace of single-precision floats with CGFloat casts. (#5718)
Replacing all non-integral, single-precision floating point literals with double-precision values explicitly cast to CGFloat.  For example, `0.1f` should become `(CGFloat)0.1`.

Regex used:
```
([0-9]*\.)([0-9]*?)([1-9]+)([0-9]*?)[fF]
```

PiperOrigin-RevId: 220683126
2018-11-12 10:50:01 -05:00
Robert Moore
74a27253e8
Global replace of integral single-precision literals with integer literals. (#5709)
Global replace of integral single-precision literals with integer literals.

Regular expression used:
```perl
/[^\w]([0-9]+)\.[0]*[fF]/$1/
```
2018-11-08 14:02:04 -05:00
featherless
2181084272
[automated] Standardize our open source license stanza to what Xcode generates. (#4985)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on #4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at

 http://www\.apache\.org/licenses/LICENSE-2\.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
/\*
Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

Licensed under the Apache License, Version 2\.0 \(the "License"\);
you may not use this file except in compliance with the License\.
You may obtain a copy of the License at

http://www\.apache\.org/licenses/LICENSE-2\.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
See the License for the specific language governing permissions and
limitations under the License\.
\*/
```

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.
 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at
 http://www\.apache\.org/licenses/LICENSE-2\.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
// Copyright $1-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
```
2018-08-31 12:13:07 -04:00
Jeff Verkoeyen
9854044c96 Revert "[automated] Standardize our open source license stanza to what Xcode generates. (#4982)"
This reverts commit b45bc2fdd4dfe12fc76751a45c9cf7b0d6c1261f.
2018-08-31 12:01:24 -04:00
featherless
b45bc2fdd4
[automated] Standardize our open source license stanza to what Xcode generates. (#4982)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on https://github.com/material-components/material-components-ios/pull/4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

### Find

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at

 http://www\.apache\.org/licenses/LICENSE-2\.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.
 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at
 http://www\.apache\.org/licenses/LICENSE-2\.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

### Replace

```
// Copyright $1-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
```
2018-08-31 11:49:00 -04:00
Wenyu Zhang
7d33f7597e
[Math] added MDCCeilScaled and MDCFloorScaled (#1917) (#4867)
closes #1917
2018-08-23 12:32:55 -04:00
Robert Moore
04ca713388
[Math] Fix CGFloat errors in tests. (#4858)
An internal build failed (once) when compiling the Math tests because
double-precision floating point
values were being implicitly cast to single-precision. Marking each of these
as either single-precision float or CGFloat (where convenient). Except for the
tests that measure rounding errors, single- and double-precision isn't
important for the test outputs.

Sample error:

material_components_ios/components/private/Math/tests/unit/MDCMathTests.m:33:38: error: implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float') [-Werror,-Wconversion]
  CGRect misalignedRect = CGRectMake(0.45, 0.78, 1.01, 5.98);
                          ~~~~~~~~~~ ^~~~
2018-08-21 09:10:27 -04:00
Robert Moore
f1bb92ee92 [BottomNavigation, Math] Fix BOOL types (#4436)
Two files were using C99 `bool` instead of Objective-C `BOOL` types. This
could lead to breakages in the future if the `BOOL` type were redefined by the
Objective-C headers.
2018-06-26 13:42:22 -04:00
Sam Morrison
c63eeafda4
[Chips] Pixel align subviews (#2739)
* [Chips] Pixel align subviews

* Document MDCSizeCeilWithScale

* Scale arg
2017-12-19 16:23:36 -05:00
Will Larche
1bd5590bbb
[Kokoro] Support for TextFields, Math, and Typography (#2432)
* [TextFields] Kokoro work.

* [Math] Imports needed for kokoro.

* [Kokoro] Support for MDCMath.

* [TextFields] Alphabetizing.

* [Kokoro] Formatting.

* [Kokoro] Formatting
2017-11-16 22:25:52 -05:00
featherless
5c87a3fd9a
[BottomSheet] Add BUILD file for kokoro + bazel support. (#2396)
* [BottomSheet] Add BUILD file for kokoro + bazel support.

I will be sending out a variety of pull requests soon to the bottom sheet. Adding the component to kokoro will let the PRs land more quickly.

* Remove unused load statements.
2017-11-10 17:35:16 -05:00
Sam Morrison
663120a830 Shapes (#2086) 2017-10-04 15:29:06 -04:00
Robert Moore
65bf96dd7c [Math] MDCRectAlignToScale treats scale 0 as 1 (#2045)
Rather than potentially returning a CGRectNull and causing UIKit crashes
if it's assigned to a view's frame or bounds, treat a scale of 0 as a
scale of 1.

Closes #2044
2017-09-27 20:28:37 +09:00
Robert Moore
4fd3a41963 [Math] Round CGPoint and align UIView centers (#2042)
Although it is possible to currently align a CGRect (frame) to a
pixel-aligned bounding rectangle, in some cases manipulating the frame
is neither possible nor desirable (such as when the transform is not the
identity).  Adding two new methods to support rounding a CGPoint to a
pixel and aligning the center point of a UIVIew given its bounds.
2017-09-27 01:54:56 +09:00
Junius Gunaratne
d200d6cdef [Math] Add degrees to radians method to MDCMath (#2015)
* Adding radian/degree math

* Cast to float
2017-09-21 10:02:58 -07:00
Robert Moore
2a65ea5809 [Math] Adding more unit tests for rect alignment (#1751)
Adding unit tests for a scale of zero and CGRectNull inputs.

References #1723
2017-08-08 12:03:02 -04:00
Robert Moore
e03ad370c6 [Math] Align frames to pixel boundaries (#1730)
Adding a new function to realign a CGRect (frame) to pixel boundaries
based on the screen scale. After a review of the catalog, I'm updating
the areas where I found misaligned frames.

Closes #1723
2017-08-07 16:46:32 -04:00
Sam Morrison
f466588e4f [Feature Highlight] Swipe to dismiss (#1636)
* Add new Dismiss gesture recognizer to allow swiping away feature highlights

* Tap outside the feature highlight to dismiss

* Formatting and cleanup

* Fix unused var warnings

* Correctly cancel animation when gesture recognizer gets cancelled

* Fade out text when starting dismiss gesture

* Formatting

* Ignore multiple touches

* Remove debug state logging

* Fade text in/out during dismissal gesture

* Address comments

* Prevent floating point conversion warnings

* MDCPow / MDCSqrt

* Add accessibilityPerformEscape to feature highlight
2017-07-17 17:59:03 -04:00
Will Larche
d8a58feecd [All] Formatting. (#1329) 2017-04-18 18:10:02 -04:00
Will Larche
ff5d165869 [Math] New private math component (#1325)
* [Math] New private component.

* [Math] Putting MaterialMath everywhere it could help.
2017-04-17 16:14:17 -04:00