Skip to content

Commit c756188

Browse files
committed
fix (hmr): Fix the Android version for the HMR issue. See nativescript-vue#388
1 parent ad9e007 commit c756188

File tree

1 file changed

+25
-1
lines changed
  • platform/nativescript/runtime/components

1 file changed

+25
-1
lines changed

platform/nativescript/runtime/components/frame.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { setFrame, getFrame, deleteFrame } from '../../util/frame'
22
import { isHMRChecking, resetHMRChecking } from '../../util/hmr'
33
import { isAndroid, isIOS } from 'tns-core-modules/platform'
44
import { ios as iosUtils } from 'tns-core-modules/utils/utils'
5+
import { _setAndroidFragmentTransitions } from 'tns-core-modules/ui/frame/fragment.transitions'
56

67
let idCounter = 1
78

@@ -159,7 +160,30 @@ export default {
159160
// replace the controllers instead of pushing directly
160161
frame._ios.controller.setViewControllersAnimated(newControllers, false)
161162
} else {
162-
// TODO: Implement for Android
163+
const frameId = frame._android.frameId
164+
frame._isBack = false
165+
backstackEntry.frameId = frameId
166+
167+
const manager = frame._getFragmentManager()
168+
const currentEntry = frame._currentEntry
169+
170+
const newFragmentTag = `fragment${frameId}[-1]`
171+
const newFragment = frame.createFragment(backstackEntry, newFragmentTag)
172+
const animated = false
173+
const navigationTransition = null
174+
175+
const transaction = manager.beginTransaction()
176+
_setAndroidFragmentTransitions(
177+
animated,
178+
navigationTransition,
179+
currentEntry,
180+
backstackEntry,
181+
transaction,
182+
frameId
183+
)
184+
transaction.remove(currentEntry.fragment)
185+
transaction.replace(frame.containerViewId, newFragment, newFragmentTag)
186+
transaction.commitAllowingStateLoss()
163187
}
164188
resetHMRChecking()
165189
},

0 commit comments

Comments
 (0)