mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
add Clipboard component for ios and android
Summary:
add Clipboard component for ios and android
```javascript
import Clipboard from 'react-native'
Clipboard.get((content)=>{
console.log('here is content in clipboard:%s',content)
});
var content = 'here is a string';
Clipboard.set(content);
```
Closes https://github.com/facebook/react-native/pull/4384
Reviewed By: svcscm
Differential Revision: D2738881
Pulled By: mkonicek
fb-gh-sync-id: a06df32d1eb2824cc9ca3de9d45e4e67fd2edbc9
This commit is contained in:
committed by
facebook-github-bot-4
parent
cd4574498d
commit
90c7ad112f
@@ -9,6 +9,6 @@
|
||||
|
||||
#import "RCTBridgeModule.h"
|
||||
|
||||
@interface RCTPasteboard : NSObject <RCTBridgeModule>
|
||||
@interface RCTClipboard : NSObject <RCTBridgeModule>
|
||||
|
||||
@end
|
||||
@@ -7,11 +7,13 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTPasteboard.h"
|
||||
#import "RCTClipboard.h"
|
||||
|
||||
#import "RCTUtils.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@implementation RCTPasteboard
|
||||
@implementation RCTClipboard
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
@@ -20,9 +22,16 @@ RCT_EXPORT_MODULE()
|
||||
return dispatch_get_main_queue();
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setPasteboardString:(NSString *)string)
|
||||
RCT_EXPORT_METHOD(getString:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[[UIPasteboard generalPasteboard] setString:string];
|
||||
UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
|
||||
callback(@[RCTNullIfNil(clipboard.string)]);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setString:(NSString *)content)
|
||||
{
|
||||
UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
|
||||
clipboard.string = content;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user