forked from supertitanoboa/mementos-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: Testing that images are saved into S3 Add Camera service Adds cleanup method and newImage directive TODO: newImage's directive template Add newImage directive template Adds new camera and directive js files into index.html Adds newImage directive tag into newItem template Adds newImage directives and templates and formatting Creates media.camera.service - Uses the ngCordova to inject $cordovaCamera - Adds the camera service into the core modules Adding all cordova hooks into the .gitignore Fixes Camera Feature Uncommets $httpProvider.withCredentials config Restores signup as inital page
- Loading branch information
1 parent
9f8f00b
commit 0e80ab4
Showing
15 changed files
with
188 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('app.core', []); | ||
angular.module('app.core', ['app.media', 'ngCordova']); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular | ||
.module('app.media') | ||
.factory('Camera', Camera); | ||
|
||
/* @ngInject */ | ||
function Camera($q, $cordovaCamera) { | ||
|
||
var service = { | ||
takePhoto: takePhoto | ||
}; | ||
|
||
return service; | ||
|
||
function takePhoto() { | ||
var q = $q.defer(); | ||
|
||
// DOCs about Options | ||
// https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md#cameraoptions | ||
var cameraOptions = { | ||
destinationType : 0, | ||
sourceType : 1, | ||
encodingType: 0, | ||
allowEdit : true, | ||
quality: 100, | ||
targetWidth: 640, | ||
targetHeight: 640, | ||
correctOrientation: true, | ||
saveToPhotoAlbum: false | ||
}; | ||
|
||
$cordovaCamera.getPicture(cameraOptions) | ||
.then(function(result) { | ||
q.resolve(result); | ||
}, function(err) { | ||
q.reject(err); | ||
}); | ||
|
||
return q.promise; | ||
} | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(function() { | ||
|
||
'use strict'; | ||
angular.module('app.media', []); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div ng-show="imageHasBeenTaken" class="card list new-image-container"> | ||
|
||
<div class="item item-image-wrap header-area"> | ||
<h2>Are you happy with your picture?</h2> | ||
</div> | ||
|
||
<div class="item item-image-wrap" style="display: block"> | ||
<img ng-src="data:image/jpeg;base64,{{image}}"/> | ||
</div> | ||
|
||
<div class="item action" style="display: block"> | ||
<button class="save button button-clear button-balanced ion-checkmark-round" on-tap="saveImage(image)"></button> | ||
<button class="cancel button button-clear ion-close-round button-assertive" on-tap="cancel()"></button> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
(function() { | ||
|
||
angular | ||
.module('app.moment.items') | ||
.directive('newImage', newImage); | ||
|
||
/* @ngInject */ | ||
function newImage(Camera) { | ||
|
||
return { | ||
restrict: 'EA', | ||
replace: true, | ||
templateUrl: 'app/moment/items/newImage.directive.html', | ||
link: link | ||
}; | ||
|
||
function link (scope, element, attrs) { | ||
var vm = scope; | ||
|
||
vm.saveImage = saveImage; | ||
vm.cancel = cancel; | ||
|
||
vm.imageHasBeenTaken = false; | ||
vm.image = null; | ||
|
||
activate(); | ||
|
||
////////////////////////////////////////// | ||
|
||
function activate() { | ||
Camera.takePhoto() | ||
.then(function(image) { | ||
vm.image = image; | ||
vm.imageHasBeenTaken = true; | ||
}) | ||
.catch(function(err) { | ||
console.error(err); | ||
}); | ||
} | ||
|
||
function saveImage(image) { | ||
vm.insertIntoMoment('image/jpeg', image); | ||
vm.imageHasBeenTaken = false; | ||
vm.done(); | ||
} | ||
|
||
function cancel() { | ||
vm.imageHasBeenTaken = false; | ||
vm.image = null; | ||
vm.done(); | ||
} | ||
|
||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="card image-item-container"> | ||
<div class="item item-image-wrap"> | ||
<img ng-src="data:image/jpeg;base64,{{ item.payload }}"/> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(function() { | ||
|
||
angular | ||
.module('app.moment.items') | ||
.directive('showImage', showImage); | ||
|
||
/* @ngInject */ | ||
function showImage() { | ||
|
||
var directive = { | ||
restrict: 'EA', | ||
templateUrl: 'app/moment/items/showImage.directive.html', | ||
replace: true | ||
}; | ||
|
||
return directive; | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
.new-items { | ||
.buttons { | ||
display: block; | ||
margin: 0 auto; | ||
|
||
button { | ||
display: inline-block; | ||
} | ||
} | ||
} | ||
.buttons { | ||
display: block; | ||
margin: 0 auto; | ||
|
||
button { | ||
display: inline-block; | ||
} | ||
} | ||
} | ||
|
||
.item-image-wrap { | ||
img { | ||
display: block; | ||
height: auto; | ||
width: auto; | ||
max-width: 85vw; | ||
margin: 0 auto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters