feat:Navigator add extra
This commit is contained in:
parent
276c8c9ef9
commit
bf7a22a4d7
@ -33,7 +33,7 @@ - (void)viewDidLoad {
|
||||
[self.view addSubview:it];
|
||||
}];
|
||||
[self addChildViewController:panel];
|
||||
[panel config:jsContent alias:self.filePath];
|
||||
[panel config:jsContent alias:self.filePath extra:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -77,7 +77,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
|
||||
if ([file containsString:@"NavigatorDemo"]) {
|
||||
DoricViewController *doricViewController = [[DoricViewController alloc]
|
||||
initWithScheme:[NSString stringWithFormat:@"assets://demo/%@", file]
|
||||
alias:self.demoFilePaths[(NSUInteger) indexPath.row]];
|
||||
alias:self.demoFilePaths[(NSUInteger) indexPath.row]
|
||||
extra:nil
|
||||
];
|
||||
[self.navigationController pushViewController:doricViewController animated:NO];
|
||||
} else {
|
||||
DemoVC *demoVC = [[DemoVC alloc] initWithPath:file];
|
||||
|
@ -41,8 +41,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, strong) NSMutableDictionary *initialParams;
|
||||
@property(nonatomic, strong) DoricRootNode *rootNode;
|
||||
@property(nonatomic, strong) NSMutableDictionary <NSString *, DoricViewNode *> *headNodes;
|
||||
@property(nonatomic, copy) NSString *extra;
|
||||
|
||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source;
|
||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra;
|
||||
|
||||
- (DoricAsyncResult *)callEntity:(NSString *)method, ...;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
@implementation DoricContext
|
||||
|
||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source {
|
||||
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra {
|
||||
if (self = [super init]) {
|
||||
_driver = [DoricDriver instance];
|
||||
_pluginInstanceMap = [NSMutableDictionary new];
|
||||
@ -39,6 +39,7 @@ - (instancetype)initWithScript:(NSString *)script source:(NSString *)source {
|
||||
_script = script;
|
||||
_source = source;
|
||||
_initialParams = [@{@"width": @(0), @"height": @(0)} mutableCopy];
|
||||
_extra = extra;
|
||||
[self callEntity:DORIC_ENTITY_CREATE, nil];
|
||||
}
|
||||
return self;
|
||||
@ -78,7 +79,7 @@ - (void)initContextWithWidth:(CGFloat)width height:(CGFloat)height {
|
||||
it[@"width"] = @(width);
|
||||
it[@"height"] = @(height);
|
||||
}];
|
||||
[self callEntity:DORIC_ENTITY_INIT, self.initialParams, nil];
|
||||
[self callEntity:DORIC_ENTITY_INIT, self.initialParams, self.extra, nil];
|
||||
}
|
||||
|
||||
- (void)reload:(NSString *)script {
|
||||
|
@ -25,5 +25,5 @@
|
||||
@interface DoricPanel : UIViewController
|
||||
@property(nonatomic, strong) DoricContext *doricContext;
|
||||
|
||||
- (void)config:(NSString *)script alias:(NSString *)alias;
|
||||
- (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extra;
|
||||
@end
|
@ -22,8 +22,8 @@
|
||||
|
||||
@implementation DoricPanel
|
||||
|
||||
- (void)config:(NSString *)script alias:(NSString *)alias {
|
||||
self.doricContext = [[[DoricContext alloc] initWithScript:script source:alias] also:^(DoricContext *it) {
|
||||
- (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extra {
|
||||
self.doricContext = [[[DoricContext alloc] initWithScript:script source:alias extra:extra] also:^(DoricContext *it) {
|
||||
[it.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
||||
[self.view addSubview:it];
|
||||
}]];
|
||||
|
@ -8,7 +8,7 @@
|
||||
* 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,
|
||||
* distributed under the License is distributed onO 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.
|
||||
@ -22,5 +22,5 @@
|
||||
#import "DoricNavBarDelegate.h"
|
||||
|
||||
@interface DoricViewController : UIViewController <DoricNavigatorDelegate, DoricNavBarDelegate>
|
||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias;
|
||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra;
|
||||
@end
|
@ -32,7 +32,7 @@ @interface DoricViewController ()
|
||||
@end
|
||||
|
||||
@implementation DoricViewController
|
||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra {
|
||||
if (self = [super init]) {
|
||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:scheme];
|
||||
@ -46,7 +46,7 @@ - (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
||||
}];
|
||||
[self.view addSubview:panel.view];
|
||||
[self addChildViewController:panel];
|
||||
[panel config:result alias:alias];
|
||||
[panel config:result alias:alias extra:extra];
|
||||
panel.doricContext.navigator = self;
|
||||
panel.doricContext.navBar = self;
|
||||
self.doricPanel = panel;
|
||||
@ -78,8 +78,8 @@ - (void)viewWillLayoutSubviews {
|
||||
self.doricPanel.view.height = self.view.height;
|
||||
}
|
||||
|
||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated {
|
||||
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias];
|
||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra {
|
||||
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias extra:extra];
|
||||
[self.navigationController pushViewController:viewController animated:animated];
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol DoricNavigatorDelegate <NSObject>
|
||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated;
|
||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra;
|
||||
|
||||
- (void)doric_navigator_pop:(BOOL)animated;
|
||||
@end
|
||||
|
@ -24,10 +24,19 @@ @implementation DoricNavigatorPlugin
|
||||
- (void)push:(NSDictionary *)params {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
BOOL animated = YES;
|
||||
if (params[@"animated"]) {
|
||||
animated = [params[@"animated"] boolValue];
|
||||
NSString *scheme = params[@"scheme"];
|
||||
NSString *alias = scheme;
|
||||
NSDictionary *config = params[@"config"];
|
||||
if (config) {
|
||||
if (config[@"animated"]) {
|
||||
animated = [config[@"animated"] boolValue];
|
||||
}
|
||||
|
||||
if (config[@"alias"]) {
|
||||
alias = config[@"alias"];
|
||||
}
|
||||
}
|
||||
[self.doricContext.navigator doric_navigator_push:params[@"scheme"] alias:params[@"alias"] animated:animated];
|
||||
[self.doricContext.navigator doric_navigator_push:scheme alias:alias animated:animated extra:config[@"extra"]];
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user