From 254f0e4c01353f2a08f0087dfd092ab433324ef3 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 5 Nov 2019 02:10:14 -0800 Subject: [PATCH] Use generated interface for commands in Switch component Summary: Use codegened native commands in Switch changelog: [internal] Reviewed By: TheSavior Differential Revision: D18266849 fbshipit-source-id: a2de0e7342619c437f6d34f8dbf413f2f2888548 --- .../Switch/RCTSwitchComponentView.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm b/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm index a7c1aae36f2..c6edab447e3 100644 --- a/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm @@ -10,9 +10,13 @@ #import #import #import +#import using namespace facebook::react; +@interface RCTSwitchComponentView () +@end + @implementation RCTSwitchComponentView { UISwitch *_switchView; } @@ -96,4 +100,16 @@ using namespace facebook::react; ->onChange(SwitchOnChangeStruct{.value = static_cast(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