| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,9 +146,5 @@ function _test_onLiveSync_ModuleContext_TypeStyle(context: { type, path }) { | |||
| 146 | 146 | } | |
| 147 | 147 | ||
| 148 | 148 | function waitUntilLivesyncComplete(frame: Frame) { | |
| 149 | - if (isAndroid) { | ||
| 150 | - TKUnit.waitUntilReady(() => frame._executingEntry === null); | ||
| 151 | - } else { | ||
| 152 | - TKUnit.waitUntilReady(() => frame.currentPage.isLoaded); | ||
| 153 | - } | ||
| 149 | + TKUnit.waitUntilReady(() => frame._executingEntry === null); | ||
| 154 | 150 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ import { | |||
| 5 | 5 | } from "."; | |
| 6 | 6 | ||
| 7 | 7 | import { | |
| 8 | - ViewBase, Property, booleanConverter, eachDescendant, EventData, layout, | ||
| 8 | + ViewBase, Property, booleanConverter, EventData, layout, | ||
| 9 | 9 | getEventOrGestureName, traceEnabled, traceWrite, traceCategories, | |
| 10 | 10 | InheritedProperty, ShowModalOptions | |
| 11 | 11 | } from "../view-base"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,8 +169,11 @@ export function _setAndroidFragmentTransitions( | |||
| 169 | 169 | ||
| 170 | 170 | // Having transition means we have custom animation | |
| 171 | 171 | if (transition) { | |
| 172 | - // we do not use Android backstack so setting popEnter / popExit is meaningless (3rd and 4th optional args) | ||
| 173 | - fragmentTransaction.setCustomAnimations(AnimationType.enterFakeResourceId, AnimationType.exitFakeResourceId); | ||
| 172 | + if (fragmentTransaction) { | ||
| 173 | + // we do not use Android backstack so setting popEnter / popExit is meaningless (3rd and 4th optional args) | ||
| 174 | + fragmentTransaction.setCustomAnimations(AnimationType.enterFakeResourceId, AnimationType.exitFakeResourceId); | ||
| 175 | + } | ||
| 176 | + | ||
| 174 | 177 | setupAllAnimation(newEntry, transition); | |
| 175 | 178 | if (currentFragmentNeedsDifferentAnimation) { | |
| 176 | 179 | setupExitAndPopEnterAnimation(currentEntry, transition); | |
@@ -502,6 +505,8 @@ function clearEntry(entry: ExpandedEntry, removeListener: boolean): void { | |||
| 502 | 505 | clearAnimationListener(entry.exitAnimator, listener); | |
| 503 | 506 | clearAnimationListener(entry.popEnterAnimator, listener); | |
| 504 | 507 | clearAnimationListener(entry.popExitAnimator, listener); | |
| 508 | + clearAnimationListener(entry.defaultEnterAnimator, listener); | ||
| 509 | + clearAnimationListener(entry.defaultExitAnimator, listener); | ||
| 505 | 510 | } | |
| 506 | 511 | } | |
| 507 | 512 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,14 @@ | |||
| 1 | 1 | // Definitions. | |
| 2 | 2 | import { | |
| 3 | 3 | AndroidFrame as AndroidFrameDefinition, AndroidActivityCallbacks, | |
| 4 | - AndroidFragmentCallbacks, BackstackEntry, NavigationTransition | ||
| 4 | + AndroidFragmentCallbacks, BackstackEntry, NavigationTransition, NavigationEntry | ||
| 5 | 5 | } from "."; | |
| 6 | 6 | import { Page } from "../page"; | |
| 7 | 7 | ||
| 8 | 8 | // Types. | |
| 9 | 9 | import * as application from "../../application"; | |
| 10 | 10 | import { | |
| 11 | - FrameBase, goBack, stack, NavigationContext, NavigationType, | ||
| 11 | + FrameBase, goBack, stack, NavigationType, | ||
| 12 | 12 | Observable, View, traceCategories, traceEnabled, traceError, traceWrite | |
| 13 | 13 | } from "./frame-common"; | |
| 14 | 14 | ||
@@ -21,7 +21,6 @@ import { profile } from "../../profiling"; | |||
| 21 | 21 | ||
| 22 | 22 | // TODO: Remove this and get it from global to decouple builder for angular | |
| 23 | 23 | import { createViewFromEntry } from "../builder"; | |
| 24 | - import { getModuleName } from "../../utils/utils"; | ||
| 25 | 24 | ||
| 26 | 25 | export * from "./frame-common"; | |
| 27 | 26 | ||
@@ -37,6 +36,7 @@ const INTENT_EXTRA = "com.tns.activity"; | |||
| 37 | 36 | const ROOT_VIEW_ID_EXTRA = "com.tns.activity.rootViewId"; | |
| 38 | 37 | const FRAMEID = "_frameId"; | |
| 39 | 38 | const CALLBACKS = "_callbacks"; | |
| 39 | + const HMR_REPLACE_TRANSITION = "fade"; | ||
| 40 | 40 | ||
| 41 | 41 | const ownerSymbol = Symbol("_owner"); | |
| 42 | 42 | const activityRootViewsMap = new Map<number, WeakRef<View>>(); | |
@@ -319,6 +319,18 @@ export class Frame extends FrameBase { | |||
| 319 | 319 | restoreAnimatorState(this._currentEntry, this._cachedAnimatorState); | |
| 320 | 320 | this._cachedAnimatorState = null; | |
| 321 | 321 | } | |
| 322 | + | ||
| 323 | + // restore original fragment transitions if we just completed replace navigation (hmr) | ||
| 324 | + if (navigationType === NavigationType.replace) { | ||
| 325 | + _clearEntry(entry); | ||
| 326 | + | ||
| 327 | + const animated = entry.entry.animated; | ||
| 328 | + const navigationTransition = this._getNavigationTransition(entry.entry); | ||
| 329 | + const currentEntry = null; | ||
| 330 | + const newEntry = entry; | ||
| 331 | + const transaction = null; | ||
| 332 | + _setAndroidFragmentTransitions(animated, navigationTransition, currentEntry, newEntry, transaction, this._android.frameId); | ||
| 333 | + } | ||
| 322 | 334 | } | |
| 323 | 335 | ||
| 324 | 336 | public onBackPressed(): boolean { | |
@@ -381,12 +393,20 @@ export class Frame extends FrameBase { | |||
| 381 | 393 | const newFragmentTag = `fragment${fragmentId}[${navDepth}]`; | |
| 382 | 394 | const newFragment = this.createFragment(newEntry, newFragmentTag); | |
| 383 | 395 | const transaction = manager.beginTransaction(); | |
| 384 | - const animated = currentEntry ? this._getIsAnimatedNavigation(newEntry.entry) : false; | ||
| 396 | + let animated = currentEntry ? this._getIsAnimatedNavigation(newEntry.entry) : false; | ||
| 385 | 397 | // NOTE: Don't use transition for the initial navigation (same as on iOS) | |
| 386 | 398 | // On API 21+ transition won't be triggered unless there was at least one | |
| 387 | 399 | // layout pass so we will wait forever for transitionCompleted handler... | |
| 388 | 400 | // https://github.com/NativeScript/NativeScript/issues/4895 | |
| 389 | - const navigationTransition = this._currentEntry ? this._getNavigationTransition(newEntry.entry) : null; | ||
| 401 | + let navigationTransition: NavigationTransition; | ||
| 402 | + if (isReplace) { | ||
| 403 | + animated = true; | ||
| 404 | + navigationTransition = { name: HMR_REPLACE_TRANSITION, duration: 100 }; | ||
| 405 | + } else if (this._currentEntry) { | ||
| 406 | + navigationTransition = this._getNavigationTransition(newEntry.entry); | ||
| 407 | + } else { | ||
| 408 | + navigationTransition = null; | ||
| 409 | + } | ||
| 390 | 410 | ||
| 391 | 411 | _setAndroidFragmentTransitions(animated, navigationTransition, currentEntry, newEntry, transaction, this._android.frameId); | |
| 392 | 412 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,12 +7,11 @@ import { profile } from "../../profiling"; | |||
| 7 | 7 | ||
| 8 | 8 | //Types. | |
| 9 | 9 | import { | |
| 10 | - FrameBase, View, isCategorySet, layout, NavigationContext, | ||
| 10 | + FrameBase, View, isCategorySet, layout, | ||
| 11 | 11 | NavigationType, traceCategories, traceEnabled, traceWrite | |
| 12 | 12 | } from "./frame-common"; | |
| 13 | 13 | import { _createIOSAnimatedTransitioning } from "./fragment.transitions"; | |
| 14 | 14 | ||
| 15 | - import { createViewFromEntry } from "../builder"; | ||
| 16 | 15 | import * as utils from "../../utils/utils"; | |
| 17 | 16 | ||
| 18 | 17 | export * from "./frame-common"; | |
@@ -24,6 +23,7 @@ const DELEGATE = "_delegate"; | |||
| 24 | 23 | const NAV_DEPTH = "_navDepth"; | |
| 25 | 24 | const TRANSITION = "_transition"; | |
| 26 | 25 | const NON_ANIMATED_TRANSITION = "non-animated"; | |
| 26 | + const HMR_REPLACE_TRANSITION = "fade"; | ||
| 27 | 27 | ||
| 28 | 28 | let navDepth = -1; | |
| 29 | 29 | ||
@@ -88,13 +88,16 @@ export class Frame extends FrameBase { | |||
| 88 | 88 | ||
| 89 | 89 | let navigationTransition: NavigationTransition; | |
| 90 | 90 | let animated = this.currentPage ? this._getIsAnimatedNavigation(backstackEntry.entry) : false; | |
| 91 | - if (animated) { | ||
| 91 | + if (isReplace) { | ||
| 92 | + animated = true; | ||
| 93 | + navigationTransition = { name: HMR_REPLACE_TRANSITION, duration: 100 } | ||
| 94 | + viewController[TRANSITION] = navigationTransition; | ||
| 95 | + } else if (animated) { | ||
| 92 | 96 | navigationTransition = this._getNavigationTransition(backstackEntry.entry); | |
| 93 | 97 | if (navigationTransition) { | |
| 94 | 98 | viewController[TRANSITION] = navigationTransition; | |
| 95 | 99 | } | |
| 96 | - } | ||
| 97 | - else { | ||
| 100 | + } else { | ||
| 98 | 101 | //https://github.com/NativeScript/NativeScript/issues/1787 | |
| 99 | 102 | viewController[TRANSITION] = { name: NON_ANIMATED_TRANSITION }; | |
| 100 | 103 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | // Definitions. | |
| 2 | - import { Frame } from "../frame"; | ||
| 2 | + import { Frame, BackstackEntry } from "../frame"; | ||
| 3 | 3 | import { NavigationType } from "../frame/frame-common"; | |
| 4 | 4 | ||
| 5 | 5 | // Types. | |
@@ -15,6 +15,8 @@ export * from "./page-common"; | |||
| 15 | 15 | ||
| 16 | 16 | const ENTRY = "_entry"; | |
| 17 | 17 | const DELEGATE = "_delegate"; | |
| 18 | + const TRANSITION = "_transition"; | ||
| 19 | + const NON_ANIMATED_TRANSITION = "non-animated"; | ||
| 18 | 20 | ||
| 19 | 21 | const majorVersion = iosUtils.MajorVersion; | |
| 20 | 22 | ||
@@ -130,7 +132,7 @@ class UIViewControllerImpl extends UIViewController { | |||
| 130 | 132 | const frame = navigationController ? (<any>navigationController).owner : null; | |
| 131 | 133 | // Skip navigation events if modal page is shown. | |
| 132 | 134 | if (!owner._presentedViewController && frame) { | |
| 133 | - const newEntry = this[ENTRY]; | ||
| 135 | + const newEntry: BackstackEntry = this[ENTRY]; | ||
| 134 | 136 | ||
| 135 | 137 | let isBack: boolean; | |
| 136 | 138 | let navType = frame.navigationType; | |
@@ -146,6 +148,18 @@ class UIViewControllerImpl extends UIViewController { | |||
| 146 | 148 | } | |
| 147 | 149 | ||
| 148 | 150 | frame.setCurrent(newEntry, navType); | |
| 151 | + | ||
| 152 | + if (frame.navigationType === NavigationType.replace) { | ||
| 153 | + let controller = newEntry.resolvedPage.ios; | ||
| 154 | + if (controller) { | ||
| 155 | + if (newEntry.entry.animated) { | ||
| 156 | + controller[TRANSITION] = frame._getNavigationTransition(newEntry.entry); | ||
| 157 | + } else { | ||
| 158 | + controller[TRANSITION] = { name: NON_ANIMATED_TRANSITION }; | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + | ||
| 149 | 163 | frame.navigationType = isBack ? NavigationType.back : NavigationType.forward; | |
| 150 | 164 | ||
| 151 | 165 | // If page was shown with custom animation - we need to set the navigationController.delegate to the animatedDelegate. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments