Skip to content

Commit 4e29a13

Browse files
shwantonShawn Dempsey
andcommitted
[Fabric] Convert UISlider to RCTSlider shim (microsoft#1525)
* [Fabric] Replace UIKit with RCTUIKit * [Fabric] Convert UISlider to RCTUISlider shim * Add macOS tags * Refactor RCTSlider to RCTUISlider for Fabric Co-authored-by: Shawn Dempsey <shawndempsey@fb.com>
1 parent fafcf4c commit 4e29a13

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

React/Base/RCTUIKit.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,14 @@ NS_INLINE CGRect CGRectValue(NSValue *value)
468468
}
469469

470470
#endif // ] TARGET_OS_OSX
471+
472+
//
473+
// fabric component types
474+
//
475+
476+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
477+
#define RCTUISlider UISlider
478+
#else
479+
@interface RCTUISlider : NSSlider
480+
@end
481+
#endif // ]TODO(macOS GH#774)

React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ @interface RCTSliderComponentView () <RCTImageResponseDelegate>
2323
@end
2424

2525
@implementation RCTSliderComponentView {
26-
UISlider *_sliderView;
26+
RCTUISlider *_sliderView; // TODO(macOS GH#774)
2727
float _previousValue;
2828

2929
UIImage *_trackImage;
@@ -48,7 +48,7 @@ - (instancetype)initWithFrame:(CGRect)frame
4848
static const auto defaultProps = std::make_shared<const SliderProps>();
4949
_props = defaultProps;
5050

51-
_sliderView = [[UISlider alloc] initWithFrame:self.bounds];
51+
_sliderView = [[RCTUISlider alloc] initWithFrame:self.bounds]; // TODO(macOS GH#774)
5252

5353
[_sliderView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];
5454
[_sliderView addTarget:self
@@ -284,17 +284,17 @@ - (void)setThumbImage:(UIImage *)thumbImage
284284
[_sliderView setThumbImage:thumbImage forState:UIControlStateNormal];
285285
}
286286

287-
- (void)onChange:(UISlider *)sender
287+
- (void)onChange:(RCTUISlider *)sender // TODO(macOS GH#774)
288288
{
289289
[self onChange:sender withContinuous:YES];
290290
}
291291

292-
- (void)sliderTouchEnd:(UISlider *)sender
292+
- (void)sliderTouchEnd:(RCTUISlider *)sender // TODO(macOS GH#774)
293293
{
294294
[self onChange:sender withContinuous:NO];
295295
}
296296

297-
- (void)onChange:(UISlider *)sender withContinuous:(BOOL)continuous
297+
- (void)onChange:(RCTUISlider *)sender withContinuous:(BOOL)continuous // TODO(macOS GH#774)
298298
{
299299
float value = sender.value;
300300

0 commit comments

Comments
 (0)