MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / _tearDownUI

Function _tearDownUI

packages/core/ui/core/view-base/index.ts:1276–1332  ·  view source on GitHub ↗
(force?: boolean)

Source from the content-addressed store, hash-verified

1274 */
1275 @profile
1276 public _tearDownUI(force?: boolean): void {
1277 // No context means we are already teared down.
1278 if (!this._context) {
1279 return;
1280 }
1281 const preserveNativeView = this.reusable && !force;
1282
1283 this.resetNativeViewInternal();
1284
1285 if (!preserveNativeView) {
1286 this.eachChild((child) => {
1287 child._tearDownUI(force);
1288
1289 return true;
1290 });
1291 }
1292
1293 if (this.parent) {
1294 this.parent._removeViewFromNativeVisualTree(this);
1295 }
1296
1297 // const nativeView = this.nativeViewProtected;
1298 // if (nativeView && __ANDROID__) {
1299 // const recycle = this.recycleNativeView;
1300 // let shouldRecycle = false;
1301 // if (recycle === "always") {
1302 // shouldRecycle = true;
1303 // } else if (recycle === "auto" && !this._disableNativeViewRecycling) {
1304 // const propertiesSet = Object.getOwnPropertySymbols(this).length + Object.getOwnPropertySymbols(this.style).length / 2;
1305 // shouldRecycle = propertiesSet <= this.recyclePropertyCounter;
1306 // }
1307
1308 // // const nativeParent = __ANDROID__ ? (<android.view.View>nativeView).getParent() : (<UIView>nativeView).superview;
1309 // const nativeParent = (<android.view.View>nativeView).getParent();
1310 // const animation = (<android.view.View>nativeView).getAnimation();
1311 // if (shouldRecycle && !nativeParent && !animation) {
1312 // putNativeView(this._context, this);
1313 // }
1314 // }
1315
1316 if (!preserveNativeView) {
1317 this.disposeNativeView();
1318
1319 this._suspendNativeUpdates(SuspendType.UISetup);
1320
1321 this.setNativeView(null);
1322 this._androidView = null;
1323 this._iosView = null;
1324
1325 this._context = null;
1326 }
1327
1328 if (this.domNode) {
1329 this.domNode.dispose();
1330 this.domNode = undefined;
1331 }
1332 }
1333

Callers

nothing calls this directly

Calls 5

_tearDownUIMethod · 0.80
disposeMethod · 0.80
eachChildMethod · 0.45
disposeNativeViewMethod · 0.45

Tested by

no test coverage detected