This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-js/lib/src/native/navigator.js
2020-09-05 14:19:49 +08:00

26 lines
868 B
JavaScript

export function internalScheme(context, panelClass) {
return `_internal_://export?class=${encodeURIComponent(panelClass.name)}&context=${context.id}`;
}
export function navigator(context) {
const moduleName = "navigator";
return {
push: (source, config) => {
if (typeof source === 'function') {
source = internalScheme(context, source);
}
if (config && config.extra) {
config.extra = JSON.stringify(config.extra);
}
return context.callNative(moduleName, 'push', {
source, config
});
},
pop: (animated = true) => {
return context.callNative(moduleName, 'pop', { animated });
},
openUrl: (url) => {
return context.callNative(moduleName, "openUrl", url);
},
};
}