From 656e72c174042a87c652a15301d1068b3922ce90 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Sat, 23 Nov 2019 17:22:27 +0800 Subject: [PATCH] feat:add NavigatorPlugin for iOS ,only files and protocol --- iOS/Pod/Classes/DoricContext.h | 3 +- iOS/Pod/Classes/DoricRegistry.m | 2 ++ iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.h | 24 ++++++++++++++ iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m | 31 +++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.h create mode 100644 iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m diff --git a/iOS/Pod/Classes/DoricContext.h b/iOS/Pod/Classes/DoricContext.h index 6607ba4b..7c1bcefd 100644 --- a/iOS/Pod/Classes/DoricContext.h +++ b/iOS/Pod/Classes/DoricContext.h @@ -22,13 +22,14 @@ #import #import "DoricDriver.h" +#import "DoricNavigatorProtocol.h" NS_ASSUME_NONNULL_BEGIN @class DoricRootNode; @interface DoricContext : NSObject - +@property(nonatomic, weak) id navigator; @property(nonatomic, strong) NSString *contextId; @property(nonatomic, strong) DoricDriver *driver; @property(nonatomic, strong) NSMutableDictionary *pluginInstanceMap; diff --git a/iOS/Pod/Classes/DoricRegistry.m b/iOS/Pod/Classes/DoricRegistry.m index e538d993..99a0ca3b 100644 --- a/iOS/Pod/Classes/DoricRegistry.m +++ b/iOS/Pod/Classes/DoricRegistry.m @@ -35,6 +35,7 @@ #import "DoricSliderNode.h" #import "DoricSlideItemNode.h" #import "DoricStoragePlugin.h" +#import "DoricNavigatorPlugin.h" @interface DoricRegistry () @@ -61,6 +62,7 @@ - (void)innerRegister { [self registerNativePlugin:DoricModalPlugin.class withName:@"modal"]; [self registerNativePlugin:DoricNetworkPlugin.class withName:@"network"]; [self registerNativePlugin:DoricStoragePlugin.class withName:@"storage"]; + [self registerNativePlugin:DoricNavigatorPlugin.class withName:@"navigator"]; [self registerViewNode:DoricStackNode.class withName:@"Stack"]; [self registerViewNode:DoricVLayoutNode.class withName:@"VLayout"]; diff --git a/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.h b/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.h new file mode 100644 index 00000000..d5ea4947 --- /dev/null +++ b/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.h @@ -0,0 +1,24 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// Created by pengfei.zhou on 2019/11/23. +// + +#import +#import "DoricNativePlugin.h" + +@interface DoricNavigatorPlugin : DoricNativePlugin +@end \ No newline at end of file diff --git a/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m b/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m new file mode 100644 index 00000000..d711b304 --- /dev/null +++ b/iOS/Pod/Classes/Plugin/DoricNavigatorPlugin.m @@ -0,0 +1,31 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// Created by pengfei.zhou on 2019/11/23. +// + +#import "DoricNavigatorPlugin.h" + + +@implementation DoricNavigatorPlugin +- (void)push:(NSDictionary *)params { + [self.doricContext.navigator push:params[@"scheme"] alias:params[@"alias"]]; +} + +- (void)pop { + [self.doricContext.navigator pop]; +} +@end \ No newline at end of file