chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-27 15:11:09 -07:00
parent 2efe8f8135
commit c7db78b586
21 changed files with 203 additions and 177 deletions

View File

@@ -21,6 +21,7 @@ if (isIOS) {
// >> application-ios-delegate
//// Add custom application delegate
if (isIOS) {
@NativeClass
class MyDelegate extends UIResponder implements UIApplicationDelegate {
public static ObjCProtocols = [UIApplicationDelegate];

View File

@@ -49,11 +49,11 @@ function printTNSInfo() {
console.log('platform.Device.sdkVersion = ' + platform.Device.sdkVersion);
console.log('platform.Device.deviceType = ' + platform.Device.deviceType);
console.log('platform.screen.mainScreen.widthDIPs = ' + platform.screen.mainScreen.widthDIPs);
console.log('platform.screen.mainScreen.heightDIPs = ' + platform.screen.mainScreen.heightDIPs);
console.log('platform.screen.mainScreen.scale = ' + platform.screen.mainScreen.scale);
console.log('platform.screen.mainScreen.widthPixels = ' + platform.screen.mainScreen.widthPixels);
console.log('platform.screen.mainScreen.heightPixels = ' + platform.screen.mainScreen.heightPixels);
console.log('platform.Screen.mainScreen.widthDIPs = ' + platform.Screen.mainScreen.widthDIPs);
console.log('platform.Screen.mainScreen.heightDIPs = ' + platform.Screen.mainScreen.heightDIPs);
console.log('platform.Screen.mainScreen.scale = ' + platform.Screen.mainScreen.scale);
console.log('platform.Screen.mainScreen.widthPixels = ' + platform.Screen.mainScreen.widthPixels);
console.log('platform.Screen.mainScreen.heightPixels = ' + platform.Screen.mainScreen.heightPixels);
}
function print() {

View File

@@ -347,7 +347,7 @@ export class GridLayoutTest extends testModule.UITest<RemovalTrackingGridLayout>
this.waitUntilTestElementLayoutIsValid();
TKUnit.assertTrue(btn.getMeasuredWidth() === this.testView.getMeasuredWidth());
TKUnit.assertTrue(this.testView.getMeasuredWidth() < platform.screen.mainScreen.widthPixels);
TKUnit.assertTrue(this.testView.getMeasuredWidth() < platform.Screen.mainScreen.widthPixels);
}
public test_measuredWidth_when_not_stretched_two_columns() {

View File

@@ -95,8 +95,8 @@ export class SafeAreaTests extends testModule.UITest<any> {
const b = bottom(layout);
equal(l, 0, `${layout}.left - actual:${l}; expected: ${0}`);
equal(t, 0, `${layout}.top - actual:${t}; expected: ${0}`);
equal(r, platform.screen.mainScreen.widthPixels, `${layout}.right - actual:${r}; expected: ${platform.screen.mainScreen.widthPixels}`);
equal(b, platform.screen.mainScreen.heightPixels, `${layout}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
equal(r, platform.Screen.mainScreen.widthPixels, `${layout}.right - actual:${r}; expected: ${platform.Screen.mainScreen.widthPixels}`);
equal(b, platform.Screen.mainScreen.heightPixels, `${layout}.bottom - actual:${b}; expected: ${platform.Screen.mainScreen.heightPixels}`);
}
// Absolute

View File

@@ -52,8 +52,8 @@ export class ListViewSafeAreaTest extends UITest<ListView> {
const b = bottom(listView);
equal(l, 0, `${listView}.left - actual:${l}; expected: ${0}`);
equal(t, 0, `${listView}.top - actual:${t}; expected: ${0}`);
equal(r, platform.screen.mainScreen.widthPixels, `${listView}.right - actual:${r}; expected: ${platform.screen.mainScreen.widthPixels}`);
equal(b, platform.screen.mainScreen.heightPixels, `${listView}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
equal(r, platform.Screen.mainScreen.widthPixels, `${listView}.right - actual:${r}; expected: ${platform.Screen.mainScreen.widthPixels}`);
equal(b, platform.Screen.mainScreen.heightPixels, `${listView}.bottom - actual:${b}; expected: ${platform.Screen.mainScreen.heightPixels}`);
}
private list_view_in_full_screen_test(pageOptions?: helper.PageOptions) {

View File

@@ -46,8 +46,8 @@ export class RepeaterSafeAreaTest extends UITest<Repeater> {
const b = bottom(repeater);
equal(l, 0, `${repeater}.left - actual:${l}; expected: ${0}`);
equal(t, 0, `${repeater}.top - actual:${t}; expected: ${0}`);
equal(r, platform.screen.mainScreen.widthPixels, `${repeater}.right - actual:${r}; expected: ${platform.screen.mainScreen.widthPixels}`);
equal(b, platform.screen.mainScreen.heightPixels, `${repeater}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
equal(r, platform.Screen.mainScreen.widthPixels, `${repeater}.right - actual:${r}; expected: ${platform.Screen.mainScreen.widthPixels}`);
equal(b, platform.Screen.mainScreen.heightPixels, `${repeater}.bottom - actual:${b}; expected: ${platform.Screen.mainScreen.heightPixels}`);
}
private repeater_in_full_screen_test(pageOptions?: helper.PageOptions) {

View File

@@ -1,22 +1,6 @@
import * as TKUnit from '../../tk-unit';
import * as app from '@nativescript/core/application';
import * as helper from '../../ui-helper';
import * as viewModule from '@nativescript/core/ui/core/view';
import * as stackLayoutModule from '@nativescript/core/ui/layouts/stack-layout';
import * as wrapLayoutModule from '@nativescript/core/ui/layouts/wrap-layout';
import * as layoutBaseModule from '@nativescript/core/ui/layouts/layout-base';
import * as pageModule from '@nativescript/core/ui/page';
import * as gestureModule from '@nativescript/core/ui/gestures';
import { Label } from '@nativescript/core/ui/label';
// >> article-require-repeater-module
import * as repeaterModule from '@nativescript/core/ui/repeater';
// << article-require-repeater-module
// >> article-require-modules-repeater
import * as observableArray from '@nativescript/core/data/observable-array';
import * as labelModule from '@nativescript/core/ui/label';
// << article-require-modules-repeater
import { Application, Label, Page, StackLayout, WrapLayout, LayoutBase, View, GestureTypes, Repeater, ObservableArray } from '@nativescript/core';
var FEW_ITEMS = [0, 1, 2];
var MANY_ITEMS = [];
@@ -25,15 +9,15 @@ for (var i = 0; i < 100; i++) {
}
export function test_recycling() {
const setters = new Map<string, stackLayoutModule.StackLayout>();
setters.set('itemsLayout', new stackLayoutModule.StackLayout());
helper.nativeView_recycling_test(() => new repeaterModule.Repeater(), null, null, setters);
const setters = new Map<string, StackLayout>();
setters.set('itemsLayout', new StackLayout());
helper.nativeView_recycling_test(() => new Repeater(), null, null, setters);
}
export function test_set_items_to_array_loads_all_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
// >> article-repeater-with-array
var colors = ['red', 'green', 'blue'];
repeater.items = colors;
@@ -50,9 +34,9 @@ export function test_set_items_to_array_loads_all_items() {
}
export function test_set_items_to_array_creates_views() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = FEW_ITEMS;
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
@@ -63,9 +47,9 @@ export function test_set_items_to_array_creates_views() {
}
export function test_refresh_after_adding_items_to_array_loads_new_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
var colors = ['red', 'green', 'blue'];
repeater.items = colors;
@@ -85,9 +69,9 @@ export function test_refresh_after_adding_items_to_array_loads_new_items() {
}
export function test_refresh_reloads_all_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
var testStarted = false;
var itemsToBind = <Array<any>>FEW_ITEMS;
@@ -114,9 +98,9 @@ export function test_refresh_reloads_all_items() {
}
export function test_set_itmes_to_null_clears_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = FEW_ITEMS;
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, 'views count.');
@@ -131,16 +115,16 @@ export function test_set_itmes_to_null_clears_items() {
export function test_set_itemsLayout_accepted() {
// >> article-repeater-layout
var repeater = new repeaterModule.Repeater();
var stackLayout = new stackLayoutModule.StackLayout();
var repeater = new Repeater();
var stackLayout = new StackLayout();
stackLayout.orientation = 'horizontal';
repeater.itemsLayout = stackLayout;
// << article-repeater-layout
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = FEW_ITEMS;
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assert((<stackLayoutModule.StackLayout>repeater.itemsLayout).orientation === 'horizontal', 'views count.');
TKUnit.assert((<StackLayout>repeater.itemsLayout).orientation === 'horizontal', 'views count.');
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, 'views count.');
}
@@ -148,9 +132,9 @@ export function test_set_itemsLayout_accepted() {
}
export function test_set_itmes_to_undefiend_clears_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = FEW_ITEMS;
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, 'views count.');
@@ -164,9 +148,9 @@ export function test_set_itmes_to_undefiend_clears_items() {
}
export function test_set_itmes_to_different_source_loads_new_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = [1, 2, 3];
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, 'views count.');
@@ -180,11 +164,11 @@ export function test_set_itmes_to_different_source_loads_new_items() {
}
export function test_set_items_to_observable_array_loads_all_items() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
// >> article-repeater-observablearray
var colors = new observableArray.ObservableArray(['red', 'green', 'blue']);
var colors = new ObservableArray(['red', 'green', 'blue']);
repeater.items = colors;
// << article-repeater-observablearray
@@ -198,10 +182,10 @@ export function test_set_items_to_observable_array_loads_all_items() {
}
export function test_add_to_observable_array_refreshes_the_Repeater() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
var colors = new observableArray.ObservableArray(['red', 'green', 'blue']);
function testAction(views: Array<View>) {
var colors = new ObservableArray(['red', 'green', 'blue']);
repeater.items = colors;
TKUnit.assertEqual(getChildrenCount(repeater), 3, 'getChildrenCount');
@@ -217,10 +201,10 @@ export function test_add_to_observable_array_refreshes_the_Repeater() {
}
export function test_remove_from_observable_array_refreshes_the_Repeater() {
var repeater = new repeaterModule.Repeater();
var data = new observableArray.ObservableArray([1, 2, 3]);
var repeater = new Repeater();
var data = new ObservableArray([1, 2, 3]);
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = data;
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
@@ -235,10 +219,10 @@ export function test_remove_from_observable_array_refreshes_the_Repeater() {
}
export function test_splice_observable_array_refreshes_the_Repeater() {
var repeater = new repeaterModule.Repeater();
var data = new observableArray.ObservableArray(['a', 'b', 'c']);
var repeater = new Repeater();
var data = new ObservableArray(['a', 'b', 'c']);
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.items = data;
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
@@ -254,7 +238,7 @@ export function test_splice_observable_array_refreshes_the_Repeater() {
}
export function test_usingAppLevelConvertersInRepeaterItems() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
var dateConverter = function (value, format) {
var result = format;
@@ -267,13 +251,13 @@ export function test_usingAppLevelConvertersInRepeaterItems() {
return result;
};
app.getResources()['dateConverter'] = dateConverter;
Application.getResources()['dateConverter'] = dateConverter;
var data = new observableArray.ObservableArray();
var data = new ObservableArray();
data.push({ date: new Date() });
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.itemTemplate = '<Label id="testLabel" text="{{ date, date | dateConverter(\'DD.MM.YYYY\') }}" />';
repeater.items = data;
@@ -286,9 +270,9 @@ export function test_usingAppLevelConvertersInRepeaterItems() {
}
export function test_BindingRepeaterToASimpleArray() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.itemTemplate = '<Label id="testLabel" text="{{ $value }}" />';
repeater.items = [1, 2, 3];
@@ -303,9 +287,9 @@ export function test_BindingRepeaterToASimpleArray() {
}
export function test_ItemTemplateFactoryFunction() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.itemTemplate = () => {
var label = new Label();
label.id = 'testLabel';
@@ -326,9 +310,9 @@ export function test_ItemTemplateFactoryFunction() {
}
export function test_BindingRepeaterToASimpleArrayWithExpression() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
repeater.itemTemplate = '<Label id="testLabel" text="{{ $value, $value + \' some static text\' }}" />';
repeater.items = [1, 2, 3];
@@ -343,14 +327,14 @@ export function test_BindingRepeaterToASimpleArrayWithExpression() {
}
export var test_RepeaterItemsGestureBindings = function () {
var testFunc = function (page: pageModule.Page) {
var repeater = <repeaterModule.Repeater>page.getViewById('repeater');
var testFunc = function (page: Page) {
var repeater = <Repeater>page.getViewById('repeater');
var hasObservers = false;
var eachChildCallback = function (childItem: viewModule.View) {
if (childItem instanceof labelModule.Label) {
var gestureObservers = childItem.getGestureObservers(gestureModule.GestureTypes.tap);
var eachChildCallback = function (childItem: View) {
if (childItem instanceof Label) {
var gestureObservers = childItem.getGestureObservers(GestureTypes.tap);
hasObservers = gestureObservers ? gestureObservers.length > 0 : false;
} else if (childItem instanceof layoutBaseModule.LayoutBase) {
} else if (childItem instanceof LayoutBase) {
childItem.eachChildView(eachChildCallback);
}
@@ -366,17 +350,17 @@ export var test_RepeaterItemsGestureBindings = function () {
};
export var test_RepeaterItemsParentBindingsShouldWork = function () {
var testFunc = function (page: pageModule.Page) {
var repeater = <repeaterModule.Repeater>page.getViewById('repeater');
var testFunc = function (page: Page) {
var repeater = <Repeater>page.getViewById('repeater');
var expectedText = page.bindingContext['parentViewProperty'];
var testPass = false;
var eachChildCallback = function (childItem: viewModule.View) {
if (childItem instanceof labelModule.Label) {
testPass = (<labelModule.Label>childItem).text === expectedText;
var eachChildCallback = function (childItem: View) {
if (childItem instanceof Label) {
testPass = (<Label>childItem).text === expectedText;
if (testPass === false) {
return false;
}
} else if (childItem instanceof layoutBaseModule.LayoutBase) {
} else if (childItem instanceof LayoutBase) {
childItem.eachChildView(eachChildCallback);
}
@@ -392,9 +376,9 @@ export var test_RepeaterItemsParentBindingsShouldWork = function () {
};
export function test_ChildrenAreNotCreatedUntilTheRepeaterIsLoaded() {
var repeater = new repeaterModule.Repeater();
var repeater = new Repeater();
repeater.itemsLayout = new wrapLayoutModule.WrapLayout();
repeater.itemsLayout = new WrapLayout();
TKUnit.assertEqual(getChildrenCount(repeater), 0, 'Repeater should not create its children until loaded.');
repeater.itemTemplate = '<Label id="testLabel" text="{{ $value, $value + \' some static text\' }}" />';
@@ -403,7 +387,7 @@ export function test_ChildrenAreNotCreatedUntilTheRepeaterIsLoaded() {
repeater.items = [1, 2, 3];
TKUnit.assertEqual(getChildrenCount(repeater), 0, 'Repeater should not create its children until loaded.');
function testAction(views: Array<viewModule.View>) {
function testAction(views: Array<View>) {
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, 'Repeater should have created its children when loaded.');
}
@@ -413,8 +397,8 @@ export function test_ChildrenAreNotCreatedUntilTheRepeaterIsLoaded() {
/*
export function test_no_memory_leak_when_items_is_regular_array(done) {
var createFunc = function (): repeaterModule.Repeater {
var repeater = new repeaterModule.Repeater();
var createFunc = function (): Repeater {
var repeater = new Repeater();
repeater.items = FEW_ITEMS;
return repeater;
};
@@ -426,10 +410,10 @@ export function test_no_memory_leak_when_items_is_regular_array(done) {
export function test_no_memory_leak_when_items_is_observable_array(done) {
// Keep the reference to the observable array to test the weakEventListener
var colors = new observableArray.ObservableArray(["red", "green", "blue"]);
var colors = new ObservableArray(["red", "green", "blue"]);
var createFunc = function (): repeaterModule.Repeater {
var repeater = new repeaterModule.Repeater();
var createFunc = function (): Repeater {
var repeater = new Repeater();
repeater.items = colors;
return repeater;
};
@@ -439,14 +423,14 @@ export function test_no_memory_leak_when_items_is_observable_array(done) {
}, done);
}
*/
function getChildrenCount(repeater: repeaterModule.Repeater): number {
function getChildrenCount(repeater: Repeater): number {
return repeater.itemsLayout.getChildrenCount();
}
function getChildAt(repeater: repeaterModule.Repeater, index: number): viewModule.View {
function getChildAt(repeater: Repeater, index: number): View {
return repeater.itemsLayout.getChildAt(index);
}
function getChildAtText(repeater: repeaterModule.Repeater, index: number): string {
return (<labelModule.Label>getChildAt(repeater, index)).text + '';
function getChildAtText(repeater: Repeater, index: number): string {
return (<Label>getChildAt(repeater, index)).text + '';
}

View File

@@ -55,8 +55,8 @@ class ScrollLayoutSafeAreaTest extends UITest<ScrollView> {
const b = bottom(scrollView);
equal(l, 0, `${scrollView}.left - actual:${l}; expected: ${0}`);
equal(t, 0, `${scrollView}.top - actual:${t}; expected: ${0}`);
equal(r, platform.screen.mainScreen.widthPixels, `${scrollView}.right - actual:${r}; expected: ${platform.screen.mainScreen.widthPixels}`);
equal(b, platform.screen.mainScreen.heightPixels, `${scrollView}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
equal(r, platform.Screen.mainScreen.widthPixels, `${scrollView}.right - actual:${r}; expected: ${platform.Screen.mainScreen.widthPixels}`);
equal(b, platform.Screen.mainScreen.heightPixels, `${scrollView}.bottom - actual:${b}; expected: ${platform.Screen.mainScreen.heightPixels}`);
}
private scroll_view_in_full_screen_test(pageOptions?: helper.PageOptions) {

View File

@@ -46,8 +46,8 @@ export class WebViewSafeAreaTest extends UITest<WebView> {
const b = bottom(webView);
equal(l, 0, `${webView}.left - actual:${l}; expected: ${0}`);
equal(t, 0, `${webView}.top - actual:${t}; expected: ${0}`);
equal(r, platform.screen.mainScreen.widthPixels, `${webView}.right - actual:${r}; expected: ${platform.screen.mainScreen.widthPixels}`);
equal(b, platform.screen.mainScreen.heightPixels, `${webView}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
equal(r, platform.Screen.mainScreen.widthPixels, `${webView}.right - actual:${r}; expected: ${platform.Screen.mainScreen.widthPixels}`);
equal(b, platform.Screen.mainScreen.heightPixels, `${webView}.bottom - actual:${b}; expected: ${platform.Screen.mainScreen.heightPixels}`);
}
private webview_in_full_screen_test(pageOptions?: helper.PageOptions) {

View File

@@ -1,18 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "ES2017",
"module": "esnext",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"lib": ["es2018", "dom"],
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
"~/*": ["src/*"],
"tns-core-modules/*": ["@nativescript/core/*"]
}
},
"exclude": ["node_modules", "platforms"]
}
}

View File

@@ -1,19 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "ES2017",
"module": "esnext",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"lib": ["es2018", "dom"],
"baseUrl": ".",
"paths": {
"~/*": ["src/*"],
"tns-core-modules/*": ["@nativescript/core/*"]
}
},
"exclude": ["e2e", "node_modules", "platforms"]
}
}

View File

@@ -3,45 +3,47 @@ g.initGlobal();
// Register "dynamically" loaded module that need to be resolved by the
// XML/component builders.
import * as coreUIModules from './ui/index';
global.registerModule('@nativescript/core/ui', () => coreUIModules);
global.registerModule('text/formatted-string', () => require('./text/formatted-string'));
global.registerModule('text/span', () => require('./text/span'));
global.registerModule('ui/text-base/formatted-string', () => require('./ui/text-base/formatted-string'));
global.registerModule('ui/text-base/span', () => require('./ui/text-base/span'));
global.registerModule('ui/action-bar', () => require('./ui/action-bar'));
global.registerModule('ui/activity-indicator', () => require('./ui/activity-indicator'));
global.registerModule('ui/bottom-navigation', () => require('./ui/bottom-navigation'));
global.registerModule('ui/button', () => require('./ui/button'));
global.registerModule('ui/content-view', () => require('./ui/content-view'));
global.registerModule('ui/date-picker', () => require('./ui/date-picker'));
global.registerModule('ui/frame', () => require('./ui/frame'));
global.registerModule('ui/html-view', () => require('./ui/html-view'));
global.registerModule('ui/image', () => require('./ui/image'));
global.registerModule('ui/label', () => require('./ui/label'));
global.registerModule('ui/layouts/absolute-layout', () => require('./ui/layouts/absolute-layout'));
global.registerModule('ui/layouts/dock-layout', () => require('./ui/layouts/dock-layout'));
global.registerModule('ui/layouts/grid-layout', () => require('./ui/layouts/grid-layout'));
global.registerModule('ui/layouts/stack-layout', () => require('./ui/layouts/stack-layout'));
global.registerModule('ui/layouts/flexbox-layout', () => require('./ui/layouts/flexbox-layout'));
global.registerModule('ui/layouts/wrap-layout', () => require('./ui/layouts/wrap-layout'));
global.registerModule('ui/list-picker', () => require('./ui/list-picker'));
global.registerModule('ui/page', () => require('./ui/page'));
global.registerModule('ui/placeholder', () => require('./ui/placeholder'));
global.registerModule('ui/progress', () => require('./ui/progress'));
global.registerModule('ui/proxy-view-container', () => require('./ui/proxy-view-container'));
global.registerModule('ui/repeater', () => require('./ui/repeater'));
global.registerModule('ui/scroll-view', () => require('./ui/scroll-view'));
global.registerModule('ui/search-bar', () => require('./ui/search-bar'));
global.registerModule('ui/segmented-bar', () => require('./ui/segmented-bar'));
global.registerModule('ui/slider', () => require('./ui/slider'));
global.registerModule('ui/switch', () => require('./ui/switch'));
global.registerModule('ui/tab-view', () => require('./ui/tab-view'));
global.registerModule('ui/tab-navigation-base/tab-strip', () => require('./ui/tab-navigation-base/tab-strip'));
global.registerModule('ui/tab-navigation-base/tab-strip-item', () => require('./ui/tab-navigation-base/tab-strip-item'));
global.registerModule('ui/tab-navigation-base/tab-content-item', () => require('./ui/tab-navigation-base/tab-content-item'));
global.registerModule('ui/tabs', () => require('./ui/tabs'));
global.registerModule('ui/web-view', () => require('./ui/web-view'));
global.registerModule('ui/text-field', () => require('./ui/text-field'));
global.registerModule('ui/text-view', () => require('./ui/text-view'));
global.registerModule('ui/time-picker', () => require('./ui/time-picker'));
global.registerModule('ui/list-view', () => require('./ui/list-view'));
// global.registerModule('text/formatted-string', () => require('./text/formatted-string'));
// global.registerModule('text/span', () => require('./text/span'));
// global.registerModule('ui/text-base/formatted-string', () => require('./ui/text-base/formatted-string'));
// global.registerModule('ui/text-base/span', () => require('./ui/text-base/span'));
// global.registerModule('ui/action-bar', () => require('./ui/action-bar'));
// global.registerModule('ui/activity-indicator', () => require('./ui/activity-indicator'));
// global.registerModule('ui/bottom-navigation', () => require('./ui/bottom-navigation'));
// global.registerModule('ui/button', () => require('./ui/button'));
// global.registerModule('ui/content-view', () => require('./ui/content-view'));
// global.registerModule('ui/date-picker', () => require('./ui/date-picker'));
// global.registerModule('ui/frame', () => require('./ui/frame'));
// global.registerModule('ui/html-view', () => require('./ui/html-view'));
// global.registerModule('ui/image', () => require('./ui/image'));
// global.registerModule('ui/label', () => require('./ui/label'));
// global.registerModule('ui/layouts/absolute-layout', () => require('./ui/layouts/absolute-layout'));
// global.registerModule('ui/layouts/dock-layout', () => require('./ui/layouts/dock-layout'));
// global.registerModule('ui/layouts/grid-layout', () => require('./ui/layouts/grid-layout'));
// global.registerModule('ui/layouts/stack-layout', () => require('./ui/layouts/stack-layout'));
// global.registerModule('ui/layouts/flexbox-layout', () => require('./ui/layouts/flexbox-layout'));
// global.registerModule('ui/layouts/wrap-layout', () => require('./ui/layouts/wrap-layout'));
// global.registerModule('ui/list-picker', () => require('./ui/list-picker'));
// global.registerModule('ui/page', () => require('./ui/page'));
// global.registerModule('ui/placeholder', () => require('./ui/placeholder'));
// global.registerModule('ui/progress', () => require('./ui/progress'));
// global.registerModule('ui/proxy-view-container', () => require('./ui/proxy-view-container'));
// global.registerModule('ui/repeater', () => require('./ui/repeater'));
// global.registerModule('ui/scroll-view', () => require('./ui/scroll-view'));
// global.registerModule('ui/search-bar', () => require('./ui/search-bar'));
// global.registerModule('ui/segmented-bar', () => require('./ui/segmented-bar'));
// global.registerModule('ui/slider', () => require('./ui/slider'));
// global.registerModule('ui/switch', () => require('./ui/switch'));
// global.registerModule('ui/tab-view', () => require('./ui/tab-view'));
// global.registerModule('ui/tab-navigation-base/tab-strip', () => require('./ui/tab-navigation-base/tab-strip'));
// global.registerModule('ui/tab-navigation-base/tab-strip-item', () => require('./ui/tab-navigation-base/tab-strip-item'));
// global.registerModule('ui/tab-navigation-base/tab-content-item', () => require('./ui/tab-navigation-base/tab-content-item'));
// global.registerModule('ui/tabs', () => require('./ui/tabs'));
// global.registerModule('ui/web-view', () => require('./ui/web-view'));
// global.registerModule('ui/text-field', () => require('./ui/text-field'));
// global.registerModule('ui/text-view', () => require('./ui/text-view'));
// global.registerModule('ui/time-picker', () => require('./ui/time-picker'));
// global.registerModule('ui/list-view', () => require('./ui/list-view'));

View File

@@ -22,6 +22,7 @@ const maxTabsCount = 5;
const majorVersion = iOSNativeHelper.MajorVersion;
const isPhone = Device.deviceType === 'Phone';
@NativeClass
class UITabBarControllerImpl extends UITabBarController {
private _owner: WeakRef<BottomNavigation>;

View File

@@ -27,7 +27,50 @@ const MODULES = {
NavigationButton: 'ui/action-bar',
SegmentedBarItem: 'ui/segmented-bar',
};
const legacyShortBarrels = [
'text/formatted-string',
'text/span',
'ui/text-base/formatted-string',
'ui/text-base/span',
'ui/action-bar',
'ui/activity-indicator',
'ui/bottom-navigation',
'ui/button',
'ui/content-view',
'ui/date-picker',
'ui/frame',
'ui/html-view',
'ui/image',
'ui/label',
'ui/layouts/absolute-layout',
'ui/layouts/dock-layout',
'ui/layouts/grid-layout',
'ui/layouts/stack-layout',
'ui/layouts/flexbox-layout',
'ui/layouts/wrap-layout',
'ui/list-picker',
'ui/page',
'ui/placeholder',
'ui/progress',
'ui/proxy-view-container',
'ui/repeater',
'ui/scroll-view',
'ui/search-bar',
'ui/segmented-bar',
'ui/slider',
'ui/switch',
'ui/tab-view',
'ui/tab-navigation-base/tab-strip',
'ui/tab-navigation-base/tab-strip-item',
'ui/tab-navigation-base/tab-content-item',
'ui/tabs',
'ui/web-view',
'ui/text-field',
'ui/text-view',
'ui/time-picker',
'ui/list-view',
];
const CORE_UI_BARREL = '@nativescript/core/ui';
const CODE_FILE = 'codeFile';
const CSS_FILE = 'cssFile';
const IMPORT = 'import';
@@ -39,21 +82,28 @@ const createComponentInstance = profile('createComponentInstance', (elementName:
let resolvedModuleName;
try {
if (typeof namespace === 'string') {
resolvedModuleName = resolveModuleName(namespace, '');
if (legacyShortBarrels.includes(namespace)) {
// console.log('CORE_UI_BARREL namespace:', namespace)
resolvedModuleName = CORE_UI_BARREL;
} else {
// console.log('CUSTOM namespace:', namespace)
resolvedModuleName = resolveModuleName(namespace, '');
}
instanceModule = global.loadModule(resolvedModuleName, true);
} else {
// load module from @nativescript/core/ui or mapped paths
resolvedModuleName =
MODULES[elementName] ||
UI_PATH +
(elementName.toLowerCase().indexOf('layout') !== -1 ? 'layouts/' : '') +
elementName
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase();
// resolvedModuleName =
// MODULES[elementName] ||
// UI_PATH +
// (elementName.toLowerCase().indexOf('layout') !== -1 ? 'layouts/' : '') +
// elementName
// .split(/(?=[A-Z])/)
// .join('-')
// .toLowerCase();
instanceModule = global.loadModule(CORE_UI_BARREL, false);
// don't register core modules for HMR self-accept
instanceModule = global.loadModule(resolvedModuleName, false);
// instanceModule = global.loadModule(resolvedModuleName, false);
}
// Get the component type from module.

View File

@@ -463,6 +463,7 @@ function _getLongPressData(args: GestureEventData): GestureEventDataWithState {
};
}
@NativeClass
class TouchGestureRecognizer extends UIGestureRecognizer {
public observer: GesturesObserver;
private _eventData: TouchGestureEventData;

View File

@@ -25,6 +25,7 @@ interface ViewItemIndex {
type ItemView = View & ViewItemIndex;
@NativeClass
class ListViewCell extends UITableViewCell {
public static initWithEmptyBackground(): ListViewCell {
const cell = <ListViewCell>ListViewCell.new();

View File

@@ -57,6 +57,7 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
}
}
@NativeClass
class UISearchBarImpl extends UISearchBar {
sizeThatFits(size: CGSize): CGSize {
// iOS11 SDK does not support passing sizeThatFits(...) non-finite width value;

View File

@@ -18,6 +18,7 @@ export * from './tab-view-common';
const majorVersion = iOSNativeHelper.MajorVersion;
const isPhone = Device.deviceType === 'Phone';
@NativeClass
class UITabBarControllerImpl extends UITabBarController {
private _owner: WeakRef<TabView>;

View File

@@ -92,6 +92,7 @@ class BackgroundIndicatorTemplate extends NSObject implements MDCTabBarIndicator
}
}
@NativeClass
class UIPageViewControllerImpl extends UIPageViewController {
tabBar: MDCTabBar;
scrollView: UIScrollView;

View File

@@ -79,6 +79,7 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
}
}
@NativeClass
class UITextFieldImpl extends UITextField {
private _owner: WeakRef<TextField>;

View File

@@ -71,6 +71,7 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
}
}
@NativeClass
class NoScrollAnimationUITextView extends UITextView {
// see https://github.com/NativeScript/NativeScript/issues/6863
// UITextView internally scrolls the text you are currently typing to visible when newline character