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
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
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
* 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
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.
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.
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
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.
```
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.
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
* 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.
* [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
* [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.
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
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
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
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
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
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
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