Skip to content
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
9 changes: 9 additions & 0 deletions React/Base/RCTUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,12 @@ NS_INLINE CGRect CGRectValue(NSValue *value)
@interface RCTUISlider : NSSlider
@end
#endif // ]TODO(macOS GH#774)

// RCTUISwitch

#if !TARGET_OS_OSX // [TODO(macOS GH#774)
#define RCTUISwitch UISwitch
#else
@interface RCTUISwitch : NSSwitch
@end
#endif // ]TODO(macOS GH#774)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @interface RCTSwitchComponentView () <RCTSwitchViewProtocol>
@end

@implementation RCTSwitchComponentView {
UISwitch *_switchView;
RCTUISwitch *_switchView; // TODO(macOS GH#774)
BOOL _isInitialValueSet;
}

Expand All @@ -32,7 +32,7 @@ - (instancetype)initWithFrame:(CGRect)frame
static const auto defaultProps = std::make_shared<const SwitchProps>();
_props = defaultProps;

_switchView = [[UISwitch alloc] initWithFrame:self.bounds];
_switchView = [[RCTUISwitch alloc] initWithFrame:self.bounds]; // TODO(macOS GH#774)

[_switchView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];

Expand Down Expand Up @@ -90,7 +90,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
[super updateProps:props oldProps:oldProps];
}

- (void)onChange:(UISwitch *)sender
- (void)onChange:(RCTUISwitch *)sender // TODO(macOS GH#774)
{
const auto &props = *std::static_pointer_cast<const SwitchProps>(_props);
if (props.value == sender.on) {
Expand Down