Skip to content

Instantly share code, notes, and snippets.

@gvlamadrid
Last active January 30, 2018 09:34
Show Gist options
  • Select an option

  • Save gvlamadrid/1715a6652e04216548e7c3ba11b0cdf0 to your computer and use it in GitHub Desktop.

Select an option

Save gvlamadrid/1715a6652e04216548e7c3ba11b0cdf0 to your computer and use it in GitHub Desktop.
diff --git a/node_modules/react-native/Libraries/Text/RCTTextFieldManager.m b/node_modules/react-native/Libraries/Text/RCTTextFieldManager.m
--- a/node_modules/react-native/Libraries/Text/RCTTextFieldManager.m
+++ b/node_modules/react-native/Libraries/Text/RCTTextFieldManager.m
@@ -72,6 +72,23 @@
{
view.font = [RCTFont updateFont:view.font withFamily:json ?: defaultView.font.familyName];
}
+RCT_CUSTOM_VIEW_PROPERTY(showDoneButton, BOOL, RCTTextField)
+{
+ if (json && ([RCTConvert BOOL:json])) {
+ UIToolbar* toolbar = [[UIToolbar alloc] init];
+ [toolbar sizeToFit];
+ UIBarButtonItem* flex = [[UIBarButtonItem alloc]
+ initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
+ target:nil action:nil];
+ UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]
+ initWithTitle:@"OK" style:(UIBarButtonItemStylePlain)
+ target:view action:@selector(handleDoneButtonFromInputAccessory)];
+ toolbar.items = @[flex, doneButton];
+ view.inputAccessoryView = toolbar;
+ } else {
+ view.inputAccessoryView = nil;
+ }
+};
RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView
@gvlamadrid
Copy link
Copy Markdown
Author

gvlamadrid commented Jan 30, 2018

  • RN v0.44.2
  • fork from https://gist.github.com/chih/3aa8b3bbd490137a31f0b864eff1532e
  • use curl https://gist.githubusercontent.com/gvlamadrid/afbbbad0f986d837693e4912c216cfdc/raw/f7e5891de1d1072e3796b7f77f0ebb343379ec22/showDoneButton.patch | git apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment