From eb0edee9f7b9427a4c25f2cb6369d6312bb12a93 Mon Sep 17 00:00:00 2001 From: Nobody Date: Wed, 14 Aug 2024 15:43:00 -0700 Subject: [PATCH] Internal change. PiperOrigin-RevId: 663080530 --- components/Slider/src/MDCSlider.m | 8 ++++++++ components/private/ThumbTrack/src/MDCThumbView.m | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/Slider/src/MDCSlider.m b/components/Slider/src/MDCSlider.m index afba93e014c..b7e7f96acd3 100644 --- a/components/Slider/src/MDCSlider.m +++ b/components/Slider/src/MDCSlider.m @@ -34,8 +34,10 @@ static inline UIColor *MDCThumbTrackDefaultColor(void) { return MDCPalette.bluePalette.tint500; } @interface MDCSlider () +#if !TARGET_OS_VISION @property(nonnull, nonatomic, strong) UIImpactFeedbackGenerator *feedbackGenerator API_AVAILABLE(ios(10.0)); +#endif @property(nonatomic) CGFloat previousValue; @end @@ -119,8 +121,10 @@ - (void)commonMDCSliderInit { _mdc_overrideBaseElevation = -1; _hapticsEnabled = YES; +#if !TARGET_OS_VISION self.feedbackGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight]; +#endif _shouldEnableHapticsForAllDiscreteValues = NO; _previousValue = -CGFLOAT_MAX; @@ -706,6 +710,7 @@ - (BOOL)accessibilityActivate { - (void)thumbTrackValueChanged:(__unused MDCThumbTrack *)thumbTrack { [self sendActionsForControlEvents:UIControlEventValueChanged]; UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.accessibilityValue); +#if !TARGET_OS_VISION if (self.hapticsEnabled && _previousValue != _thumbTrack.value) { BOOL valueCrossesAboveAnchor = (_previousValue < _thumbTrack.filledTrackAnchorValue && _thumbTrack.filledTrackAnchorValue <= _thumbTrack.value); @@ -719,11 +724,14 @@ - (void)thumbTrackValueChanged:(__unused MDCThumbTrack *)thumbTrack { [self.feedbackGenerator impactOccurred]; } } +#endif self.previousValue = _thumbTrack.value; } - (void)thumbTrackTouchDown:(__unused MDCThumbTrack *)thumbTrack { +#if !TARGET_OS_VISION [self.feedbackGenerator prepare]; +#endif [self sendActionsForControlEvents:UIControlEventTouchDown]; } diff --git a/components/private/ThumbTrack/src/MDCThumbView.m b/components/private/ThumbTrack/src/MDCThumbView.m index 16d50da4ae9..b49849f9d36 100644 --- a/components/private/ThumbTrack/src/MDCThumbView.m +++ b/components/private/ThumbTrack/src/MDCThumbView.m @@ -40,7 +40,13 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self) { // TODO: Remove once MDCShadowLayer is rasterized by default. self.layer.shouldRasterize = YES; - self.layer.rasterizationScale = [UIScreen mainScreen].scale; + if (@available(iOS 13.0, *)) { + self.layer.rasterizationScale = UITraitCollection.currentTraitCollection.displayScale; + } else { +#if !TARGET_OS_VISION + self.layer.rasterizationScale = UIScreen.mainScreen.scale; +#endif + } _shadowColor = UIColor.blackColor; _shapeGenerator = [[MDCRectangleShapeGenerator alloc] init];