[UIApplication] Use prefix on category name for UIApplication+AppExtensions so that category names don't conflict in ObjC namespace.
sourced from cl/285233749
Corrects a bug in an font scaling test that assumed the test host had its
content sizes category set to `UIContentSizeCategoryLarge`.
Discovered while authoring #8476.
This method's logic exists frequently throughout our componentry and theming extensions as a mechanism for scaling a scalable font with the preferred content size category.
This change introduces a new API that can be invoked by each of the components and theming extensions that support Dynamic Type.
Part of https://github.com/material-components/material-components-ios/issues/7470
- `-mdc_scaledFontForSizeCategory:` has been documented as preferred over `-mdc_scaledFontForCurrentSizeCategory` because it encourages use of trait collections and is more testable as a result.
- The method summaries follow the verb form guidance at https://developers.google.com/style/reference-verbs (i.e. "Returns" instead of "Return").
- `mdc_scalingCurve's` property type is now typedef'd so that it can be consistently used throughout the Typography target.
- All of the public API have been copy-edited for clarity and conciseness.
Closes https://github.com/material-components/material-components-ios/issues/7474
Prior to this change, mdc_scalingCurve was implemented using retain semantics insteaad of copy semantics. This potentially enabled a class of surprising bugs if mutable dictionaries were being assigned and then modified after the fact.
After this change, mdc_scalingCurve implements copy semantics as its public API defines.
The added test was verified to fail prior to this PR's change, and passes with the PR's change.
Closes https://github.com/material-components/material-components-ios/issues/7472
The original README for Typography is not composed by separate files. This PR solely adds a separate file for Dynamic Type section, which needs to be integrated into the root one later.
This is a follow up PR for #7166 adds @objc annotations to Swift catalogMetadata() methods, because the Swift 4 compiler no longer attempts to infer what methods should be visible to Objective-C. As a result of this change in the compiler, no Swift examples were showing up in Dragons after #7166. See this article: https://useyourloaf.com/blog/objc-warnings-upgrading-to-swift-4/ for additional context.
Adds a new scheme that vends fonts with an associated scaling curve.
This is a BREAKING CHANGE due to a new, required property in the MDCTypographyScheming protocol.
To easily migrate, clients can add the following method to their custom implementations of MDCTypographyScheming.
- (BOOL)mdc_adjustsFontForContentSizeCategory {
return NO;
}
MDCFontScalar allows us to add an associated scaling curve to UIFont instances. This scaling curve allows us to support Dynamic Type by creating differently sized fonts based on a UIContentSizeCategory.
MDCFontScaler offers similar, but limited, functionality as UIKit's UIFontMetrics.
Next iteration of our Dynamic Type.
Mimics Apple's new APIs. (UIFontMetrics)
Adds MDCFontScalar to attach curves.
Adds UIFont category to expose fontScaledForCategory methods.
Adds new MDCTypographyScheme with scalable fonts.
Adds sample to demonstrate new curves.
### Context
By default, Objective-C code will only perform availability checks for iOS APIs introduced from iOS 11 and up. We can enable -Wunguarded-availability to turn on available checks for older SDKs.
Additional context for this behavior comes from [llvm](https://reviews.llvm.org/D34264);
> [This patch](https://reviews.llvm.org/D34264) adds a new warning flag called -Wunguarded-availability-new. If -Wunguarded-availability is off, this warning only warns about uses of APIs that have been introduced in macOS >= 10.13, iOS >= 11, watchOS >= 4 and tvOS >= 11. This warning is on by default. We decided to use this kind of solution as we didn't want to turn on -Wunguarded-availability by default, as we didn't want our users to get warnings about uses of old APIs in their existing projects.
### What's happening in this change
This change turns on -Wunguarded-availability. This has the effect of the compiler performing availability checks for all APIs at or above the current deployment target (iOS 8.0). As such, this PR addresses several instances of code that were not performing availability checks.
Going forward, we will be able to use availability to encode our supported SDKs into the APIs that we provide. For example, we could annotate MDCActivityIndicator with NS_AVAILABLE_IOS(9_0) and all of our code would then have to use runtime checks prior to using this API.
### Caveats
Because -Wunguarded-availability is not enabled by default in Objective-C, our clients will need to proactively enable this flag in order to be warned of any use of APIs that support OS versions < 11.0. We can mitigate this risk in two ways:
1. Clearly announce any changes in our supported OS versions.
2. Encourage clients to enable -Wunguarded-availability.
We have had errors when generating the docs using jazzy specifically around components giving a fatal error around not finding imports when depending on other components. This is because each component for jazzy is isolated and on its own unless we provide the framework root. This caused our website generator to crash each time and fail to generate a new website.
This should resolve this problem.
QA=
Before the fix when running the website generator we got these errors:
```
/material-components-ios/components/BottomAppBar/src/MDCBottomAppBarView.h:17:9: fatal error: 'MaterialButtons.h' file not found
building site
building search index
^C/Library/Ruby/Gems/2.3.0/gems/rouge-3.1.1/lib/rouge/lexer.rb:458:in `load': Interrupt
from /Library/Ruby/Gems/2.3.0/gems/rouge-3.1.1/lib/rouge/lexer.rb:458:in `load_lexer'
from /Library/Ruby/Gems/2.3.0/gems/rouge-3.1.1/lib/rouge.rb:50:in `block in <top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/rouge-3.1.1/lib/rouge.rb:49:in `each'
from /Library/Ruby/Gems/2.3.0/gems/rouge-3.1.1/lib/rouge.rb:49:in `<top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/jazzy_markdown.rb:2:in `require'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/jazzy_markdown.rb:2:in `<top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc.rb:7:in `require'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc.rb:7:in `<top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/config.rb:5:in `require'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/config.rb:5:in `<top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy.rb:1:in `require'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy.rb:1:in `<top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/bin/jazzy:13:in `require'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/bin/jazzy:13:in `<top (required)>'
from /usr/local/bin/jazzy:22:in `load'
from /usr/local/bin/jazzy:22:in `<top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:74:in `load'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:28:in `run'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/cli.rb:463:in `exec'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/cli.rb:27:in `dispatch'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/cli.rb:18:in `start'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/exe/bundle:30:in `block in <top (required)>'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
from /Library/Ruby/Gems/2.3.0/gems/bundler-2.0.1/exe/bundle:22:in `<top (required)>'
from /usr/local/bin/bundle:22:in `load'
from /usr/local/bin/bundle:22:in `<main>'
/material-components-site-generator/scripts/lib/reporter.js:36
throw e;
^
Error: Command failed: bundle exec jazzy --output "/material-components-site-generator/.stage/ios/catalog/bottomnavigation/api-docs/" --theme "/material-components-site-generator/ios-api-docs-src/theme" --head '/components' --use-safe-filenames
at checkExecSyncError (child_process.js:601:13)
at execSync (child_process.js:641:13)
at JazzyApiGenerator.build (/material-components-site-generator/scripts/lib/jazzy-api-generator.js:34:5)
at PlatformSite.generateApiDocs (/material-components-site-generator/scripts/lib/platform-site.js:212:17)
at platformSites.forEach (/material-components-site-generator/scripts/build:86:14)
at Array.forEach (<anonymous>)
at reporter.step (/material-components-site-generator/scripts/build:85:21)
at Reporter.step (/material-components-site-generator/scripts/lib/reporter.js:32:22)
at Object.<anonymous> (/material-components-site-generator/scripts/build:84:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
```
Now we no longer get fatal errors or crash when running the script.
This change was automatically generated by running a find replace of the following strings:
```
mdc_unit_test_suite(
mdc_unit_test_suite(
name = "unit_tests",
```
And then running buildifier to enforce style:
find . -name BUILD | xargs ~/buildifier
This is an automated change generated by running the following command:
find . -name BUILD | xargs buildifier
buildifier can be installed from https://github.com/bazelbuild/buildtools
This change formats all of our BUILD files with the buildifier formatter in preparation for us having a BUILD format linter as part of our presubmits and so that we can cleanly run buildozer commands against the codebase.
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
Our creativity knows no bounds.
### 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\.
*\*/
```
```
/\*
*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 ([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 ([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.
```
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.
```
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.
```
We can now make use of @available throughout our codebase.
We support Xcode 9 and up, which includes the iOS 11 SDK. This means we can remove any guards for SDKs prior to iOS 11.
This was cleaned up by running a global find-and-replace with the following regular expression:
```
Find:#if defined\(__IPHONE_11_0\) && \(__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0\)\n(.+if \(@available\(iOS 11.0, \*\)\) \{(?:.|\n)*?)(?:#else(?:.|\n)*?)?\n#endif
Replace:$1
```
With some additional cleanup for stragglers that didn't match this pattern. Note that else clauses were intentionally dropped.
Closes https://github.com/material-components/material-components-ios/issues/4909
* [TextFields] Adding todos for #4331
* [TextFields] Creating simple equality files.
* [TextFields] Prevents fonts that are almost the same but not quite from messing up the rendering.
* [Typography] Adding tests for font equality.
* [TextFields] Formatting.
* [Typography] Adding Math to the bazel file.
* [Typography] PR feedback.
* [Typography] PR feedback.
* [Typography] Comment.
* [Typography] PR feedback.
* [Typography] PR feedback.
* [Typography] Updating podspec.
* [Typography] Asserts for bazel.
* [Typography] Logging for tests.
* [Typography] Loggin.g
* [Typography] Removing logging and the deeper check.
* [Typography] Making simple equality a category.
* [TextFields] Using new method.