ionic-Material Design , Codecanyon
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<!--View Information-->
|
||||
<!--View name : Device Flashlight-->
|
||||
<!--Controller name : flashLightCtrl-->
|
||||
<!--Controller path : www/templates/hardware-connect/flash-light/js/controllers.js-->
|
||||
<!--State name : app.flashLight-->
|
||||
<!--URL : #app/flashLight-->
|
||||
|
||||
<ion-view title="Flash Light">
|
||||
<!--flash light section-->
|
||||
<!--flash light icon section-->
|
||||
<ion-content id="flash-light-content" scroll="false">
|
||||
<div class="row">
|
||||
<div id="flash-light-icon" class="col">
|
||||
<i ng-class="{'flash-light-color' : isTurnOn}" class="fa fa-diamond center-screen icon-flash-light"></i>
|
||||
</div>
|
||||
</div><!--end flash light icon section-->
|
||||
|
||||
<div class="row">
|
||||
<!--flash light control section-->
|
||||
<div id="flash-light-control" class="col">
|
||||
<p>Devise Flash Light</p>
|
||||
<a ng-class="{'md-warn' : isTurnOn}" class="md-raised md-primary md-button md-default-theme"
|
||||
ng-click="flashLight()">
|
||||
Turn {{isTurnOn == true ? 'OFF' : 'On'}}
|
||||
</a>
|
||||
</div><!--end flash light control section-->
|
||||
</div>
|
||||
</ion-content><!--end flash light section-->
|
||||
</ion-view>
|
||||
@@ -0,0 +1,52 @@
|
||||
// For using flashlight you have to install $cordovaFlashlight by running the following
|
||||
// command in your cmd.exe for windows or terminal for mac:
|
||||
// $ cd your_project_path
|
||||
// $ ionic plugin remove nl.x-services.plugins.flashlight
|
||||
// $ ionic plugin add https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin.git
|
||||
//
|
||||
// Learn more about $cordovaFlashlight :
|
||||
// http://ngcordova.com/docs/plugins/flashlight/
|
||||
//
|
||||
// Controller of Flashlight page.
|
||||
appControllers.controller('flashLightCtrl', function ($scope, $cordovaFlashlight, $timeout) {
|
||||
|
||||
// initialForm is the first activity in the controller.
|
||||
// It will initial all variable data and let the function works when page load.
|
||||
$scope.initialForm = function () {
|
||||
//$scope.isTurnOn is Flashlight status.
|
||||
$scope.isTurnOn = false;
|
||||
|
||||
//$scope.deviceInformation is getting device platform.
|
||||
$scope.deviceInformation = ionic.Platform.device();
|
||||
//If you start your application with flash Light feature.
|
||||
//You have to add timeout for 2 sec before run it.
|
||||
}; // End initialForm.
|
||||
|
||||
// flashLight for turn on and off flashLight.
|
||||
$scope.flashLight = function () {
|
||||
// turn on flashLight
|
||||
if ($scope.isTurnOn == false) {
|
||||
// turn on flashLight for Android
|
||||
if ($scope.deviceInformation.platform == "Android") {
|
||||
$scope.isTurnOn = true;
|
||||
$timeout(function () {
|
||||
$cordovaFlashlight.switchOn();
|
||||
}, 50);
|
||||
}
|
||||
// turn on flashLight for IOS
|
||||
else {
|
||||
$scope.isTurnOn = true;
|
||||
$cordovaFlashlight.switchOn();
|
||||
}
|
||||
} // End turn on flashLight.
|
||||
|
||||
// turn off flashLight.
|
||||
else {
|
||||
$scope.isTurnOn = false;
|
||||
$cordovaFlashlight.switchOff();
|
||||
}// End turn off flashLight.
|
||||
};// End flashLight.
|
||||
|
||||
$scope.initialForm();
|
||||
|
||||
});// End of Flashlight Controller.
|
||||
Reference in New Issue
Block a user