58 Commits

Author SHA1 Message Date
Wenyu Zhang
6774704b28 [MDC-iOS] Remove Slider testExplicitlyNonDiscreteSliderAlignsToThumbPosition test.
PiperOrigin-RevId: 513626475
2023-03-02 13:39:09 -08:00
Nobody
ac1c286e31 Fixed up imports for Slider
PiperOrigin-RevId: 476113171
2022-09-22 09:00:05 -07:00
Janette James
679faa474a Update dots when active segment shrinks and thumb crosses anchor
PiperOrigin-RevId: 448971493
2022-05-16 08:53:48 -07:00
Jeff Verkoeyen
86a8c97dc7 Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 400788645
2021-10-04 12:41:07 -07:00
Alyssa Weiss
fd6682bdd2 Update MDCSlider to respect UISemanticContentAttribute.
PiperOrigin-RevId: 387190352
2021-07-27 14:02:53 -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
Randall Li
d03c34293f
[Material][Availability] Migrates Slider to MDCAvailability. (#9704)
[Material][Availability] Migrates Slider to MDCAvailability.
2020-02-14 09:08:07 -05: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
ed7b654e4a
[ThumbTrack] Discrete dots scale slowly with track height. (#8744)
The discrete dots in the ThumbTrack originally assumed that the track would
only ever be 2 points high. Now that customizable heights are allowed, the
dots should scale more slowly.

This is still not perfect, since the original positioning of the ticks resulted in the filled track stopping at non-center positions of each tick. However, it is an incremental improvement and better VX will necessitate Material Design inputs.

![Example showing misaligned track and tick mark.](https://user-images.githubusercontent.com/1753199/68304829-95f09600-0074-11ea-90c0-90b1a344327e.png)

Improves #8741
2019-11-06 15:36:41 -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
Bryan Oltman
d6d13cdfac
[Slider] Add trackHeight property (#8740)
* [Slider] Add trackHeight property

* Add track size tests for discrete sliders

* Update doc comment for trackHeight
2019-11-05 17:47:36 -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
Yarden Eitan
1b7b249805
[Slider] Add snapshot tests for setting preferredFont with adju… (#8645)
This PR adds 2 snapshot tests to verify the behavior for setting preferredFont on the Banner's text elements when adjustsFontForContentSizeCategory is set to YES.

It is important to note that Slider currently doesn't expose any font property nor allows setting adjustsFontForContentSizeCategory on the label of the thumbtrack. These snapshot tests allow us to verify once we provide these APIs to see the changes to the font size.
Opened b/143287831 for tracking.

Closes #8643
2019-10-31 15:58:38 -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
Wenyu Zhang
4d47e68dd8
[Slider] Add shadowColor to support dynamic color behavior. (#7972)
Closes https://github.com/material-components/material-components-ios/issues/7866.
2019-07-21 15:22:58 -04:00
Wenyu Zhang
cf7ed4c5f9
[Slider] change track background color. (#7967)
Follow up PR to https://github.com/material-components/material-components-ios/pull/7960#pullrequestreview-263953047.
2019-07-18 21:56:17 -04:00
Wenyu Zhang
ceb874acaf
[Slider] Add snapshot test for dynamic color with elevation. (#7960)
Prepare for https://github.com/material-components/material-components-ios/issues/7866.
2019-07-18 19:49:14 -04: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
65426c86f9
[Slider] Add basic snapshot tests. (#6640)
Adding a few snapshot tests to capture the basic styling/appearance of
Sliders.
2019-02-19 09:26:53 -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
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