diff --git a/CHANGELOG.md b/CHANGELOG.md index e511bdab1c..7dc5973a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ + +## [6.1.2](https://github.com/NativeScript/NativeScript/compare/6.1.1...6.1.2) (2019-10-15) + + +### Bug Fixes + +* expose orientation to application module ([#7832](https://github.com/NativeScript/NativeScript/issues/7832)) ([4166e2d](https://github.com/NativeScript/NativeScript/commit/4166e2d)) +* **frame-android:** IllegalStateException: The specified child already has a parent ([#7948](https://github.com/NativeScript/NativeScript/issues/7948)) ([ff30c48](https://github.com/NativeScript/NativeScript/commit/ff30c48)) +* **tabs-ios9:** no view controller managing visible view error ([#7837](https://github.com/NativeScript/NativeScript/issues/7837)) ([7fe8d1c](https://github.com/NativeScript/NativeScript/commit/7fe8d1c)) + + +### Features + +* **css:** add attribute scoped css without global refresh ([#7907](https://github.com/NativeScript/NativeScript/issues/7907)) ([#7947](https://github.com/NativeScript/NativeScript/issues/7947)) ([b377eb6](https://github.com/NativeScript/NativeScript/commit/b377eb6)) + + + ## [6.1.1](https://github.com/NativeScript/NativeScript/compare/6.1.0...6.1.1) (2019-09-11) diff --git a/build/clear-private-definitions.js b/build/clear-private-definitions.js new file mode 100644 index 0000000000..a8a5cabbd6 --- /dev/null +++ b/build/clear-private-definitions.js @@ -0,0 +1,51 @@ +const path = require("path"); +const fs = require("fs"); +const readdirp = require("readdirp"); + +const inputFolder = path.resolve(process.argv[2]); + +console.log(`Clearing private definitions in ${inputFolder}`); + +function filterTypeScriptFiles(content) { + var leadingPrivate = /^.*@private/ig; + if (leadingPrivate.test(content)) { + return { shouldDelete: true }; + } + + let blockCommentPrivate = /\/\*\*([^](?!\*\/))*@module([^](?!\*\/))*@private[^]*?\*\//g; + if (blockCommentPrivate.test(content)) { + return { shouldDelete: true }; + } + + let newContent = content; + newContent = newContent.replace(/\/\/[\/\s]*@private[^]*?\/\/[\/\s]*?@endprivate/gm, ""); + + if (newContent !== content) { + return { shouldReplace: true, newContent: newContent }; + } + + return { shouldReplace: false, shouldDelete: false }; +}; + +readdirp(inputFolder, { + fileFilter: ["*.d.ts"], + directoryFilter: function (di) { return !di.path.includes("node_modules"); } +}).on("data", (entry) => { + const { fullPath } = entry; + const content = fs.readFileSync(fullPath, "utf8"); + const { shouldDelete, shouldReplace, newContent } = filterTypeScriptFiles(content); + + if (shouldDelete) { + console.log("[Delete]", fullPath) + fs.unlinkSync(fullPath); + } else if (shouldReplace) { + console.log("[Cleared]", fullPath) + fs.writeFileSync(fullPath, newContent, "utf8", (err) => { + console.log("ERROR writing file: " + fullPath, error); + }) + } +}) + .on("warn", error => console.error("non-fatal error", error)) + .on("error", error => console.error("fatal error", error)) + .on("end", () => console.log("done")); + diff --git a/build/create-release-changelog-pr.js b/build/create-release-changelog-pr.js deleted file mode 100644 index 409f46ddaf..0000000000 --- a/build/create-release-changelog-pr.js +++ /dev/null @@ -1,18 +0,0 @@ -const { readFileSync } = require("fs"); -const { resolve } = require("path"); -const { createPR, argsParser, gitBranch } = require("./pr-helper"); - -const currentBranch = argsParser().currentBranch || gitBranch; -const modulesPackageVersion = argsParser().packageVersion || JSON.parse(readFileSync(resolve(process.cwd(), "tns-core-modules/package.json")).toString()).version; -const title = argsParser().title || `release: cut the ${modulesPackageVersion} release`; -const baseBranch = argsParser().base || "release"; -const body = argsParser().body || "docs: update changelog"; - -const postQuery = { - "body": body, - "head": currentBranch, - "base": baseBranch, - "title": title -} - -createPR(postQuery); \ No newline at end of file diff --git a/build/pack-dist.sh b/build/pack-dist.sh new file mode 100755 index 0000000000..cc6685a86e --- /dev/null +++ b/build/pack-dist.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -x +set -e + +DIST=dist; +ROOT_DIR=$(cd `dirname $0` && pwd)/..; +cd "$ROOT_DIR" + +( + cd "$DIST/tns-platform-declarations" + TGZ="$(npm pack)" + mv "$TGZ" "../$TGZ" +) + +( + cd "$DIST/tns-core-modules" + TGZ="$(npm pack)" + mv "$TGZ" "../$TGZ" +) \ No newline at end of file diff --git a/build/prepare-dist.sh b/build/prepare-dist.sh new file mode 100755 index 0000000000..7f7c08fcc2 --- /dev/null +++ b/build/prepare-dist.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -x +set -e + +DIST=dist; +ROOT_DIR=$(cd `dirname $0` && pwd)/..; +cd "$ROOT_DIR" + +mkdir -p "$DIST" + +## NPM INSTALL +( + echo "NPM install in root of the repo" + cd "$ROOT_DIR" + npm install +) + +## Prepare Platfrom Declarations +( + PACKAGE=tns-platform-declarations; + + echo "Clearing $DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE*.tgz" + + echo "Copying $PACKAGE $DIST/$PACKAGE..." + npx ncp "$PACKAGE" "$DIST/$PACKAGE" + + echo "Copying README and LICENSE to $DIST/$PACKAGE" + npx ncp LICENSE "$DIST/$PACKAGE"/LICENSE + + cd "$DIST/$PACKAGE" + + echo 'Running npm install...' + npm install + + echo 'Running npm test...' + npm test +) + +## Prepare Core Modules +( + PACKAGE=tns-core-modules; + + echo "Clearing $DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE*.tgz" + + echo "Copying $PACKAGE $DIST/$PACKAGE..." + npx ncp "$PACKAGE" "$DIST/$PACKAGE" + + echo "Cleaning inner readme.md-s ..." + npx rimraf "$DIST/$PACKAGE/**/README.md" + npx rimraf "$DIST/$PACKAGE/**/Readme.md" + + echo "Copying README and LICENSE to $DIST/$PACKAGE" + npx ncp LICENSE "$DIST"/"$PACKAGE"/LICENSE + npx ncp README.md "$DIST"/"$PACKAGE"/README.md + + ( + echo 'TypeScript transpile...' + cd "$DIST/$PACKAGE" + npm install + npx tsc + ) + + echo "Clearing typescript definitions from private APIs..." + node build/clear-private-definitions "$DIST/$PACKAGE" +) diff --git a/build/run-testsapp.grunt.js b/build/run-testsapp.grunt.js deleted file mode 100644 index 533a58462c..0000000000 --- a/build/run-testsapp.grunt.js +++ /dev/null @@ -1,354 +0,0 @@ -module.exports = { - - run: function(grunt) { - var pathModule = require("path"); - - var modulesPackageConfig = grunt.file.readJSON('package.json'); - - //Construct and validate the arguments - var args = { - platform: grunt.option("platform"), - modulesPath: grunt.option("modulesPath"), - tnsPath: grunt.option("tnsPath"), - emulatorProcessIdentifier: grunt.option("emuPId"), - emuAvdName: grunt.option("avd"), - outFile: grunt.option("logFilePath"), - runtimePath: grunt.option("runtimePath"), - runtimeVersion: grunt.option("runtimeVersion"), - showEmu: grunt.option("showEmu"), - runAppOnly: grunt.option("runAppOnly"), - pathToApp: grunt.option("pathToApp") - }; - - (function validateInput(){ - if (!(/^(Android|iOS)$/).test(args.platform)) { - throw new Error("Invalid target platform specified! Use --platform=Android|iOS"); - } - - if (args.platform === "Android") { - if (!args.emulatorProcessIdentifier) { - throw new Error("Please, specify an identifier of the emulator process so that it can be stopped (--emuPId=...). Too many emulators started might cause machine overload"); - } - if (!args.emuAvdName) { - throw new Error("Please, specify the name of the AVD to start (--avd=...)."); - } - } - - if (args.runAppOnly && !args.pathToApp) { - throw new Error("runAppOnly called, but no path to application specified. Please, add the path via the (--pathToApp=...) parameter."); - } - }()); - - var localCfg = { - tnsPath: args.tnsPath || "tns", - emulatorProcessIdentifier: args.emulatorProcessIdentifier, - modulesPath: args.modulesPath || "./bin/dist/tns-core-modules-" + modulesPackageConfig.version + ".tgz", - emuAvdName: args.emuAvdName, - outFile: args.outFile || "./TestRunResult.txt", - frameworkArgument: args.runtimePath ? " --frameworkPath=" + args.runtimePath : "", - runtimeVersionArgument: args.runtimeVersion ? "@" + args.runtimeVersion : "", - showEmu: args.showEmu || false, - runAppOnly: args.runAppOnly || false, - - workingDir:".testsapprun", - testsAppName:"TestsApp", - tnsCoreModulesSource: pathModule.resolve("./tns-core-modules"), - applicationDir: pathModule.join(".testsapprun", "TestsApp"), - appDir: pathModule.join(".testsapprun", "TestsApp", "app"), - pathToApk: "./platforms/android/build/outputs/apk/TestsApp-debug.apk", - pathToApp: "./platforms/ios/build/emulator/TestsApp.app", - deployedAppName:"org.nativescript.TestsApp", - mainActivityName:"com.tns.NativeScriptActivity", - pathToCompiledTests: "bin/dist/tests/app", - simulatorSysLog: pathModule.join(process.env.HOME, "Library/Logs/CoreSimulator", args.emuAvdName, "/system.log"), - platform: args.platform - } - - if (localCfg.runAppOnly) { - localCfg.pathToApp = localCfg.pathToApk = args.pathToApp; - localCfg.applicationDir = "./"; - } - - grunt.initConfig({ - clean: { - workingDir: { - src: localCfg.workingDir - }, - originalAppDir: { - src: [ - localCfg.appDir + "/*", - "!" + pathModule.join(localCfg.appDir, "App_Resources") + "" - ] - }, - modules: { - src: pathModule.join(localCfg.applicationDir, "node_modules", "tns-core-modules") - }, - tempExtractedModules: { - src: pathModule.join(localCfg.applicationDir, "node_modules", "package") - }, - simulatorLog: { - src: localCfg.simulatorSysLog, - options: { - force: true - } - } - }, - mkdir: { - workingDir: { - options: { - create: [localCfg.workingDir], - mode: 0700 - } - } - }, - copy: { - testsAppToRunDir: { - src: "**/*.*", - dest: localCfg.appDir, - cwd: localCfg.pathToCompiledTests, - expand: true - }, - modulesToDir: { - expand: true, - src: "**/*.*", - cwd: pathModule.join(localCfg.applicationDir, "node_modules", "package"), - dest: pathModule.join(localCfg.applicationDir, "node_modules", "tns-core-modules") - }, - addAndroidPermissions: { - src: "AndroidManifest.xml", - dest: localCfg.applicationDir + "/app/App_Resources/Android/", - cwd: localCfg.applicationDir + "/app/App_Resources/Android", - expand: true, - options: { - process: function(content, srcPath) { - var newContent = content; - - var internetPermissionFinder = /((\s*)]*android\.permission\.INTERNET[^>]*>)/; - - if (!/uses-permission[^>]*android\.permission\.ACCESS_NETWORK_STATE/.test(content)) { - newContent = newContent.replace(internetPermissionFinder, "$1$2"); - } - if (!/uses-permission[^>]*android\.permission\.ACCESS_FINE_LOCATION/.test(content)) { - newContent = newContent.replace(internetPermissionFinder, "$1$2"); - } - return newContent; - } - } - }, - addiOSPermissions: { - src: localCfg.testsAppName + "-Info.plist", - dest: pathModule.join(localCfg.applicationDir,"/platforms/ios/", localCfg.testsAppName) + "/", - cwd: pathModule.join(localCfg.applicationDir,"/platforms/ios/", localCfg.testsAppName), - expand: true, - options: { - process: function(content, srcPath) { - var newContent = content; - - var lastDictLocator = /(<\/dict>\s*<\/plist>)$/gm; - - if (!/NSAppTransportSecurity/.test(content)) { - newContent = newContent.replace(lastDictLocator, "NSAppTransportSecurity\n$1"); - } - if (!/NSAllowsArbitraryLoads/.test(content)) { - newContent = newContent.replace(lastDictLocator, "\nNSAllowsArbitraryLoads\n\n\n$1"); - } - return newContent; - } - } - }, - simulatorLog: { - src: localCfg.simulatorSysLog, - dest: localCfg.outFile - } - }, - exec: { - killAndroidEmulator: { - cmd: "pkill '" + localCfg.emulatorProcessIdentifier + "'", - exitCode: [0, 1] - }, - killiOSEmulator: { - cmd: "pkill Simulator", - exitCode: [0, 1] - }, - createApp: { - cmd: localCfg.tnsPath + " create " + localCfg.testsAppName, - cwd: localCfg.workingDir - }, - restartAdb: { - cmd: "adb kill-server && adb start-server" - }, - uninstallExistingAndroidApp: { - cmd: "adb uninstall " + localCfg.deployedAppName - }, - installNewAndroidApp: { - cmd: "adb install " + localCfg.pathToApk, - cwd: localCfg.applicationDir - }, - startAndroidEmulator: { - cmd: "emulator -avd " + localCfg.emuAvdName + " -no-audio " + (args.showEmu ? "" : "-no-window") + "&" - }, - startAndroidApp: { - cmd: "adb shell am start -n " + localCfg.deployedAppName + "/" + localCfg.mainActivityName - }, - uninstallExistingiOSApp: { - cmd: "xcrun simctl uninstall " + localCfg.emuAvdName + " org.nativescript." + localCfg.testsAppName, - cwd: localCfg.applicationDir - }, - installNewiOSApp: { - cmd: "xcrun simctl install " + localCfg.emuAvdName + " " + localCfg.pathToApp, - cwd: localCfg.applicationDir - }, - startiOSApp: { - cmd: "xcrun simctl launch " + localCfg.emuAvdName + " org.nativescript." + localCfg.testsAppName - }, - "npm-i-modules": { - cmd: "npm i " + pathModule.relative(localCfg.applicationDir, localCfg.modulesPath), - cwd: localCfg.applicationDir - }, - "npm-i-widgets": { - cmd: "npm i tns-core-modules-widgets@next", - cwd: localCfg.applicationDir - } - }, - shell: { - collectAndroidLog: { - command: "./expect.exp " + "'adb logcat *:D' " + localCfg.outFile, - options: { - execOptions: { - maxBuffer: Infinity - } - } - }, - waitiOSLogCompletion: { - command: "./expect.exp " + "'tail -f " + localCfg.simulatorSysLog + "' " + localCfg.outFile, - options: { - execOptions: { - maxBuffer: Infinity - } - } - }, - startiOSSimulator: { - command: "xcrun instruments -w " + localCfg.emuAvdName, - options: { - failOnError: false - }, - }, - buildApp: { - command: "tns build " + localCfg.platform.toLowerCase(), - options: { - execOptions: { - maxBuffer: Infinity, - cwd: localCfg.applicationDir - } - } - }, - addPlatform: { - command: "tns platform add " + localCfg.platform.toLowerCase() + localCfg.runtimeVersionArgument + " " + localCfg.frameworkArgument, - options: { - execOptions: { - maxBuffer: Infinity, - cwd: localCfg.applicationDir - } - } - }, - } - }); - - grunt.loadNpmTasks("grunt-shell"); - grunt.loadNpmTasks("grunt-exec"); - grunt.loadNpmTasks("grunt-mkdir"); - grunt.loadNpmTasks("grunt-contrib-clean"); - grunt.loadNpmTasks("grunt-contrib-copy"); - - var getPlatformSpecificTask = function(templatedTaskName) { - return templatedTaskName.replace(/\{platform\}/, localCfg.platform); - } - - grunt.registerTask("startEmulatorAndroid", [ - getPlatformSpecificTask("exec:startAndroidEmulator"), - ]); - - grunt.registerTask("startEmulatoriOS", [ - getPlatformSpecificTask("shell:startiOSSimulator"), - ]); - - grunt.registerTask("collectLogAndroid", [ - "shell:collectAndroidLog" - ]); - - grunt.registerTask("collectLogiOS", [ - "shell:waitiOSLogCompletion", - "copy:simulatorLog" - ]); - - grunt.registerTask("doPreUninstallAppAndroid", [ - "exec:restartAdb" - ]); - - grunt.registerTask("doPreUninstallAppiOS", [ - "clean:simulatorLog" - ]); - - grunt.registerTask("cleanup", [ -// getPlatformSpecificTask("exec:kill{platform}Emulator"), - "clean:workingDir" - ]); - - grunt.registerTask("buildOnly", [ - "exec:createApp", - "clean:originalAppDir", - "copy:testsAppToRunDir", - "clean:modules", - "exec:npm-i-modules", - "exec:npm-i-widgets", - "copy:modulesToDir", - "clean:tempExtractedModules", - - "shell:addPlatform", - getPlatformSpecificTask("copy:add{platform}Permissions"), - "shell:buildApp", - ]); - - grunt.registerTask("buildTestsApp", [ - "cleanup", - "mkdir:workingDir", - "buildOnly" - - ]); - grunt.registerTask("buildOnlyTestsApp", ["buildTestsApp"]); - - grunt.registerTask("runOnly", [ -// getPlatformSpecificTask("doPreUninstallApp{platform}"), - - getPlatformSpecificTask("exec:uninstallExisting{platform}App"), - getPlatformSpecificTask("exec:installNew{platform}App"), - getPlatformSpecificTask("exec:start{platform}App"), - getPlatformSpecificTask("collectLog{platform}"), - ]); - - grunt.registerTask("runApp", [ -// "cleanup", -// getPlatformSpecificTask("startEmulator{platform}"), - "runOnly", - "cleanup" - - ]); - - grunt.registerTask("runOnlyTestsApp", ["runApp"]); - - - var tasksToExecute = ["runApp"]; - if (!localCfg.runAppOnly) { - tasksToExecute = [ - "cleanup", - "mkdir:workingDir", - getPlatformSpecificTask("startEmulator{platform}"), - "buildOnly", - "runOnly", - "cleanup" - ]; - } - - grunt.registerTask("testsapp", tasksToExecute); - } -} diff --git a/e2e/ui-tests-app/.vscode/launch.json b/e2e/ui-tests-app/.vscode/launch.json index 1c798a1645..f50412d011 100644 --- a/e2e/ui-tests-app/.vscode/launch.json +++ b/e2e/ui-tests-app/.vscode/launch.json @@ -27,7 +27,8 @@ "--colors", "--opts", "../config/mocha.opts", - "--grep=bottom-navigation", + "--grep", + "gestures-events-gestures", "-a", ], "internalConsoleOptions": "openOnSessionStart", @@ -45,10 +46,7 @@ "--opts", "../config/mocha.opts", "--grep=bottom-navigation", - "android", - "--grep=bottom-navigation", - "--port", - "8889", + "android" ], "internalConsoleOptions": "openOnSessionStart" } diff --git a/e2e/ui-tests-app/app/events/gestures-page.ts b/e2e/ui-tests-app/app/events/gestures-page.ts index 03166a8e21..674a3f5964 100644 --- a/e2e/ui-tests-app/app/events/gestures-page.ts +++ b/e2e/ui-tests-app/app/events/gestures-page.ts @@ -1,55 +1,56 @@ -import * as labelModule from "tns-core-modules/ui/label"; -import * as gestures from "tns-core-modules/ui/gestures"; -import * as button from "tns-core-modules/ui/button"; -import * as pages from "tns-core-modules/ui/page"; -import * as deviceProperties from "tns-core-modules/platform"; -import * as stackLayoutModule from "tns-core-modules/ui/layouts/stack-layout"; +import { + GestureEventData, + RotationGestureEventData, + GestureTypes, + SwipeGestureEventData, + PanGestureEventData, + PinchGestureEventData, + GestureStateTypes +} from "tns-core-modules/ui/gestures"; +import { Button } from "tns-core-modules/ui/button"; +import { Label } from "tns-core-modules/ui/label"; +import { Page } from "tns-core-modules/ui/page"; +import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; +import { screen, isAndroid } from "tns-core-modules/platform"; export function createPage() { - - var stack = new stackLayoutModule.StackLayout(); - var labelHeight = Math.round(deviceProperties.screen.mainScreen.heightPixels / (7 * deviceProperties.screen.mainScreen.scale)); - var stopButton = new button.Button(); + const stack = new StackLayout(); + var stopButton = new Button(); + if (isAndroid) { + stopButton.height = 30; + stopButton.fontSize = 8; + } stopButton.text = "Stop Detecting Gestures"; + stopButton.automationText = "stopGesturesDetecting"; stack.addChild(stopButton); - var tapLabel = new labelModule.Label(); - tapLabel.text = "Tap here"; + const labelHeight = Math.round(screen.mainScreen.heightPixels / (10 * screen.mainScreen.scale)); + + const tapLabel = createLabel("Tap here", labelHeight); stack.addChild(tapLabel); - var doubletapLabel = new labelModule.Label(); - doubletapLabel.text = "Double Tap here"; - stack.addChild(doubletapLabel); + const doubleTapLabel = createLabel("Double Tap here", labelHeight); + stack.addChild(doubleTapLabel); + + const longPressLabel = createLabel("Long Press here", labelHeight); + stack.addChild(longPressLabel); - var longpressLabel = new labelModule.Label(); - longpressLabel.text = "Long Press here"; - stack.addChild(longpressLabel); + const tapAndDoubleTapLabel = createLabel("Tap or Double Tap", labelHeight, true); + stack.addChild(tapAndDoubleTapLabel); - var swipeLabel = new labelModule.Label(); - swipeLabel.height = labelHeight; - swipeLabel.text = "Swipe here"; - swipeLabel.textWrap = true; + const swipeLabel = createLabel("Swipe here", labelHeight, true); stack.addChild(swipeLabel); - var panLabel = new labelModule.Label(); - panLabel.height = labelHeight; - panLabel.text = "Pan here"; - panLabel.textWrap = true; + const panLabel = createLabel("Pan here", labelHeight, true); stack.addChild(panLabel); - var pinchLabel = new labelModule.Label(); - pinchLabel.height = labelHeight; - pinchLabel.text = "Pinch here"; - pinchLabel.textWrap = true; + const pinchLabel = createLabel("Pinch here", labelHeight, true); stack.addChild(pinchLabel); - var rotaionLabel = new labelModule.Label(); - rotaionLabel.height = labelHeight; - rotaionLabel.text = "Rotate here"; - rotaionLabel.textWrap = true; - stack.addChild(rotaionLabel); + const rotationLabel = createLabel("Rotate here", labelHeight, true); + stack.addChild(rotationLabel); - stopButton.on(button.Button.tapEvent, function () { + stopButton.on("tap", function () { observer1.disconnect(); observer2.disconnect(); observer3.disconnect(); @@ -57,77 +58,111 @@ export function createPage() { observer5.disconnect(); observer6.disconnect(); observer7.disconnect(); + observer8.disconnect(); + observer9.disconnect(); tapLabel.text = "Gestures detection disabled"; - doubletapLabel.text = "Gestures detection disabled"; - longpressLabel.text = "Gestures detection disabled"; - swipeLabel.text = "Gesturesd detection disabled"; + tapLabel.automationText = "Gestures detection disabled"; + doubleTapLabel.text = "Gestures detection disabled"; + doubleTapLabel.automationText = "Gestures detection disabled"; + longPressLabel.text = "Gestures detection disabled"; + longPressLabel.automationText = "Gestures detection disabled"; + swipeLabel.text = "Gestures detection disabled"; + swipeLabel.automationText = "Gestures detection disabled"; panLabel.text = "Gestures detection disabled"; + panLabel.automationText = "Gestures detection disabled"; pinchLabel.text = "Gestures detection disabled"; - rotaionLabel.text = "Gestures detection disabled"; + pinchLabel.automationText = "Gestures detection disabled"; + rotationLabel.text = "Gestures detection disabled"; + rotationLabel.automationText = "Gestures detection disabled"; + tapAndDoubleTapLabel.text = "Gestures detection disabled"; + tapAndDoubleTapLabel.automationText = "Gestures detection disabled"; }); - tapLabel.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) { + tapLabel.on(GestureTypes[GestureTypes.tap], function (args: GestureEventData) { tapLabel.text = "Tap gesture detected, " + (args.object === tapLabel); }); - var observer1 = tapLabel.getGestureObservers(gestures.GestureTypes.tap)[0]; + const observer1 = tapLabel.getGestureObservers(GestureTypes.tap)[0]; - doubletapLabel.on(gestures.GestureTypes.doubleTap, function (args: gestures.GestureEventData) { - doubletapLabel.text = "Double Tap gesture detected, " + (args.object === doubletapLabel); + doubleTapLabel.on(GestureTypes[GestureTypes.doubleTap], function (args: GestureEventData) { + doubleTapLabel.text = "Double Tap gesture detected, " + (args.object === doubleTapLabel); }); - var observer2 = doubletapLabel.getGestureObservers(gestures.GestureTypes.doubleTap)[0]; + const observer2 = doubleTapLabel.getGestureObservers(GestureTypes.doubleTap)[0]; - longpressLabel.on(gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) { - longpressLabel.text = "Long Press gesture detected, " + (args.object === longpressLabel); + longPressLabel.on(GestureTypes[GestureTypes.longPress], function (args: GestureEventData) { + longPressLabel.text = "Long Press gesture detected, " + (args.object === longPressLabel); }); - var observer3 = longpressLabel.getGestureObservers(gestures.GestureTypes.longPress)[0]; + const observer3 = longPressLabel.getGestureObservers(GestureTypes.longPress)[0]; - swipeLabel.on(gestures.GestureTypes.swipe, function (args: gestures.SwipeGestureEventData) { + swipeLabel.on(GestureTypes[GestureTypes.swipe], function (args: SwipeGestureEventData) { swipeLabel.text = "Swipe Direction: " + args.direction + ", " + (args.object === swipeLabel); // + getStateAsString(args.state); }); - var observer4 = swipeLabel.getGestureObservers(gestures.GestureTypes.swipe)[0]; + const observer4 = swipeLabel.getGestureObservers(GestureTypes.swipe)[0]; - panLabel.on(gestures.GestureTypes.pan, function (args: gestures.PanGestureEventData) { + panLabel.on(GestureTypes[GestureTypes.pan], function (args: PanGestureEventData) { panLabel.text = "Pan deltaX:" + Math.round(args.deltaX) + "; deltaY:" + Math.round(args.deltaY) + ";" + ", " + (args.object === panLabel) + getStateAsString(args.state); }); - var observer5 = panLabel.getGestureObservers(gestures.GestureTypes.pan)[0]; + const observer5 = panLabel.getGestureObservers(GestureTypes.pan)[0]; - pinchLabel.on(gestures.GestureTypes.pinch, function (args: gestures.PinchGestureEventData) { + pinchLabel.on(GestureTypes[GestureTypes.pinch], function (args: PinchGestureEventData) { pinchLabel.text = "Pinch Scale: " + Math.round(args.scale) + ", " + (args.object === pinchLabel) + getStateAsString(args.state); }); - var observer6 = pinchLabel.getGestureObservers(gestures.GestureTypes.pinch)[0]; + const observer6 = pinchLabel.getGestureObservers(GestureTypes.pinch)[0]; - rotaionLabel.on(gestures.GestureTypes.rotation, function (args: gestures.RotationGestureEventData) { - rotaionLabel.text = "Rotation: " + Math.round(args.rotation) + ", " + (args.object === rotaionLabel) + getStateAsString(args.state); + rotationLabel.on(GestureTypes[GestureTypes.rotation], function (args: RotationGestureEventData) { + rotationLabel.text = "Rotation: " + Math.round(args.rotation) + ", " + (args.object === rotationLabel) + getStateAsString(args.state); }); - var observer7 = rotaionLabel.getGestureObservers(gestures.GestureTypes.rotation)[0]; + const observer7 = rotationLabel.getGestureObservers(GestureTypes.rotation)[0]; - var page = new pages.Page(); - page.content = stack; + tapAndDoubleTapLabel.on(GestureTypes[GestureTypes.doubleTap], function (args: GestureEventData) { + tapAndDoubleTapLabel.text = "Last action: Double tap gesture, " + (args.object === tapAndDoubleTapLabel); + }); + + const observer8 = tapAndDoubleTapLabel.getGestureObservers(GestureTypes.doubleTap)[0]; + tapAndDoubleTapLabel.on(GestureTypes[GestureTypes.tap], function (args: GestureEventData) { + tapAndDoubleTapLabel.text = "Last action: Tap gesture, " + (args.object === tapAndDoubleTapLabel); + }); + + const observer9 = tapAndDoubleTapLabel.getGestureObservers(GestureTypes.tap)[0]; + + const page = new Page(); + page.content = stack; + return page; } -var states = new Array(); -function getStateAsString(state: gestures.GestureStateTypes): string { - if (state === gestures.GestureStateTypes.began) { +function getStateAsString(state: GestureStateTypes): string { + const states = new Array(); + if (state === GestureStateTypes.began) { states.length = 0; states.push("began"); - } else if (state === gestures.GestureStateTypes.cancelled) { + } else if (state === GestureStateTypes.cancelled) { states.push("cancelled"); - } else if (state === gestures.GestureStateTypes.changed) { + } else if (state === GestureStateTypes.changed) { if (states.indexOf("changed") === -1) { states.push("changed"); } - } else if (state === gestures.GestureStateTypes.ended) { + } else if (state === GestureStateTypes.ended) { states.push("ended"); } return ", states: " + states.join(","); } + +function createLabel(text: string, labelHeight: number, shouldWrap = false) { + const label = new Label(); + label.height = labelHeight; + label.text = text; + label.textWrap = shouldWrap; + label.borderColor = "green"; + label.borderWidth = 1; + + return label; +} \ No newline at end of file diff --git a/e2e/ui-tests-app/app/events/handlers-page.ts b/e2e/ui-tests-app/app/events/handlers-page.ts index d3ffe29801..24308b61bf 100644 --- a/e2e/ui-tests-app/app/events/handlers-page.ts +++ b/e2e/ui-tests-app/app/events/handlers-page.ts @@ -1,16 +1,27 @@ -import * as observable from "tns-core-modules/data/observable"; -import * as gestures from "tns-core-modules/ui/gestures"; -import * as pages from "tns-core-modules/ui/page"; +import { EventData } from "tns-core-modules/data/observable"; +import { GestureEventData } from "tns-core-modules/ui/gestures"; +import { Page } from "tns-core-modules/ui/page"; +import { Label } from "tns-core-modules/ui/label/label"; -export function pageLoaded(args: observable.EventData) { - var page = args.object; - page.bindingContext = { tapAction: tapAction, doubleTapAction: doubleTapAction }; +export function pageLoaded(args: EventData) { + var page = args.object; + page.bindingContext = { tapAction: tapAction, doubleTapAction: doubleTapAction, cleanResult: cleanResult }; } -export function tapAction(args: gestures.GestureEventData) { - console.log("tapAction"); +export function tapAction(args: GestureEventData) { + setResult(args, "tapAction"); } -export function doubleTapAction(args: gestures.GestureEventData) { - console.log("doubleTapAction"); +export function doubleTapAction(args: GestureEventData) { + setResult(args, "doubleTapAction"); } + +export function cleanResult(args: GestureEventData) { + setResult(args, ""); +} + +const setResult = (args: GestureEventData, text: string) => { + console.log(text); + const resultPanel: Label = (((args.object).page)).getViewById("resultContainer"); + resultPanel.text = text; +}; diff --git a/e2e/ui-tests-app/app/events/handlers-page.xml b/e2e/ui-tests-app/app/events/handlers-page.xml index 275055a405..d3ea351780 100644 --- a/e2e/ui-tests-app/app/events/handlers-page.xml +++ b/e2e/ui-tests-app/app/events/handlers-page.xml @@ -2,5 +2,8 @@