refact:change field name from scheme to source
This commit is contained in:
parent
9e54ba1ea6
commit
0961cb9fc9
@ -106,7 +106,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(tv.getContext(), DemoDebugActivity.class);
|
Intent intent = new Intent(tv.getContext(), DemoDebugActivity.class);
|
||||||
intent.putExtra("scheme", "assets://src/" + data[position]);
|
intent.putExtra("source", "assets://src/" + data[position]);
|
||||||
intent.putExtra("alias", data[position]);
|
intent.putExtra("alias", data[position]);
|
||||||
tv.getContext().startActivity(intent);
|
tv.getContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class DoricActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.doric_activity);
|
setContentView(R.layout.doric_activity);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
mDoricFragment = DoricFragment.newInstance(getScheme(), getAlias(), getExtra());
|
mDoricFragment = DoricFragment.newInstance(getSource(), getAlias(), getExtra());
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.container, mDoricFragment)
|
.add(R.id.container, mDoricFragment)
|
||||||
.commit();
|
.commit();
|
||||||
@ -43,8 +43,8 @@ public class DoricActivity extends AppCompatActivity {
|
|||||||
/**
|
/**
|
||||||
* @return Scheme for DoricFragment to load.
|
* @return Scheme for DoricFragment to load.
|
||||||
*/
|
*/
|
||||||
protected String getScheme() {
|
protected String getSource() {
|
||||||
return getIntent().getStringExtra("scheme");
|
return getIntent().getStringExtra("source");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,9 +35,9 @@ import androidx.navigation.Navigation;
|
|||||||
*/
|
*/
|
||||||
public class DoricFragment extends Fragment {
|
public class DoricFragment extends Fragment {
|
||||||
|
|
||||||
public static DoricFragment newInstance(String scheme, String alias, String extra) {
|
public static DoricFragment newInstance(String source, String alias, String extra) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("scheme", scheme);
|
args.putString("source", source);
|
||||||
args.putString("alias", alias);
|
args.putString("alias", alias);
|
||||||
args.putString("extra", extra);
|
args.putString("extra", extra);
|
||||||
DoricFragment fragment = new DoricFragment();
|
DoricFragment fragment = new DoricFragment();
|
||||||
|
@ -72,9 +72,9 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void push(String scheme, String alias, String extra) {
|
public void push(String source, String alias, String extra) {
|
||||||
Bundle argument = new Bundle();
|
Bundle argument = new Bundle();
|
||||||
argument.putString("scheme", scheme);
|
argument.putString("source", source);
|
||||||
argument.putString("alias", alias);
|
argument.putString("alias", alias);
|
||||||
argument.putString("extra", extra);
|
argument.putString("extra", extra);
|
||||||
getNavController()
|
getNavController()
|
||||||
@ -170,9 +170,9 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
|||||||
}
|
}
|
||||||
showLoading();
|
showLoading();
|
||||||
final String alias = argument.getString("alias");
|
final String alias = argument.getString("alias");
|
||||||
String scheme = argument.getString("scheme");
|
String source = argument.getString("source");
|
||||||
final String extra = argument.getString("extra");
|
final String extra = argument.getString("extra");
|
||||||
DoricJSLoaderManager.getInstance().loadJSBundle(scheme).setCallback(new AsyncResult.Callback<String>() {
|
DoricJSLoaderManager.getInstance().loadJSBundle(source).setCallback(new AsyncResult.Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(String result) {
|
public void onResult(String result) {
|
||||||
doricPanel.config(result, alias, extra);
|
doricPanel.config(result, alias, extra);
|
||||||
|
@ -30,14 +30,14 @@ import pub.doric.async.AsyncResult;
|
|||||||
*/
|
*/
|
||||||
public class DoricAssetJSLoader implements IDoricJSLoader {
|
public class DoricAssetJSLoader implements IDoricJSLoader {
|
||||||
@Override
|
@Override
|
||||||
public boolean filter(String scheme) {
|
public boolean filter(String source) {
|
||||||
return scheme.startsWith("assets");
|
return source.startsWith("assets");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResult<String> request(String scheme) {
|
public AsyncResult<String> request(String source) {
|
||||||
AsyncResult<String> result = new AsyncResult<>();
|
AsyncResult<String> result = new AsyncResult<>();
|
||||||
String assetPath = scheme.substring("assets://".length());
|
String assetPath = source.substring("assets://".length());
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
AssetManager assetManager = Doric.application().getAssets();
|
AssetManager assetManager = Doric.application().getAssets();
|
||||||
|
@ -35,14 +35,14 @@ public class DoricHttpJSLoader implements IDoricJSLoader {
|
|||||||
private OkHttpClient okHttpClient = new OkHttpClient();
|
private OkHttpClient okHttpClient = new OkHttpClient();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filter(String scheme) {
|
public boolean filter(String source) {
|
||||||
return scheme.startsWith("http");
|
return source.startsWith("http");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResult<String> request(String scheme) {
|
public AsyncResult<String> request(String source) {
|
||||||
final AsyncResult<String> ret = new AsyncResult<>();
|
final AsyncResult<String> ret = new AsyncResult<>();
|
||||||
okHttpClient.newCall(new Request.Builder().url(scheme).build()).enqueue(new Callback() {
|
okHttpClient.newCall(new Request.Builder().url(source).build()).enqueue(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||||
ret.setError(e);
|
ret.setError(e);
|
||||||
|
@ -52,11 +52,11 @@ public class DoricJSLoaderManager {
|
|||||||
return Inner.sInstance;
|
return Inner.sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsyncResult<String> loadJSBundle(String scheme) {
|
public AsyncResult<String> loadJSBundle(String source) {
|
||||||
Collection<IDoricJSLoader> jsLoaders = getJSLoaders();
|
Collection<IDoricJSLoader> jsLoaders = getJSLoaders();
|
||||||
for (IDoricJSLoader jsLoader : jsLoaders) {
|
for (IDoricJSLoader jsLoader : jsLoaders) {
|
||||||
if (jsLoader.filter(scheme)) {
|
if (jsLoader.filter(source)) {
|
||||||
return jsLoader.request(scheme);
|
return jsLoader.request(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new AsyncResult<>("");
|
return new AsyncResult<>("");
|
||||||
|
@ -23,7 +23,7 @@ import pub.doric.async.AsyncResult;
|
|||||||
* @CreateDate: 2019-11-23
|
* @CreateDate: 2019-11-23
|
||||||
*/
|
*/
|
||||||
public interface IDoricJSLoader {
|
public interface IDoricJSLoader {
|
||||||
boolean filter(String scheme);
|
boolean filter(String source);
|
||||||
|
|
||||||
AsyncResult<String> request(String scheme);
|
AsyncResult<String> request(String source);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package pub.doric.navigator;
|
|||||||
* @CreateDate: 2019-11-23
|
* @CreateDate: 2019-11-23
|
||||||
*/
|
*/
|
||||||
public interface IDoricNavigator {
|
public interface IDoricNavigator {
|
||||||
void push(String scheme, String alias, String extra);
|
void push(String source, String alias, String extra);
|
||||||
|
|
||||||
void pop();
|
void pop();
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public class NavigatorPlugin extends DoricJavaPlugin {
|
|||||||
if (navigator != null) {
|
if (navigator != null) {
|
||||||
try {
|
try {
|
||||||
JSObject jsObject = jsDecoder.decode().asObject();
|
JSObject jsObject = jsDecoder.decode().asObject();
|
||||||
String scheme = jsObject.getProperty("scheme").asString().value();
|
String source = jsObject.getProperty("source").asString().value();
|
||||||
String alias = scheme;
|
String alias = source;
|
||||||
String extra = "";
|
String extra = "";
|
||||||
JSValue config = jsObject.getProperty("config");
|
JSValue config = jsObject.getProperty("config");
|
||||||
if (config.isObject()) {
|
if (config.isObject()) {
|
||||||
@ -60,7 +60,7 @@ public class NavigatorPlugin extends DoricJavaPlugin {
|
|||||||
extra = extraJS.asString().value();
|
extra = extraJS.asString().value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
navigator.push(jsObject.getProperty("scheme").asString().value(),
|
navigator.push(jsObject.getProperty("source").asString().value(),
|
||||||
alias,
|
alias,
|
||||||
extra
|
extra
|
||||||
);
|
);
|
||||||
|
@ -15,8 +15,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
String scheme = "assets://src/" + BUNDLE_NAME + ".js";
|
String source = "assets://src/" + BUNDLE_NAME + ".js";
|
||||||
getIntent().putExtra("scheme", scheme);
|
getIntent().putExtra("source", scheme);
|
||||||
getIntent().putExtra("alias", BUNDLE_NAME);
|
getIntent().putExtra("alias", BUNDLE_NAME);
|
||||||
this.getSupportFragmentManager().beginTransaction().add(R.id.root, new DoricFragment()).commit();
|
this.getSupportFragmentManager().beginTransaction().add(R.id.root, new DoricFragment()).commit();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ @implementation AppDelegate
|
|||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
NSString *bundleName = @"__$__";
|
NSString *bundleName = @"__$__";
|
||||||
DoricViewController *doricViewController = [[DoricViewController alloc] initWithScheme:[NSString stringWithFormat:@"assets://src/%@.js", bundleName]
|
DoricViewController *doricViewController = [[DoricViewController alloc] initWithSource:[NSString stringWithFormat:@"assets://src/%@.js", bundleName]
|
||||||
alias:bundleName
|
alias:bundleName
|
||||||
extra:@""];
|
extra:@""];
|
||||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||||
|
@ -8,7 +8,7 @@ @implementation SceneDelegate
|
|||||||
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
|
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
|
||||||
UIWindowScene *windowScene = (UIWindowScene *) scene;
|
UIWindowScene *windowScene = (UIWindowScene *) scene;
|
||||||
NSString *bundleName = @"__$__";
|
NSString *bundleName = @"__$__";
|
||||||
DoricViewController *doricViewController = [[DoricViewController alloc] initWithScheme:[NSString stringWithFormat:@"assets://src/%@.js", bundleName]
|
DoricViewController *doricViewController = [[DoricViewController alloc] initWithSource:[NSString stringWithFormat:@"assets://src/%@.js", bundleName]
|
||||||
alias:bundleName
|
alias:bundleName
|
||||||
extra:@""];
|
extra:@""];
|
||||||
doricViewController.view.backgroundColor = [UIColor whiteColor];
|
doricViewController.view.backgroundColor = [UIColor whiteColor];
|
||||||
|
@ -77,7 +77,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
|
|||||||
}
|
}
|
||||||
NSString *file = self.demoFilePaths[(NSUInteger) indexPath.row];
|
NSString *file = self.demoFilePaths[(NSUInteger) indexPath.row];
|
||||||
DoricViewController *doricViewController = [[DoricViewController alloc]
|
DoricViewController *doricViewController = [[DoricViewController alloc]
|
||||||
initWithScheme:[NSString stringWithFormat:@"assets://src/%@", file]
|
initWithSource:[NSString stringWithFormat:@"assets://src/%@", file]
|
||||||
alias:self.demoFilePaths[(NSUInteger) indexPath.row]
|
alias:self.demoFilePaths[(NSUInteger) indexPath.row]
|
||||||
extra:nil
|
extra:nil
|
||||||
];
|
];
|
||||||
|
@ -32,5 +32,5 @@ extern NSString *const DORIC_MASK_RETRY;
|
|||||||
@property(nonatomic, strong) UIView *loadingView;
|
@property(nonatomic, strong) UIView *loadingView;
|
||||||
@property(nonatomic, strong) UIView *errorView;
|
@property(nonatomic, strong) UIView *errorView;
|
||||||
|
|
||||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra;
|
- (instancetype)initWithSource:(NSString *)source alias:(NSString *)alias extra:(NSString *)extra;
|
||||||
@end
|
@end
|
||||||
|
@ -29,16 +29,16 @@ @interface DoricViewController ()
|
|||||||
@property(nonatomic) BOOL navBarHidden;
|
@property(nonatomic) BOOL navBarHidden;
|
||||||
@property(nonatomic, strong) UIImage *navBarImage;
|
@property(nonatomic, strong) UIImage *navBarImage;
|
||||||
@property(nonatomic, strong) UIView *maskView;
|
@property(nonatomic, strong) UIView *maskView;
|
||||||
@property(nonatomic, copy) NSString *scheme;
|
@property(nonatomic, copy) NSString *source;
|
||||||
@property(nonatomic, copy) NSString *alias;
|
@property(nonatomic, copy) NSString *alias;
|
||||||
@property(nonatomic, copy) NSString *extra;
|
@property(nonatomic, copy) NSString *extra;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricViewController
|
@implementation DoricViewController
|
||||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias extra:(NSString *)extra {
|
- (instancetype)initWithSource:(NSString *)source alias:(NSString *)alias extra:(NSString *)extra {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||||
_scheme = scheme;
|
_source = source;
|
||||||
_alias = alias;
|
_alias = alias;
|
||||||
_extra = extra;
|
_extra = extra;
|
||||||
_doricPanel = [DoricPanel new];
|
_doricPanel = [DoricPanel new];
|
||||||
@ -105,8 +105,8 @@ - (void)viewWillLayoutSubviews {
|
|||||||
self.doricPanel.view.height = self.view.height;
|
self.doricPanel.view.height = self.view.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra {
|
- (void)doric_navigator_push:(NSString *)source alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra {
|
||||||
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias extra:extra];
|
DoricViewController *viewController = [[DoricViewController alloc] initWithSource:source alias:alias extra:extra];
|
||||||
[self.navigationController pushViewController:viewController animated:animated];
|
[self.navigationController pushViewController:viewController animated:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ - (void)hideMask {
|
|||||||
|
|
||||||
- (void)loadJSBundle {
|
- (void)loadJSBundle {
|
||||||
[self showLoading];
|
[self showLoading];
|
||||||
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:self.scheme];
|
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:self.source];
|
||||||
result.resultCallback = ^(NSString *result) {
|
result.resultCallback = ^(NSString *result) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self hideMask];
|
[self hideMask];
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
@implementation DoricHttpJSLoader
|
@implementation DoricHttpJSLoader
|
||||||
|
|
||||||
- (BOOL)filter:(NSString *)scheme {
|
- (BOOL)filter:(NSString *)source {
|
||||||
return [scheme hasPrefix:@"http"];
|
return [source hasPrefix:@"http"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (DoricAsyncResult <NSString *> *)request:(NSString *)scheme {
|
- (DoricAsyncResult <NSString *> *)request:(NSString *)source {
|
||||||
DoricAsyncResult *ret = [DoricAsyncResult new];
|
DoricAsyncResult *ret = [DoricAsyncResult new];
|
||||||
NSURL *URL = [NSURL URLWithString:scheme];
|
NSURL *URL = [NSURL URLWithString:source];
|
||||||
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
|
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
|
||||||
[[[NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]
|
[[[NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]
|
||||||
dataTaskWithRequest:request
|
dataTaskWithRequest:request
|
||||||
|
@ -29,5 +29,5 @@
|
|||||||
|
|
||||||
- (void)addJSLoader:(id <DoricLoaderProtocol>)loader;
|
- (void)addJSLoader:(id <DoricLoaderProtocol>)loader;
|
||||||
|
|
||||||
- (DoricAsyncResult <NSString *> *)request:(NSString *)scheme;
|
- (DoricAsyncResult <NSString *> *)request:(NSString *)source;
|
||||||
@end
|
@end
|
||||||
|
@ -55,11 +55,11 @@ - (void)addJSLoader:(id <DoricLoaderProtocol>)loader {
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (DoricAsyncResult <NSString *> *)request:(NSString *)scheme {
|
- (DoricAsyncResult <NSString *> *)request:(NSString *)source {
|
||||||
__block DoricAsyncResult *ret;
|
__block DoricAsyncResult *ret;
|
||||||
[self.loaders enumerateObjectsUsingBlock:^(id <DoricLoaderProtocol> obj, BOOL *stop) {
|
[self.loaders enumerateObjectsUsingBlock:^(id <DoricLoaderProtocol> obj, BOOL *stop) {
|
||||||
if ([obj filter:scheme]) {
|
if ([obj filter:source]) {
|
||||||
ret = [obj request:scheme];
|
ret = [obj request:source];
|
||||||
*stop = YES;
|
*stop = YES;
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#import "DoricAsyncResult.h"
|
#import "DoricAsyncResult.h"
|
||||||
|
|
||||||
@protocol DoricLoaderProtocol <NSObject>
|
@protocol DoricLoaderProtocol <NSObject>
|
||||||
- (BOOL)filter:(NSString *)scheme;
|
- (BOOL)filter:(NSString *)source;
|
||||||
|
|
||||||
- (DoricAsyncResult <NSString *> *)request:(NSString *)scheme;
|
- (DoricAsyncResult <NSString *> *)request:(NSString *)source;
|
||||||
@end
|
@end
|
@ -21,14 +21,14 @@
|
|||||||
|
|
||||||
|
|
||||||
@implementation DoricMainBundleJSLoader
|
@implementation DoricMainBundleJSLoader
|
||||||
- (BOOL)filter:(NSString *)scheme {
|
- (BOOL)filter:(NSString *)source {
|
||||||
return [scheme hasPrefix:@"assets"];
|
return [source hasPrefix:@"assets"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (DoricAsyncResult <NSString *> *)request:(NSString *)scheme {
|
- (DoricAsyncResult <NSString *> *)request:(NSString *)source {
|
||||||
DoricAsyncResult <NSString *> *ret = [DoricAsyncResult new];
|
DoricAsyncResult <NSString *> *ret = [DoricAsyncResult new];
|
||||||
NSString *path = [[NSBundle mainBundle] bundlePath];
|
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||||
NSString *fullPath = [path stringByAppendingPathComponent:[scheme substringFromIndex:@"assets://".length]];
|
NSString *fullPath = [path stringByAppendingPathComponent:[source substringFromIndex:@"assets://".length]];
|
||||||
NSError *error;
|
NSError *error;
|
||||||
NSString *jsContent = [NSString stringWithContentsOfFile:fullPath encoding:NSUTF8StringEncoding error:&error];
|
NSString *jsContent = [NSString stringWithContentsOfFile:fullPath encoding:NSUTF8StringEncoding error:&error];
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@protocol DoricNavigatorDelegate <NSObject>
|
@protocol DoricNavigatorDelegate <NSObject>
|
||||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra;
|
- (void)doric_navigator_push:(NSString *)source alias:(NSString *)alias animated:(BOOL)animated extra:(NSString *)extra;
|
||||||
|
|
||||||
- (void)doric_navigator_pop:(BOOL)animated;
|
- (void)doric_navigator_pop:(BOOL)animated;
|
||||||
@end
|
@end
|
||||||
|
@ -24,8 +24,8 @@ @implementation DoricNavigatorPlugin
|
|||||||
- (void)push:(NSDictionary *)params {
|
- (void)push:(NSDictionary *)params {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
BOOL animated = YES;
|
BOOL animated = YES;
|
||||||
NSString *scheme = params[@"scheme"];
|
NSString *source = params[@"source"];
|
||||||
NSString *alias = scheme;
|
NSString *alias = source;
|
||||||
NSDictionary *config = params[@"config"];
|
NSDictionary *config = params[@"config"];
|
||||||
if (config) {
|
if (config) {
|
||||||
if (config[@"animated"]) {
|
if (config[@"animated"]) {
|
||||||
@ -36,7 +36,7 @@ - (void)push:(NSDictionary *)params {
|
|||||||
alias = config[@"alias"];
|
alias = config[@"alias"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[self.doricContext.navigator doric_navigator_push:scheme alias:alias animated:animated extra:config[@"extra"]];
|
[self.doricContext.navigator doric_navigator_push:source alias:alias animated:animated extra:config[@"extra"]];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,22 +463,3 @@ - (void)layoutSelf:(CGSize)targetSize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
DoricVLayoutView *vLayout(NSArray <__kindof UIView *> *views) {
|
|
||||||
DoricVLayoutView *layout = [[DoricVLayoutView alloc] initWithFrame:CGRectZero];
|
|
||||||
for (__kindof UIView *uiView in views) {
|
|
||||||
[layout addSubview:uiView];
|
|
||||||
}
|
|
||||||
layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent];
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
DoricHLayoutView *hLayout(NSArray <__kindof UIView *> *views) {
|
|
||||||
DoricHLayoutView *layout = [[DoricHLayoutView alloc] initWithFrame:CGRectZero];
|
|
||||||
for (__kindof UIView *uiView in views) {
|
|
||||||
[layout addSubview:uiView];
|
|
||||||
}
|
|
||||||
layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent];
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
@ -2504,12 +2504,12 @@ function navbar(context) {
|
|||||||
|
|
||||||
function navigator(context) {
|
function navigator(context) {
|
||||||
return {
|
return {
|
||||||
push: function (scheme, config) {
|
push: function (source, config) {
|
||||||
if (config && config.extra) {
|
if (config && config.extra) {
|
||||||
config.extra = JSON.stringify(config.extra);
|
config.extra = JSON.stringify(config.extra);
|
||||||
}
|
}
|
||||||
return context.callNative('navigator', 'push', {
|
return context.callNative('navigator', 'push', {
|
||||||
scheme: scheme, config: config
|
source: source, config: config
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pop: function (animated) {
|
pop: function (animated) {
|
||||||
|
@ -1879,12 +1879,12 @@ function navbar(context) {
|
|||||||
|
|
||||||
function navigator(context) {
|
function navigator(context) {
|
||||||
return {
|
return {
|
||||||
push: (scheme, config) => {
|
push: (source, config) => {
|
||||||
if (config && config.extra) {
|
if (config && config.extra) {
|
||||||
config.extra = JSON.stringify(config.extra);
|
config.extra = JSON.stringify(config.extra);
|
||||||
}
|
}
|
||||||
return context.callNative('navigator', 'push', {
|
return context.callNative('navigator', 'push', {
|
||||||
scheme, config
|
source, config
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pop: (animated = true) => {
|
pop: (animated = true) => {
|
||||||
|
@ -3338,12 +3338,12 @@ function navbar(context) {
|
|||||||
|
|
||||||
function navigator(context) {
|
function navigator(context) {
|
||||||
return {
|
return {
|
||||||
push: (scheme, config) => {
|
push: (source, config) => {
|
||||||
if (config && config.extra) {
|
if (config && config.extra) {
|
||||||
config.extra = JSON.stringify(config.extra);
|
config.extra = JSON.stringify(config.extra);
|
||||||
}
|
}
|
||||||
return context.callNative('navigator', 'push', {
|
return context.callNative('navigator', 'push', {
|
||||||
scheme, config
|
source, config
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pop: (animated = true) => {
|
pop: (animated = true) => {
|
||||||
|
2
doric-js/index.d.ts
vendored
2
doric-js/index.d.ts
vendored
@ -754,7 +754,7 @@ declare module 'doric/lib/src/native/navbar' {
|
|||||||
declare module 'doric/lib/src/native/navigator' {
|
declare module 'doric/lib/src/native/navigator' {
|
||||||
import { BridgeContext } from "doric/lib/src/runtime/global";
|
import { BridgeContext } from "doric/lib/src/runtime/global";
|
||||||
export function navigator(context: BridgeContext): {
|
export function navigator(context: BridgeContext): {
|
||||||
push: (scheme: string, config?: {
|
push: (source: string, config?: {
|
||||||
alias?: string | undefined;
|
alias?: string | undefined;
|
||||||
animated?: boolean | undefined;
|
animated?: boolean | undefined;
|
||||||
extra?: object | undefined;
|
extra?: object | undefined;
|
||||||
|
2
doric-js/lib/src/native/navigator.d.ts
vendored
2
doric-js/lib/src/native/navigator.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
import { BridgeContext } from "../runtime/global";
|
import { BridgeContext } from "../runtime/global";
|
||||||
export declare function navigator(context: BridgeContext): {
|
export declare function navigator(context: BridgeContext): {
|
||||||
push: (scheme: string, config?: {
|
push: (source: string, config?: {
|
||||||
alias?: string | undefined;
|
alias?: string | undefined;
|
||||||
animated?: boolean | undefined;
|
animated?: boolean | undefined;
|
||||||
extra?: object | undefined;
|
extra?: object | undefined;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
export function navigator(context) {
|
export function navigator(context) {
|
||||||
return {
|
return {
|
||||||
push: (scheme, config) => {
|
push: (source, config) => {
|
||||||
if (config && config.extra) {
|
if (config && config.extra) {
|
||||||
config.extra = JSON.stringify(config.extra);
|
config.extra = JSON.stringify(config.extra);
|
||||||
}
|
}
|
||||||
return context.callNative('navigator', 'push', {
|
return context.callNative('navigator', 'push', {
|
||||||
scheme, config
|
source, config
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pop: (animated = true) => {
|
pop: (animated = true) => {
|
||||||
|
@ -17,7 +17,7 @@ import { BridgeContext } from "../runtime/global"
|
|||||||
|
|
||||||
export function navigator(context: BridgeContext) {
|
export function navigator(context: BridgeContext) {
|
||||||
return {
|
return {
|
||||||
push: (scheme: string, config?: {
|
push: (source: string, config?: {
|
||||||
alias?: string,
|
alias?: string,
|
||||||
animated?: boolean,
|
animated?: boolean,
|
||||||
extra?: object,
|
extra?: object,
|
||||||
@ -26,7 +26,7 @@ export function navigator(context: BridgeContext) {
|
|||||||
(config as any).extra = JSON.stringify(config.extra)
|
(config as any).extra = JSON.stringify(config.extra)
|
||||||
}
|
}
|
||||||
return context.callNative('navigator', 'push', {
|
return context.callNative('navigator', 'push', {
|
||||||
scheme, config
|
source, config
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
pop: (animated = true) => {
|
pop: (animated = true) => {
|
||||||
|
@ -6,7 +6,7 @@ export class NavigatorPlugin extends DoricPlugin {
|
|||||||
navigation: NavigationElement | undefined = document.getElementsByTagName('doric-navigation')[0] as (NavigationElement | undefined)
|
navigation: NavigationElement | undefined = document.getElementsByTagName('doric-navigation')[0] as (NavigationElement | undefined)
|
||||||
|
|
||||||
push(args: {
|
push(args: {
|
||||||
scheme: string,
|
source: string,
|
||||||
config?: {
|
config?: {
|
||||||
alias?: string,
|
alias?: string,
|
||||||
extra?: string,
|
extra?: string,
|
||||||
@ -14,8 +14,8 @@ export class NavigatorPlugin extends DoricPlugin {
|
|||||||
}) {
|
}) {
|
||||||
if (this.navigation) {
|
if (this.navigation) {
|
||||||
const div = new DoricElement
|
const div = new DoricElement
|
||||||
div.src = args.scheme
|
div.src = args.source
|
||||||
div.alias = args.config?.alias || args.scheme
|
div.alias = args.config?.alias || args.source
|
||||||
this.navigation.push(div)
|
this.navigation.push(div)
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user