├── .gitignore
├── LICENSE
├── README.md
├── demo
├── app
│ ├── App_Resources
│ │ ├── Android
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── app.gradle
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── drawable-ldpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── drawable-nodpi
│ │ │ │ └── splash_screen.xml
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── background.png
│ │ │ │ ├── icon.png
│ │ │ │ └── logo.png
│ │ │ ├── values-v21
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ └── iOS
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── icon-29.png
│ │ │ │ ├── icon-29@2x.png
│ │ │ │ ├── icon-29@3x.png
│ │ │ │ ├── icon-40.png
│ │ │ │ ├── icon-40@2x.png
│ │ │ │ ├── icon-40@3x.png
│ │ │ │ ├── icon-50.png
│ │ │ │ ├── icon-50@2x.png
│ │ │ │ ├── icon-57.png
│ │ │ │ ├── icon-57@2x.png
│ │ │ │ ├── icon-60@2x.png
│ │ │ │ ├── icon-60@3x.png
│ │ │ │ ├── icon-72.png
│ │ │ │ ├── icon-72@2x.png
│ │ │ │ ├── icon-76.png
│ │ │ │ ├── icon-76@2x.png
│ │ │ │ └── icon-83.5@2x.png
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.launchimage
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Default-568h@2x.png
│ │ │ │ ├── Default-667h@2x.png
│ │ │ │ ├── Default-736h@3x.png
│ │ │ │ ├── Default-Landscape.png
│ │ │ │ ├── Default-Landscape@2x.png
│ │ │ │ ├── Default-Landscape@3x.png
│ │ │ │ ├── Default-Portrait.png
│ │ │ │ ├── Default-Portrait@2x.png
│ │ │ │ ├── Default.png
│ │ │ │ └── Default@2x.png
│ │ │ ├── LaunchScreen.AspectFill.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchScreen-AspectFill.png
│ │ │ │ └── LaunchScreen-AspectFill@2x.png
│ │ │ └── LaunchScreen.Center.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchScreen-Center.png
│ │ │ │ └── LaunchScreen-Center@2x.png
│ │ │ ├── Info.plist
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── build.xcconfig
│ ├── README.md
│ ├── app.css
│ ├── app.js.map
│ ├── app.ts
│ ├── main-page.js.map
│ ├── main-page.ts
│ ├── main-page.xml
│ └── package.json
├── hooks
│ ├── after-watch
│ │ └── nativescript-dev-typescript.js
│ ├── before-prepare
│ │ └── nativescript-dev-typescript.js
│ ├── before-watch
│ │ └── nativescript-dev-typescript.js
│ └── before-watchPatterns
│ │ └── nativescript-dev-typescript.js
├── package-lock.json
├── package.json
├── references.d.ts
└── tsconfig.json
└── src
├── .npmignore
├── flashlight-common.js
├── flashlight.android.js
├── flashlight.ios.js
├── index.d.ts
├── package-lock.json
├── package.json
├── platforms
└── android
│ └── AndroidManifest.xml
└── references.d.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vscode/
3 | node_modules/
4 | demo/lib/
5 | demo/platforms/
6 | demo/app/*.js
7 | src/platforms/android/*.aar
8 | *.log
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | The MIT License (MIT)
3 |
4 | Copyright (c) 2015 TJ VanToll
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NativeScript Flashlight Plugin
2 | A plugin for using your device's flashlight in NativeScript Android and iOS apps.
3 |
4 | [![NPM version][npm-image]][npm-url]
5 | [![Downloads][downloads-image]][npm-url]
6 |
7 | [npm-image]:http://img.shields.io/npm/v/nativescript-flashlight.svg
8 | [npm-url]:https://npmjs.org/package/nativescript-flashlight
9 | [downloads-image]:http://img.shields.io/npm/dm/nativescript-flashlight.svg
10 |
11 | ## Installation
12 |
13 | Run the following command from the root of your project:
14 |
15 | ```
16 | $ tns plugin add nativescript-flashlight
17 | ```
18 |
19 | This command automatically installs the necessary files, as well as stores nativescript-flashlight as a dependency in your project's `package.json` file.
20 |
21 | ## Usage
22 |
23 | To use the flashlight module you must first `require()` it:
24 |
25 | ```js
26 | // JavaScript
27 | var flashlight = require("nativescript-flashlight");
28 | ```
29 |
30 | Or if you’re using TypeScript, `import` the module:
31 |
32 | ```typescript
33 | // TypeScript
34 | import * as flashlight from "nativescript-flashlight";
35 | ```
36 |
37 | After you have a reference to the module you can then call its `on()`, `off()`, and `toggle()` methods. For example, the code below turns your device's flashlight on with an `intensity` setting of 25%.
38 |
39 | The optional `intensity` is supported __only on iOS__ and is by default `1.0`, which is 100% brightness.
40 |
41 | ```js
42 | // my-page.js
43 | var flashlight = require("nativescript-flashlight");
44 | flashlight.on({
45 | intensity: 0.25
46 | });
47 | ```
48 |
49 | In most cases you'll want to wrap your `on()` call with a check of `isAvailable()`, to handle devices where a flashlight is not available:
50 |
51 | ```js
52 | // my-page.js
53 | var flashlight = require("nativescript-flashlight");
54 | if (flashlight.isAvailable()) {
55 | flashlight.on();
56 | } else {
57 | alert("A flashlight is not available on your device.");
58 | }
59 | ```
60 |
61 | ## Examples
62 |
63 | The code below creates a button that toggles the device's flashlight:
64 |
65 | ```xml
66 |
67 |
68 |
69 |
70 |
71 |
72 | ```
73 |
74 | ```js
75 | // my-page.js
76 | var flashlight = require("nativescript-flashlight");
77 | var observable = require("data/observable");
78 | var viewModel = new observable.Observable();
79 |
80 | // Set the initial text of the button
81 | viewModel.set("flashlightState", "Turn on");
82 |
83 | // A tap handle for the page's button. Toggle the state of the flashlight
84 | // and the button's text
85 | viewModel.toggleFlashlight = function() {
86 | if (flashlight.isAvailable()) {
87 | flashlight.toggle({
88 | intensity: 0.6 // optional, supported on iOS only (default: 1.0 which is 100% brightness)
89 | });
90 | viewModel.set("flashlightState", (flashlight.isOn() ? "Turn off" : "Turn on"));
91 | } else {
92 | alert("A flashlight is not available on your device.");
93 | }
94 | };
95 |
96 | function pageLoaded(args) {
97 | var page = args.object;
98 | page.bindingContext = viewModel;
99 | }
100 |
101 | exports.pageLoaded = pageLoaded;
102 | ```
103 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
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.flashlightdemo"
12 | }
13 | aaptOptions {
14 | additionalParameters "--no-version-vectors"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-hdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-hdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-ldpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-ldpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-ldpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-ldpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-mdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-mdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 | -
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xhdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xxhdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/values-v21/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3d5afe
4 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
14 |
15 |
16 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 | #757575
5 | #33B5E5
6 | #272734
7 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
21 |
22 |
23 |
31 |
32 |
34 |
35 |
36 |
42 |
43 |
45 |
46 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "29x29",
5 | "idiom" : "iphone",
6 | "filename" : "icon-29.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "29x29",
11 | "idiom" : "iphone",
12 | "filename" : "icon-29@2x.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-29@3x.png",
19 | "scale" : "3x"
20 | },
21 | {
22 | "size" : "40x40",
23 | "idiom" : "iphone",
24 | "filename" : "icon-40@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-40@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "57x57",
35 | "idiom" : "iphone",
36 | "filename" : "icon-57.png",
37 | "scale" : "1x"
38 | },
39 | {
40 | "size" : "57x57",
41 | "idiom" : "iphone",
42 | "filename" : "icon-57@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "icon-60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "29x29",
59 | "idiom" : "ipad",
60 | "filename" : "icon-29.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "29x29",
65 | "idiom" : "ipad",
66 | "filename" : "icon-29@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "40x40",
71 | "idiom" : "ipad",
72 | "filename" : "icon-40.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "40x40",
77 | "idiom" : "ipad",
78 | "filename" : "icon-40@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "50x50",
83 | "idiom" : "ipad",
84 | "filename" : "icon-50.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "50x50",
89 | "idiom" : "ipad",
90 | "filename" : "icon-50@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "72x72",
95 | "idiom" : "ipad",
96 | "filename" : "icon-72.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "72x72",
101 | "idiom" : "ipad",
102 | "filename" : "icon-72@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "76x76",
107 | "idiom" : "ipad",
108 | "filename" : "icon-76.png",
109 | "scale" : "1x"
110 | },
111 | {
112 | "size" : "76x76",
113 | "idiom" : "ipad",
114 | "filename" : "icon-76@2x.png",
115 | "scale" : "2x"
116 | },
117 | {
118 | "size" : "83.5x83.5",
119 | "idiom" : "ipad",
120 | "filename" : "icon-83.5@2x.png",
121 | "scale" : "2x"
122 | }
123 | ],
124 | "info" : {
125 | "version" : 1,
126 | "author" : "xcode"
127 | }
128 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "extent" : "full-screen",
5 | "idiom" : "iphone",
6 | "subtype" : "736h",
7 | "filename" : "Default-736h@3x.png",
8 | "minimum-system-version" : "8.0",
9 | "orientation" : "portrait",
10 | "scale" : "3x"
11 | },
12 | {
13 | "extent" : "full-screen",
14 | "idiom" : "iphone",
15 | "subtype" : "736h",
16 | "filename" : "Default-Landscape@3x.png",
17 | "minimum-system-version" : "8.0",
18 | "orientation" : "landscape",
19 | "scale" : "3x"
20 | },
21 | {
22 | "extent" : "full-screen",
23 | "idiom" : "iphone",
24 | "subtype" : "667h",
25 | "filename" : "Default-667h@2x.png",
26 | "minimum-system-version" : "8.0",
27 | "orientation" : "portrait",
28 | "scale" : "2x"
29 | },
30 | {
31 | "orientation" : "portrait",
32 | "idiom" : "iphone",
33 | "filename" : "Default@2x.png",
34 | "extent" : "full-screen",
35 | "minimum-system-version" : "7.0",
36 | "scale" : "2x"
37 | },
38 | {
39 | "extent" : "full-screen",
40 | "idiom" : "iphone",
41 | "subtype" : "retina4",
42 | "filename" : "Default-568h@2x.png",
43 | "minimum-system-version" : "7.0",
44 | "orientation" : "portrait",
45 | "scale" : "2x"
46 | },
47 | {
48 | "orientation" : "portrait",
49 | "idiom" : "ipad",
50 | "filename" : "Default-Portrait.png",
51 | "extent" : "full-screen",
52 | "minimum-system-version" : "7.0",
53 | "scale" : "1x"
54 | },
55 | {
56 | "orientation" : "landscape",
57 | "idiom" : "ipad",
58 | "filename" : "Default-Landscape.png",
59 | "extent" : "full-screen",
60 | "minimum-system-version" : "7.0",
61 | "scale" : "1x"
62 | },
63 | {
64 | "orientation" : "portrait",
65 | "idiom" : "ipad",
66 | "filename" : "Default-Portrait@2x.png",
67 | "extent" : "full-screen",
68 | "minimum-system-version" : "7.0",
69 | "scale" : "2x"
70 | },
71 | {
72 | "orientation" : "landscape",
73 | "idiom" : "ipad",
74 | "filename" : "Default-Landscape@2x.png",
75 | "extent" : "full-screen",
76 | "minimum-system-version" : "7.0",
77 | "scale" : "2x"
78 | },
79 | {
80 | "orientation" : "portrait",
81 | "idiom" : "iphone",
82 | "filename" : "Default.png",
83 | "extent" : "full-screen",
84 | "scale" : "1x"
85 | },
86 | {
87 | "orientation" : "portrait",
88 | "idiom" : "iphone",
89 | "filename" : "Default@2x.png",
90 | "extent" : "full-screen",
91 | "scale" : "2x"
92 | },
93 | {
94 | "orientation" : "portrait",
95 | "idiom" : "iphone",
96 | "filename" : "Default-568h@2x.png",
97 | "extent" : "full-screen",
98 | "subtype" : "retina4",
99 | "scale" : "2x"
100 | },
101 | {
102 | "orientation" : "portrait",
103 | "idiom" : "ipad",
104 | "extent" : "to-status-bar",
105 | "scale" : "1x"
106 | },
107 | {
108 | "orientation" : "portrait",
109 | "idiom" : "ipad",
110 | "filename" : "Default-Portrait.png",
111 | "extent" : "full-screen",
112 | "scale" : "1x"
113 | },
114 | {
115 | "orientation" : "landscape",
116 | "idiom" : "ipad",
117 | "extent" : "to-status-bar",
118 | "scale" : "1x"
119 | },
120 | {
121 | "orientation" : "landscape",
122 | "idiom" : "ipad",
123 | "filename" : "Default-Landscape.png",
124 | "extent" : "full-screen",
125 | "scale" : "1x"
126 | },
127 | {
128 | "orientation" : "portrait",
129 | "idiom" : "ipad",
130 | "extent" : "to-status-bar",
131 | "scale" : "2x"
132 | },
133 | {
134 | "orientation" : "portrait",
135 | "idiom" : "ipad",
136 | "filename" : "Default-Portrait@2x.png",
137 | "extent" : "full-screen",
138 | "scale" : "2x"
139 | },
140 | {
141 | "orientation" : "landscape",
142 | "idiom" : "ipad",
143 | "extent" : "to-status-bar",
144 | "scale" : "2x"
145 | },
146 | {
147 | "orientation" : "landscape",
148 | "idiom" : "ipad",
149 | "filename" : "Default-Landscape@2x.png",
150 | "extent" : "full-screen",
151 | "scale" : "2x"
152 | }
153 | ],
154 | "info" : {
155 | "version" : 1,
156 | "author" : "xcode"
157 | }
158 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-AspectFill.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-AspectFill@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-Center.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-Center@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tjvantoll/nativescript-flashlight/076574c544c26dff9d053728894009cfe7987766/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | Flashlight
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiresFullScreen
28 |
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/build.xcconfig:
--------------------------------------------------------------------------------
1 | // You can add custom settings here
2 | // for example you can uncomment the following line to force distribution code signing
3 | // CODE_SIGN_IDENTITY = iPhone Distribution
4 | // 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
5 | // DEVELOPMENT_TEAM = YOUR_TEAM_ID;
6 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
7 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
8 |
--------------------------------------------------------------------------------
/demo/app/README.md:
--------------------------------------------------------------------------------
1 | # NativeScript TypeScript Template
2 |
3 | This template creates a NativeScript app with the NativeScript hello world example,
4 | however, in this template the example is built with TypeScript.
5 |
6 | You can create a new app that uses this template with either the `--template` option.
7 |
8 | ```
9 | tns create my-app-name --template tns-template-hello-world-ts
10 | ```
11 |
12 | Or the `--tsc` shorthand.
13 |
14 | ```
15 | tns create my-app-name --tsc
16 | ```
17 |
--------------------------------------------------------------------------------
/demo/app/app.css:
--------------------------------------------------------------------------------
1 | .title {
2 | font-size: 30;
3 | horizontal-align: center;
4 | margin: 20;
5 | }
6 |
7 | button {
8 | font-size: 42;
9 | horizontal-align: center;
10 | }
11 |
12 | label {
13 | font-size: 20;
14 | margin: 20;
15 | }
16 |
17 | slider {
18 | margin: 0 20;
19 | }
20 |
21 | .message {
22 | font-size: 20;
23 | color: #284848;
24 | horizontal-align: center;
25 | margin: 0 20;
26 | text-align: center;
27 | }
28 |
--------------------------------------------------------------------------------
/demo/app/app.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,WAAW,WAAW,aAAa,CAAC,CAAC;AAC5C,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC"}
--------------------------------------------------------------------------------
/demo/app/app.ts:
--------------------------------------------------------------------------------
1 | import application = require("tns-core-modules/application");
2 | application.start({ moduleName: "main-page" });
3 |
--------------------------------------------------------------------------------
/demo/app/main-page.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"main-page.js","sourceRoot":"","sources":["main-page.ts"],"names":[],"mappings":";AAAA,2BAA0D,iBAAiB,CAAC,CAAA;AAG5E,IAAY,UAAU,WAAM,yBAAyB,CAAC,CAAA;AAEtD,IAAI,SAAS,GAAG,IAAI,uBAAU,EAAE,CAAC;AACjC,SAAS,CAAC,GAAG,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;AAC5C,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAE/B,0BAAiC,GAAG;IAClC,EAAE,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC7B,UAAU,CAAC,MAAM,CAAC;YAChB,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,GAAG;SAC5C,CAAC,CAAC;QACH,SAAS,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC;IACjF,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AATe,wBAAgB,mBAS/B,CAAA;AAAA,CAAC;AAEF,oBAA2B,IAAe;IACxC,IAAI,IAAI,GAAS,IAAI,CAAC,MAAM,CAAC;IAC7B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;IAEhC,IAAI,MAAM,GAAW,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,UAAC,IAAwB;QACnD,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC;AARe,kBAAU,aAQzB,CAAA"}
--------------------------------------------------------------------------------
/demo/app/main-page.ts:
--------------------------------------------------------------------------------
1 | import { EventData, Observable, PropertyChangeData } from "tns-core-modules/data/observable";
2 | import { Page } from "tns-core-modules/ui/page";
3 | import { Slider } from "tns-core-modules/ui/slider";
4 | import * as flashlight from "nativescript-flashlight";
5 |
6 | let viewModel = new Observable();
7 | viewModel.set("flashlightState", "Turn on");
8 | viewModel.set("intensity", 50);
9 |
10 | export function toggleFlashlight(arg) {
11 | if (flashlight.isAvailable()) {
12 | flashlight.toggle({
13 | intensity: viewModel.get("intensity") / 100
14 | });
15 | viewModel.set("flashlightState", (flashlight.isOn() ? "Turn off" : "Turn on"));
16 | } else {
17 | alert("A flashlight is not available on your device.");
18 | }
19 | }
20 |
21 | export function pageLoaded(args: EventData) {
22 | const page = args.object;
23 | page.bindingContext = viewModel;
24 |
25 | const slider = page.getViewById("intensitySlider");
26 | if (slider) {
27 | slider.on("propertyChange", (args: PropertyChangeData) => {
28 | console.log("Intensity set to: " + args.value);
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/demo/app/main-page.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/demo/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "app.js"
3 | }
4 |
--------------------------------------------------------------------------------
/demo/hooks/after-watch/nativescript-dev-typescript.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-typescript/lib/after-watch.js");
2 |
--------------------------------------------------------------------------------
/demo/hooks/before-prepare/nativescript-dev-typescript.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-typescript/lib/before-prepare.js");
2 |
--------------------------------------------------------------------------------
/demo/hooks/before-watch/nativescript-dev-typescript.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-typescript/lib/watch.js");
2 |
--------------------------------------------------------------------------------
/demo/hooks/before-watchPatterns/nativescript-dev-typescript.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-typescript/lib/before-watchPatterns.js");
2 |
--------------------------------------------------------------------------------
/demo/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "ansi-regex": {
6 | "version": "2.1.1",
7 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
8 | "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
9 | "dev": true
10 | },
11 | "ansi-styles": {
12 | "version": "2.2.1",
13 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
14 | "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
15 | "dev": true
16 | },
17 | "babel-code-frame": {
18 | "version": "6.26.0",
19 | "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
20 | "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
21 | "dev": true,
22 | "requires": {
23 | "chalk": "^1.1.3",
24 | "esutils": "^2.0.2",
25 | "js-tokens": "^3.0.2"
26 | }
27 | },
28 | "babel-messages": {
29 | "version": "6.23.0",
30 | "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz",
31 | "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=",
32 | "dev": true,
33 | "requires": {
34 | "babel-runtime": "^6.22.0"
35 | }
36 | },
37 | "babel-runtime": {
38 | "version": "6.26.0",
39 | "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
40 | "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
41 | "dev": true,
42 | "requires": {
43 | "core-js": "^2.4.0",
44 | "regenerator-runtime": "^0.11.0"
45 | }
46 | },
47 | "babel-traverse": {
48 | "version": "6.16.0",
49 | "resolved": "http://registry.npmjs.org/babel-traverse/-/babel-traverse-6.16.0.tgz",
50 | "integrity": "sha1-+6ha4f1NEH3pzgAxScxX9TvvDE8=",
51 | "dev": true,
52 | "requires": {
53 | "babel-code-frame": "^6.16.0",
54 | "babel-messages": "^6.8.0",
55 | "babel-runtime": "^6.9.0",
56 | "babel-types": "^6.16.0",
57 | "babylon": "^6.11.0",
58 | "debug": "^2.2.0",
59 | "globals": "^8.3.0",
60 | "invariant": "^2.2.0",
61 | "lodash": "^4.2.0"
62 | }
63 | },
64 | "babel-types": {
65 | "version": "6.16.0",
66 | "resolved": "http://registry.npmjs.org/babel-types/-/babel-types-6.16.0.tgz",
67 | "integrity": "sha1-ccyh2+Uzd2YiXFwZMHHo68vP/P4=",
68 | "dev": true,
69 | "requires": {
70 | "babel-runtime": "^6.9.1",
71 | "esutils": "^2.0.2",
72 | "lodash": "^4.2.0",
73 | "to-fast-properties": "^1.0.1"
74 | }
75 | },
76 | "babylon": {
77 | "version": "6.11.4",
78 | "resolved": "http://registry.npmjs.org/babylon/-/babylon-6.11.4.tgz",
79 | "integrity": "sha1-deH1IYfvoM3lpUGn9/3aOPbrW9I=",
80 | "dev": true
81 | },
82 | "balanced-match": {
83 | "version": "1.0.0",
84 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
85 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
86 | "dev": true
87 | },
88 | "brace-expansion": {
89 | "version": "1.1.11",
90 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
91 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
92 | "dev": true,
93 | "requires": {
94 | "balanced-match": "^1.0.0",
95 | "concat-map": "0.0.1"
96 | }
97 | },
98 | "chalk": {
99 | "version": "1.1.3",
100 | "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
101 | "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
102 | "dev": true,
103 | "requires": {
104 | "ansi-styles": "^2.2.1",
105 | "escape-string-regexp": "^1.0.2",
106 | "has-ansi": "^2.0.0",
107 | "strip-ansi": "^3.0.0",
108 | "supports-color": "^2.0.0"
109 | }
110 | },
111 | "concat-map": {
112 | "version": "0.0.1",
113 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
114 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
115 | "dev": true
116 | },
117 | "core-js": {
118 | "version": "2.5.7",
119 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz",
120 | "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==",
121 | "dev": true
122 | },
123 | "debug": {
124 | "version": "2.6.9",
125 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
126 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
127 | "dev": true,
128 | "requires": {
129 | "ms": "2.0.0"
130 | }
131 | },
132 | "escape-string-regexp": {
133 | "version": "1.0.5",
134 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
135 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
136 | "dev": true
137 | },
138 | "esutils": {
139 | "version": "2.0.2",
140 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
141 | "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
142 | "dev": true
143 | },
144 | "glob": {
145 | "version": "6.0.4",
146 | "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
147 | "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=",
148 | "dev": true,
149 | "requires": {
150 | "inflight": "^1.0.4",
151 | "inherits": "2",
152 | "minimatch": "2 || 3",
153 | "once": "^1.3.0",
154 | "path-is-absolute": "^1.0.0"
155 | }
156 | },
157 | "globals": {
158 | "version": "8.18.0",
159 | "resolved": "http://registry.npmjs.org/globals/-/globals-8.18.0.tgz",
160 | "integrity": "sha1-k9SmK9ysOM+vr8R9awNHaMsP/LQ=",
161 | "dev": true
162 | },
163 | "has-ansi": {
164 | "version": "2.0.0",
165 | "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
166 | "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
167 | "dev": true,
168 | "requires": {
169 | "ansi-regex": "^2.0.0"
170 | }
171 | },
172 | "inflight": {
173 | "version": "1.0.6",
174 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
175 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
176 | "dev": true,
177 | "requires": {
178 | "once": "^1.3.0",
179 | "wrappy": "1"
180 | }
181 | },
182 | "inherits": {
183 | "version": "2.0.3",
184 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
185 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
186 | "dev": true
187 | },
188 | "invariant": {
189 | "version": "2.2.4",
190 | "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
191 | "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
192 | "dev": true,
193 | "requires": {
194 | "loose-envify": "^1.0.0"
195 | }
196 | },
197 | "js-tokens": {
198 | "version": "3.0.2",
199 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
200 | "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
201 | "dev": true
202 | },
203 | "lazy": {
204 | "version": "1.0.11",
205 | "resolved": "https://registry.npmjs.org/lazy/-/lazy-1.0.11.tgz",
206 | "integrity": "sha1-2qBoIGKCVCwIgojpdcKXwa53tpA=",
207 | "dev": true
208 | },
209 | "lodash": {
210 | "version": "4.17.11",
211 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
212 | "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
213 | "dev": true
214 | },
215 | "loose-envify": {
216 | "version": "1.4.0",
217 | "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
218 | "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
219 | "dev": true,
220 | "requires": {
221 | "js-tokens": "^3.0.0 || ^4.0.0"
222 | }
223 | },
224 | "minimatch": {
225 | "version": "3.0.4",
226 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
227 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
228 | "dev": true,
229 | "requires": {
230 | "brace-expansion": "^1.1.7"
231 | }
232 | },
233 | "minimist": {
234 | "version": "0.0.8",
235 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
236 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
237 | "dev": true
238 | },
239 | "mkdirp": {
240 | "version": "0.5.1",
241 | "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
242 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
243 | "dev": true,
244 | "requires": {
245 | "minimist": "0.0.8"
246 | }
247 | },
248 | "ms": {
249 | "version": "2.0.0",
250 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
251 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
252 | "dev": true
253 | },
254 | "nativescript-dev-typescript": {
255 | "version": "0.7.8",
256 | "resolved": "https://registry.npmjs.org/nativescript-dev-typescript/-/nativescript-dev-typescript-0.7.8.tgz",
257 | "integrity": "sha512-2hrLxFde4DH2yGb2XFMtLOlhlMOipz/a0vD5b+cALusF3OkwQpFcRFAIjpD28B5ur0hRZcg9VURnUBTfQra+yA==",
258 | "dev": true,
259 | "requires": {
260 | "nativescript-hook": "^0.2.0",
261 | "semver": "5.5.0",
262 | "typescript": "~3.1.1"
263 | },
264 | "dependencies": {
265 | "typescript": {
266 | "version": "3.1.6",
267 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz",
268 | "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==",
269 | "dev": true
270 | }
271 | }
272 | },
273 | "nativescript-flashlight": {
274 | "version": "file:../src",
275 | "dependencies": {
276 | "tns-core-modules": {
277 | "version": "5.0.5",
278 | "bundled": true,
279 | "requires": {
280 | "tns-core-modules-widgets": "5.0.1",
281 | "tslib": "^1.9.3"
282 | }
283 | },
284 | "tns-core-modules-widgets": {
285 | "version": "5.0.1",
286 | "bundled": true
287 | },
288 | "tns-platform-declarations": {
289 | "version": "5.0.5",
290 | "bundled": true
291 | },
292 | "tslib": {
293 | "version": "1.9.3",
294 | "bundled": true
295 | }
296 | }
297 | },
298 | "nativescript-hook": {
299 | "version": "0.2.4",
300 | "resolved": "https://registry.npmjs.org/nativescript-hook/-/nativescript-hook-0.2.4.tgz",
301 | "integrity": "sha1-5ZHh2a1BWotPMwnBVzFXevRKPdQ=",
302 | "dev": true,
303 | "requires": {
304 | "glob": "^6.0.1",
305 | "mkdirp": "^0.5.1"
306 | }
307 | },
308 | "once": {
309 | "version": "1.4.0",
310 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
311 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
312 | "dev": true,
313 | "requires": {
314 | "wrappy": "1"
315 | }
316 | },
317 | "path-is-absolute": {
318 | "version": "1.0.1",
319 | "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
320 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
321 | "dev": true
322 | },
323 | "regenerator-runtime": {
324 | "version": "0.11.1",
325 | "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
326 | "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
327 | "dev": true
328 | },
329 | "semver": {
330 | "version": "5.5.0",
331 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
332 | "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==",
333 | "dev": true
334 | },
335 | "strip-ansi": {
336 | "version": "3.0.1",
337 | "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
338 | "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
339 | "dev": true,
340 | "requires": {
341 | "ansi-regex": "^2.0.0"
342 | }
343 | },
344 | "supports-color": {
345 | "version": "2.0.0",
346 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
347 | "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
348 | "dev": true
349 | },
350 | "tns-core-modules": {
351 | "version": "5.0.5",
352 | "resolved": "https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-5.0.5.tgz",
353 | "integrity": "sha512-AUwrn6TIhrTc88IO9X7SU4otT/dU84CPfHtAZHW+D05/alkkupfqrbHtQXjDH+TBkwiKbq48dBmI6OpM9Pablg==",
354 | "requires": {
355 | "tns-core-modules-widgets": "5.0.1",
356 | "tslib": "^1.9.3"
357 | }
358 | },
359 | "tns-core-modules-widgets": {
360 | "version": "5.0.1",
361 | "resolved": "https://registry.npmjs.org/tns-core-modules-widgets/-/tns-core-modules-widgets-5.0.1.tgz",
362 | "integrity": "sha512-zDml+PISblTkAQ+Xd4JcMHl/o5dpAn0B+R2fLtxWjNIhkNzNfz+FmfMtH7Js2wnwtLp+kC2ZNOQRVAzOBquxAQ=="
363 | },
364 | "to-fast-properties": {
365 | "version": "1.0.3",
366 | "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz",
367 | "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=",
368 | "dev": true
369 | },
370 | "tslib": {
371 | "version": "1.9.3",
372 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
373 | "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
374 | },
375 | "typescript": {
376 | "version": "2.8.4",
377 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.8.4.tgz",
378 | "integrity": "sha512-IIU5cN1mR5J3z9jjdESJbnxikTrEz3lzAw/D0Tf45jHpBp55nY31UkUvmVHoffCfKHTqJs3fCLPDxknQTTFegQ==",
379 | "dev": true
380 | },
381 | "wrappy": {
382 | "version": "1.0.2",
383 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
384 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
385 | "dev": true
386 | }
387 | }
388 | }
389 |
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "NativeScript flashlight sample",
3 | "license": "MIT",
4 | "nativescript": {
5 | "id": "org.nativescript.flashlightdemo",
6 | "tns-ios": {
7 | "version": "5.0.0"
8 | },
9 | "tns-android": {
10 | "version": "5.0.0"
11 | }
12 | },
13 | "dependencies": {
14 | "tns-core-modules": "~5.0.5",
15 | "nativescript-flashlight": "file:../src"
16 | },
17 | "devDependencies": {
18 | "babel-traverse": "6.16.0",
19 | "babel-types": "6.16.0",
20 | "babylon": "6.11.4",
21 | "lazy": "1.0.11",
22 | "nativescript-dev-typescript": "~0.7.8",
23 | "typescript": "~2.8.0"
24 | }
25 | }
--------------------------------------------------------------------------------
/demo/references.d.ts:
--------------------------------------------------------------------------------
1 | /// Needed for autocompletion and compilation.
--------------------------------------------------------------------------------
/demo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "experimentalDecorators": true,
6 | "emitDecoratorMetadata": true,
7 | "noEmitHelpers": true,
8 | "noEmitOnError": true,
9 | "lib": [
10 | "es6",
11 | "dom"
12 | ],
13 | "baseUrl": ".",
14 | "paths": {
15 | "~/*": [
16 | "app/*"
17 | ],
18 | "*": [
19 | "./node_modules/tns-core-modules/*",
20 | "./node_modules/*"
21 | ]
22 | }
23 | },
24 | "exclude": [
25 | "node_modules",
26 | "platforms"
27 | ]
28 | }
--------------------------------------------------------------------------------
/src/.npmignore:
--------------------------------------------------------------------------------
1 | platforms/android/AndroidManifest.xml
2 | references.d.ts
--------------------------------------------------------------------------------
/src/flashlight-common.js:
--------------------------------------------------------------------------------
1 | var flashlight = {
2 | _on: false,
3 |
4 | toggle: function(arg) {
5 | if (flashlight._on) {
6 | flashlight.off();
7 | } else {
8 | flashlight.on(arg);
9 | }
10 | flashlight._on = !flashlight._on;
11 | },
12 |
13 | isOn: function() {
14 | return flashlight._on;
15 | },
16 |
17 | _checkAvailability: function() {
18 | if (!this.isAvailable()) {
19 | throw new Error("A flashlight is not available on this device. " +
20 | "Check for availability with isAvailable().");
21 | }
22 | }
23 | };
24 |
25 | module.exports = flashlight;
26 |
--------------------------------------------------------------------------------
/src/flashlight.android.js:
--------------------------------------------------------------------------------
1 | var platformModule = require("tns-core-modules/platform");
2 | var application = require("tns-core-modules/application");
3 | var flashlight = require("./flashlight-common");
4 | var camera;
5 | // Used when device has camera2 API
6 | var appContext;
7 | var cameraManager;
8 | // Used when device lacks camera2 API
9 | var parameters;
10 |
11 | flashlight.isAvailable = function () {
12 | var packageManager = com.tns.NativeScriptApplication.getInstance().getPackageManager();
13 | return packageManager.hasSystemFeature(android.content.pm.PackageManager.FEATURE_CAMERA_FLASH);
14 | };
15 |
16 | flashlight.hasCamera2API = function () {
17 | return platformModule.device.sdkVersion > 20;
18 | };
19 |
20 | flashlight.on = function () {
21 | this._checkAvailability();
22 | if (flashlight.hasCamera2API()) {
23 | if (!camera) {
24 | appContext = application.getNativeApplication().getApplicationContext();
25 | cameraManager = appContext.getSystemService(android.content.Context.CAMERA_SERVICE);
26 | camera = cameraManager.getCameraIdList()[0];
27 | }
28 | cameraManager.setTorchMode(camera, true);
29 | } else {
30 | if (camera === undefined) {
31 | camera = android.hardware.Camera.open(0);
32 | parameters = camera.getParameters();
33 | }
34 | parameters.setFlashMode(android.hardware.Camera.Parameters.FLASH_MODE_TORCH);
35 | camera.setParameters(parameters);
36 | camera.startPreview();
37 | }
38 | };
39 |
40 | flashlight.off = function () {
41 | if (flashlight.hasCamera2API()) {
42 | cameraManager.setTorchMode(camera, false);
43 | } else {
44 | parameters.setFlashMode(camera.Parameters.FLASH_MODE_OFF);
45 | camera.setParameters(parameters);
46 | camera.stopPreview();
47 | camera.release();
48 | }
49 | };
50 |
51 | module.exports = flashlight;
52 |
--------------------------------------------------------------------------------
/src/flashlight.ios.js:
--------------------------------------------------------------------------------
1 | var flashlight = require("./flashlight-common");
2 | var device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo);
3 |
4 | flashlight.isAvailable = function() {
5 | return !!device;
6 | };
7 |
8 | flashlight.on = function(arg) {
9 | this._checkAvailability();
10 |
11 | var intensity = AVCaptureMaxAvailableTorchLevel;
12 | if (arg && arg.intensity) {
13 | var requestedIntensity = arg.intensity;
14 | if (requestedIntensity > 0.0 && requestedIntensity < 1.0) {
15 | intensity = requestedIntensity;
16 | }
17 | }
18 |
19 | if (device.lockForConfiguration()) {
20 | device.setTorchModeOnWithLevelError(intensity);
21 | device.flashMode = AVCaptureFlashMode.On;
22 | device.unlockForConfiguration();
23 | }
24 | };
25 |
26 | flashlight.off = function() {
27 | if (device.lockForConfiguration()) {
28 | device.torchMode = AVCaptureTorchMode.Off;
29 | device.flashMode = AVCaptureFlashMode.Off;
30 | device.unlockForConfiguration();
31 | }
32 | };
33 |
34 | module.exports = flashlight;
35 |
--------------------------------------------------------------------------------
/src/index.d.ts:
--------------------------------------------------------------------------------
1 | export interface SwitchOnOptions {
2 | /**
3 | * Brightness setting, in the range 0.0 - 1.0, used on iOS only.
4 | * Default 1.0 (full brightness).
5 | */
6 | intensity?: number;
7 | }
8 |
9 | /**
10 | * Check if the device has flashlight capability.
11 | */
12 | export function isAvailable();
13 |
14 | /**
15 | * Check if the device’s flashlight is currently on.
16 | */
17 | export function isOn();
18 |
19 | /**
20 | * Turn the flashlight ON.
21 | */
22 | export function on(arg?: SwitchOnOptions);
23 |
24 | /**
25 | * Turn the flashlight OFF.
26 | */
27 | export function off();
28 |
29 | /**
30 | * Toggle the state of the flashlight.
31 | */
32 | export function toggle(arg?: SwitchOnOptions);
33 |
--------------------------------------------------------------------------------
/src/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-flashlight",
3 | "version": "2.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "tns-core-modules": {
8 | "version": "5.0.5",
9 | "resolved": "https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-5.0.5.tgz",
10 | "integrity": "sha512-AUwrn6TIhrTc88IO9X7SU4otT/dU84CPfHtAZHW+D05/alkkupfqrbHtQXjDH+TBkwiKbq48dBmI6OpM9Pablg==",
11 | "dev": true,
12 | "requires": {
13 | "tns-core-modules-widgets": "5.0.1",
14 | "tslib": "^1.9.3"
15 | }
16 | },
17 | "tns-core-modules-widgets": {
18 | "version": "5.0.1",
19 | "resolved": "https://registry.npmjs.org/tns-core-modules-widgets/-/tns-core-modules-widgets-5.0.1.tgz",
20 | "integrity": "sha512-zDml+PISblTkAQ+Xd4JcMHl/o5dpAn0B+R2fLtxWjNIhkNzNfz+FmfMtH7Js2wnwtLp+kC2ZNOQRVAzOBquxAQ==",
21 | "dev": true
22 | },
23 | "tns-platform-declarations": {
24 | "version": "5.0.5",
25 | "resolved": "https://registry.npmjs.org/tns-platform-declarations/-/tns-platform-declarations-5.0.5.tgz",
26 | "integrity": "sha512-paU+SgAPsDC3VH6YfvkQdfCzp24i+40sDz1L99AA2TCgqVnlrwgBxc25dhK18ai2gQR/ZqN3amYrexBnf4MUQQ==",
27 | "dev": true
28 | },
29 | "tslib": {
30 | "version": "1.9.3",
31 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
32 | "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==",
33 | "dev": true
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-flashlight",
3 | "version": "2.0.1",
4 | "description": "A flashlight NativeScript module for Android and iOS",
5 | "main": "flashlight",
6 | "typings": "index.d.ts",
7 | "nativescript": {
8 | "platforms": {
9 | "ios": "1.1.0",
10 | "android": "1.1.0"
11 | }
12 | },
13 | "scripts": {
14 | "demo.ios": "cd ../demo && tns run ios --syncAllFiles",
15 | "demo.android": "cd ../demo && tns run android --syncAllFiles"
16 | },
17 | "repository": {
18 | "type": "git",
19 | "url": "https://github.com/tjvantoll/nativescript-flashlight.git"
20 | },
21 | "keywords": [
22 | "NativeScript"
23 | ],
24 | "author": "TJ VanToll (http://tjvantoll.com/)",
25 | "contributors": [
26 | {
27 | "name": "Brad Martin",
28 | "email": "bradwaynemartin@gmail.com",
29 | "url": "https://github.com/bradmartin"
30 | },
31 | {
32 | "name": "Eddy Verbruggen",
33 | "email": "eddyverbruggen@gmail.com",
34 | "url": "https://github.com/eddyverbruggen"
35 | }
36 | ],
37 | "license": {
38 | "type": "MIT",
39 | "url": "https://github.com/tjvantoll/nativescript-flashlight/blob/master/LICENSE"
40 | },
41 | "bugs": {
42 | "url": "https://github.com/tjvantoll/nativescript-flashlight/issues"
43 | },
44 | "homepage": "https://github.com/tjvantoll/nativescript-flashlight",
45 | "devDependencies": {
46 | "tns-core-modules": "~5.0.5",
47 | "tns-platform-declarations": "~5.0.5"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/platforms/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/references.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------