Skip to content

Commit cadbbef

Browse files
authored
Merge branch 'master' into vlaeva/unset-value
2 parents cd99afc + bd38745 commit cadbbef

11 files changed

+109
-187
lines changed

Diff for: .travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
- ANDROID_BUILD_TOOLS_VERSION=23.0.1
99
- ANDROID_ABI=armeabi-v7a
1010
- ANDROID_TAG=google_apis
11-
- APPIUM_VERSION=1.6.3
11+
- APPIUM_VERSION=1.6.5
1212
language: android
1313
jdk:
1414
- oraclejdk8
@@ -38,16 +38,15 @@ install:
3838
- npm run tslint
3939
- cd ../tests
4040
- npm install
41+
- npm i appium@$APPIUM_VERSION
4142
before_script:
4243
- echo no | android create avd --force -n test -t android-$EMULATOR_API_LEVEL --abi $ANDROID_ABI
4344
- emulator -memory 1024 -avd test -no-audio -no-window &
4445
- android-wait-for-emulator
4546
script:
46-
-
47-
-
4847
- tns build android
4948
- android-wait-for-emulator
50-
- npm run run-appium-android
49+
- npm run appium --runtype=android19 --appium=$APPIUM_VERSION
5150
before_deploy:
5251
- cd ../nativescript-angular
5352
- npm install -g nativescript --ignore-scripts

Diff for: nativescript-angular/animations/animation-player.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { AnimationPlayer } from "@angular/animations";
2-
import {
3-
KeyframeAnimation,
4-
KeyframeAnimationInfo,
5-
} from "tns-core-modules/ui/animation/keyframe-animation";
2+
import { KeyframeAnimation }
3+
from "tns-core-modules/ui/animation/keyframe-animation";
64

75
import { NgView } from "../element-registry";
8-
import { Keyframe, getAnimationCurve, parseAnimationKeyframe } from "./utils";
6+
import { Keyframe, createKeyframeAnimation } from "./utils";
97

108
export class NativeScriptAnimationPlayer implements AnimationPlayer {
119
public parentPlayer: AnimationPlayer = null;
@@ -86,15 +84,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
8684
}
8785

8886
private initKeyframeAnimation(keyframes: Keyframe[], duration: number, delay: number, easing: string) {
89-
let info = new KeyframeAnimationInfo();
90-
info.isForwards = true;
91-
info.iterations = 1;
92-
info.duration = duration === 0 ? 0.01 : duration;
93-
info.delay = delay;
94-
info.curve = getAnimationCurve(easing);
95-
info.keyframes = keyframes.map(parseAnimationKeyframe);
96-
97-
this.animation = KeyframeAnimation.keyframeAnimationFromInfo(info);
87+
this.animation = createKeyframeAnimation(keyframes, duration, delay, easing);
9888
}
9989

10090
private onFinish() {

Diff for: nativescript-angular/animations/utils.ts

+40-125
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,54 @@
11
import {
2+
KeyframeAnimation,
3+
KeyframeAnimationInfo,
24
KeyframeDeclaration,
35
KeyframeInfo,
46
} from "tns-core-modules/ui/animation/keyframe-animation";
5-
import { CssAnimationProperty } from "tns-core-modules/ui/core/properties";
6-
import { AnimationCurve } from "tns-core-modules/ui/enums";
7+
import { parseKeyframeDeclarations } from "tns-core-modules/ui/styling/css-animation-parser";
8+
import { animationTimingFunctionConverter } from "tns-core-modules/ui/styling/converters";
79

810
export interface Keyframe {
911
[key: string]: string | number;
10-
}
11-
12-
interface Transformation {
13-
property: string;
14-
value: number | { x: number, y: number };
15-
}
16-
17-
const TRANSFORM_MATCHER = new RegExp(/(.+)\((.+)\)/);
18-
const TRANSFORM_SPLITTER = new RegExp(/[\s,]+/);
19-
20-
const STYLE_TRANSFORMATION_MAP = Object.freeze({
21-
"scale": value => ({ property: "scale", value }),
22-
"scale3d": value => ({ property: "scale", value }),
23-
"scaleX": value => ({ property: "scale", value: { x: value, y: 1 } }),
24-
"scaleY": value => ({ property: "scale", value: { x: 1, y: value } }),
25-
26-
"translate": value => ({ property: "translate", value }),
27-
"translate3d": value => ({ property: "translate", value }),
28-
"translateX": value => ({ property: "translate", value: { x: value, y: 0 } }),
29-
"translateY": value => ({ property: "translate", value: { x: 0, y: value } }),
30-
31-
"rotate": value => ({ property: "rotate", value }),
32-
33-
"none": _value => [
34-
{ property: "scale", value: { x: 1, y: 1 } },
35-
{ property: "translate", value: { x: 0, y: 0 } },
36-
{ property: "rotate", value: 0 },
37-
],
38-
});
39-
40-
const STYLE_CURVE_MAP = Object.freeze({
41-
"ease": AnimationCurve.ease,
42-
"linear": AnimationCurve.linear,
43-
"ease-in": AnimationCurve.easeIn,
44-
"ease-out": AnimationCurve.easeOut,
45-
"ease-in-out": AnimationCurve.easeInOut,
46-
"spring": AnimationCurve.spring,
47-
});
48-
49-
export function getAnimationCurve(value: string): any {
50-
if (!value) {
51-
return AnimationCurve.ease;
52-
}
53-
54-
const curve = STYLE_CURVE_MAP[value];
55-
if (curve) {
56-
return curve;
57-
}
58-
59-
const [, property = "", pointsString = ""] = TRANSFORM_MATCHER.exec(value) || [];
60-
const coords = pointsString.split(TRANSFORM_SPLITTER).map(stringToBezieCoords);
61-
62-
if (property !== "cubic-bezier" || coords.length !== 4) {
63-
throw new Error(`Invalid value for animation: ${value}`);
64-
} else {
65-
return (<any>AnimationCurve).cubicBezier(...coords);
12+
offset: number;
13+
}
14+
15+
export function createKeyframeAnimation(
16+
styles: Keyframe[],
17+
duration: number,
18+
delay: number,
19+
easing: string)
20+
: KeyframeAnimation {
21+
22+
const info = createKeyframeAnimationInfo(styles, duration, delay, easing);
23+
return KeyframeAnimation.keyframeAnimationFromInfo(info);
24+
}
25+
26+
const createKeyframeAnimationInfo = (
27+
styles: Keyframe[],
28+
duration: number,
29+
delay: number,
30+
easing: string
31+
): KeyframeAnimationInfo => ({
32+
isForwards: true,
33+
duration: duration || 0.01,
34+
delay,
35+
curve: getCurve(easing),
36+
keyframes: styles.map(parseAnimationKeyframe),
6637
}
67-
}
68-
69-
export function parseAnimationKeyframe(styles: Keyframe) {
70-
let keyframeInfo = <KeyframeInfo>{};
71-
keyframeInfo.duration = <number>styles.offset;
72-
keyframeInfo.declarations = Object.keys(styles).reduce((declarations, prop) => {
73-
let value = styles[prop];
74-
75-
const property = CssAnimationProperty._getByCssName(prop);
76-
if (property) {
77-
if (typeof value === "string" && property._valueConverter) {
78-
value = property._valueConverter(<string>value);
79-
}
80-
declarations.push({ property: property.name, value });
81-
} else if (typeof value === "string" && prop === "transform") {
82-
declarations.push(...parseTransformation(<string>value));
83-
}
38+
);
8439

85-
return declarations;
86-
}, new Array<KeyframeDeclaration>());
87-
88-
return keyframeInfo;
89-
}
90-
91-
function stringToBezieCoords(value: string): number {
92-
let result = parseFloat(value);
93-
if (result < 0) {
94-
return 0;
95-
} else if (result > 1) {
96-
return 1;
97-
}
98-
99-
return result;
100-
}
40+
const getCurve = (value: string) => animationTimingFunctionConverter(value);
10141

102-
function parseTransformation(styleString: string): KeyframeDeclaration[] {
103-
return parseStyle(styleString)
104-
.reduce((transformations, style) => {
105-
const transform = STYLE_TRANSFORMATION_MAP[style.property](style.value);
106-
107-
if (Array.isArray(transform)) {
108-
transformations.push(...transform);
109-
} else if (typeof transform !== "undefined") {
110-
transformations.push(transform);
111-
}
112-
113-
return transformations;
114-
}, new Array<Transformation>());
115-
}
116-
117-
function parseStyle(text: string): Transformation[] {
118-
return text.split(TRANSFORM_SPLITTER).map(stringToTransformation).filter(t => !!t);
119-
}
120-
121-
function stringToTransformation(text: string): Transformation {
122-
const [, property = "", stringValue = ""] = TRANSFORM_MATCHER.exec(text) || [];
123-
if (!property) {
124-
return;
125-
}
42+
const parseAnimationKeyframe = (styles: Keyframe): KeyframeInfo => ({
43+
duration: getKeyframeDuration(styles),
44+
declarations: getDeclarations(styles),
45+
});
12646

127-
const [x, y] = stringValue.split(",").map(parseFloat);
128-
if (x && y) {
129-
return { property, value: {x, y} };
130-
} else {
131-
let value: number = x;
47+
const getKeyframeDuration = (styles: Keyframe): number => styles.offset;
13248

133-
if (stringValue.slice(-3) === "rad") {
134-
value *= 180.0 / Math.PI;
135-
}
49+
function getDeclarations(styles: Keyframe): KeyframeDeclaration[] {
50+
const unparsedDeclarations: KeyframeDeclaration[] =
51+
Object.keys(styles).map(property => ({ property, value: styles[property] }));
13652

137-
return { property, value };
138-
}
53+
return parseKeyframeDeclarations(unparsedDeclarations);
13954
}

Diff for: nativescript-angular/value-accessors/checked-value-accessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const CHECKED_VALUE_ACCESSOR = {
2020
*/
2121
@Directive({
2222
selector:
23-
"Switch[ngModel],Switch[formControlName]," +
24-
"switch[ngModel],switch[formControlName]",
23+
"Switch[ngModel],Switch[formControlName],Switch[formControl]," +
24+
"switch[ngModel],switch[formControlName],switch[formControl]",
2525
providers: [CHECKED_VALUE_ACCESSOR],
2626
host: {
2727
"(touch)": "onTouched()",

Diff for: nativescript-angular/value-accessors/date-value-accessor.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ const DATE_VALUE_ACCESSOR = {
1919
* ```
2020
*/
2121
@Directive({
22-
selector: "DatePicker[ngModel],DatePicker[formControlName]," +
23-
"datepicker[ngModel],datepicker[formControlName]," +
24-
"datePicker[ngModel],datePicker[formControlName]," +
25-
"date-picker[ngModel],date-picker[formControlName]",
22+
selector: "DatePicker[ngModel],DatePicker[formControlName],DatePicker[formControl]," +
23+
"datepicker[ngModel],datepicker[formControlName],datepicker[formControl]," +
24+
"datePicker[ngModel],datePicker[formControlName],datePicker[formControl]," +
25+
"date-picker[ngModel],date-picker[formControlName],date-picker[formControl]",
2626
providers: [DATE_VALUE_ACCESSOR],
2727
host: {
2828
"(touch)": "onTouched()",

Diff for: nativescript-angular/value-accessors/number-value-accessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const NUMBER_VALUE_ACCESSOR = {
2020
*/
2121
@Directive({
2222
selector:
23-
"Slider[ngModel],Slider[formControlName]," +
24-
"slider[ngModel],slider[formControlName]",
23+
"Slider[ngModel],Slider[formControlName],Slider[formControl]," +
24+
"slider[ngModel],slider[formControlName],slider[formControl]",
2525
providers: [NUMBER_VALUE_ACCESSOR],
2626
host: {
2727
"(touch)": "onTouched()",

Diff for: nativescript-angular/value-accessors/selectedIndex-value-accessor.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ export type SelectableView = {selectedIndex: number} & View;
2222
*/
2323
@Directive({
2424
selector:
25-
"SegmentedBar[ngModel],SegmentedBar[formControlName]," +
26-
"segmentedBar[ngModel],segmentedBar[formControlName]," +
27-
"segmentedbar[ngModel],segmentedbar[formControlName]," +
28-
"segmented-bar[ngModel],segmented-bar[formControlName]," +
25+
"SegmentedBar[ngModel],SegmentedBar[formControlName],SegmentedBar[formControl]," +
26+
"segmentedBar[ngModel],segmentedBar[formControlName],segmentedBar[formControl]," +
27+
"segmentedbar[ngModel],segmentedbar[formControlName],segmentedbar[formControl]," +
28+
"segmented-bar[ngModel],segmented-bar[formControlName],segmented-bar[formControl]," +
2929

30-
"ListPicker[ngModel],ListPicker[formControlName]," +
31-
"listPicker[ngModel],listPicker[formControlName]," +
32-
"listpicker[ngModel],listpicker[formControlName]," +
33-
"list-picker[ngModel],list-picker[formControlName]," +
30+
"ListPicker[ngModel],ListPicker[formControlName],ListPicker[formControl]," +
31+
"listPicker[ngModel],listPicker[formControlName],listPicker[formControl]," +
32+
"listpicker[ngModel],listpicker[formControlName],listpicker[formControl]," +
33+
"list-picker[ngModel],list-picker[formControlName],list-picker[formControl]," +
3434

35-
"TabView[ngModel],TabView[formControlName]," +
36-
"tabView[ngModel],tabView[formControlName]," +
37-
"tabview[ngModel],tabview[formControlName]," +
38-
"tab-view[ngModel],tab-view[formControlName]",
35+
"TabView[ngModel],TabView[formControlName],TabView[formControl]," +
36+
"tabView[ngModel],tabView[formControlName],tabView[formControl]," +
37+
"tabview[ngModel],tabview[formControlName],tabview[formControl]," +
38+
"tab-view[ngModel],tab-view[formControlName],tab-view[formControl]",
3939
providers: [SELECTED_INDEX_VALUE_ACCESSOR],
4040
host: {
4141
"(touch)": "onTouched()",

Diff for: nativescript-angular/value-accessors/text-value-accessor.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ export type TextView = {text: string} & View;
2222
*/
2323
@Directive({
2424
selector:
25-
"TextField[ngModel],TextField[formControlName]," +
26-
"textField[ngModel],textField[formControlName]," +
27-
"textfield[ngModel],textfield[formControlName]," +
28-
"text-field[ngModel],text-field[formControlName]," +
25+
"TextField[ngModel],TextField[formControlName],TextField[formControl]," +
26+
"textField[ngModel],textField[formControlName],textField[formControl]," +
27+
"textfield[ngModel],textfield[formControlName],textfield[formControl]," +
28+
"text-field[ngModel],text-field[formControlName],text-field[formControl]," +
2929

30-
"TextView[ngModel],TextView[formControlName]," +
31-
"textView[ngModel],textView[formControlName]," +
32-
"textview[ngModel],textview[formControlName]," +
33-
"text-view[ngModel],text-view[formControlName]," +
30+
"TextView[ngModel],TextView[formControlName],TextView[formControl]," +
31+
"textView[ngModel],textView[formControlName],textView[formControl]," +
32+
"textview[ngModel],textview[formControlName],textview[formControl]," +
33+
"text-view[ngModel],text-view[formControlName],text-view[formControl]," +
3434

35-
"SearchBar[ngModel],SearchBar[formControlName]," +
36-
"searchBar[ngModel],searchBar[formControlName]," +
37-
"searchbar[ngModel],searchbar[formControlName]," +
38-
"search-bar[ngModel], search-bar[formControlName]",
35+
"SearchBar[ngModel],SearchBar[formControlName],SearchBar[formControl]," +
36+
"searchBar[ngModel],searchBar[formControlName],searchBar[formControl]," +
37+
"searchbar[ngModel],searchbar[formControlName],searchbar[formControl]," +
38+
"search-bar[ngModel], search-bar[formControlName],search-bar[formControl]",
3939
providers: [TEXT_VALUE_ACCESSOR],
4040
host: {
4141
"(touch)": "onTouched()",

Diff for: nativescript-angular/value-accessors/time-value-accessor.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const TIME_VALUE_ACCESSOR = {
2020
*/
2121
@Directive({
2222
selector:
23-
"TimePicker[ngModel],TimePicker[formControlName]," +
24-
"timepicker[ngModel],timepicker[formControlName]," +
25-
"timePicker[ngModel],timePicker[formControlName]," +
26-
"time-picker[ngModel],time-picker[formControlName]",
23+
"TimePicker[ngModel],TimePicker[formControlName],TimePicker[formControl]," +
24+
"timepicker[ngModel],timepicker[formControlName],timepicker[formControl]," +
25+
"timePicker[ngModel],timePicker[formControlName],timePicker[formControl]," +
26+
"time-picker[ngModel],time-picker[formControlName],time-picker[formControl]",
2727
providers: [TIME_VALUE_ACCESSOR],
2828
host: {
2929
"(touch)": "onTouched()",

Diff for: tests/app/App_Resources/Android/app.gradle

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Add your native dependencies here:
2+
3+
// Uncomment to add recyclerview-v7 dependency
4+
//dependencies {
5+
// compile 'com.android.support:recyclerview-v7:+'
6+
//}
7+
8+
android {
9+
defaultConfig {
10+
generatedDensities = []
11+
applicationId = "org.nativescript.tests"
12+
13+
//override supported platforms
14+
// ndk {
15+
// abiFilters.clear()
16+
// abiFilters "armeabi-v7a"
17+
// }
18+
19+
}
20+
aaptOptions {
21+
additionalParameters "--no-version-vectors"
22+
}
23+
}

0 commit comments

Comments
 (0)