mirror of
https://github.com/wu736139669/RN_AWord.git
synced 2026-08-05 06:24:39 +00:00
添加很多页面
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// ASHUIMenuControllerManager.h
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/19.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "RCTBridgeModule.h"
|
||||
#import "RCTLog.h"
|
||||
@interface ASHUIMenuControllerManager : NSObject<RCTBridgeModule>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// ASHUIMenuControllerManager.m
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/19.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ASHUIMenuControllerManager.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "UIViewController+Category.h"
|
||||
@implementation ASHUIMenuControllerManager
|
||||
{
|
||||
NSMapTable *_callbacks;
|
||||
UIMenuController *_menu;
|
||||
}
|
||||
RCT_EXPORT_MODULE();
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return dispatch_get_main_queue();
|
||||
}
|
||||
RCT_EXPORT_METHOD(hideMenu)
|
||||
{
|
||||
if (_menu) {
|
||||
[_menu setMenuVisible:NO];
|
||||
}
|
||||
}
|
||||
RCT_EXPORT_METHOD(showMenuWithTitleArr:(NSArray*)titleArray withXPoint:(nonnull NSNumber*)xpoint withYPoint:(nonnull NSNumber*)ypoint withCallback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
if (!_callbacks) {
|
||||
_callbacks = [NSMapTable strongToStrongObjectsMapTable];
|
||||
}
|
||||
|
||||
if(titleArray.count>0){
|
||||
NSMutableArray* itemArr = [NSMutableArray array];
|
||||
[titleArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:obj action:@selector(meunClick:)];
|
||||
[itemArr addObject:menuItem];
|
||||
}];
|
||||
|
||||
UIViewController *controller = RCTKeyWindow().rootViewController;
|
||||
|
||||
while (controller.presentedViewController) {
|
||||
controller = controller.presentedViewController;
|
||||
}
|
||||
|
||||
if (controller == nil) {
|
||||
RCTLogError(@"Tried to display MenuController but there is no application window. options: %@", titleArray);
|
||||
return;
|
||||
}
|
||||
controller.rnDelegate = self;
|
||||
UIView *sourceView = controller.view;
|
||||
[sourceView becomeFirstResponder];
|
||||
|
||||
|
||||
UIMenuController *menu = [UIMenuController sharedMenuController];
|
||||
[menu setMenuItems:itemArr];
|
||||
[menu setTargetRect:CGRectMake(xpoint.floatValue, ypoint.floatValue, 1.0, 1.0) inView:sourceView];
|
||||
[menu setMenuVisible:YES animated:YES];
|
||||
_menu = menu;
|
||||
[_callbacks setObject:callback forKey:menu];
|
||||
}else{
|
||||
callback(@[@"no title"]);
|
||||
}
|
||||
}
|
||||
|
||||
-(void)meunClick:(UIMenuController*)menuController
|
||||
{
|
||||
if ([_callbacks objectForKey:menuController]) {
|
||||
((RCTResponseSenderBlock)[_callbacks objectForKey:menuController])(@[@"no title", @1]);
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// ASHUtilManager.h
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/22.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "RCTBridgeModule.h"
|
||||
#import "RCTLog.h"
|
||||
@interface ASHUtilManager : NSObject <RCTBridgeModule>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// ASHUtilManager.m
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/22.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ASHUtilManager.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
@implementation ASHUtilManager
|
||||
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
//复制文本
|
||||
RCT_EXPORT_METHOD(pasteWithText:(NSString*)text)
|
||||
{
|
||||
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
||||
pasteboard.string = text;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// MessageInfo.h
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/18.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <LKDBHelper.h>
|
||||
#import "NSObject+LKDBHelper.h"
|
||||
@interface MessageInfo : NSObject
|
||||
|
||||
@property(nonatomic, strong) NSString* title;
|
||||
@property(nonatomic, strong) NSString* image;
|
||||
@property(nonatomic, strong) NSString* infoKey;
|
||||
|
||||
-(NSDictionary*)dictionary;
|
||||
-(NSString*)JSON;
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// MessageInfo.m
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/18.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MessageInfo.h"
|
||||
|
||||
@implementation MessageInfo
|
||||
+(NSString *)getTableName
|
||||
{
|
||||
return @"MessageInfo";
|
||||
}
|
||||
+ (NSString*)getPrimaryKey
|
||||
{
|
||||
return @"infoKey";
|
||||
}
|
||||
-(NSDictionary*)dictionary
|
||||
{
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:self.infoKey, @"id", self.title,@"title", self.image,@"imageurl", nil];
|
||||
}
|
||||
-(NSString*)JSON
|
||||
{
|
||||
return [NSString stringWithFormat:@"{'id':%@,'title':%@,'imageurl':%@}",self.infoKey,self.title,self.image];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// MessageInfoManager.h
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/18.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "RCTBridgeModule.h"
|
||||
#import "RCTLog.h"
|
||||
@interface MessageInfoManager : NSObject <RCTBridgeModule>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// MessageInfoManager.m
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/18.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MessageInfoManager.h"
|
||||
#import "MessageInfo.h"
|
||||
#import <LKDBHelper.h>
|
||||
#import "NSObject+LKDBHelper.h"
|
||||
#import "UIView+React.h"
|
||||
@implementation MessageInfoManager
|
||||
|
||||
|
||||
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
RCT_EXPORT_METHOD(getMessageArrWithCallBack:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
RCTLogInfo(@"getMessageArrWithCallBack");
|
||||
NSMutableArray* array = [MessageInfo searchWithWhere:nil orderBy:nil offset:0 count:MAXFLOAT];
|
||||
if (array) {
|
||||
NSMutableArray* resultArr = [NSMutableArray array];
|
||||
[array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
|
||||
[resultArr addObject:[obj dictionary]];
|
||||
}];
|
||||
callback(@[[NSNull null], resultArr]);
|
||||
|
||||
}else{
|
||||
callback(@[@"no data", [NSNull null]]);
|
||||
}
|
||||
|
||||
}
|
||||
RCT_EXPORT_METHOD(saveMessageWithKey:(NSString*)key withImage:(NSString*)image withTitle:(NSString*)title withCallBack:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
RCTLogInfo(@"saveMessageWithKey");
|
||||
MessageInfo* info = [[MessageInfo alloc] init];
|
||||
info.infoKey = key;
|
||||
info.image = image;
|
||||
info.title = title;
|
||||
|
||||
|
||||
BOOL ret = [MessageInfo insertWhenNotExists:info];
|
||||
if (ret) {
|
||||
callback(@[[NSNull null], @1]);
|
||||
}else{
|
||||
callback(@[@"unkonwerror", [NSNull null]]);
|
||||
}
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(isExistWithKey:(NSString*)key withCallBack:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
NSMutableArray* array = [MessageInfo searchWithWhere:@{@"infokey":key}];
|
||||
|
||||
callback(@[[NSNull null], @(array.count>0?1:0)]);
|
||||
}
|
||||
RCT_EXPORT_METHOD(delWithKey:(NSString*)key withCallBack:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
BOOL ret = [MessageInfo deleteWithWhere:@{@"infokey":key}];
|
||||
callback(@[[NSNull null], @(ret)]);
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// UIViewController+Category.h
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/19.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIViewController (Category)
|
||||
|
||||
@property (nonatomic, weak)id rnDelegate;
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// UIViewController+Category.m
|
||||
// testdemo
|
||||
//
|
||||
// Created by xmfish on 16/2/19.
|
||||
// Copyright © 2016年 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIViewController+Category.h"
|
||||
#import "objc/runtime.h"
|
||||
static char rnDelegateURLKey;
|
||||
@implementation UIViewController (Category)
|
||||
|
||||
- (void)setRnDelegate:(id)rnDelegate
|
||||
{
|
||||
objc_setAssociatedObject(self,&rnDelegateURLKey, rnDelegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
- (id)rnDelegate
|
||||
{
|
||||
return objc_getAssociatedObject(self, &rnDelegateURLKey);
|
||||
}
|
||||
-(BOOL)canBecomeFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
|
||||
if (action == @selector(meunClick:) ){
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
-(void)meunClick:(id)sender
|
||||
{
|
||||
if (self.rnDelegate && [self.rnDelegate respondsToSelector:@selector(meunClick:)]) {
|
||||
[self.rnDelegate meunClick:sender];
|
||||
}
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user