114 Commits

Author SHA1 Message Date
Andrew Overton
1f46b8b02d [Multiple components] Fix Cocoapods/compilation issues
PiperOrigin-RevId: 323829252
2020-07-29 11:28:05 -07:00
Andrew Overton
40e108d6b3 [Tabs] Add non fixed clustered centered layout style
PiperOrigin-RevId: 321388615
2020-07-15 10:34:49 -07:00
Jeff Verkoeyen
a66e645d94 Internal change
PiperOrigin-RevId: 315818254
2020-06-10 19:50:52 -07:00
Jeff Verkoeyen
d404e5e832 Internal change
PiperOrigin-RevId: 313588352
2020-05-28 08:11:54 -07:00
Jeff Verkoeyen
b5aa93e81c Internal change
PiperOrigin-RevId: 312773402
2020-05-21 17:44:22 -07:00
Nobody
70716800b8 Internal change
PiperOrigin-RevId: 312085611
2020-05-18 16:41:12 +00:00
Andrew Overton
0740f3d9e0 [Tabs] Add programmatic tab switcher buttons to TabBarView example
PiperOrigin-RevId: 310356364
2020-05-07 16:54:47 +00:00
Jeff Verkoeyen
92254ea119 Rename all icons to an ic_<#name#> convention.
PiperOrigin-RevId: 308232277
2020-04-24 04:33:51 -07:00
Andrew Overton
1666348de9 [Tabs] Add ScrollableCentered option to TabBarView example
PiperOrigin-RevId: 307083566
2020-04-17 11:43:51 -07:00
Bryan Oltman
99345ad508 [Tabs] Add example to expose a bug where tab selection indicator and selected text highlighting can get out of sync.
To reproduce:
1. Build and run the Dragons catalog app.
2. Launch the Tabs -> Text Tabs example.
3. Change alignment to "Selected Center".
4. Tap "Select First"
5. Tap "Select Last"
6. Tap "Select First" again
7. Tap "Select Last" again

Expected:
The selected (last) tab has both the selection indicator beneath it and highlighted text (white with 100% alpha)

Actual:
The selected (last) tab has the selection indicator beneath it, but its text styled as though it is not selected.
PiperOrigin-RevId: 306568811
2020-04-14 20:34:46 -07:00
Bryan Oltman
687ca49597
[Tabs] Add Swift example for MDCTabBarView (#9246)
Adds a rudimentary Swift example for `MDCTabBarView`

Fixes #9068
2019-12-11 13:33:23 -05:00
Robert Moore
1606c38d20 [Tabs] Fix examples. (#9233)
Mostly crash fixes. Corrects button theming for the `TabBarIconExample` as
well.

Found after #9125
2019-12-10 14:43:31 -05:00
Andrew Overton
38840677ff
[Tabs] Don't use MDCTabBarColorThemer in examples (#9125)
This PR makes it so that Tabs examples use the theming extension instead of the themer.

Related to #9061.
Related to #9063.
Related to #9062.
2019-12-05 15:30:13 -05:00
Robert Moore
93700ab4d9 [Tabs] Improve accessibility for TabBar example. (#8983)
The Tab Bar View Controller with Interface Builder example had no way to
dismiss with Voice Over, disappearing labels, and too much code.  Provides an
AppBar with back button, labels on every child view controller, and better
support for Dynamic Type.

|Before|After 1 AXXXL|After 2 XS|
|---|---|---|
|![IMG_0110](https://user-images.githubusercontent.com/1753199/68987915-134aa200-07fd-11ea-8424-277e0b6eb1ee.PNG)|![IMG_0114](https://user-images.githubusercontent.com/1753199/68987917-1d6ca080-07fd-11ea-8a1c-d1c372665fe5.PNG)|![IMG_0115](https://user-images.githubusercontent.com/1753199/68987918-22c9eb00-07fd-11ea-8b74-ec85cb602e93.PNG)|

Closes #8978
2019-11-18 08:31:07 -05:00
featherless
5425884431
[examples] Annotate all catalogShouldHideNavigation invocations with @objc. (#8791)
Context:

Due to changes in the Swift runtime over the past years, methods that are considered "optional" in Objective-C need to have @objc annotations in order for Objective-C to be able to perform `respondsToSelector:` invocations.

Problem:
Many of our examples had not annotated their `catalogShouldHideNavigation` methods with the `@objc` annotation, causing the Catalog to wrap the examples in a container app bar view controller. The reason most of these examples would implement `catalogShouldHideNavigation` is because they are managing their own navigation (e.g. to demonstrate AppBar functionality), so this would often result in duplicate AppBars appearing in the example.

The fix:
All `catalogShouldHideNavigation` Swift methods have been annotated with `@objc`.

Fixes https://github.com/material-components/material-components-ios/issues/7576
Fixes https://github.com/material-components/material-components-ios/issues/7578
2019-11-12 16:54:55 -05:00
Robert Moore
1ce82c678b
[Tabs] Expand configuration in MDCTabBarView example. (#8498)
Adds configuration options for `preferredLayoutStyle` and toggling
`contentInset`.

|Fewer Tabs (Portrait)|More Tabs (Landscape)|
|---|---|
|![Simulator Screen Shot - iPhone 7 - 2019-09-25 at 09 12 25](https://user-images.githubusercontent.com/1753199/65605352-f3260180-df76-11e9-8fcd-2cd68ec30fa3.png)|![Simulator Screen Shot - iPhone 7 - 2019-09-25 at 09 15 47](https://user-images.githubusercontent.com/1753199/65605434-181a7480-df77-11e9-993d-1a9c4e7a68e0.png)|


Helps exercise #8236
2019-09-25 10:57:40 -04:00
Robert Moore
3913e29f52
[Tabs] Drop iOS 9 guards. (#7999)
Part of #2651
2019-07-23 12:22:42 -04:00
Robert Moore
be5bd6e9c7
[Tabs] Expose selection change animation properties. (#7944)
When a custom item view changes its intrinsic content size, it will need to
trigger a layout on the `MDCTabBarView` to adjust to the new size. Because the
layout should generally be animated, the TabBarView should expose its animation
duration value for use by the custom view (or its view controller) in the
animation block.

|Using UIView animation defaults|With This PR|
|---|---|
|![tabbar-animation-develop](https://user-images.githubusercontent.com/1753199/61412161-f6c54a00-a89c-11e9-9368-41ca6e4a4919.gif)|![tabbar-animation-changed](https://user-images.githubusercontent.com/1753199/61412165-fc229480-a89c-11e9-9934-5e83b19ecf5b.gif)|

Closes #7943
Closes #7942
2019-07-19 20:22:52 -07:00
Robert Moore
3a0c1ee2e8
[Tabs] Allow clients to calculate when a view appears/disappears. (#7841)
A new API, `- rectForItem:inCoordinateSpace:` provides the item's corresponding
view's frame in the provided coordinate space. Clients can use this API to
calculate which views are "shown" at any given time. A simple use of this API
for that purpose is added to the example view controller.

Alternative solution to #6275
Closes #7839
2019-07-12 20:35:29 -04:00
Robert Moore
640220d66d
[Tabs] Fix segmented control position. (#7898)
On smaller devices, the constraints of the segmented control caused it to overlap the tab bar slightly.

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone SE - 2019-07-11 at 23 52 17](https://user-images.githubusercontent.com/1753199/61101216-f1987300-a436-11e9-93c0-6dbce2274a25.png)|![Simulator Screen Shot - iPhone SE - 2019-07-11 at 23 49 14](https://user-images.githubusercontent.com/1753199/61101138-c01fa780-a436-11e9-8940-6117f1613673.png)|


Closes #7813
2019-07-12 14:43:21 -04:00
Robert Moore
4d99e84305
[Tabs] Retain custom view in example. (#7901)
When switching to title-only Tabs, the custom view was lost because the `UITabBarItem` was recreated incorrectly.

Part of #7896
Follow-up to 7897
2019-07-12 14:42:56 -04:00
Robert Moore
f2b2580144
[Tabs] Fix title-only example. (#7897)
Once support for `selectedItem` was added, the example no longer correctly changed to title-only Tabs. This is because UITabBarItem seems to never allow setting `selectedItem` to `nil` once it has been read and returned anything other than `nil`.

Closes #7896
2019-07-12 10:34:09 -04:00
Robert Moore
09a7df6530
[Tabs] Add bottom divider. (#7817)
Adds the bottom divider and an API to make it visible and customize its color.

## TabBarView Example View Controller
|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone 7 - 2019-07-08 at 23 39 56](https://user-images.githubusercontent.com/1753199/60857758-b64d3880-a1d9-11e9-90de-fa4c4ebc942a.png)|![Simulator Screen Shot - iPhone 7 - 2019-07-08 at 23 34 30](https://user-images.githubusercontent.com/1753199/60857771-c36a2780-a1d9-11e9-830a-53e0074788ac.png)|


Closes #7742
2019-07-09 09:30:11 -04:00
Robert Moore
9e8165694e
[Tabs] Add setSelected:animated: API for custom views. (#7810)
Adds a new required protocol method for setting a custom view to be selected. This makes it easier for custom views to respond to selection events.

Closes #7801
2019-07-08 15:47:35 -04:00
Robert Moore
4cb495c435
[Tabs] Add item style options for TabBarView example. (#7808)
Adds the option to display text-only, image-only, or text-and-image Tabs in the TabBarView example view controller.

Part of #7748
2019-07-08 15:29:43 -04:00
Robert Moore
88e5a52f9f
[Tabs] Allow setting ripple color. (#7784)
Adds a property that customizes the ripple color.

## Example View Controller

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone X - 2019-07-03 at 00 14 24](https://user-images.githubusercontent.com/1753199/60562949-a809a300-9d27-11e9-963d-830356ed845c.png)|![Simulator Screen Shot - iPhone X - 2019-07-03 at 00 12 49](https://user-images.githubusercontent.com/1753199/60562952-ad66ed80-9d27-11e9-8013-db5dba602bf3.png)|

Closes #7657
2019-07-03 10:41:09 -04:00
Robert Moore
e4aee2a13b
[Tabs] Customize selection indicator color. (#7774)
Adds the ability to set a custom selection indicator color to the tab bar.

Closes #7657
2019-07-02 13:50:33 -04:00
Robert Moore
5a7efb0fcc
[Tabs] Inject dummy scroll view into example. (#7772)
This change has no visible effect. It injects a scroll view into the TabBarView example view controller so that the injected AppBar won't manipulate the Tab Bar's insets.

Follow-up from #7744
2019-07-02 10:33:29 -04:00
Robert Moore
4842c32fd8
[Tabs] Fixes layout for changing font sizes. (#7771)
When different font sizes for different states are used, the item view may end up with a different layout or even a different intrinsic content size.

Follow-up to #7757
2019-07-02 09:49:55 -04:00
Robert Moore
febf914e97
[Tabs] Adds support for rendering custom views. (#7755)
Clients can provide their own custom views if MDCTabBarView doesn't provide
sufficient behavior by default. An example custom view (containing a UISwitch)
is added to the Dragons example and a test.

![Simulator Screen Shot - iPhone 7 - 2019-06-28 at 22 49 36](https://user-images.githubusercontent.com/1753199/60379003-26e59f80-99f9-11e9-8d68-49d775c7b3c8.png)


Closes #7722
2019-07-01 08:59:37 -04:00
Cody Weaver
029692a0ba [TabBarView] Add titleFontForState APIs (#7757)
Adds `titleFont:forState:` APIs to customize the font of selected and unselected items generally. A future change may enable support for `-[UIBarItem titleTextAttributesForState:]`.

## Dragons Example View Controller

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone 7 - 2019-06-30 at 22 38 45](https://user-images.githubusercontent.com/1753199/60407218-e9634c80-9b87-11e9-9bef-10c2449002a7.png)|![Simulator Screen Shot - iPhone 7 - 2019-06-30 at 22 39 36](https://user-images.githubusercontent.com/1753199/60407236-f718d200-9b87-11e9-8380-195235c9494e.png)|


Part of #7657
2019-07-01 01:13:34 -04:00
mikefan1991
c3fe63e5e2 [Tabs] Add accessibility traits support (#7739)
Add UIAccessibility traits to item view.

**Testing**
accessibilityTraits
Steps to reproduce

1. Update the example to have a custom accessibilityTraits for one of the tabBarItems
    1. Optionally have it change those traits in the `tabBarView:didSelectItem:` delegate method.
2. item1.accessibilityTraits = @"Hello world";
3. Launch on a device
4. Select the item with Voiceover on
5. Navigate to the other items with titles but no custom value.
2019-06-28 00:45:34 -04:00
mikefan1991
ca5afce441 [Tabs] Add the user selection visible logic (#7740)
Add the logic that the selected item will be visible once on screen.
If the selected item is changed when the tab bar view is displayed, the scroll process is animated.
If the selected item is set before the tab bar view is displayed, the scroll process is not animated.

![tabs-selection-scroll](https://user-images.githubusercontent.com/1753199/60311093-abfe8500-9923-11e9-9654-a8e4bda2a6a2.gif)


Part of #7728
2019-06-28 00:44:52 -04:00
mikefan1991
46c8e51ae3 [Tabs] Add delegate support to MDCTabBarView (#7725)
This PR is adding the delegate support for the MDCTabBarView. Two delegate methods shoudSelect and didSelect is defined.

close #7658
2019-06-27 13:00:55 -04:00
Ang
60d5f0dbef [Tabs] Adds justified and scrollable layout to MDCTabBarView (#7704)
Adds justified and scrollable layout for MDCTabBarView and corresponding tests.

## Example View Controller

|Before|After (Portrait)|After (Landscape)
|---|---|---|
|![60151483-ea246900-97aa-11e9-9c1e-688f1d241512](https://user-images.githubusercontent.com/1753199/60179832-920e5680-97ec-11e9-8131-ebcf17f853de.png)|![Simulator Screen Shot - iPhone 7 - 2019-06-26 at 08 27 47](https://user-images.githubusercontent.com/1753199/60179840-98043780-97ec-11e9-9d3a-cbcfd48cb202.png)|![Simulator Screen Shot - iPhone 7 - 2019-06-26 at 08 29 09](https://user-images.githubusercontent.com/1753199/60179813-815de080-97ec-11e9-9d7b-14e19fae4df1.png)|


Part of Issue #7645
2019-06-26 11:13:30 -04:00
Robert Moore
88e145c62b
[Tabs] Add imageTintColorForState APIs. (#7714)
Adds an image tint color for the `.normal` and `.selected` states.

## Example View Controller

The intrinsic content size is known to be incorrect for bars where items have both titles and images. It will be fixed as part of https://github.com/material-components/material-components-ios/pull/7704.

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone 7 - 2019-06-24 at 13 20 57](https://user-images.githubusercontent.com/1753199/60151475-e7297880-97aa-11e9-8fc1-205b44011d5f.png)|![Simulator Screen Shot - iPhone 7 - 2019-06-26 at 00 37 13](https://user-images.githubusercontent.com/1753199/60151483-ea246900-97aa-11e9-9c1e-688f1d241512.png)|

Part of #7657
2019-06-26 08:09:38 -04:00
mikefan1991
e243456b42 [Tabs] Add user selection support to the MDCTabBarView (#7713)
Adds basic tap support to items in the tab bar.

## TabBarView Example View Controller

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone 7 - 2019-06-24 at 13 20 57](https://user-images.githubusercontent.com/1753199/60150317-2d300d80-97a6-11e9-8d9c-025b28888427.png)|![Simulator Screen Shot - iPhone 7 - 2019-06-26 at 00 04 09](https://user-images.githubusercontent.com/1753199/60150319-315c2b00-97a6-11e9-90d8-9c8348dcd0de.png)|

Part of #7644
2019-06-26 00:40:53 -04:00
Robert Moore
41369ecc17
[Tabs] Add barTintColor API. (#7711)
Adding a `barTintColor` to match APIs on MDCBottomNavigationBar, MDCBottomAppBar, MDCTabBar, and UITabBar.

Part of #7657
2019-06-25 15:37:35 -04:00
Robert Moore
d202640cd3
[Tabs] Send tab item title/image to views (#7698)
Initial configuration of title and image for itemviews. Does not yet have KVO (coming later). Is using a temporary layout that will be replaced later.

##  Dragon Example Screenshots

|Before|After|
|---|---|
|![Simulator Screen Shot - iPhone 7 - 2019-06-24 at 13 23 15](https://user-images.githubusercontent.com/1753199/60038806-3d030100-9683-11e9-9121-9daa78134e1b.png)|![Simulator Screen Shot - iPhone 7 - 2019-06-24 at 13 20 57](https://user-images.githubusercontent.com/1753199/60038676-fb725600-9682-11e9-83e5-3f0dd7a7669c.png)|


Part of #7697
2019-06-24 13:53:46 -04:00
Robert Moore
d0f3843388
[Tabs] Add missing example. (#7671)
The example was moved but I failed to add it to git from its new location.

Follow-up to #7655
2019-06-21 10:54:30 -04:00
Yarden Eitan
e78713078a
[Tabs] Adds the Ripple behavior to Tabs. (#7583)
## Related links
* Bug: Closes #7379 
* Ripple: [MDCRippleTouchController](https://github.com/material-components/material-components-ios/tree/develop/components/Ripple)

## Introduction
This PR integrates [`MDCRippleTouchController`](https://github.com/material-components/material-components-ios/blob/develop/components/Ripple/src/MDCRippleTouchController.h) into [`MDCTabBar`](https://github.com/material-components/material-components-ios/tree/develop/components/Tabs). This behavior is an opt in flag property added to MDCTabBar, `enableRippleBehavior`.  This improves the visual touch feedback for our users as MDCInkView didn't support our current motion guidelines. We are also marking any of the Ink APIs ToBeDeprecated as part of the [Deprecation Policy](cb6b8e9599/contributing/deprecation_policy.md (step-4-add-a-comment-to-the-api-indicating-that-it-will-be-deprecated)).

## Videos
| Before | After |
| - | - |
|![oldRipple](https://user-images.githubusercontent.com/4066863/59460503-38219000-8ded-11e9-938f-fadf0596cc5f.gif)|![newRipple](https://user-images.githubusercontent.com/4066863/59460535-525b6e00-8ded-11e9-97dd-9285aba8e290.gif)|
2019-06-15 12:48:22 -04:00
Andrew Overton
2607ee1aaa
[Tabs] Revert revert of #7518 (#7566)
This PR un-reverts #7518 and makes it so that the delegate methods introduced in #7518 are only called if the items are nonnull.

#7555 should be merged in first.

Closes #6275.
2019-06-14 15:32:37 -04:00
Cody Weaver
1a716e77b2 Revert "[Tabs] Give MDCTabBarDelegate pass through methods for "willDisplayCell"/"didEndDisplayingCell" (#7518)"
This reverts commit 08100bd8e16678eb271011a5a0bbf9e1e3e280c2.
2019-06-10 12:56:20 -04:00
Andrew Overton
08100bd8e1
[Tabs] Give MDCTabBarDelegate pass through methods for "willDisplayCell"/"didEndDisplayingCell" (#7518)
One of the solutions proposed in #6275 is to provide pass through methods for the UICollectionViewDelegate methods `-collectionView:willDisplayCell:forItemAtIndexPath:` and `-collectionView:didEndDisplayingCell:forItemAtIndexPath:`. This is the one I chose, mainly because it seemed the most straightforward. [One comment](https://github.com/material-components/material-components-ios/issues/6275#issuecomment-453650714) said we should be careful about this approach, and [another](https://github.com/material-components/material-components-ios/issues/6275#issuecomment-454204635) said we needed to look more into the "pre-fetching" behavior of these methods. It seems like a good approach to me... Scrolling through the tabs in the TabBarTextOnlyExample with print statements seems to work how I would expect it to. 👍
2019-06-07 11:39:40 -04:00
Yarden Eitan
efe61588a6
update (#7246)
We need to add @objc annotations to colorScheme and typographyScheme instances in our Swift examples, because we moved to Swift 4.2, the respondsToSelector won't find `setColorScheme:` and `setTypographyScheme:` setters otherwise.
2019-04-23 10:21:14 -04:00
Andrew Overton
c56d5d76d3
Add @objc annotations to get examples to show up in Dragons (#7168)
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.
2019-04-17 21:35:43 -04:00
Andrew Overton
b38372192f
Update to Swift 4.2 (#7166)
This PR updates the Swift version to 4.2.

Partially resolves #6874.
2019-04-17 16:59:02 -04:00
Robert Moore
6f8f35a128
[Tabs] Fix constraint crash in example. (#7010)
When adding a Star, the example would crash because one of the two
x/y values would nearly always be 0. This was caused by converting a
double into an integer in an earlier PR.

Closes #7009
2019-04-03 11:48:57 -04:00
featherless
f17b01c584
Enable -Wunguarded-availability. (#6776)
### 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.
2019-03-08 10:01:17 -05: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