26 Commits

Author SHA1 Message Date
Jeff Verkoeyen
eb82984224 Internal change
PiperOrigin-RevId: 331764642
2020-09-15 07:31:56 -07:00
Wenyu Zhang
bb04d0aab5 [Shapes] Use the path's boundingBox to determine the scale used when borderWidth is deducted from the path.
PiperOrigin-RevId: 324334338
2020-07-31 18:45:05 -07:00
Wenyu Zhang
aeacc8dcc6 [Shapes] Add a snapshot test for small path rendered in a large bounding box with same borderWidth and cornerRadius.
PiperOrigin-RevId: 323814069
2020-07-29 10:23:00 -07:00
Yarden Eitan
f4263fe70e [Shape] Update shapeLayer to the correct path to correctly be a mask for content.
PiperOrigin-RevId: 322911498
2020-07-23 18:33:38 -07:00
Yarden Eitan
a5ddb265b2 [Shapes] Fixes for the shape shadow layer if the borderWidth is set multiple times and there isn't a prepareShadowPath pass.
PiperOrigin-RevId: 322888549
2020-07-23 16:18:22 -07:00
Jeff Verkoeyen
2db3fd1ced [Shapes] Fix divide by zero bug.
This bug was happening when an MDCShapedShadowLayer has an empty frame and a positive shapedBorderWidth value, and a path is assigned. The MDCShapedShadowLayer was attempting to calculate a value in relation to the bounds of the MDCShapedShadowLayer, which in turn was resulting in a divide by zero.

This change adds safeguards around the divisions to ensure that a division does not occur if the width or height are sufficiently close to zero.

PiperOrigin-RevId: 322768484
2020-07-23 05:37:21 -07:00
Jeff Verkoeyen
fb4f43d36c [Shapes] Add unit tests demonstrating a divide by zero error.
This error can happen when an MDCShapedShadowLayer has an empty frame and a positive shapedBorderWidth value, and a path is assigned. There is a divide by zero in the logic introduced in cl/322615641.

In a subsequent change I will fix the bug and update the test accordingly.

PiperOrigin-RevId: 322689400
2020-07-22 17:23:02 -07:00
Yarden Eitan
3f3816f014 [Shapes] Updates the shapeGenerator with a line width to inset the line rather than center it.
There is a visual difference when using lineWidth instead of borderWidth due to lineWidth drawing on the path, and borderWidth insetting from the path.
To resolve this, the path is made smaller by half the width of the line, thus to create a similar visual appearance as if borderWidth was set.

PiperOrigin-RevId: 322615641
2020-07-22 11:24:19 -07:00
Wenyu Zhang
245b90cd57 [ShadowLayer] Resolve UIColor instance when it is set as shapedBackgroundColor to MDCShapedShadowLayer.
PiperOrigin-RevId: 313387989
2020-05-27 07:53:01 -07:00
Wenyu Zhang
b19e4e964d [ShadowLayer] Add prepareShadowPath to MDCShadowLayer to allow its subclass preparing shadow path before MDCShadowLayer lays out its sublayers.
PiperOrigin-RevId: 313383830
2020-05-27 07:20:37 -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
Bryan Oltman
d7e0e82b07
[Shapes] Update MDCShapedShadowLayer color properties to use copy semantics (#9756)
Updates the shapedBackgroundColor and shapedBorderColor properties of MDCShapedShadowLayer to use the copy attribute (instead of strong). This fixes a memory leak associated with the internal issue b/149094748.
2020-02-18 21:45:55 -05:00
featherless
162a063bda
[bazel] Remove all unused mdc_objc_library loads. (#9376)
Found by searching for all references to `\bmdc_objc_library` and removing load statements from files that only returned one result.

Clean up as part of https://github.com/material-components/material-components-ios/issues/9363
2020-01-02 14:34:36 -05:00
Cody Weaver
a18d6e6b41
[Shapes] Update border color to support dynamic color (#8308)
### Context

Currently the `setBorderColor` method of MDCShapedShadowLayer can receive a dynamic color but will use the light mode color because it doesn't not know about traitCollections since it is a CALayer subclass. This causes a problem for any component that subclasses `UIControl` and updates its visuals based on state. For instance MDCCard within `setHighlighted` calls `updateBorderColor` which then would call `setBorderColor` on the shapedShadowLayer. Since traitCollection was never involved here the border gets render as it's in a light mode even if it happens to be in a dark mode. Additionally, we may need this for other CGColor things but this will unblock card for now.

### Screenshots

| Before | After |
| - | - |
|![before](https://user-images.githubusercontent.com/7131294/62970425-73d0da00-bddd-11e9-8643-6ae5b039a3a2.gif)|![after](https://user-images.githubusercontent.com/7131294/62970438-7d5a4200-bddd-11e9-9a38-45b7e8bb8328.gif)|
2019-08-14 09:18:51 -04:00
Robert Moore
b556ab09c3
[Shapes] Use Starlark macros. (#8192)
Add more Starlark macro use to the BUILD file to make releasing easier.

Part of #8150
2019-08-02 16:33:12 -04:00
Julien Poumailloux
783fd07621 Fix memory leak in -[MDCRectangleShapeGenerator pathForSize:] by returning an autoreleased CGPathRef (#7913)
Fixes #7912
2019-07-15 08:32:09 -04:00
featherless
e2550dbb55
(automated) Regenerate all component readmes. (#7201)
This is an automated change. It was generated by running:

    ./scripts/generate_all_readmes
2019-04-22 13:29:48 +03:00
Wenyu Zhang
a4e6886f22
Fix some CGFloat conversion. (#7130) 2019-04-12 12:09:19 -04:00
Robert Moore
ac4b4eafcd
[Shapes] Add basic Snapshot tests. (#6919)
Adding simple Snapshot tests for shape generators and elevation.

Closes #6804
2019-03-20 12:48:01 -04:00
Yarden Eitan
c4d24627ee
updated jazzy yaml files to include framework root (#6750)
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.
2019-03-01 16:52:02 -05:00
Yarden Eitan
10abd4524d
[Shapes] Move shapes from components/private to components/ - Part 3 (last part) (#6734)
This is the third and last part of the migration of moving the Shape libraries away from the private/ folder. Continuation to PR: #6664 and #6495

Tracking bug, progress and more details can be found here: #6494

This resolves #6494

Because Shapes and ShapeLibrary have been used in production and are an integral part of the shape scheme and theming. Moreover, with to stop the confusion of clients that the library should not be imported as it is under private, we want to migrate the Shape libs to be under components/ instead of components/private.

The migration will be a 7 step migration to not break clients internally.
**We have completed steps 1 to 6, This PR concludes step 7 and the entire migration**

1. move the folders to the new directory.
2. Make the old component's BUILD and Podspec targets depend on the new component (and nothing else).
3. Delete all implementation files from the old component.
4. Replace the contents of the old component's headers with import statements to the new component's header. If the new component has headers that match the old component's, then the new component's headers will need to be named uniquely for a period of time to allow clients to migrate over.
5. Once all clients have migrated from the old component, delete the old component. This is a breaking change.
6. If you had to create temporary header names in the new component, then in a separate release add the new headers that you want the new component to use. Move the content of the old headers into the new headers and replace the old headers with an import of the new headers. Migrate clients to the desired headers.
7. Once all clients have moved off of the old headers, delete the old headers.
2019-02-28 16:54:58 -05:00
Yarden Eitan
25ff47e248
[Shapes]! Move shapes from components/private to components/ - Part 2 (#6664)
This is the second part of the migration of moving the Shape libraries away from the private/ folder. Continuation to PR: #6495

**This is a breaking change**

Tracking bug, progress and more details can be found here: #6494

Because Shapes and ShapeLibrary have been used in production and are an integral part of the shape scheme and theming. Moreover, with to stop the confusion of clients that the library should not be imported as it is under private, we want to migrate the Shape libs to be under components/ instead of components/private.

The migration will be a 7 step migration to not break clients internally.
**We have completed steps 1 to 4, This PR concludes step 5**

1. move the folders to the new directory.
2. Make the old component's BUILD and Podspec targets depend on the new component (and nothing else).
3. Delete all implementation files from the old component.
4. Replace the contents of the old component's headers with import statements to the new component's header. If the new component has headers that match the old component's, then the new component's headers will need to be named uniquely for a period of time to allow clients to migrate over.
5. Once all clients have migrated from the old component, delete the old component. This is a breaking change.
6. If you had to create temporary header names in the new component, then in a separate release add the new headers that you want the new component to use. Move the content of the old headers into the new headers and replace the old headers with an import of the new headers. Migrate clients to the desired headers.
7. Once all clients have moved off of the old headers, delete the old headers.

Passes bazel build and pod build locally.
2019-02-20 11:31:59 -05:00
Yarden Eitan
017b613a75
shape path nil check (#6616)
Our `MDCShapedShadowLayer` in `layoutSublayers` sets the path based on the shape generator's `pathForSize` method. This in turn sets the `shadowPath` of the CALayer. However, if `shapeGenerator` is nil, the `shadowPath` will become nil as well, nullifying any set up of `shadowPath` that has been set prior by the client.

This fixes this issue and most likely resolves an internal issue.
2019-02-14 17:05:37 -05:00
Yarden Eitan
de5d200599
[Shapes] Move shapes from components/private to components/ (#6495)
This is the first part of the migration of moving the Shape libraries away from the private/ folder.

Tracking bug, progress and more details can be found here: #6494 

"Because Shapes and ShapeLibrary have been used in production and are an integral part of the shape scheme and theming. Moreover, with to stop the confusion of clients that the library should not be imported as it is under private, we want to migrate the Shape libs to be under components/ instead of components/private.

The migration will be a 7 step migration to not break clients internally.

1. move the folders to the new directory.
2. Make the old component's BUILD and Podspec targets depend on the new component (and nothing else).
3. Delete all implementation files from the old component.
4. Replace the contents of the old component's headers with import statements to the new component's header. If the new component has headers that match the old component's, then the new component's headers will need to be named uniquely for a period of time to allow clients to migrate over.
5. Once all clients have migrated from the old component, delete the old component. This is a breaking change.
6. If you had to create temporary header names in the new component, then in a separate release add the new headers that you want the new component to use. Move the content of the old headers into the new headers and replace the old headers with an import of the new headers. Migrate clients to the desired headers.
7. Once all clients have moved off of the old headers, delete the old headers.

Passes bazel build and pod build locally.
2019-01-28 17:51:27 -05:00