GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #3885 from NativeScript/hhristov/recycle-native-vi… · Cayan/NativeScript@86b9be3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/app/ui-tests-app
    • app.ts
    • mainPage.ts
  • tests/app
    • TKUnit.ts
    • testRunner.ts
    • ui
      • action-bar
        • action-bar-tests.android.ts
      • core/bindable
        • bindable-tests.ts
      • layouts
        • common-layout-tests.ts
        • flexbox-layout-tests.ts
        • layout-helper.android.ts
      • list-picker
        • list-picker-tests-native.android.ts
        • list-picker-tests.ts
      • list-view
        • list-view-tests.ts
      • page
        • page-tests-common.ts
        • page-tests.android.ts
        • page-tests.ios.ts
      • repeater
        • repeater-tests.ts
      • segmented-bar
        • segmented-bar-tests-native.ios.ts
      • switch
        • switch-tests.ts
      • tab-view
        • tab-view-tests.ts
      • text-view
        • text-view-tests.ts
      • time-picker
        • time-picker-tests.ts
      • view
        • view-tests-common.ts
  • tns-core-modules
    • application
      • application-common.ts
      • application.android.ts
      • application.d.ts
      • application.ios.ts
    • ui
      • action-bar
        • action-bar.android.ts
        • action-bar.ios.ts
      • activity-indicator
        • activity-indicator-common.ts
        • activity-indicator.android.ts
      • animation
        • animation.android.ts
        • animation.ios.ts
      • border
        • border.ts
      • button
        • button-common.ts
        • button.android.ts
      • content-view
        • content-view.ts
      • core
        • bindable
          • bindable.ts
        • properties
          • properties.ts
        • view-base
          • view-base.d.ts
          • view-base.ts
        • view
          • view-common.ts
          • view.android.ts
          • view.d.ts
          • view.ios.ts
      • date-picker
        • date-picker-common.ts
        • date-picker.android.ts
      • editable-text-base
        • editable-text-base.android.ts
      • frame
        • activity.android.ts
        • frame.android.ts
        • frame.ios.ts
      • gestures
        • gestures.ios.ts
      • html-view
        • html-view-common.ts
        • html-view.android.ts
        • html-view.ios.ts
      • image
        • image-common.ts
        • image.android.ts
        • image.ios.ts
      • label
        • label.android.ts
        • label.ios.ts
      • layouts
        • absolute-layout
          • absolute-layout-common.ts
          • absolute-layout.android.ts
        • dock-layout
          • dock-layout-common.ts
          • dock-layout.android.ts
        • flexbox-layout
          • flexbox-layout-common.ts
          • flexbox-layout.android.ts
        • grid-layout
          • grid-layout-common.ts
          • grid-layout.android.ts
        • layout-base.ios.ts
        • layout.android.ts
        • layout.ios.ts
        • stack-layout
          • stack-layout-common.ts
          • stack-layout.android.ts
        • wrap-layout
          • wrap-layout-common.ts
          • wrap-layout.android.ts
      • list-picker
        • list-picker-common.ts
        • list-picker.android.ts
        • list-picker.ios.ts
      • list-view
        • list-view-common.ts
        • list-view.android.ts
        • list-view.ios.ts
      • page
        • page.android.ts
        • page.ios.ts
      • placeholder
        • placeholder.android.ts
        • placeholder.ios.ts
      • progress
        • progress-common.ts
        • progress.android.ts
        • progress.ios.ts
      • proxy-view-container
        • proxy-view-container.ts
      • repeater
        • repeater.ts
      • scroll-view
        • scroll-view-common.ts
        • scroll-view.android.ts
        • scroll-view.ios.ts
      • search-bar
        • search-bar-common.ts
        • search-bar.android.ts
        • search-bar.ios.ts
      • segmented-bar
        • segmented-bar-common.ts
        • segmented-bar.android.ts
        • segmented-bar.ios.ts
      • slider
        • slider-common.ts
        • slider.android.ts
        • slider.ios.ts
      • styling
        • background.android.ts
        • background.ios.ts
      • switch
        • switch-common.ts
        • switch.android.ts
        • switch.ios.ts
      • tab-view
        • tab-view.android.ts
        • tab-view.ios.ts
      • text-base
        • text-base-common.ts
        • text-base.android.ts
      • text-field
        • text-field-common.ts
        • text-field.android.ts
      • text-view
        • text-view.android.ts
        • text-view.ios.ts
      • time-picker
        • time-picker-common.ts
        • time-picker.android.ts
      • transition
        • transition.android.ts
      • utils.ios.ts
      • web-view
        • web-view.android.ts
        • web-view.ios.ts
  • tns-platform-declarations/android
    • org.nativescript.widgets.d.ts
  • tsconfig.json

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/app/ui-tests-app/app.ts‎

Copy file name to clipboardExpand all lines: apps/app/ui-tests-app/app.ts
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,10 @@ application.on(application.lowMemoryEvent, function (args: application.Applicati
6969
});
7070

7171
application.on(application.uncaughtErrorEvent, function (args: application.UnhandledErrorEventData) {
72-
if (args.android) {
73-
// For Android applications, args.android is NativeScriptError.
74-
console.log("### NativeScriptError: " + args.android);
75-
} else if (args.ios) {
76-
// For iOS applications, args.ios is NativeScriptError.
77-
console.log("### NativeScriptError: " + args.ios);
78-
}
72+
console.log("### NativeScriptError: " + args.error);
73+
console.log("### nativeException: " + (<any>args.error).nativeException);
74+
console.log("### stackTace: " + (<any>args.error).stackTrace);
75+
console.log("### stack: " + args.error.stack);
7976
});
8077

8178
application.setCssFileName("ui-tests-app/app.css");
Collapse file

‎apps/app/ui-tests-app/mainPage.ts‎

Copy file name to clipboardExpand all lines: apps/app/ui-tests-app/mainPage.ts
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ var oldExamples: Map<string, string> = new Map<string, string>();
1515

1616
export function pageLoaded(args: EventData) {
1717
let page = <Page>args.object;
18-
let view = require("ui/core/view");
19-
let wrapLayout = <WrapLayout>view.getViewById(page, "wrapLayoutWithExamples");
20-
18+
let wrapLayout = page.getViewById<WrapLayout>("wrapLayoutWithExamples");
2119
examples.set("action-bar", "action-bar/main-page");
2220
examples.set("bindings", "bindings/main-page");
2321
examples.set("css", "css/main-page");
@@ -46,8 +44,8 @@ export function pageLoaded(args: EventData) {
4644
let viewModel = new MainPageViewModel(wrapLayout, examples);
4745
page.bindingContext = viewModel;
4846

49-
var parent = page.getViewById('parentLayout');
50-
var searchBar = page.getViewById('textView');
47+
var parent = page.getViewById('parentLayout');
48+
var searchBar = page.getViewById('textView');
5149

5250
if (parent.android) {
5351
parent.android.setFocusableInTouchMode(true);
@@ -57,7 +55,7 @@ export function pageLoaded(args: EventData) {
5755

5856
refresh();
5957
}
60-
58+
6159
// should be removes
6260
export function refresh() {
6361
oldExamples.set("actStyle", "action-bar/all");
@@ -217,7 +215,7 @@ export class MainPageViewModel extends observable.Observable {
217215
}
218216

219217
btn.style.color = new colorModule.Color(this.colors[count++ % 3]);
220-
btn.on(buttonModule.Button.tapEvent, function(eventData) {
218+
btn.on(buttonModule.Button.tapEvent, function (eventData) {
221219
let text = btn.text;
222220
this.loadExample(text);
223221
}, this);
Collapse file

‎tests/app/TKUnit.ts‎

Copy file name to clipboardExpand all lines: tests/app/TKUnit.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,13 @@ export var wait = function (seconds: number) {
366366
}, seconds, false);
367367
};
368368

369-
export var waitUntilReady = function (isReady: () => boolean, timeoutSec: number = 20, shouldThrow: boolean = true) {
369+
export var waitUntilReady = function (isReady: () => boolean, timeoutSec: number = 3, shouldThrow: boolean = true) {
370370
if (!isReady) {
371371
return;
372372
}
373373

374374
if (Application.ios) {
375-
var waitTime = 20 / 1000;
375+
const waitTime = 20 / 1000;
376376
var totalWaitTime = 0;
377377
while (true) {
378378
utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop).runUntilDate(<any>NSDate.dateWithTimeIntervalSinceNow(waitTime));
Collapse file

‎tests/app/testRunner.ts‎

Copy file name to clipboardExpand all lines: tests/app/testRunner.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,12 @@ function printRunTestStats() {
344344
page.style.backgroundColor = unsetValue;
345345
page.content = stack;
346346
messageContainer.focus();
347+
page.style.fontSize = 11;
347348
if (page.android) {
348-
setTimeout(() => messageContainer.dismissSoftInput());
349+
setTimeout(() => {
350+
messageContainer.dismissSoftInput();
351+
(<android.view.View>messageContainer.nativeView).scrollTo(0, 0);
352+
});
349353
}
350354
}
351355

Collapse file

‎tests/app/ui/action-bar/action-bar-tests.android.ts‎

Copy file name to clipboardExpand all lines: tests/app/ui/action-bar/action-bar-tests.android.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function test_actionItem_visibility() {
1111
actionItem.text = "Test";
1212
const page = actionTestsCommon.createPageAndNavigate();
1313
page.actionBar.actionItems.addItem(actionItem);
14-
const toolbar = <android.support.v7.widget.Toolbar>(<any>page.actionBar)._toolbar;
14+
const toolbar = <android.support.v7.widget.Toolbar>page.actionBar.nativeView;
1515
const menu = toolbar.getMenu();
1616

1717
TKUnit.assertTrue(menu.hasVisibleItems(), "Visibility does not work");
@@ -25,7 +25,7 @@ export function test_navigationButton_visibility() {
2525
const page = actionTestsCommon.createPageAndNavigate();
2626
page.actionBar.navigationButton = actionItem;
2727

28-
const toolbar = <android.support.v7.widget.Toolbar>(<any>page.actionBar)._toolbar;
28+
const toolbar = <android.support.v7.widget.Toolbar>page.actionBar.nativeView;
2929

3030
TKUnit.assertNotNull(toolbar.getNavigationIcon(), "Visibility does not work");
3131
actionItem.visibility = Visibility.collapse;
@@ -72,4 +72,4 @@ export function test_add_actionItem_with_actionView_propagates_context() {
7272
TKUnit.assertNull(actionButton._context, "Action button context should be null before added");
7373
actionItem.actionView = actionButton;
7474
TKUnit.assertNotNull(actionButton._context, "Action button context should not be null after add");
75-
}
75+
}
Collapse file

‎tests/app/ui/core/bindable/bindable-tests.ts‎

Copy file name to clipboardExpand all lines: tests/app/ui/core/bindable/bindable-tests.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ export function test_BindingToDictionaryAtAppLevel() {
604604
pageViewModel.set("testProperty", testPropertyName);
605605
const dict = {};
606606
dict[testPropertyName] = expectedValue;
607-
appModule.resources["dict"] = dict;
607+
appModule.getResources()["dict"] = dict;
608608

609609
const testFunc = function (views: Array<View>) {
610610
const testLabel = <Label>(views[0]);
@@ -629,7 +629,7 @@ export function test_BindingConverterCalledEvenWithNullValue() {
629629
const testPropertyValue = null;
630630
const expectedValue = "collapsed";
631631
pageViewModel.set("testProperty", testPropertyValue);
632-
appModule.resources["converter"] = function (value) {
632+
appModule.getResources()["converter"] = function (value) {
633633
if (value) {
634634
return "visible";
635635
} else {
Collapse file

‎tests/app/ui/layouts/common-layout-tests.ts‎

Copy file name to clipboardExpand all lines: tests/app/ui/layouts/common-layout-tests.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function percent_support_nativeLayoutParams_are_correct(test: testModule.
3030

3131
test.waitUntilTestElementLayoutIsValid();
3232

33-
let lp = getNativeLayoutParams(btn._nativeView);
33+
let lp = getNativeLayoutParams(btn.nativeView);
3434
TKUnit.assertEqual(lp.width, 100, "width");
3535
TKUnit.assertEqual(lp.widthPercent, -1, "widthPercent");
3636
TKUnit.assertEqual(lp.height, 100, "height");
Collapse file

‎tests/app/ui/layouts/flexbox-layout-tests.ts‎

Copy file name to clipboardExpand all lines: tests/app/ui/layouts/flexbox-layout-tests.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export function testFlexboxPage() {
174174
function view(id: string) {
175175
return <View>page.getViewById(id);
176176
}
177+
TKUnit.waitUntilReady(() => page.isLayoutValid);
177178
isLeftOf(view("six"), view("one"));
178179
isAbove(view("one"), view("scrollview"));
179180
isAbove(view("title"), view("firstlabel"));
Collapse file

‎tests/app/ui/layouts/layout-helper.android.ts‎

Copy file name to clipboardExpand all lines: tests/app/ui/layouts/layout-helper.android.ts
+41-53Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import {Button} from "tns-core-modules/ui/button";
2-
import {StackLayout} from "tns-core-modules/ui/layouts/stack-layout";
3-
import {GridLayout} from "tns-core-modules/ui/layouts/grid-layout";
1+
import { Button } from "tns-core-modules/ui/button";
2+
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
3+
import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
44

55
import * as utils from "tns-core-modules/utils/utils";
66
import * as TKUnit from "../../TKUnit";
77
import * as def from "./layout-helper";
88

99
var DELTA = 0.1;
1010

11-
class NativeButton extends android.widget.Button {
12-
private owner: def.MeasuredView;
13-
14-
constructor(context: android.content.Context, owner: def.MeasuredView) {
11+
class NativeButton extends android.widget.Button {
12+
constructor(context: android.content.Context, public owner: def.MeasuredView) {
1513
super(context);
16-
this.owner = owner;
1714
return global.__native(this);
1815
}
1916

@@ -31,11 +28,8 @@ class NativeButton extends android.widget.Button {
3128
}
3229

3330
class NativeStackLayout extends org.nativescript.widgets.StackLayout {
34-
private owner: def.MeasuredView;
35-
36-
constructor(context: android.content.Context, owner: def.MeasuredView) {
31+
constructor(context: android.content.Context, public owner: def.MeasuredView) {
3732
super(context);
38-
this.owner = owner;
3933
return global.__native(this);
4034
}
4135

@@ -53,11 +47,8 @@ class NativeStackLayout extends org.nativescript.widgets.StackLayout {
5347
}
5448

5549
class NativeGridLayout extends org.nativescript.widgets.GridLayout {
56-
private owner: def.MeasuredView;
57-
58-
constructor(context: android.content.Context, owner: def.MeasuredView) {
50+
constructor(context: android.content.Context, public owner: def.MeasuredView) {
5951
super(context);
60-
this.owner = owner;
6152
return global.__native(this);
6253
}
6354

@@ -75,19 +66,18 @@ class NativeGridLayout extends org.nativescript.widgets.GridLayout {
7566
}
7667

7768
export class MyButton extends Button implements def.MyButton {
78-
private _layout: android.view.View;
69+
nativeView: NativeButton;
7970

80-
get android(): android.view.View {
81-
return this._layout;
71+
public createNativeView() {
72+
return new NativeButton(this._context, this);
8273
}
8374

84-
get _nativeView(): android.view.View {
85-
return this._layout;
75+
public initNativeView(): void {
76+
this.nativeView.owner = this;
8677
}
8778

88-
public _createNativeView() {
89-
this._layout = new NativeButton(this._context, this);
90-
return this._layout;
79+
public disposeNativeView() {
80+
this.nativeView.owner = undefined;
9181
}
9282

9383
public measureCount: number = 0;
@@ -112,36 +102,35 @@ export class MyButton extends Button implements def.MyButton {
112102
}
113103

114104
get layoutWidth(): number {
115-
return this._layout.getWidth();
105+
return this.nativeView.getWidth();
116106
}
117107

118108
get layoutHeight(): number {
119-
return this._layout.getHeight();
109+
return this.nativeView.getHeight();
120110
}
121111

122112
get layoutLeft(): number {
123-
return this._layout.getLeft();
113+
return this.nativeView.getLeft();
124114
}
125115

126116
get layoutTop(): number {
127-
return this._layout.getTop();
117+
return this.nativeView.getTop();
128118
}
129119
}
130120

131121
export class MyStackLayout extends StackLayout implements def.MyStackLayout {
132-
private _layout: android.view.View;
122+
nativeView: NativeStackLayout;
133123

134-
get android(): android.view.View {
135-
return this._layout;
124+
public createNativeView() {
125+
return new NativeStackLayout(this._context, this);
136126
}
137127

138-
get _nativeView(): android.view.View {
139-
return this._layout;
128+
public initNativeView(): void {
129+
this.nativeView.owner = this;
140130
}
141131

142-
public _createNativeView() {
143-
this._layout = new NativeStackLayout(this._context, this);
144-
return this._layout;
132+
public disposeNativeView() {
133+
this.nativeView.owner = undefined;
145134
}
146135

147136
public measureCount: number = 0;
@@ -166,36 +155,35 @@ export class MyStackLayout extends StackLayout implements def.MyStackLayout {
166155
}
167156

168157
get layoutWidth(): number {
169-
return this._layout.getWidth();
158+
return this.nativeView.getWidth();
170159
}
171160

172161
get layoutHeight(): number {
173-
return this._layout.getHeight();
162+
return this.nativeView.getHeight();
174163
}
175164

176165
get layoutLeft(): number {
177-
return this._layout.getLeft();
166+
return this.nativeView.getLeft();
178167
}
179168

180169
get layoutTop(): number {
181-
return this._layout.getTop();
170+
return this.nativeView.getTop();
182171
}
183172
}
184173

185174
export class MyGridLayout extends GridLayout implements def.MyGridLayout {
186-
private _layout: android.view.View;
175+
nativeView: NativeGridLayout;
187176

188-
get android(): android.view.View {
189-
return this._layout;
177+
public createNativeView() {
178+
return new NativeGridLayout(this._context, this);
190179
}
191180

192-
get _nativeView(): android.view.View {
193-
return this._layout;
181+
public initNativeView(): void {
182+
this.nativeView.owner = this;
194183
}
195184

196-
public _createNativeView() {
197-
this._layout = new NativeGridLayout(this._context, this);
198-
return this._layout;
185+
public disposeNativeView() {
186+
this.nativeView.owner = undefined;
199187
}
200188

201189
public measureCount: number = 0;
@@ -220,19 +208,19 @@ export class MyGridLayout extends GridLayout implements def.MyGridLayout {
220208
}
221209

222210
get layoutWidth(): number {
223-
return this._layout.getWidth();
211+
return this.nativeView.getWidth();
224212
}
225213

226214
get layoutHeight(): number {
227-
return this._layout.getHeight();
215+
return this.nativeView.getHeight();
228216
}
229217

230218
get layoutLeft(): number {
231-
return this._layout.getLeft();
219+
return this.nativeView.getLeft();
232220
}
233221

234222
get layoutTop(): number {
235-
return this._layout.getTop();
223+
return this.nativeView.getTop();
236224
}
237225
}
238226

@@ -258,4 +246,4 @@ export function dp(value: number): number {
258246

259247
export function dip(value: number): number {
260248
return utils.layout.toDevicePixels(value);
261-
}
249+
}
Collapse file

‎tests/app/ui/list-picker/list-picker-tests-native.android.ts‎

Copy file name to clipboard
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as listPickerModule from "tns-core-modules/ui/list-picker";
22

33
export function getNativeItemsCount(listPicker: listPickerModule.ListPicker): number {
4-
var maxValue = listPicker.android.getMaxValue();
4+
var maxValue = listPicker.nativeView.getMaxValue();
55

66
if (listPicker.items.length === 0 && maxValue === 0) {
77
return 0;
@@ -12,6 +12,6 @@ export function getNativeItemsCount(listPicker: listPickerModule.ListPicker): nu
1212

1313
export function selectNativeItem(listPicker: listPickerModule.ListPicker, index: number): void {
1414
var oldIndex = listPicker.selectedIndex;
15-
listPicker.android.setValue(index);
16-
(<any>listPicker)._valueChangedListener.onValueChange(listPicker.android, oldIndex, index);
17-
}
15+
listPicker.nativeView.setValue(index);
16+
listPicker.nativeView.valueChangedListener.onValueChange(listPicker.android, oldIndex, index);
17+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.