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:
DimitrisRK
2020-06-13 23:46:57 +03:00
committed by GitHub
parent 3198f92580
commit c73952f364

View File

@ -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) {