Skip to content

[Fabric] Convert UISlider to RCTSlider shim #1525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions React/Base/RCTUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,14 @@ NS_INLINE CGRect CGRectValue(NSValue *value)
}

#endif // ] TARGET_OS_OSX

//
// fabric component types
//

#if !TARGET_OS_OSX // [TODO(macOS GH#774)
#define RCTUISlider UISlider
#else
@interface RCTUISlider : NSSlider
@end
#endif // ]TODO(macOS GH#774)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ @interface RCTSliderComponentView () <RCTImageResponseDelegate>
@end

@implementation RCTSliderComponentView {
UISlider *_sliderView;
RCTUISlider *_sliderView; // TODO(macOS GH#774)
float _previousValue;

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

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

[_sliderView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];
[_sliderView addTarget:self
Expand Down Expand Up @@ -284,17 +284,17 @@ - (void)setThumbImage:(UIImage *)thumbImage
[_sliderView setThumbImage:thumbImage forState:UIControlStateNormal];
}

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

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

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

Expand Down