Skip to content

Commit 44e2249

Browse files
author
hshristov
committed
fix android onSelectedItem handler.
fix ios transition (previous fix was not enough)
1 parent 0386d07 commit 44e2249

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

ui/frame/frame.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class PageFragmentBody extends android.app.Fragment {
182182
return true;
183183
}
184184

185-
super.onOptionsItemSelected(item);
185+
return super.onOptionsItemSelected(item);
186186
}
187187
}
188188

ui/frame/frame.ios.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,18 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
226226
}
227227

228228
public navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
229-
// This method is needed otherwise it will be too late and transition will completed before page is layouted.
229+
// In this method we need to layout the new page otherwise page will be shown empty and update after that which is bad UX.
230230
var frame = this._owner;
231-
var backStack = frame.backStack;
232-
var currentEntry = backStack.length > 0 ? backStack[backStack.length - 1] : null;
233231
var newEntry: definition.BackstackEntry = viewController[ENTRY];
234-
235-
var isBack = currentEntry && newEntry === currentEntry;
236-
if (!isBack) {
237-
var newPage = newEntry.resolvedPage;
238-
239-
if (!frame._currentEntry) {
240-
frame._currentEntry = newEntry;
241-
}
242-
else {
243-
frame._navigateToEntry = newEntry;
244-
}
245-
232+
var newPage = newEntry.resolvedPage;
233+
if (!newPage.parent) {
234+
frame._navigateToEntry = newEntry;
246235
frame._addView(newPage);
247236
frame.populateMenuItems(newPage);
248237
}
238+
else if (newPage.parent !== frame) {
239+
throw new Error("Page is already shown on another frame.");
240+
}
249241
}
250242

251243
public navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
@@ -255,6 +247,8 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
255247
var currentEntry = backStack.length > 0 ? backStack[backStack.length - 1] : null;
256248
var newEntry: definition.BackstackEntry = viewController[ENTRY];
257249

250+
// This code check if navigation happened through UI (e.g. back button or swipe gesture).
251+
// When calling goBack on frame isBack will be false.
258252
var isBack: boolean = currentEntry && newEntry === currentEntry;
259253
if (isBack) {
260254
try {
@@ -267,16 +261,16 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
267261
}
268262

269263
var page = frame.currentPage;
270-
if (page && isBack) {
264+
if (page && !navigationController.viewControllers.containsObject(page.ios)) {
271265
frame._removeView(page);
272266
}
273267

274-
var newPage = newEntry.resolvedPage;
275-
276268
frame._navigateToEntry = null;
277269
frame._currentEntry = newEntry;
278270
frame.updateNavigationBar();
279-
271+
272+
var newPage = newEntry.resolvedPage;
273+
280274
// notify the page
281275
newPage.onNavigatedTo(newEntry.entry.context);
282276
frame._processNavigationQueue(newPage);

0 commit comments

Comments
 (0)