diff --git a/.gitignore b/.gitignore
index 9e3fa2f..9476098 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@ node_modules/
.vscode/
tests/platforms/
tests/node_modules/
+example/node_modules/
+example/platforms/
dist/
diff --git a/example/app/App_Resources/Android/AndroidManifest.xml b/example/app/App_Resources/Android/AndroidManifest.xml
new file mode 100644
index 0000000..9db8321
--- /dev/null
+++ b/example/app/App_Resources/Android/AndroidManifest.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/app/App_Resources/Android/app.gradle b/example/app/App_Resources/Android/app.gradle
new file mode 100644
index 0000000..381845b
--- /dev/null
+++ b/example/app/App_Resources/Android/app.gradle
@@ -0,0 +1,23 @@
+// Add your native dependencies here:
+
+// Uncomment to add recyclerview-v7 dependency
+//dependencies {
+// compile 'com.android.support:recyclerview-v7:+'
+//}
+
+android {
+ defaultConfig {
+ generatedDensities = []
+ applicationId = "org.nativescript.example"
+
+ //override supported platforms
+ // ndk {
+ // abiFilters.clear()
+ // abiFilters "armeabi-v7a"
+ // }
+
+ }
+ aaptOptions {
+ additionalParameters "--no-version-vectors"
+ }
+}
diff --git a/example/app/App_Resources/Android/drawable-hdpi/background.png b/example/app/App_Resources/Android/drawable-hdpi/background.png
new file mode 100644
index 0000000..eb381c2
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-hdpi/background.png differ
diff --git a/example/app/App_Resources/Android/drawable-hdpi/icon.png b/example/app/App_Resources/Android/drawable-hdpi/icon.png
new file mode 100644
index 0000000..1034356
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-hdpi/icon.png differ
diff --git a/example/app/App_Resources/Android/drawable-hdpi/logo.png b/example/app/App_Resources/Android/drawable-hdpi/logo.png
new file mode 100644
index 0000000..5218f4c
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-hdpi/logo.png differ
diff --git a/example/app/App_Resources/Android/drawable-ldpi/background.png b/example/app/App_Resources/Android/drawable-ldpi/background.png
new file mode 100644
index 0000000..748b2ad
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-ldpi/background.png differ
diff --git a/example/app/App_Resources/Android/drawable-ldpi/icon.png b/example/app/App_Resources/Android/drawable-ldpi/icon.png
new file mode 100644
index 0000000..ddfc17a
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-ldpi/icon.png differ
diff --git a/example/app/App_Resources/Android/drawable-ldpi/logo.png b/example/app/App_Resources/Android/drawable-ldpi/logo.png
new file mode 100644
index 0000000..b9e102a
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-ldpi/logo.png differ
diff --git a/example/app/App_Resources/Android/drawable-mdpi/background.png b/example/app/App_Resources/Android/drawable-mdpi/background.png
new file mode 100644
index 0000000..efeaf29
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-mdpi/background.png differ
diff --git a/example/app/App_Resources/Android/drawable-mdpi/icon.png b/example/app/App_Resources/Android/drawable-mdpi/icon.png
new file mode 100644
index 0000000..486e410
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-mdpi/icon.png differ
diff --git a/example/app/App_Resources/Android/drawable-mdpi/logo.png b/example/app/App_Resources/Android/drawable-mdpi/logo.png
new file mode 100644
index 0000000..6263387
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-mdpi/logo.png differ
diff --git a/example/app/App_Resources/Android/drawable-nodpi/splash_screen.xml b/example/app/App_Resources/Android/drawable-nodpi/splash_screen.xml
new file mode 100644
index 0000000..ada77f9
--- /dev/null
+++ b/example/app/App_Resources/Android/drawable-nodpi/splash_screen.xml
@@ -0,0 +1,8 @@
+
+ -
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/example/app/App_Resources/Android/drawable-xhdpi/background.png b/example/app/App_Resources/Android/drawable-xhdpi/background.png
new file mode 100644
index 0000000..612bbd0
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xhdpi/background.png differ
diff --git a/example/app/App_Resources/Android/drawable-xhdpi/icon.png b/example/app/App_Resources/Android/drawable-xhdpi/icon.png
new file mode 100644
index 0000000..f291882
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xhdpi/icon.png differ
diff --git a/example/app/App_Resources/Android/drawable-xhdpi/logo.png b/example/app/App_Resources/Android/drawable-xhdpi/logo.png
new file mode 100644
index 0000000..ad8ee2f
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xhdpi/logo.png differ
diff --git a/example/app/App_Resources/Android/drawable-xxhdpi/background.png b/example/app/App_Resources/Android/drawable-xxhdpi/background.png
new file mode 100644
index 0000000..0fa88e2
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xxhdpi/background.png differ
diff --git a/example/app/App_Resources/Android/drawable-xxhdpi/icon.png b/example/app/App_Resources/Android/drawable-xxhdpi/icon.png
new file mode 100644
index 0000000..4f69cb2
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xxhdpi/icon.png differ
diff --git a/example/app/App_Resources/Android/drawable-xxhdpi/logo.png b/example/app/App_Resources/Android/drawable-xxhdpi/logo.png
new file mode 100644
index 0000000..6683278
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xxhdpi/logo.png differ
diff --git a/example/app/App_Resources/Android/drawable-xxxhdpi/background.png b/example/app/App_Resources/Android/drawable-xxxhdpi/background.png
new file mode 100644
index 0000000..c650f64
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xxxhdpi/background.png differ
diff --git a/example/app/App_Resources/Android/drawable-xxxhdpi/icon.png b/example/app/App_Resources/Android/drawable-xxxhdpi/icon.png
new file mode 100644
index 0000000..50887a8
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xxxhdpi/icon.png differ
diff --git a/example/app/App_Resources/Android/drawable-xxxhdpi/logo.png b/example/app/App_Resources/Android/drawable-xxxhdpi/logo.png
new file mode 100644
index 0000000..fa6331c
Binary files /dev/null and b/example/app/App_Resources/Android/drawable-xxxhdpi/logo.png differ
diff --git a/example/app/App_Resources/Android/values-v21/colors.xml b/example/app/App_Resources/Android/values-v21/colors.xml
new file mode 100644
index 0000000..a64641a
--- /dev/null
+++ b/example/app/App_Resources/Android/values-v21/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #3d5afe
+
\ No newline at end of file
diff --git a/example/app/App_Resources/Android/values-v21/styles.xml b/example/app/App_Resources/Android/values-v21/styles.xml
new file mode 100644
index 0000000..dac8727
--- /dev/null
+++ b/example/app/App_Resources/Android/values-v21/styles.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/app/App_Resources/Android/values/colors.xml b/example/app/App_Resources/Android/values/colors.xml
new file mode 100644
index 0000000..74ad882
--- /dev/null
+++ b/example/app/App_Resources/Android/values/colors.xml
@@ -0,0 +1,7 @@
+
+
+ #F5F5F5
+ #757575
+ #33B5E5
+ #272734
+
\ No newline at end of file
diff --git a/example/app/App_Resources/Android/values/styles.xml b/example/app/App_Resources/Android/values/styles.xml
new file mode 100644
index 0000000..1e8c7f2
--- /dev/null
+++ b/example/app/App_Resources/Android/values/styles.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..5f53593
--- /dev/null
+++ b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,128 @@
+{
+ "images" : [
+ {
+ "size" : "29x29",
+ "idiom" : "iphone",
+ "filename" : "icon-29.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "iphone",
+ "filename" : "icon-29@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "iphone",
+ "filename" : "icon-29@3x.png",
+ "scale" : "3x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "iphone",
+ "filename" : "icon-40@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "iphone",
+ "filename" : "icon-40@3x.png",
+ "scale" : "3x"
+ },
+ {
+ "size" : "57x57",
+ "idiom" : "iphone",
+ "filename" : "icon-57.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "57x57",
+ "idiom" : "iphone",
+ "filename" : "icon-57@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "60x60",
+ "idiom" : "iphone",
+ "filename" : "icon-60@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "60x60",
+ "idiom" : "iphone",
+ "filename" : "icon-60@3x.png",
+ "scale" : "3x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "ipad",
+ "filename" : "icon-29.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "ipad",
+ "filename" : "icon-29@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "ipad",
+ "filename" : "icon-40.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "ipad",
+ "filename" : "icon-40@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "50x50",
+ "idiom" : "ipad",
+ "filename" : "icon-50.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "50x50",
+ "idiom" : "ipad",
+ "filename" : "icon-50@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "72x72",
+ "idiom" : "ipad",
+ "filename" : "icon-72.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "72x72",
+ "idiom" : "ipad",
+ "filename" : "icon-72@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "76x76",
+ "idiom" : "ipad",
+ "filename" : "icon-76.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "76x76",
+ "idiom" : "ipad",
+ "filename" : "icon-76@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "83.5x83.5",
+ "idiom" : "ipad",
+ "filename" : "icon-83.5@2x.png",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
new file mode 100644
index 0000000..9e15af0
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
new file mode 100644
index 0000000..7b9e555
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
new file mode 100644
index 0000000..76f61ec
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
new file mode 100644
index 0000000..15b06db
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
new file mode 100644
index 0000000..585065f
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
new file mode 100644
index 0000000..a450c42
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png
new file mode 100644
index 0000000..4a62478
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png
new file mode 100644
index 0000000..01ff7c1
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png
new file mode 100644
index 0000000..beea819
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png
new file mode 100644
index 0000000..c3dc7b0
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
new file mode 100644
index 0000000..457b6d9
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
new file mode 100644
index 0000000..fa5a6ac
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png
new file mode 100644
index 0000000..556bdd6
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png
new file mode 100644
index 0000000..4f69cb2
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
new file mode 100644
index 0000000..94abcf7
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
new file mode 100644
index 0000000..2e71dd3
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
new file mode 100644
index 0000000..4abc9ec
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/Contents.json b/example/app/App_Resources/iOS/Assets.xcassets/Contents.json
new file mode 100644
index 0000000..da4a164
--- /dev/null
+++ b/example/app/App_Resources/iOS/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json
new file mode 100644
index 0000000..4414bad
--- /dev/null
+++ b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json
@@ -0,0 +1,158 @@
+{
+ "images" : [
+ {
+ "extent" : "full-screen",
+ "idiom" : "iphone",
+ "subtype" : "736h",
+ "filename" : "Default-736h@3x.png",
+ "minimum-system-version" : "8.0",
+ "orientation" : "portrait",
+ "scale" : "3x"
+ },
+ {
+ "extent" : "full-screen",
+ "idiom" : "iphone",
+ "subtype" : "736h",
+ "filename" : "Default-Landscape@3x.png",
+ "minimum-system-version" : "8.0",
+ "orientation" : "landscape",
+ "scale" : "3x"
+ },
+ {
+ "extent" : "full-screen",
+ "idiom" : "iphone",
+ "subtype" : "667h",
+ "filename" : "Default-667h@2x.png",
+ "minimum-system-version" : "8.0",
+ "orientation" : "portrait",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "iphone",
+ "filename" : "Default@2x.png",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "scale" : "2x"
+ },
+ {
+ "extent" : "full-screen",
+ "idiom" : "iphone",
+ "subtype" : "retina4",
+ "filename" : "Default-568h@2x.png",
+ "minimum-system-version" : "7.0",
+ "orientation" : "portrait",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "filename" : "Default-Portrait.png",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "filename" : "Default-Landscape.png",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "filename" : "Default-Portrait@2x.png",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "filename" : "Default-Landscape@2x.png",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "iphone",
+ "filename" : "Default.png",
+ "extent" : "full-screen",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "iphone",
+ "filename" : "Default@2x.png",
+ "extent" : "full-screen",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "iphone",
+ "filename" : "Default-568h@2x.png",
+ "extent" : "full-screen",
+ "subtype" : "retina4",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "extent" : "to-status-bar",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "filename" : "Default-Portrait.png",
+ "extent" : "full-screen",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "extent" : "to-status-bar",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "filename" : "Default-Landscape.png",
+ "extent" : "full-screen",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "extent" : "to-status-bar",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "filename" : "Default-Portrait@2x.png",
+ "extent" : "full-screen",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "extent" : "to-status-bar",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "filename" : "Default-Landscape@2x.png",
+ "extent" : "full-screen",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
new file mode 100644
index 0000000..d7f17fc
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
new file mode 100644
index 0000000..b884154
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
new file mode 100644
index 0000000..faab4b6
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
new file mode 100644
index 0000000..3365ba3
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
new file mode 100644
index 0000000..a44945c
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
new file mode 100644
index 0000000..e6dca62
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
new file mode 100644
index 0000000..1a50079
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
new file mode 100644
index 0000000..73d8b92
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
new file mode 100644
index 0000000..9f1f6ce
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
new file mode 100644
index 0000000..514fc5c
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json
new file mode 100644
index 0000000..4f4e9c5
--- /dev/null
+++ b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json
@@ -0,0 +1,22 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchScreen-AspectFill.png",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchScreen-AspectFill@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
new file mode 100644
index 0000000..c293f9c
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
new file mode 100644
index 0000000..233693a
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json
new file mode 100644
index 0000000..23c0ffd
--- /dev/null
+++ b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json
@@ -0,0 +1,22 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchScreen-Center.png",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchScreen-Center@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
new file mode 100644
index 0000000..a5a775a
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png differ
diff --git a/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
new file mode 100644
index 0000000..154c193
Binary files /dev/null and b/example/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png differ
diff --git a/example/app/App_Resources/iOS/Info.plist b/example/app/App_Resources/iOS/Info.plist
new file mode 100644
index 0000000..ea3e3ea
--- /dev/null
+++ b/example/app/App_Resources/iOS/Info.plist
@@ -0,0 +1,47 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleDisplayName
+ ${PRODUCT_NAME}
+ CFBundleExecutable
+ ${EXECUTABLE_NAME}
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ ${PRODUCT_NAME}
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIRequiresFullScreen
+
+ UIRequiredDeviceCapabilities
+
+ armv7
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/example/app/App_Resources/iOS/LaunchScreen.storyboard b/example/app/App_Resources/iOS/LaunchScreen.storyboard
new file mode 100644
index 0000000..2ad9471
--- /dev/null
+++ b/example/app/App_Resources/iOS/LaunchScreen.storyboard
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/app/App_Resources/iOS/build.xcconfig b/example/app/App_Resources/iOS/build.xcconfig
new file mode 100644
index 0000000..4b01184
--- /dev/null
+++ b/example/app/App_Resources/iOS/build.xcconfig
@@ -0,0 +1,7 @@
+// You can add custom settings here
+// for example you can uncomment the following line to force distribution code signing
+// CODE_SIGN_IDENTITY = iPhone Distribution
+// To build for device with Xcode 8 you need to specify your development team. More info: https://developer.apple.com/library/prerelease/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
+// DEVELOPMENT_TEAM = YOUR_TEAM_ID;
+ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
diff --git a/example/app/README.md b/example/app/README.md
new file mode 100644
index 0000000..9c4d225
--- /dev/null
+++ b/example/app/README.md
@@ -0,0 +1,24 @@
+# NativeScript TypeScript Template
+
+This template creates a NativeScript app with the NativeScript hello world example,
+however, in this template the example is built with TypeScript.
+
+You can create a new app that uses this template with either the `--template` option.
+
+```
+tns create my-app-name --template tns-template-hello-world-ts
+```
+
+Or the `--tsc` shorthand.
+
+```
+tns create my-app-name --tsc
+```
+
+> Note: Both commands will create a new NativeScript app that uses the latest version of this template published to [npm] (https://www.npmjs.com/package/tns-template-hello-world-ts).
+
+If you want to create a new app that uses the source of the template from the `master` branch, you can execute the following:
+
+```
+tns create my-app-name --template https://github.com/NativeScript/template-hello-world-ts.git#master
+```
diff --git a/example/app/app.css b/example/app/app.css
new file mode 100644
index 0000000..b1c0f42
--- /dev/null
+++ b/example/app/app.css
@@ -0,0 +1,20 @@
+/*
+In NativeScript, the app.css file is where you place CSS rules that
+you would like to apply to your entire application. Check out
+http://docs.nativescript.org/ui/styling for a full list of the CSS
+selectors and properties you can use to style UI components.
+
+/*
+For example, the following CSS rule changes the font size of all UI
+components that have the btn class name.
+*/
+.btn {
+ font-size: 18;
+}
+
+/*
+In many cases you may want to use the NativeScript core theme instead
+of writing your own CSS rules. For a full list of class names in the theme
+refer to http://docs.nativescript.org/ui/theme.
+*/
+@import 'nativescript-theme-core/css/core.light.css';
diff --git a/example/app/app.js b/example/app/app.js
new file mode 100644
index 0000000..1a5a466
--- /dev/null
+++ b/example/app/app.js
@@ -0,0 +1,5 @@
+"use strict";
+require("./bundle-config");
+var app = require('application');
+app.start({ moduleName: 'main-page' });
+//# sourceMappingURL=app.js.map
\ No newline at end of file
diff --git a/example/app/app.js.map b/example/app/app.js.map
new file mode 100644
index 0000000..393f269
--- /dev/null
+++ b/example/app/app.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,QAAO,iBAAiB,CAAC,CAAA;AACzB,IAAY,GAAG,WAAM,aAAa,CAAC,CAAA;AAEnC,GAAG,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC"}
\ No newline at end of file
diff --git a/example/app/app.ts b/example/app/app.ts
new file mode 100644
index 0000000..e76d0c5
--- /dev/null
+++ b/example/app/app.ts
@@ -0,0 +1,4 @@
+import "./bundle-config";
+import * as app from 'application';
+
+app.start({ moduleName: 'main-page' });
\ No newline at end of file
diff --git a/example/app/bundle-config.js b/example/app/bundle-config.js
new file mode 100644
index 0000000..018741b
--- /dev/null
+++ b/example/app/bundle-config.js
@@ -0,0 +1,7 @@
+if (global.TNS_WEBPACK) {
+ //registers tns-core-modules UI framework modules
+ require("bundle-entry-points");
+ //register application modules
+ global.registerModule("main-page", function () { return require("./main-page"); });
+}
+//# sourceMappingURL=bundle-config.js.map
\ No newline at end of file
diff --git a/example/app/bundle-config.js.map b/example/app/bundle-config.js.map
new file mode 100644
index 0000000..8cce0ee
--- /dev/null
+++ b/example/app/bundle-config.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"bundle-config.js","sourceRoot":"","sources":["bundle-config.ts"],"names":[],"mappings":"AAAA,EAAE,CAAC,CAAO,MAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5B,iDAAiD;IACjD,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAE/B,8BAA8B;IAC9B,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,cAAM,OAAA,OAAO,CAAC,aAAa,CAAC,EAAtB,CAAsB,CAAC,CAAC;AACrE,CAAC"}
\ No newline at end of file
diff --git a/example/app/bundle-config.ts b/example/app/bundle-config.ts
new file mode 100644
index 0000000..0b45bb5
--- /dev/null
+++ b/example/app/bundle-config.ts
@@ -0,0 +1,7 @@
+if ((global).TNS_WEBPACK) {
+ //registers tns-core-modules UI framework modules
+ require("bundle-entry-points");
+
+ //register application modules
+ global.registerModule("main-page", () => require("./main-page"));
+}
diff --git a/example/app/main-page.js b/example/app/main-page.js
new file mode 100644
index 0000000..5d1a932
--- /dev/null
+++ b/example/app/main-page.js
@@ -0,0 +1,40 @@
+"use strict";
+var nativescript_intl_1 = require("nativescript-intl");
+var observable_1 = require("data/observable");
+var model;
+function onNavigating(args) {
+ var page = args.object;
+ model = observable_1.fromObject({ "mediumDateTimeOptions": "", "longDateOptions": "", "fullDateOptions": "", "shortDateTimeOptions": "" });
+ page.bindingContext = model;
+}
+exports.onNavigating = onNavigating;
+function onTap() {
+ var mediumDateTimeOptions = {
+ "year": "numeric",
+ "month": "short",
+ "day": "numeric",
+ "hour": "numeric",
+ "minute": "2-digit",
+ "second": "numeric"
+ };
+ model.set("mediumDateTimeOptions", new nativescript_intl_1.DateTimeFormat("en-US", mediumDateTimeOptions).format(new Date()));
+ var longDateOptions = { "year": "numeric", "month": "long", "day": "numeric" };
+ model.set("longDateOptions", new nativescript_intl_1.DateTimeFormat("en-US", longDateOptions).format(new Date()));
+ var fullDateOptions = {
+ "year": "numeric",
+ "month": "long",
+ "day": "numeric",
+ "weekday": "long"
+ };
+ model.set("fullDateOptions", new nativescript_intl_1.DateTimeFormat("en-US", fullDateOptions).format(new Date()));
+ var shortDateTimeOptions = {
+ "year": "numeric",
+ "month": "numeric",
+ "day": "numeric",
+ "hour": "numeric",
+ "minute": "numeric"
+ };
+ model.set("shortDateTimeOptions", new nativescript_intl_1.DateTimeFormat("en-US", fullDateOptions).format(new Date()));
+}
+exports.onTap = onTap;
+//# sourceMappingURL=main-page.js.map
\ No newline at end of file
diff --git a/example/app/main-page.js.map b/example/app/main-page.js.map
new file mode 100644
index 0000000..07b78e4
--- /dev/null
+++ b/example/app/main-page.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"main-page.js","sourceRoot":"","sources":["main-page.ts"],"names":[],"mappings":";AAEA,kCAA+B,mBAAmB,CAAC,CAAA;AACnD,2BAAuC,iBAAiB,CAAC,CAAA;AAEzD,IAAI,KAAiB,CAAC;AAEtB,sBAA6B,IAAe;IACxC,IAAI,IAAI,GAAS,IAAI,CAAC,MAAM,CAAC;IAC7B,KAAK,GAAG,uBAAU,CAAC,EAAC,uBAAuB,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAC,CAAC,CAAC;IAC5H,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;AAChC,CAAC;AAJe,oBAAY,eAI3B,CAAA;AAED;IACI,IAAI,qBAAqB,GAAG;QACxB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;KACtB,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,kCAAc,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1G,IAAI,eAAe,GAAG,EAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC;IAC7E,KAAK,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,kCAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9F,IAAI,eAAe,GAAG;QAClB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,MAAM;KACpB,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,kCAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9F,IAAI,oBAAoB,GAAG;QACvB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,SAAS;KACtB,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,kCAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;AACvG,CAAC;AA3Be,aAAK,QA2BpB,CAAA"}
\ No newline at end of file
diff --git a/example/app/main-page.ts b/example/app/main-page.ts
new file mode 100644
index 0000000..5a3bc17
--- /dev/null
+++ b/example/app/main-page.ts
@@ -0,0 +1,41 @@
+import { EventData } from "data/observable";
+import { Page } from "ui/page";
+import { DateTimeFormat } from "nativescript-intl";
+import { fromObject, Observable } from "data/observable";
+
+var model: Observable;
+
+export function onNavigating(args: EventData) {
+ let page = args.object;
+ model = fromObject({"mediumDateTimeOptions": "", "longDateOptions": "", "fullDateOptions": "", "shortDateTimeOptions": ""});
+ page.bindingContext = model;
+}
+
+export function onTap() {
+ var mediumDateTimeOptions = {
+ "year": "numeric",
+ "month": "short",
+ "day": "numeric",
+ "hour": "numeric",
+ "minute": "2-digit",
+ "second": "numeric"
+ };
+ model.set("mediumDateTimeOptions", new DateTimeFormat("en-US", mediumDateTimeOptions).format(new Date()));
+ var longDateOptions = {"year": "numeric", "month": "long", "day": "numeric"};
+ model.set("longDateOptions", new DateTimeFormat("en-US", longDateOptions).format(new Date()));
+ var fullDateOptions = {
+ "year": "numeric",
+ "month": "long",
+ "day": "numeric",
+ "weekday": "long"
+ };
+ model.set("fullDateOptions", new DateTimeFormat("en-US", fullDateOptions).format(new Date()));
+ var shortDateTimeOptions = {
+ "year": "numeric",
+ "month": "numeric",
+ "day": "numeric",
+ "hour": "numeric",
+ "minute": "numeric"
+ };
+ model.set("shortDateTimeOptions", new DateTimeFormat("en-US", fullDateOptions).format(new Date()));
+}
\ No newline at end of file
diff --git a/example/app/main-page.xml b/example/app/main-page.xml
new file mode 100644
index 0000000..505e9ea
--- /dev/null
+++ b/example/app/main-page.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/app/package.json b/example/app/package.json
new file mode 100644
index 0000000..22a4583
--- /dev/null
+++ b/example/app/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "tns-template-hello-world-ts",
+ "main": "app.js",
+ "version": "2.4.0",
+ "author": "Telerik ",
+ "description": "Nativescript hello-world-ts project template",
+ "license": "Apache-2.0",
+ "keywords": [
+ "telerik",
+ "mobile",
+ "nativescript",
+ "{N}",
+ "tns",
+ "appbuilder",
+ "template"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:NativeScript/template-hello-world-ts.git"
+ },
+ "bugs": {
+ "url": "https://github.com/NativeScript/template-hello-world-ts/issues"
+ },
+ "homepage": "https://github.com/NativeScript/template-hello-world-ts",
+ "android": {
+ "v8Flags": "--expose_gc"
+ },
+ "dependencies": {
+ "nativescript-theme-core": "^0.2.1"
+ },
+ "devDependencies": {
+ "nativescript-dev-typescript": "^0.3.2",
+ "nativescript-dev-android-snapshot": "^0.*.*"
+ }
+}
diff --git a/example/hooks/after-prepare/nativescript-dev-android-snapshot.js b/example/hooks/after-prepare/nativescript-dev-android-snapshot.js
new file mode 100644
index 0000000..f494411
--- /dev/null
+++ b/example/hooks/after-prepare/nativescript-dev-android-snapshot.js
@@ -0,0 +1 @@
+module.exports = require("nativescript-dev-android-snapshot/hooks/after-prepare-hook.js");
diff --git a/example/hooks/before-prepare/nativescript-dev-android-snapshot.js b/example/hooks/before-prepare/nativescript-dev-android-snapshot.js
new file mode 100644
index 0000000..f693b74
--- /dev/null
+++ b/example/hooks/before-prepare/nativescript-dev-android-snapshot.js
@@ -0,0 +1 @@
+module.exports = require("nativescript-dev-android-snapshot/hooks/before-prepare-hook.js");
diff --git a/example/hooks/before-prepare/nativescript-dev-typescript.js b/example/hooks/before-prepare/nativescript-dev-typescript.js
new file mode 100644
index 0000000..7116ebd
--- /dev/null
+++ b/example/hooks/before-prepare/nativescript-dev-typescript.js
@@ -0,0 +1 @@
+module.exports = require("nativescript-dev-typescript/lib/before-prepare.js");
diff --git a/example/hooks/before-watch/nativescript-dev-typescript.js b/example/hooks/before-watch/nativescript-dev-typescript.js
new file mode 100644
index 0000000..9a6ef66
--- /dev/null
+++ b/example/hooks/before-watch/nativescript-dev-typescript.js
@@ -0,0 +1 @@
+module.exports = require("nativescript-dev-typescript/lib/watch.js");
diff --git a/example/package.json b/example/package.json
new file mode 100644
index 0000000..8652565
--- /dev/null
+++ b/example/package.json
@@ -0,0 +1,26 @@
+{
+ "description": "NativeScript Application",
+ "license": "SEE LICENSE IN ",
+ "readme": "NativeScript Application",
+ "repository": "",
+ "nativescript": {
+ "id": "org.nativescript.example",
+ "tns-android": {
+ "version": "2.4.0"
+ }
+ },
+ "dependencies": {
+ "nativescript-theme-core": "^0.2.1",
+ "tns-core-modules": "2.4.0",
+ "nativescript-intl": "file:..\\dist\\nativescript-intl-0.0.5.tgz"
+ },
+ "devDependencies": {
+ "babel-traverse": "6.19.0",
+ "babel-types": "6.19.0",
+ "babylon": "6.14.1",
+ "lazy": "1.0.11",
+ "nativescript-dev-android-snapshot": "^0.*.*",
+ "nativescript-dev-typescript": "^0.3.2",
+ "typescript": "^2.0.10"
+ }
+}
\ No newline at end of file
diff --git a/example/references.d.ts b/example/references.d.ts
new file mode 100644
index 0000000..b14f383
--- /dev/null
+++ b/example/references.d.ts
@@ -0,0 +1 @@
+/// Needed for autocompletion and compilation.
\ No newline at end of file
diff --git a/example/tsconfig.json b/example/tsconfig.json
new file mode 100644
index 0000000..0ec5889
--- /dev/null
+++ b/example/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true,
+ "noEmitHelpers": true,
+ "noEmitOnError": true
+ },
+ "exclude": [
+ "node_modules",
+ "platforms"
+ ]
+}
\ No newline at end of file
diff --git a/src/index.d.ts b/src/index.d.ts
index 8276673..d5c2924 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -1 +1 @@
-export * from "./intl";
+export * from "./nativescript-intl-common";
diff --git a/src/intl.d.ts b/src/intl.d.ts
deleted file mode 100644
index d8d56f8..0000000
--- a/src/intl.d.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-export interface DateTimeFormatOptions {
- weekday?: string;
- era?: string;
- year?: string;
- month?: string;
- day?: string;
- hour?: string;
- minute?: string;
- second?: string;
- timeZoneName?: string;
- hour12?: boolean;
-}
-
-export interface DateTimeFormat {
- format(date?: Date | number): string;
-}
-
-export interface NumberFormatOptions {
- style?: string;
- currency?: string;
- currencyDisplay?: string;
- useGrouping?: boolean;
- minimumIntegerDigits?: number;
- minimumFractionDigits?: number;
- maximumFractionDigits?: number;
-}
-
-export interface NumberFormat {
- format(value: number): string;
-}
diff --git a/src/nativescript-intl-common.d.ts b/src/nativescript-intl-common.d.ts
new file mode 100644
index 0000000..c4cff31
--- /dev/null
+++ b/src/nativescript-intl-common.d.ts
@@ -0,0 +1,35 @@
+export declare var NUMERIC: string;
+export declare var LONG: string;
+export declare var SHORT: string;
+export declare var TWODIGIT: string;
+export declare var FULL: string;
+export declare class DateTimeFormat {
+ private locale;
+ private options;
+ private pattern;
+ constructor(locale?: string, options?: Intl.DateTimeFormatOptions, pattern?: string);
+ private hasTimeOptions(options);
+ private hasDateOptions(options);
+ private useFullDatePattern(intlOptions);
+ getNativePattern(patternDefinition: {
+ date?: string;
+ time?: string;
+ }, locale?: string): string;
+ private getCorrectPatternForLocale();
+ private dateTimeFormatElements;
+ private getDateElementsFromPattern(pattern);
+ private prepareDateElement(intlOption, dateElement);
+ private preparePattern(pattern, options);
+ formatNative(pattern: string, locale?: string, date?: Date): string;
+ private _preparedPattern;
+ readonly preparedPattern: string;
+ format(date?: Date): string;
+}
+export declare class NumberFormat {
+ private locale;
+ private options;
+ private pattern;
+ constructor(locale?: string, options?: Intl.NumberFormatOptions, pattern?: string);
+ formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string): string;
+ format(value: number): string;
+}
diff --git a/src/nativescript-intl-common.js b/src/nativescript-intl-common.js
new file mode 100644
index 0000000..34a3e6e
--- /dev/null
+++ b/src/nativescript-intl-common.js
@@ -0,0 +1,221 @@
+"use strict";
+exports.NUMERIC = "numeric";
+exports.LONG = "long";
+exports.SHORT = "short";
+exports.TWODIGIT = "2-digit";
+exports.FULL = "full";
+var DateTimeFormat = (function () {
+ function DateTimeFormat(locale, options, pattern) {
+ this.locale = locale;
+ this.options = options;
+ this.pattern = pattern;
+ this.dateTimeFormatElements = {
+ "M": "month",
+ "E": "weekday",
+ "c": "weekday",
+ "d": "day",
+ "y": "year",
+ "h": "hour",
+ "H": "hour",
+ "m": "minute",
+ "s": "second",
+ "z": "timeZoneName",
+ "G": "era",
+ "a": "hour12"
+ };
+ if (options && options.minute === exports.NUMERIC) {
+ this.options.minute = exports.TWODIGIT;
+ }
+ if (options && options.hour === exports.NUMERIC) {
+ this.options.hour = exports.TWODIGIT;
+ }
+ }
+ DateTimeFormat.prototype.hasTimeOptions = function (options) {
+ return options.hour !== undefined || options.minute !== undefined || options.second !== undefined;
+ };
+ DateTimeFormat.prototype.hasDateOptions = function (options) {
+ return options.weekday !== undefined || options.year !== undefined || options.month !== undefined || options.day !== undefined;
+ };
+ DateTimeFormat.prototype.useFullDatePattern = function (intlOptions) {
+ var i;
+ var propsArray = Object.keys(intlOptions);
+ var propsArrayLength = propsArray.length;
+ var result = false;
+ for (i = 0; i < propsArrayLength; i++) {
+ if (intlOptions[propsArray[i]] === exports.LONG || intlOptions[propsArray[i]] === exports.SHORT) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ };
+ DateTimeFormat.prototype.getNativePattern = function (patternDefinition, locale) {
+ return "";
+ };
+ DateTimeFormat.prototype.getCorrectPatternForLocale = function () {
+ var dateTimePatternOptions = {};
+ if (this.hasDateOptions(this.options)) {
+ if (this.useFullDatePattern(this.options)) {
+ dateTimePatternOptions.date = exports.FULL;
+ }
+ else {
+ dateTimePatternOptions.date = exports.SHORT;
+ }
+ }
+ if (this.hasTimeOptions(this.options)) {
+ dateTimePatternOptions.time = exports.FULL;
+ }
+ var result = this.getNativePattern(dateTimePatternOptions, this.locale);
+ console.log("nativePattern: " + result);
+ if (this.options.hour) {
+ if (this.options.hour12 !== undefined) {
+ result = this.options.hour12 ? result.replace(/H/g, "h") : result.replace(/h/g, "H");
+ }
+ else {
+ this.options.hour12 = !(result.indexOf("H") > -1);
+ }
+ }
+ return result;
+ };
+ DateTimeFormat.prototype.getDateElementsFromPattern = function (pattern) {
+ var result = [];
+ var patternLength = pattern.length;
+ var i = 0;
+ var stringInsidePattern = false;
+ while (i < patternLength) {
+ if (pattern[i] === '"' || pattern[i] === "'") {
+ var p = i + 1;
+ while (p < patternLength && pattern[i] !== pattern[p]) {
+ p++;
+ }
+ for (var j = i; j < p + 1; j++) {
+ result.push({
+ "isDateElement": false,
+ "patternValue": pattern[j]
+ });
+ }
+ i = p + 1;
+ continue;
+ }
+ if (this.dateTimeFormatElements.hasOwnProperty(pattern[i])) {
+ var j = i;
+ while (i < patternLength && pattern[i] === pattern[j]) {
+ i++;
+ }
+ result.push({
+ "isDateElement": true,
+ "patternValue": pattern.substr(j, i - j),
+ "intlOption": this.dateTimeFormatElements[pattern[j]]
+ });
+ }
+ else {
+ result.push({
+ "isDateElement": false,
+ "patternValue": pattern[i]
+ });
+ i++;
+ }
+ }
+ return result;
+ };
+ DateTimeFormat.prototype.prepareDateElement = function (intlOption, dateElement) {
+ switch (intlOption) {
+ case exports.NUMERIC:
+ return dateElement;
+ case exports.TWODIGIT:
+ return dateElement.repeat(2);
+ case exports.SHORT:
+ return dateElement.repeat(3);
+ case exports.LONG:
+ return dateElement.repeat(4);
+ case true:
+ return dateElement;
+ case false:
+ return "";
+ default:
+ return dateElement;
+ }
+ };
+ DateTimeFormat.prototype.preparePattern = function (pattern, options) {
+ console.log("preparePattern input - " + pattern);
+ var patternOptions = this.getDateElementsFromPattern(pattern);
+ var patternOptionsLength = patternOptions.length;
+ for (var i_1 = 0; i_1 < patternOptionsLength; i_1++) {
+ if (patternOptions[i_1].isDateElement) {
+ var formatChar = patternOptions[i_1].patternValue[0];
+ var intlOptionValue = options[patternOptions[i_1].intlOption];
+ if (intlOptionValue !== undefined) {
+ var newPatternValue = this.prepareDateElement(intlOptionValue, formatChar);
+ patternOptions[i_1].patternValue = newPatternValue;
+ }
+ else {
+ if (i_1 > 0) {
+ var j = i_1 - 1;
+ while (patternOptions[j] && patternOptions[j].isDateElement === false) {
+ if (patternOptions[j].patternValue !== " ") {
+ if (patternOptions[j].patternValue !== '"' && patternOptions[j].patternValue !== "'") {
+ patternOptions[j].patternValue = "";
+ }
+ break;
+ }
+ else {
+ patternOptions[j].patternValue = "";
+ }
+ j--;
+ }
+ }
+ patternOptions[i_1].patternValue = "";
+ }
+ }
+ }
+ var result = [];
+ var i = 0;
+ while (patternOptions[i].patternValue === "" || patternOptions[i].isDateElement === false) {
+ i++;
+ }
+ for (i; i < patternOptionsLength; i++) {
+ result.push(patternOptions[i].patternValue);
+ }
+ console.log("preparePattern output - " + result.join(""));
+ return result.join("");
+ };
+ DateTimeFormat.prototype.formatNative = function (pattern, locale, date) {
+ return "";
+ };
+ Object.defineProperty(DateTimeFormat.prototype, "preparedPattern", {
+ get: function () {
+ if (!this._preparedPattern) {
+ if (this.pattern) {
+ this._preparedPattern = this.pattern;
+ }
+ else {
+ this._preparedPattern = this.preparePattern(this.getCorrectPatternForLocale(), this.options);
+ }
+ }
+ console.log("preparedPattern: " + this._preparedPattern);
+ return this._preparedPattern;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ DateTimeFormat.prototype.format = function (date) {
+ return this.formatNative(this.preparedPattern, this.locale, date);
+ };
+ return DateTimeFormat;
+}());
+exports.DateTimeFormat = DateTimeFormat;
+var NumberFormat = (function () {
+ function NumberFormat(locale, options, pattern) {
+ this.locale = locale;
+ this.options = options;
+ this.pattern = pattern;
+ }
+ NumberFormat.prototype.formatNative = function (value, locale, options, pattern) {
+ return "";
+ };
+ NumberFormat.prototype.format = function (value) {
+ return this.formatNative(value, this.locale, this.options, this.pattern);
+ };
+ return NumberFormat;
+}());
+exports.NumberFormat = NumberFormat;
diff --git a/src/nativescript-intl-common.ts b/src/nativescript-intl-common.ts
index c67860d..a633a1a 100644
--- a/src/nativescript-intl-common.ts
+++ b/src/nativescript-intl-common.ts
@@ -1,12 +1,10 @@
-import * as Intl from "./intl";
+export var NUMERIC = "numeric";
+export var LONG = "long";
+export var SHORT = "short";
+export var TWODIGIT = "2-digit";
+export var FULL = "full";
-export var NUMERIC = 'numeric';
-export var LONG = 'long';
-export var SHORT = 'short';
-export var TWODIGIT = '2-digit';
-export var FULL = 'full';
-
-export class DateTimeFormat implements Intl.DateTimeFormat {
+export class DateTimeFormat {
constructor(private locale?: string, private options?: Intl.DateTimeFormatOptions, private pattern?: string) {
if (options && options.minute === NUMERIC) {
this.options.minute = TWODIGIT;
@@ -39,7 +37,7 @@ export class DateTimeFormat implements Intl.DateTimeFormat {
}
public getNativePattern(patternDefinition: {date?: string, time?: string}, locale?: string): string {
- return '';
+ return "";
}
private getCorrectPatternForLocale(): string {
@@ -57,28 +55,28 @@ export class DateTimeFormat implements Intl.DateTimeFormat {
}
let result = this.getNativePattern(dateTimePatternOptions, this.locale);
if (this.options.hour) {
- if (result.indexOf('H') > -1) {
- this.options.hour12 = false;
+ if (this.options.hour12 !== undefined) {
+ result = this.options.hour12 ? result.replace(/H/g, "h") : result.replace(/h/g, "H");
} else {
- this.options.hour12 = true;
+ this.options.hour12 = !(result.indexOf("H") > -1);
}
}
return result;
}
private dateTimeFormatElements = {
- 'M': 'month',
- 'E': 'weekday',
- 'c': 'weekday',
- 'd': 'day',
- 'y': 'year',
- 'h': 'hour',
- 'H': 'hour',
- 'm': 'minute',
- 's': 'second',
- 'z': 'timeZoneName',
- 'G': 'era',
- 'a': 'hour12'
+ "M": "month",
+ "E": "weekday",
+ "c": "weekday",
+ "d": "day",
+ "y": "year",
+ "h": "hour",
+ "H": "hour",
+ "m": "minute",
+ "s": "second",
+ "z": "timeZoneName",
+ "G": "era",
+ "a": "hour12"
};
// isDateElement (boolean), patternValue - dateElement content, intlOption - corresponding Intl option name
@@ -137,7 +135,7 @@ export class DateTimeFormat implements Intl.DateTimeFormat {
case true:
return dateElement;
case false:
- return '';
+ return "";
default:
return dateElement;
}
@@ -158,33 +156,33 @@ export class DateTimeFormat implements Intl.DateTimeFormat {
if (i > 0) {
let j = i - 1;
while (patternOptions[j] && patternOptions[j].isDateElement === false) {
- if (patternOptions[j].patternValue !== ' ') {
+ if (patternOptions[j].patternValue !== " ") {
if (patternOptions[j].patternValue !== '"' && patternOptions[j].patternValue !== "'") {
- patternOptions[j].patternValue = '';
+ patternOptions[j].patternValue = "";
}
break;
} else {
- patternOptions[j].patternValue = '';
+ patternOptions[j].patternValue = "";
}
j--;
}
}
- patternOptions[i].patternValue = '';
+ patternOptions[i].patternValue = "";
}
}
}
let result = [];
let i = 0;
// remove leading delimiters
- while(patternOptions[i].patternValue === '' || patternOptions[i].isDateElement === false) {i++;}
+ while(patternOptions[i].patternValue === "" || patternOptions[i].isDateElement === false) {i++;}
for(i; i < patternOptionsLength; i++) {
result.push(patternOptions[i].patternValue);
}
- return result.join('');
+ return result.join("");
}
public formatNative(pattern: string, locale?: string, date?: Date): string {
- return '';
+ return "";
}
private _preparedPattern: string;
@@ -204,11 +202,11 @@ export class DateTimeFormat implements Intl.DateTimeFormat {
}
}
-export class NumberFormat implements Intl.NumberFormat {
+export class NumberFormat {
constructor(private locale?: string, private options?: Intl.NumberFormatOptions, private pattern?: string) { }
public formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string): string {
- return '';
+ return "";
}
public format(value: number) {
diff --git a/src/nativescript-intl.android.d.ts b/src/nativescript-intl.android.d.ts
new file mode 100644
index 0000000..5f3905c
--- /dev/null
+++ b/src/nativescript-intl.android.d.ts
@@ -0,0 +1,11 @@
+import common = require("./nativescript-intl-common");
+export declare class DateTimeFormat extends common.DateTimeFormat {
+ getNativePattern(patternDefinition: {
+ date?: string;
+ time?: string;
+ }, locale?: string): string;
+ formatNative(pattern: string, locale?: string, date?: Date): string;
+}
+export declare class NumberFormat extends common.NumberFormat {
+ formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string): any;
+}
diff --git a/src/nativescript-intl.android.js b/src/nativescript-intl.android.js
new file mode 100644
index 0000000..16a2b8c
--- /dev/null
+++ b/src/nativescript-intl.android.js
@@ -0,0 +1,161 @@
+"use strict";
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var common = require("./nativescript-intl-common");
+var localesCache = new Map();
+function getNativeLocale(locale) {
+ if (localesCache.has(locale)) {
+ return localesCache.get(locale);
+ }
+ var result;
+ if (locale) {
+ locale = locale.replace(/_/g, '-');
+ var firstHypenIndex = locale.indexOf('-');
+ var lang = '';
+ var country = '';
+ if (firstHypenIndex > -1) {
+ lang = locale.substr(0, firstHypenIndex);
+ var nextHypenIndex = locale.substr(firstHypenIndex + 1).indexOf('-');
+ country = locale.substr(firstHypenIndex + 1, (nextHypenIndex > -1) ? nextHypenIndex : undefined);
+ }
+ else {
+ lang = locale;
+ }
+ if (country !== '') {
+ result = new java.util.Locale(lang, country);
+ }
+ else {
+ result = new java.util.Locale(lang);
+ }
+ }
+ else {
+ result = new java.util.Locale('en', 'US');
+ }
+ localesCache.set(locale, result);
+ return result;
+}
+var DateTimeFormat = (function (_super) {
+ __extends(DateTimeFormat, _super);
+ function DateTimeFormat() {
+ _super.apply(this, arguments);
+ }
+ DateTimeFormat.prototype.getNativePattern = function (patternDefinition, locale) {
+ var result = '';
+ var flag = 0;
+ var nativeLocale;
+ if (locale) {
+ nativeLocale = getNativeLocale(locale);
+ flag++;
+ }
+ if (patternDefinition.date) {
+ flag = flag + 2;
+ }
+ if (patternDefinition.time) {
+ flag = flag + 4;
+ }
+ var dateFormat;
+ switch (flag) {
+ case 0:
+ dateFormat = java.text.DateFormat.getDateTimeInstance();
+ break;
+ case 1:
+ dateFormat = java.text.DateFormat.getDateTimeInstance(0, 0, nativeLocale);
+ break;
+ case 2:
+ dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === common.FULL ? 0 : 3);
+ break;
+ case 3:
+ dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === common.FULL ? 0 : 3, nativeLocale);
+ break;
+ case 4:
+ dateFormat = java.text.DateFormat.getTimeInstance(1);
+ break;
+ case 5:
+ dateFormat = java.text.DateFormat.getTimeInstance(1, nativeLocale);
+ break;
+ case 6:
+ dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === common.FULL ? 0 : 3, 1);
+ break;
+ case 7:
+ dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === common.FULL ? 0 : 3, 1, nativeLocale);
+ break;
+ default:
+ break;
+ }
+ result = dateFormat.toPattern();
+ return result;
+ };
+ DateTimeFormat.prototype.formatNative = function (pattern, locale, date) {
+ var sdf = locale ? new java.text.SimpleDateFormat(pattern, getNativeLocale(locale)) : new java.text.SimpleDateFormat(pattern);
+ return sdf.format(date ? new java.util.Date(date.valueOf()) : new java.util.Date()).toString();
+ };
+ return DateTimeFormat;
+}(common.DateTimeFormat));
+exports.DateTimeFormat = DateTimeFormat;
+var NumberFormat = (function (_super) {
+ __extends(NumberFormat, _super);
+ function NumberFormat() {
+ _super.apply(this, arguments);
+ }
+ NumberFormat.prototype.formatNative = function (value, locale, options, pattern) {
+ var numberFormat;
+ if (pattern) {
+ numberFormat = new java.text.DecimalFormat(pattern);
+ }
+ else {
+ if (options) {
+ switch (options.style.toLowerCase()) {
+ case 'decimal':
+ numberFormat = java.text.NumberFormat.getNumberInstance(getNativeLocale(locale));
+ break;
+ case 'percent':
+ numberFormat = java.text.NumberFormat.getPercentInstance(getNativeLocale(locale));
+ break;
+ case 'currency':
+ numberFormat = java.text.NumberFormat.getCurrencyInstance(getNativeLocale(locale));
+ if (options.currency !== void 0) {
+ numberFormat.setCurrency(java.util.Currency.getInstance(options.currency));
+ }
+ break;
+ default:
+ numberFormat = java.text.NumberFormat.getNumberInstance(getNativeLocale(locale));
+ break;
+ }
+ }
+ else {
+ numberFormat = java.text.NumberFormat.getNumberInstance(getNativeLocale(locale));
+ }
+ }
+ if (options && options.minimumIntegerDigits !== void 0) {
+ numberFormat.setMinimumIntegerDigits(options.minimumIntegerDigits);
+ }
+ if (options && options.minimumFractionDigits !== void 0) {
+ numberFormat.setMinimumFractionDigits(options.minimumFractionDigits);
+ }
+ if (options && options.maximumFractionDigits !== void 0) {
+ numberFormat.setMaximumFractionDigits(options.maximumFractionDigits);
+ }
+ if (options && options.useGrouping !== void 0) {
+ numberFormat.setGroupingUsed(options.useGrouping);
+ }
+ var decimalFormatSymbols = locale ? new java.text.DecimalFormatSymbols(getNativeLocale(locale)) : new java.text.DecimalFormatSymbols();
+ numberFormat.setDecimalFormatSymbols(decimalFormatSymbols);
+ if (options && (options.style.toLowerCase() === 'currency' && options.currencyDisplay === 'code')) {
+ if (!pattern) {
+ var currrentPattern = numberFormat.toPattern();
+ currrentPattern = currrentPattern.replace('¤', '¤¤');
+ numberFormat = new java.text.DecimalFormat(currrentPattern);
+ numberFormat.setDecimalFormatSymbols(decimalFormatSymbols);
+ }
+ if (options.currency !== void 0) {
+ decimalFormatSymbols.setCurrency(java.util.Currency.getInstance(options.currency));
+ }
+ }
+ return numberFormat.format(value);
+ };
+ return NumberFormat;
+}(common.NumberFormat));
+exports.NumberFormat = NumberFormat;
diff --git a/src/nativescript-intl.android.ts b/src/nativescript-intl.android.ts
index b1572d1..9f26bac 100644
--- a/src/nativescript-intl.android.ts
+++ b/src/nativescript-intl.android.ts
@@ -1,5 +1,4 @@
import common = require("./nativescript-intl-common");
-import * as Intl from "./intl";
var localesCache: Map = new Map();
diff --git a/src/nativescript-intl.ios.d.ts b/src/nativescript-intl.ios.d.ts
new file mode 100644
index 0000000..d2babf6
--- /dev/null
+++ b/src/nativescript-intl.ios.d.ts
@@ -0,0 +1,11 @@
+import common = require("./nativescript-intl-common");
+export declare class DateTimeFormat extends common.DateTimeFormat {
+ getNativePattern(patternDefinition: {
+ date?: string;
+ time?: string;
+ }, locale?: string): string;
+ formatNative(pattern: string, locale?: string, date?: Date): string;
+}
+export declare class NumberFormat extends common.NumberFormat {
+ formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string): string;
+}
diff --git a/src/nativescript-intl.ios.js b/src/nativescript-intl.ios.js
new file mode 100644
index 0000000..92991da
--- /dev/null
+++ b/src/nativescript-intl.ios.js
@@ -0,0 +1,95 @@
+"use strict";
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var common = require("./nativescript-intl-common");
+var DateTimeFormat = (function (_super) {
+ __extends(DateTimeFormat, _super);
+ function DateTimeFormat() {
+ _super.apply(this, arguments);
+ }
+ DateTimeFormat.prototype.getNativePattern = function (patternDefinition, locale) {
+ var dateFormatter = NSDateFormatter.new();
+ if (locale) {
+ dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale);
+ }
+ if (patternDefinition.date) {
+ dateFormatter.dateStyle = patternDefinition.date === common.FULL ? NSDateFormatterStyle.NSDateFormatterFullStyle : NSDateFormatterStyle.NSDateFormatterShortStyle;
+ }
+ if (patternDefinition.time) {
+ dateFormatter.timeStyle = NSDateFormatterStyle.NSDateFormatterLongStyle;
+ }
+ return dateFormatter.dateFormat;
+ };
+ DateTimeFormat.prototype.formatNative = function (pattern, locale, date) {
+ var dateFormatter = NSDateFormatter.new();
+ if (locale) {
+ dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale);
+ }
+ dateFormatter.dateFormat = pattern;
+ return dateFormatter.stringFromDate(date ? NSDate.dateWithTimeIntervalSince1970(date.valueOf() / 1000) : NSDate.new());
+ };
+ return DateTimeFormat;
+}(common.DateTimeFormat));
+exports.DateTimeFormat = DateTimeFormat;
+var NumberFormat = (function (_super) {
+ __extends(NumberFormat, _super);
+ function NumberFormat() {
+ _super.apply(this, arguments);
+ }
+ NumberFormat.prototype.formatNative = function (value, locale, options, pattern) {
+ var numberFormat = NSNumberFormatter.new();
+ if (locale) {
+ numberFormat.locale = NSLocale.alloc().initWithLocaleIdentifier(locale);
+ }
+ if (options) {
+ switch (options.style.toLowerCase()) {
+ case 'decimal':
+ numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle;
+ break;
+ case 'percent':
+ numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterPercentStyle;
+ break;
+ case 'currency':
+ numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterCurrencyStyle;
+ if (options.currency !== void 0) {
+ numberFormat.currencyCode = options.currency;
+ }
+ break;
+ default:
+ numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle;
+ break;
+ }
+ }
+ else {
+ numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle;
+ }
+ if (options && options.minimumIntegerDigits !== void 0) {
+ numberFormat.minimumIntegerDigits = options.minimumIntegerDigits;
+ }
+ if (options && options.minimumFractionDigits !== void 0) {
+ numberFormat.minimumFractionDigits = options.minimumFractionDigits;
+ }
+ if (options && options.maximumFractionDigits !== void 0) {
+ numberFormat.maximumFractionDigits = options.maximumFractionDigits;
+ }
+ if (options && options.useGrouping !== void 0) {
+ numberFormat.usesGroupingSeparator = options.useGrouping;
+ }
+ if (pattern) {
+ numberFormat.positiveFormat = pattern;
+ }
+ else {
+ if (options && (options.style.toLowerCase() === 'currency' && options.currencyDisplay === 'code')) {
+ var pattern_1 = numberFormat.positiveFormat;
+ pattern_1 = pattern_1.replace('¤', '¤¤');
+ numberFormat.positiveFormat = pattern_1;
+ }
+ }
+ return numberFormat.stringFromNumber(NSNumber.alloc().initWithDouble(value));
+ };
+ return NumberFormat;
+}(common.NumberFormat));
+exports.NumberFormat = NumberFormat;
diff --git a/src/nativescript-intl.ios.ts b/src/nativescript-intl.ios.ts
index 19067eb..7b006ca 100644
--- a/src/nativescript-intl.ios.ts
+++ b/src/nativescript-intl.ios.ts
@@ -1,5 +1,4 @@
import common = require("./nativescript-intl-common");
-import * as Intl from "./intl";
export class DateTimeFormat extends common.DateTimeFormat {
public getNativePattern(patternDefinition: {date?: string, time?: string}, locale?: string): string {
diff --git a/src/package.json b/src/package.json
index d978d32..3d7451d 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,6 +1,6 @@
{
"name": "nativescript-intl",
- "version": "0.0.4",
+ "version": "0.0.5",
"description": "Provides API for using Native date, time and number formatting with an API similar to Intl.js",
"main": "nativescript-intl",
"nativescript": {
diff --git a/src/tsconfig.json b/src/tsconfig.json
index 8227147..df4c3b4 100644
--- a/src/tsconfig.json
+++ b/src/tsconfig.json
@@ -6,7 +6,7 @@
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": false,
- "declaration": false,
+ "declaration": true,
"noLib": false
},
"filesGlob": [
diff --git a/tests/app/tests/example.js b/tests/app/tests/example.js
index c911421..080b746 100644
--- a/tests/app/tests/example.js
+++ b/tests/app/tests/example.js
@@ -2,6 +2,7 @@ var intl = require("nativescript-intl");
var platform = require("platform");
var locales = [
+ "en-US",
"de-AT",
"nl-BE",
"fr-BE",
@@ -33,11 +34,11 @@ var locales = [
"tr-TR",
"uk-UA",
"en-GB",
- "en-US",
"no-NO"
];
var longDateResults = [
+ "March 21, 2016",
"21. März 2016",
"21 maart 2016",
"21 mars 2016",
@@ -69,11 +70,11 @@ var longDateResults = [
"21 Mart 2016",
"21 березня 2016 р.",
"21 March 2016",
- "March 21, 2016",
"21. mars 2016"
];
var mediumDateTimeResultsAndroid = [
+ "Mar 22, 2016 09:40:39 AM", //Mar 22, 2016, 9:40:39 AM
"22. März 2016 09:40:39", //22. März 2016, 09:40:39
"22 mrt. 2016 09:40:39",
"22 mars 2016 09:40:39",
@@ -105,11 +106,11 @@ var mediumDateTimeResultsAndroid = [
"22 Mar 2016 09:40:39",
"22 бер. 2016 р. 09:40:39", //22 бер. 2016 09:40:39
"22 Mar 2016 09:40:39", //22 Mar 2016, 09:40:39
- "Mar 22, 2016 09:40:39 AM", //Mar 22, 2016, 9:40:39 AM
"22. mar. 2016 09.40.39" //22. mar. 2016, 09.40.39
];
var mediumDateTimeResultsIOS = [
+ "Mar 22, 2016 at 09:40:39 AM", //Mar 22, 2016, 9:40:39 AM
"22. März 2016 um 09:40:39", //22. März 2016, 09:40:39
"22 mrt. 2016 09:40:39",
"22 mars 2016 09:40:39",
@@ -141,11 +142,11 @@ var mediumDateTimeResultsIOS = [
"22 Mar 2016 09:40:39",
"22 бер. 2016 р. 09:40:39", //22 бер. 2016 09:40:39
"22 Mar 2016 at 09:40:39", //22 Mar 2016, 09:40:39
- "Mar 22, 2016 at 09:40:39 AM", //Mar 22, 2016, 9:40:39 AM
"22. mar. 2016 09.40.39" //22. mar. 2016, 09.40.39
];
var shortDateTimeResultsAndroid = [
+ "3/22/2016 11:06 AM", //3/22/2016, 11:06 AM
"22.3.2016 11:06", //22.3.2016, 11:06
"22/3/2016 11:06", //22-3-2016 11:06
"22/3/2016 11:06",
@@ -177,11 +178,11 @@ var shortDateTimeResultsAndroid = [
"22 3 2016 11:06", //22.03.2016 11:06
"22.3.2016 11:06", //22.03.2016 11:06
"22/3/2016 11:06", //22/03/2016, 11:06
- "3/22/2016 11:06 AM", //3/22/2016, 11:06 AM
"22.3.2016 11.06" //22.3.2016, 11.06
];
var shortDateTimeResultsIOS = [
+ "3/22/2016, 11:06 AM",
"22.3.2016, 11:06",
"22/3/2016 11:06", //22-3-2016 11:06
"22/3/2016 11:06",
@@ -213,11 +214,11 @@ var shortDateTimeResultsIOS = [
"22.3.2016 11:06", //22.03.2016 11:06
"22.3.2016 11:06", //22.03.2016 11:06
"22/3/2016, 11:06", //22/03/2016, 11:06
- "3/22/2016, 11:06 AM",
"22.3.2016, 11.06"
];
var fullDateResults = [
+ "Tuesday, March 22, 2016",
"Dienstag, 22. März 2016",
"dinsdag 22 maart 2016",
"mardi 22 mars 2016",
@@ -249,11 +250,11 @@ var fullDateResults = [
"22 Mart 2016 Salı",
"вівторок, 22 березня 2016 р.",
"Tuesday, 22 March 2016",
- "Tuesday, March 22, 2016",
"tirsdag 22. mars 2016"
];
var mediumDateResultsAndroid = [
+ "Mar 22, 2016",
"22. März 2016",
"22 mrt. 2016",
"22 mars 2016",
@@ -285,11 +286,11 @@ var mediumDateResultsAndroid = [
"22 Mar 2016",
"22 бер. 2016 р.", //22 бер. 2016
"22 Mar 2016",
- "Mar 22, 2016",
"22. mar. 2016"
];
var mediumDateResultsIOS = [
+ "Mar 22, 2016",
"22. März 2016",
"22 mrt. 2016",
"22 mars 2016",
@@ -321,11 +322,11 @@ var mediumDateResultsIOS = [
"22 Mar 2016",
"22 бер. 2016 р.", //22 бер. 2016
"22 Mar 2016",
- "Mar 22, 2016",
"22. mar. 2016"
];
var shortDateResultsAndroid = [
+ "10/22/2016",
"22.10.2016",
"22/10/2016", //22-10-2016
"22/10/2016",
@@ -357,11 +358,11 @@ var shortDateResultsAndroid = [
"22 10 2016", //22.10.2016
"22.10.2016",
"22/10/2016",
- "10/22/2016",
"22.10.2016"
];
var shortDateResultsIOS = [
+ "10/22/2016",
"22.10.2016",
"22/10/2016", //22-10-2016
"22/10/2016",
@@ -393,11 +394,11 @@ var shortDateResultsIOS = [
"22.10.2016",
"22.10.2016",
"22/10/2016",
- "10/22/2016",
"22.10.2016"
];
var mediumTimeResultsAndroid = [
+ "12:05:39 PM",
"12:05:39",
"12:05:39",
"12:05:39",
@@ -429,11 +430,11 @@ var mediumTimeResultsAndroid = [
"12:05:39",
"12:05:39",
"12:05:39",
- "12:05:39 PM",
"12.05.39"
];
var mediumTimeResultsIOS = [
+ "12:05:39 PM",
"12:05:39",
"12:05:39",
"12:05:39",
@@ -465,11 +466,11 @@ var mediumTimeResultsIOS = [
"12:05:39",
"12:05:39",
"12:05:39",
- "12:05:39 PM",
"12.05.39"
];
var shortTimeResultsAndroid = [
+ "12:13 PM",
"12:13",
"12:13",
"12:13",
@@ -501,11 +502,11 @@ var shortTimeResultsAndroid = [
"12:13",
"12:13",
"12:13",
- "12:13 PM",
"12.13"
];
var shortTimeResultsIOS = [
+ "12:13 PM",
"12:13",
"12:13",
"12:13",
@@ -537,11 +538,11 @@ var shortTimeResultsIOS = [
"12:13",
"12:13",
"12:13",
- "12:13 PM",
"12.13"
];
var customPatternResults = [
+ "2016 October 22, Saturday 12:13:39",
"2016 Oktober 22, Samstag 12:13:39",
"2016 oktober 22, zaterdag 12:13:39",
"2016 octobre 22, samedi 12:13:39",
@@ -573,7 +574,6 @@ var customPatternResults = [
"2016 Ekim 22, Cumartesi 12:13:39",
"2016 жовтня 22, субота 12:13:39",
"2016 October 22, Saturday 12:13:39",
- "2016 October 22, Saturday 12:13:39",
"2016 oktober 22, lørdag 12:13:39"
]
@@ -835,6 +835,7 @@ describe('NativeScript-Intl-DateTimeFormat', function () {
});
var currencyCodes = [
+ "USD",
'EUR',
'EUR',
'EUR',
@@ -866,11 +867,11 @@ var currencyCodes = [
"TRY",
"UAH",
"GBP",
- "USD",
"NOK"
];
var currencyCodesResultsAndroid = [
+ "USD123456.79",
"EUR 123456,79",
"123456,79 EUR", // EUR 123456,79
"123456,79 EUR",
@@ -902,11 +903,11 @@ var currencyCodesResultsAndroid = [
"TRY123456,79", //123456,79 TRY
"123456,79 UAH",
"GBP123456.79",
- "USD123456.79",
"NOK 123456,79"
];
var currencyCodesResultsIOS = [
+ "USD123456.79",
"EUR 123456,79",
"123456,79 EUR", // EUR 123456,79
"123456,79 EUR",
@@ -938,11 +939,11 @@ var currencyCodesResultsIOS = [
"TRY123456,79", //123456,79 TRY
"123456,79 UAH",
"GBP123456.79",
- "USD123456.79",
"NOK 123456,79"
];
var currencyCodesGroupingResultsAndroid = [
+ "USD123,456.79",
"EUR 123 456,79",
"123.456,79 EUR", //EUR 123.456,79"
"123.456,79 EUR", //123 456,79 EUR
@@ -974,11 +975,11 @@ var currencyCodesGroupingResultsAndroid = [
"TRY123.456,79", //123.456,79 TRY
"123 456,79 UAH",
"GBP123,456.79",
- "USD123,456.79",
"NOK 123 456,79"
];
var currencyCodesGroupingResultsIOS = [
+ "USD123,456.79",
"EUR 123.456,79",
"123.456,79 EUR", //EUR 123.456,79"
"123.456,79 EUR", //123 456,79 EUR
@@ -1010,11 +1011,11 @@ var currencyCodesGroupingResultsIOS = [
"TRY123.456,79", //123.456,79 TRY
"123 456,79 UAH",
"GBP123,456.79",
- "USD123,456.79",
"NOK 123 456,79"
];
var currencyCodesSymbolResultsAndroid = [
+ "$123456.79",
"€ 123456,79",
"123456,79 €", //€ 123456,79
"123456,79 €",
@@ -1046,11 +1047,11 @@ var currencyCodesSymbolResultsAndroid = [
"₺123456,79", //123456,79 TL
"123456,79 ₴",
"£123456.79",
- "$123456.79",
"kr 123456,79"
];
var currencyCodesSymbolResultsIOS = [
+ "$123456.79",
"€ 123456,79",
"123456,79 €", //€ 123456,79
"123456,79 €",
@@ -1082,11 +1083,11 @@ var currencyCodesSymbolResultsIOS = [
"₺123456,79", //123456,79 TL
"123456,79 ₴",
"£123456.79",
- "$123456.79",
"kr 123456,79"
];
var percentResults = [
+ "12,345,679%",
"12 345 679 %",
"12.345.679%",
"12.345.679 %", //12 345 679 %
@@ -1118,11 +1119,11 @@ var percentResults = [
"%12.345.679",
"12 345 679%",
"12,345,679%",
- "12,345,679%",
"12 345 679 %"
];
var decimalResults = [
+ "123,456.79",
"123 456,79",
"123.456,79",
"123.456,79", //123 456,79
@@ -1154,11 +1155,11 @@ var decimalResults = [
"123.456,79",
"123 456,79",
"123,456.79",
- "123,456.79",
"123 456,79"
];
var customNumberPatternResultsAndroid = [
+ "123,456.79 $",
"123 456,79 €",
"123.456,79 €",
"123.456,79 €",
@@ -1190,11 +1191,11 @@ var customNumberPatternResultsAndroid = [
"123.456,79 ₺",
"123 456,79 ₴",
"123,456.79 £",
- "123,456.79 $",
"123 456,79 kr"
];
var customNumberPatternResultsIOS = [
+ "123,456.79 $",
"123.456,79 €",
"123.456,79 €",
"123.456,79 €",
@@ -1226,7 +1227,6 @@ var customNumberPatternResultsIOS = [
"123.456,79 ₺",
"123 456,79 ₴",
"123,456.79 £",
- "123,456.79 $",
"123 456,79 kr"
];
diff --git a/tests/getFormatsFromChrome.js b/tests/getFormatsFromChrome.js
index d497eba..db2e555 100644
--- a/tests/getFormatsFromChrome.js
+++ b/tests/getFormatsFromChrome.js
@@ -1,4 +1,5 @@
var locales = [
+ "en-US",
"de-AT",
"nl-BE",
"fr-BE",
@@ -30,7 +31,6 @@ var locales = [
"tr-TR",
"uk-UA",
"en-GB",
- "en-US",
"nb-NO"
];
@@ -107,6 +107,7 @@ var dateTimeOptions = [
];
var currencyCodes = [
+ "USD",
'EUR',
'EUR',
'EUR',
@@ -138,7 +139,6 @@ var currencyCodes = [
"TRY",
"UAH",
"GBP",
- "USD",
"NOK"
];
@@ -197,10 +197,12 @@ var numberOptions = [
var getDateTimeFormatForLocales = function () {
var i;
var j;
+ var testDate = new Date(2016, 2, 22, 19, 40, 39);
for (j = 0; j < dateTimeOptions.length; j++) {
console.log(dateTimeOptions[j].optionsName);
for (i = 0; i < locales.length; i++) {
- console.log(locales[i] + '"' + new Intl.DateTimeFormat(locales[i], dateTimeOptions[j].options).format(new Date(2016, 2, 22, 9, 40, 39)) + '",');
+ var result = new Intl.DateTimeFormat(locales[i], dateTimeOptions[j].options).format(testDate);
+ console.log(`\"${locales[i]} - \"${result}\"`);
}
console.log("");
}
@@ -215,18 +217,22 @@ var getNumberFormatForLocales = function () {
for (i = 0; i < locales.length; i++) {
var updatedCurrencyOptions = currencyOptions[j].options;
updatedCurrencyOptions.currency = currencyCodes[i];
- console.log(locales[i] + '"' + new Intl.NumberFormat(locales[i], updatedCurrencyOptions).format(testNumber) + '",');
+ var resultCurrency = new Intl.NumberFormat(locales[i], updatedCurrencyOptions).format(testNumber);
+ //console.log(locales[i] + '"' + result + '",');
+ console.log(`\"${locales[i]} - \"${resultCurrency}\"`);
}
console.log("");
}
for (j = 0; j < numberOptions.length; j++) {
console.log(numberOptions[j].optionsName);
for (i = 0; i < locales.length; i++) {
- console.log(locales[i] + '"' + new Intl.NumberFormat(locales[i], numberOptions[j].options).format(testNumber) + '",');
+ var resultNumber = new Intl.NumberFormat(locales[i], numberOptions[j].options).format(testNumber);
+ //console.log(locales[i] + '"' + resultNumber + '",');
+ console.log(`\"${locales[i]} - \"${resultNumber}\"`);
}
console.log("");
}
}
getDateTimeFormatForLocales();
-getNumberFormatForLocales();
\ No newline at end of file
+getNumberFormatForLocales();
diff --git a/tests/package.json b/tests/package.json
index 9755b61..0211851 100644
--- a/tests/package.json
+++ b/tests/package.json
@@ -2,13 +2,13 @@
"nativescript": {
"id": "org.nativescript.tests",
"tns-android": {
- "version": "2.1.1"
+ "version": "2.4.0"
}
},
"dependencies": {
- "nativescript-intl": "file:..\\dist\\nativescript-intl-0.0.3.tgz",
+ "nativescript-intl": "file:..\\dist\\nativescript-intl-0.0.5.tgz",
"nativescript-unit-test-runner": "^0.3.3",
- "tns-core-modules": "2.1.0"
+ "tns-core-modules": "^2.1.0"
},
"devDependencies": {
"babel-traverse": "6.10.4",