ben

OMÜ , Bilgisayar Mühendisliği, 13'

20 Temmuz 2016 Çarşamba

ionic-plugin-flash

 Projemize buradaki ayarları yaptıktan sonra devam edelim. Flashlight Plugini Telefonun flaşını açıp kapatmamızı sağlar. Bir nevi fener uygulaması için kullanılabilir

Plugin sayfası: http://ngcordova.com/docs/plugins/flashlight/

proje dizinimize gelip terminalden plugini ekleyelim:

$ cordova plugin add https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin.git

Sayfa bağlantısını yapalım:

www/templates/flash.html

<ion-view view-title="Flash">
  <ion-content>
 
  <br/>
   <h3>fener  Uygulaması</h3>
  <br/>
    <button class="button button-calm" ng-click="openflash()">Işıgı aç</button>
   
    <button class="button button-assertive" ng-click="closeflash()">Işıgı kapat</button>
  </ion-content>

</ion-view>

www/templates/menu.html

 <ion-list>
           *
           *
         <ion-item menu-close ui-sref="app.flash">
          Flash
        </ion-item>
          *
          *
 </ion-list>

www/js/app.js  içerisine aşağıdaki kodları yazalım,

  .state('app.flash',{
    url:'/flash',
    views: {
        'menuContent': {
          templateUrl: 'templates/flash.html',
          controller:'FlashCtrl'
        }
      }

  })

www/js/controller.js içerisine:

.controller('FlashCtrl',function($scope,$cordovaFlashlight ){

  $scope.openflash=function(){
    $cordovaFlashlight.switchOn().then(function () {  },
          function (error) {  });
  };

  $scope.closeflash=function(){
    $cordovaFlashlight.switchOff().then(function () { },
          function (error) {  });
  };
})



Uygulamamızı çalıştıralım:



NOT: Her cihazda çalışmadı, bazı telefonlarda çalıştı. %100 stabil çalışan bir plugin değil..

Hiç yorum yok: