mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
feat(android): Implementing 'onBackPressed' for frame-root (#8634)
Useful for meddling with tab-navigated apps. Co-authored-by: Dimitris - Rafail Katsampas <katsampasdr@gmail.com>
This commit is contained in:
@ -1221,20 +1221,18 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
|
|||||||
|
|
||||||
const view = this._rootView;
|
const view = this._rootView;
|
||||||
let callSuper = false;
|
let callSuper = false;
|
||||||
if (view instanceof Frame) {
|
|
||||||
callSuper = !FrameBase.goBack();
|
const viewArgs = <application.AndroidActivityBackPressedEventData>{
|
||||||
} else {
|
eventName: "activityBackPressed",
|
||||||
const viewArgs = <application.AndroidActivityBackPressedEventData>{
|
object: view,
|
||||||
eventName: "activityBackPressed",
|
activity: activity,
|
||||||
object: view,
|
cancel: false,
|
||||||
activity: activity,
|
};
|
||||||
cancel: false,
|
view.notify(viewArgs);
|
||||||
};
|
|
||||||
view.notify(viewArgs);
|
|
||||||
|
|
||||||
if (!viewArgs.cancel && !view.onBackPressed()) {
|
// In the case of Frame, use this callback only if it was overridden, since the original will cause navigation issues
|
||||||
callSuper = true;
|
if (!viewArgs.cancel && (view.onBackPressed === Frame.prototype.onBackPressed || !view.onBackPressed())) {
|
||||||
}
|
callSuper = view instanceof Frame ? !FrameBase.goBack() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callSuper) {
|
if (callSuper) {
|
||||||
|
Reference in New Issue
Block a user