46 Commits

Author SHA1 Message Date
Nobody
ac1c286e31 Fixed up imports for Slider
PiperOrigin-RevId: 476113171
2022-09-22 09:00:05 -07:00
Wenyu Zhang
8e0ed49dc6 [Slider] Set thumbIsSmallerWhenDisabled to NO to match Material spec.
PiperOrigin-RevId: 332867778
2020-09-21 09:36:43 -07:00
Bryan Oltman
c861bd32c9 [Slider] Remove checks for iOS 10 availability.
PiperOrigin-RevId: 332074254
2020-09-16 13:24:05 -07:00
Jeff Verkoeyen
7119e0c1fe [Slider] Expose thumbBorderWidth and thumbIsSmallerWhenDisabled.
These APIs enable further configuration of the slider's behavior and style.

PiperOrigin-RevId: 330570657
2020-09-08 13:10:03 -07:00
Wenyu Zhang
ab519cac9f [ThumbTrack] Turn centerVisibleArea on on ThumbView to ensure its minimum touch target size.
PiperOrigin-RevId: 325297919
2020-08-06 13:32:43 -07:00
Yarden Eitan
6326cd055a
[Slider] Allow thumb to stay filled with discrete value label (#9866)
As per Material Design: https://material.io/components/sliders/#discrete-slider a discrete slider can have it thumb stay even when a value label presents itself.

With the current implementation, when a value label on a discrete slider is displayed, the thumb disappears.

Clients can no opt-in to having the thumb continue to display itself when the value label is shown.

Tested by running catalog example on simulator with the property set to YES, as well as with unit test and snapshot test.

Closes #8986
2020-03-10 13:30:09 +02:00
Robert Moore
4194c01fbe
[Slider][ThumbTrack] Fix event handling. (#8759)
Slider/ThumbTrack event handling was broken by the way track tick visibility
was implemented. This PR fixes that event handling.

Fixes #8758
2019-11-11 16:21:44 -05:00
Robert Moore
5d6941b61d
[Slider][ThumbTrack] Continuous sliders show tick marks. (#8745)
Enables showing tick marks for continuous Sliders.

Closes #8737
2019-11-06 22:21:05 -05:00
Robert Moore
61f901fdc7
[ThumbTrack][Slider] Add API to control showing tick marks. (#8743)
A new API, `trackTickVisibility` is provided to control the visibility of
track tick marks. Specifically allows showing track tick marks for continuous
sliders and for discrete sliders even when the Thumb is not pressed.

Closes #8737
2019-11-06 14:13:25 -05:00
Yarden Eitan
8f9dd740d0
[Slider] [ThumbTrack] Add Font API and Dynamic Type support (#8708)
In this PR the main goal is to add Dynamic Type support. As part of this support I am doing the following:

1. Adding a Font API to ThumbTrack and Slider to be able to set the font of the discrete label to a scalable font.
2. Deprecating the old fontSize API (which isn't used internally).
3. Adding adjustsFontForContentSizeCategory APIs to Slider and ThumbTrack.
4. Resizing the ThumbTrack view accordingly based on the font size instead of having it static.

The snapshot tests in place allow me to present the new support for dynamic type and custom fonts.

Closes #8646
2019-11-01 10:58:07 -04:00
afweiss
8a587b8c61 [Slider] Adding Haptic Feedback When Crossing Anchored Value (#8225)
For sliders that are anchored, there is now a light vibration when the user passes over the slider's anchored value.
2019-09-03 12:30:10 -04:00
Robert Moore
efdbb44938
[Slider] Remove use of NS_ASSUME_NONNULL_BEGIN. (#8300)
The project overwhelmingly uses explicit nullability annotations. This PR
switches a test class for MDCSlider to explicit annotations.

Part of #8297
2019-08-13 12:52:32 -04:00
Robert Moore
be45bbf3ee
[Slider] Use Starlark BUILD macros. (#8194)
Add more Starlark macros to the BUILD file to make releasing easier.

Part of #8150
2019-08-02 16:33:28 -04:00
Cody Weaver
c6ab74349d
[Slider] Add MaterialElevation support (#8127)
Adds conformance to MDCElevatable and MDCElevationOverriding to
MDCSlider.

Closes #8014
2019-07-30 21:57:43 -07:00
Cody Weaver
118840dfc8
[Slider] Add traitCollectionDidChange block (#8057)
Adds a traitCollectionDidChangeBlock to MDCSlider, called when its trait collection changes.

Closes #8042
2019-07-23 20:46:43 -07:00
afweiss
46efae77c6 [Slider] Allowing Full Haptics for Discrete Sliders (#7765)
* haptics for slider

* updating formatting and style for slider haptics

* updated formatting for slider tests

* updating slider test name

* adding full haptics option for discrete sliders

* updated formatting for full haptics

* updating full haptics

* updating formatting for discrete haptics

* fixing formating
2019-07-09 09:18:08 -04:00
afweiss
2674c8cd13 [Slider] Haptics For Slider (#7738)
This adds haptics for sliders. The haptics for sliders are opt-out and cause a light vibration when the slider reaches the min or max value. These decisions were made to match apples implementation of haptics for sliders.
2019-07-01 15:55:13 -04:00
Yarden Eitan
e9ac3ee70d
[Slider] Adds the Ripple behavior to Slider. (#7600)
## Related links
* Bug: Closes #7378  
* Ripple: [MDCRippleView](https://github.com/material-components/material-components-ios/tree/develop/components/Ripple)

## Introduction
This PR integrates [`MDCRippleView`](https://github.com/material-components/material-components-ios/blob/develop/components/Ripple/src/MDCRippleView.h) into [`MDCSlider`](https://github.com/material-components/material-components-ios/tree/develop/components/Slider) by way of [`MDCThumbTrack`](https://github.com/material-components/material-components-ios/tree/develop/components/private/ThumbTrack). This behavior is an opt in flag property added to MDCSlider, `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)).
As you can see in the below videos, Ink was never implemented correctly for Slider, and therefore never appeared. With Ripple enabled, we finally get the right results, as seen [in our spec](https://material.io/design/components/sliders.html#continuous-slider).

## Videos
| Before | After |
| - | - |
|![oldRipple](https://user-images.githubusercontent.com/4066863/59466125-7ffae400-8dfa-11e9-9da2-d2ee87433f28.gif)|![newRipple](https://user-images.githubusercontent.com/4066863/59466127-81c4a780-8dfa-11e9-808a-295f8ca613c9.gif)|
2019-06-16 16:19:50 -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
Robert Moore
b443fa393b
[Slider] Deflake unit tests. (#6143)
Several unit tests were comparing the outcome of arithemtic by using
`XCTAssertEqual`, which requires absolute precision for floating point numbers.
Due to rounding errors, this is neither important nor desirable. Instead,
`XCTAssertEqualWithAccuracy` should be used.

Also corrected the order of the assertion parameters. The test value should
come before the expected value because the failure message has the template,
@"(%@) is not equal to (%@)" and when read it implies that the second value
(sentence object) is the correct value.

Removed some debug messages that managed to creep in there a while back.
2018-12-28 22:40:00 -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
Cody Weaver
27e8fcc816
[Slider] Support custom increment and decrement levels (#4534)
Implement accessibilityActivate method to respond to double tap when VoiceOver is enabled.
Closes #4507
2018-07-12 14:57:27 -04:00
John Detloff
e965234aaf
Fix accessibilityIncrement for discrete sliders (#4327)
When numberOfDiscreteValues is non-zero, the MDCSlider should use these as the step value in accessibilityIncrement and accessibilityDecrement. If the number of discrete values is fewer than 8, then VoiceOver users cannot modify the slider value by swiping up or down.
2018-05-31 11:56:20 -04:00
featherless
40f69695cf [Slider] Disabling flaky test. (#3560)
Closes https://github.com/material-components/material-components-ios/issues/3203
Closes https://github.com/material-components/material-components-ios/issues/3160
2018-04-30 09:35:53 -04:00
Robert Moore
3cbd58837b
[Slider] Add tick color API (#3344)
The Slider needs a way to support custom colors for the discrete value "ticks"
within both the filled and unfilled portions of the track.  They should also
be customizable across states (to support disabled colors).

**Before**
![slider-tick-ex-before](https://user-images.githubusercontent.com/1753199/38699189-5acc6590-3e65-11e8-8078-a92f7f4b52dc.png)

**After**
![slider-tick-ex-after](https://user-images.githubusercontent.com/1753199/38699194-5eacb89a-3e65-11e8-8b46-c607a013730b.png)


Partially implements #3137
Pivotal story: https://www.pivotaltracker.com/story/show/155525171
14f043b
2018-04-12 16:25:49 -04:00
Robert Moore
54d7fdf8da
[Slider] Add text, background color to value label (#3330)
The discrete value label should be customizable instead of inheriting
the color from the track fill color.

Partially implements #3137
Pivotal story: https://www.pivotaltracker.com/story/show/155525171
2018-04-12 14:03:08 -04:00
Robert Moore
b7d2999215
[Slider] Add inkColor, thumbColorForState:, trackFillColorForState: (#3310)
Instead of a single `color` property that maps back to multiple properties in
MDCThumbTrack, MDCSlider should make each of these properties explicit.  This
includes:

* Ink color
* Thumb color
* Track fill color
* Track background color

For `thumbColor`, `trackFillColor`, and `trackBackgroundColor`, the values are adjustable per-state
(e.g., for `.disabled`).

Partially implements #3137
Pivotal link: https://www.pivotaltracker.com/story/show/155525171
2018-04-12 08:51:04 -04:00
Adrian Secord
294643fc0b
[Slider] Add appearance properties and enable UIAppearance. (#2796)
* Add Slider appearance properties and enable UIAppearance.

Adds `thumbRadius` and `thumbElevation` as UIAppearance properties.

Makes `color`, `disabledColor`, and `trackBackgroundColor` UIAppearance-compatible.

* Added unit tests for slider.

* Remove infeasible coding unit test for now.

* Line-length formatting.

* Rename and condense color tests, sort by order that they appear in the header.

* Rename tests and mark the thumb section.

* Replace `_thumbTrack.thumbRadius` usage with `self.thumbRadius`.

* Remove NSCoding-related helper, moved to another branch.

* Search-and-replace mixup.

* Line-length fixups.
2018-01-07 12:15:02 -05:00
Robert Moore
a31a9e10c2
[Slider] Add BUILD file (#2694)
Also fix import in the component and an implicit cast in the tests.
2017-12-13 08:10:13 -05:00
Yurii Samsoniuk
f437e8187a [Slider] Use MDCPalettes for default thumb track color (#2369) 2017-11-13 23:35:35 -05:00
John Detloff
b9218a2e75
Create default light and dark color schemes for MDCSlider (#2362) 2017-11-07 13:12:09 -05:00
Adrian Secord
5bc8758de5 Porting warning fixes from internal change 166066139. 2017-08-22 17:29:23 -04:00
Randall Li
266a716f60 Fix imports to use umbrella imports (#1529)
* [ColorThemes] Use umbrella header instead of MDCColorScheme

* [Application] Use umbrella header instead of class header

* [Button] use umbrella header in private header

* [Typography] use umbrella header in private header

* icons using umbrella header in individual icon class

* [Icons] added header to umbrella header

* [collection] umbrella header instead of class header in test

* [Collections] use umbrella header in private header

* [ActivityIndicator] use umbrella header in private header

* [ButtonBar] use umbrella header in private header

* [Dialog] use umbrella header in private header

* [featurehighlight] use umbrella header in private header

* [snackbar] use umbrella header in private header

* [textFields] use umbrella header in private header

* [thumbtrack] use umbrella header in private header

* [Overlay] use umbrella header in private header

also removed spurious ’s’ at end of MaterialOverlay.h file

* [slider] use umbrella header in private header

* [buttonBar] use umbrella header in private header

* [slider] use umbrella header in test

* [Overlay] fixed overlay reference to use umbrella header
2017-06-19 15:57:48 -04:00
Scott Hyndman
4a011e75a5 [Docs] Docstravaganza (#1330)
* [Docs] Adds platform configuration for the doc site.

* [Docs] Adds path metadata for documentation site.

This field is used to determine where the file will appear in the
doc site.

* [Docs] Updates Material guideline links to latest URL.

material.google.com -> material.io/guidelines

* [Docs] Introduces a separate component index for the docsite.

* [Docs] Changes the directory used for site generation.

* [Docs] Moves documentation-site-only Markdown into its own directory.

* [Docs] Changes material.io links to use https.

* [Docs] Renames the howto and contributing docsite sections to docs.

* [Docs] Adds a navTitle field to the collection editing/styling pages.

* [Docs] Changes the FAQ heading to be one size bigger.

* [Docs] Changes the tutorial title.

* [Docs] Adds icons to three more components.

* [Docs] Introduces a root component directory called /catalog/.

* [Docs] Adds an icon to the AnimationTiming component.

* [Docs] Adds an icon for the typography component.

* [Docs] Reformats the docsite index.
2017-05-01 17:27:38 -04:00
Justin Shephard
4a7ee8154e MDC_#767 - Removed bad import and changed public delegate declaration of MDCThumbTrackDelegate to private.
Summary:
MDC_#767 - Removed bad import and changed public delegate declaration of MDCThumbTrackDelegate to private. Updated unit tests to include private method dec on SliderTests

Merge branch 'MDC_#767' of https://github.com/google/material-components-ios into MDC_#767

MDC_#767 - Updated tests to accommodate for now private delegate method on MDCSlider

Reviewers: O1 Material components iOS, randallli, ajsecord

Reviewed By: O1 Material components iOS, randallli, ajsecord

Subscribers: ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1661
2016-09-22 16:42:17 -04:00
randallli
f328856965 [Slider] Changed clamping behaviour of the min setter to mutate the max instead of clamping to its value.
Summary: Same change applied to the max setter.

Reviewers: iangordon, O1 Material components iOS

Reviewed By: iangordon, O1 Material components iOS

Subscribers: ajsecord, iangordon

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1572
2016-09-12 14:29:26 -04:00
randallli
ffd56e6d30 [FontDiskLoader, RobotoFontLoader, Typography] The results of some readability code reviews from some googlers.
Summary:
internal reference: cl/121301531
  - Renamed some of the FontDiskLoader's APIs to be more readable.
    - |registerFont| renamed to |load|
    - |unregisterFont| renamed to |unload|
    - |isRegistered| renamed to |loaded|
  - Made FondDiskLoader thread safe.
  - Made fontName and fontURL copy, readonly, nonnull properties.
  - More comments across the board and other miscellaneous Objective C Readability issues.
  - Readded to be deprecated setFontName and other APIs.

Internal implementation detail refactors:
  - Removed references to 'resource' as that was part of the old name of the FontDiskLoader class.
  - Using dispatch queue for |loaded| protection instead of @syncronized. Also using class method for |setLoaded|.
  - Fixed tests to make them not set the name of the font
  - Added more descriptive messages for tests

Reviewers: O1 Material components iOS, iangordon

Reviewed By: O1 Material components iOS, iangordon

Subscribers: iangordon

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1265
2016-09-07 12:44:47 -04:00
Max Luzuriaga
8211a44921 [Slider] Make tests language-agnosti
Summary: Randall pointed out that when run on an arabic simulator, the tests would fail for the slider's numeric value label because they relied on hard-coded string versions of several numbers, which were based on the English caracter set. These strings differ by localization, so I refactored them to not rely on hard-coded strings.

Reviewers: O1 Material components iOS, ajsecord, randallli

Reviewed By: O1 Material components iOS, ajsecord, randallli

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1419
2016-08-08 19:50:48 -04:00
Adrian Secord
8c3af252be Adding AUTHORS and removing CONTRIBUTORS.txt.
We can credit any contributor who would like to be credited this way, by adding them on request to the AUTHORS file. The copyright statement changes are required for this to work. Note that this has...

Summary:

We can credit any contributor who would like to be credited this way, by adding them on request to the AUTHORS file. The copyright statement changes are required for this to work. Note that this has no legal change, since the contributors always retained their copyright despite the copyright notice, but it's a nice acknowledgement.

Changed copyright statement to include non-Google authors.

Command run:

find * \( -name '*\.m' -or -name '*\.h' -or -name '*\.swift' \) -and -not \( -path 'scripts/external*' -name Pods  \) -print0 | xargs -0 sed -i '' 's/Copyright \(.*\) Google Inc/Copyright \1 the Material Components for iOS authors/'

Added non-source files.

Command run:

grep -Rl 'Copyright .* Google Inc' * --exclude-dir scripts/external --null | xargs -0 sed -i '' 's/Copyright \(.*\) Google Inc/Copyright \1 the Material Components for iOS authors/'

Reviewers: featherless, O1 Material components iOS, randallli

Reviewed By: O1 Material components iOS, randallli

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1415
2016-08-08 08:16:37 -07:00
Max Luzuriaga
b4ee418446 [Slider] Add discrete numeric value label
Summary:
Adds the numeric value label as detailed in the [Spec](https://material.google.com/components/sliders.html#sliders-discrete-slider) to the discrete slider component.

{F5999}

Differs from the Spec in size. I scaled up the label here to account the reality of UI components on mobile devices, which is that you need to leave enough room so that the component is obscured by the user's finger. With the size specified in the Spec the actual text wasn't visible enough without looking very closely, which would obviously be an issue for users with impaired vision. I'm currently in talks with a designer who worked on this to get approval for the new size, but changing it would be a matter of changing two constants, so I think we can go ahead with the code review without that.

To reflect the diversity of things that the slider's value can represent, including percentages, logarithmic scales, decimal numbers, etc., I've added support via a delegate to customize the string that is displayed in the value label for a given value. This is via a new `MDCSliderDelegate` protocol, which has a method `-slider:stringForValue:`. If implemented, this method is used when displaying the label. Similarly a new method `-slider:accessibilityLabelForValue:` on the delegate is used to determine what string to use as the accessibility label for a given value, so the two methods can either maintain parity or diverge depending on the use case.

When not implemented, or when the slider has no delegate, the default implementation intelligently truncates the value to however many decimal points is necessary, and displays this value in the numeric value label.

The default behavior differs for the a11y label. That label keeps its old behavior of being how filled the slider is as a percentage. My logic for this is just my intuition that for someone using a screen reader, the percentage of the slider would generally speaking be a more useful measure than a particular decimal number, since users often aren't familar with thinking of percentages as numbers between 0 and 1.

Closes #552

Reviewers: randallli, O1 Material components iOS

Reviewed By: randallli, O1 Material components iOS

Subscribers: randallli

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1284
2016-07-27 17:46:24 -04:00
Adrian Secord
3aedace959 Re-enabled 100-character line limit.
Reviewers: randallli, O1 Material components iOS

Reviewed By: randallli, O1 Material components iOS

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D965
2016-06-13 13:34:57 -04:00
randallli
8ab280fdc9 [Slider] Fix unit tests by increasing epsilon
Reviewers: #mdc_ios_owners, featherless, iangordon

Reviewed By: #mdc_ios_owners, featherless, iangordon

Projects: #material_components_ios

Differential Revision: http://codereview.cc/D686
2016-04-21 01:07:11 -04:00
Adrian Secord
b584f27105 Fixing floating-point conversion warnings in Generic iOS Device builds
Reviewers: featherless, #mdc_ios_owners, randallli

Reviewed By: featherless, #mdc_ios_owners, randallli

Projects: #material_components_ios

Differential Revision: http://codereview.cc/D222
2016-03-08 14:14:37 -08:00
Jeff Verkoeyen
d0092f692a Testing by convention.
Summary:
Similar to Catalog by convention, Testing by convention allows us to generate a fully-working unit test suite using CocoaPods wildcards.

The testing convention is to place unit test source files in a `tests/unit` folder within each component.

A complete "component by convention" now looks like so:

    component/
      examples/
        SomeExample.m
      src/
        ...
      tests/
        unit/
          SomeTest.m

This convention makes it trivially easy to run all tests in our project & generate coverage information. Here are our coverage results:

{F439}

Resolves https://github.com/google/material-components-ios/issues/106.

Reviewers: cjcox, ajsecord, #mdc_ios_owners

Reviewed By: ajsecord, #mdc_ios_owners

Projects: #material_components_ios

Differential Revision: http://codereview.cc/D158
2016-03-01 12:35:19 -05:00