android:navigator plugin push support singlePage flag and the default value is false
This commit is contained in:
parent
4e724ba922
commit
e4351e3b00
@ -25,6 +25,7 @@ import com.github.pengfeizhou.jscore.JSValue;
|
||||
import com.github.pengfeizhou.jscore.JavaValue;
|
||||
|
||||
import pub.doric.Doric;
|
||||
import pub.doric.DoricActivity;
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.extension.bridge.DoricMethod;
|
||||
import pub.doric.extension.bridge.DoricPlugin;
|
||||
@ -53,6 +54,7 @@ public class NavigatorPlugin extends DoricJavaPlugin {
|
||||
String alias = source;
|
||||
String extra = "";
|
||||
JSValue config = jsObject.getProperty("config");
|
||||
boolean singlePage = false;
|
||||
if (config.isObject()) {
|
||||
JSValue aliasJS = config.asObject().getProperty("alias");
|
||||
if (aliasJS.isString()) {
|
||||
@ -62,11 +64,23 @@ public class NavigatorPlugin extends DoricJavaPlugin {
|
||||
if (extraJS.isString()) {
|
||||
extra = extraJS.asString().value();
|
||||
}
|
||||
JSValue singlePageJS = config.asObject().getProperty("singlePage");
|
||||
if (singlePageJS.isBoolean()) {
|
||||
singlePage = singlePageJS.asBoolean().value();
|
||||
}
|
||||
}
|
||||
if (singlePage) {
|
||||
navigator.push(jsObject.getProperty("source").asString().value(),
|
||||
alias,
|
||||
extra
|
||||
);
|
||||
} else {
|
||||
Intent intent = new Intent(getDoricContext().getContext(), DoricActivity.class);
|
||||
intent.putExtra("source", source);
|
||||
intent.putExtra("alias", alias);
|
||||
intent.putExtra("extra", extra);
|
||||
getDoricContext().getContext().startActivity(intent);
|
||||
}
|
||||
promise.resolve();
|
||||
} catch (ArchiveException e) {
|
||||
e.printStackTrace();
|
||||
|
1
doric-js/index.d.ts
vendored
1
doric-js/index.d.ts
vendored
@ -818,6 +818,7 @@ declare module 'doric/lib/src/native/navigator' {
|
||||
alias?: string | undefined;
|
||||
animated?: boolean | undefined;
|
||||
extra?: object | undefined;
|
||||
singlePage?: boolean | undefined;
|
||||
} | undefined) => Promise<any>;
|
||||
pop: (animated?: boolean) => Promise<any>;
|
||||
openUrl: (url: string) => Promise<any>;
|
||||
|
1
doric-js/lib/src/native/navigator.d.ts
vendored
1
doric-js/lib/src/native/navigator.d.ts
vendored
@ -4,6 +4,7 @@ export declare function navigator(context: BridgeContext): {
|
||||
alias?: string | undefined;
|
||||
animated?: boolean | undefined;
|
||||
extra?: object | undefined;
|
||||
singlePage?: boolean | undefined;
|
||||
} | undefined) => Promise<any>;
|
||||
pop: (animated?: boolean) => Promise<any>;
|
||||
openUrl: (url: string) => Promise<any>;
|
||||
|
@ -22,6 +22,7 @@ export function navigator(context: BridgeContext) {
|
||||
alias?: string,
|
||||
animated?: boolean,
|
||||
extra?: object,
|
||||
singlePage?: boolean,
|
||||
}) => {
|
||||
if (config && config.extra) {
|
||||
(config as any).extra = JSON.stringify(config.extra)
|
||||
|
Reference in New Issue
Block a user