Skip to content

Commit

Permalink
Use generated interface for commands in Switch component
Browse files Browse the repository at this point in the history
Summary:
Use codegened native commands in Switch

changelog: [internal]

Reviewed By: TheSavior

Differential Revision: D18266849

fbshipit-source-id: a2de0e7342619c437f6d34f8dbf413f2f2888548
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Nov 5, 2019
1 parent dd06f85 commit 254f0e4
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
#import <react/components/rncore/ComponentDescriptors.h>
#import <react/components/rncore/EventEmitters.h>
#import <react/components/rncore/Props.h>
#import <react/components/rncore/RCTComponentViewHelpers.h>

using namespace facebook::react;

@interface RCTSwitchComponentView () <RCTSwitchViewProtocol>
@end

@implementation RCTSwitchComponentView {
UISwitch *_switchView;
}
Expand Down Expand Up @@ -96,4 +100,16 @@ - (void)onChange:(UISwitch *)sender
->onChange(SwitchOnChangeStruct{.value = static_cast<bool>(sender.on)});
}

#pragma mark - Native Commands

- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
{
RCTSwitchHandleCommand(self, commandName, args);
}

- (void)setValue:(BOOL)value
{
[_switchView setOn:value animated:YES];
}

@end

0 comments on commit 254f0e4

Please sign in to comment.