diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts
index ffe35051b..b2dee8dfa 100644
--- a/src/app/pages/chat/messages/messages.page.ts
+++ b/src/app/pages/chat/messages/messages.page.ts
@@ -111,19 +111,19 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.scrollChangeCallback = () => this.onContentScrolled(event);
window.addEventListener('scroll', this.scrollChangeCallback, true);
- const gesture = this.gestureController.create({
- el: this.rectangle.nativeElement,
- gestureName:'long-press',
- onStart: () => { alert('OP') },
- /* onMove () => {
- console.log('Move');
- }, */
- onEnd: () => {
- console.log('ENNNNNDS');
- },
- })
+ // const gesture = this.gestureController.create({
+ // el: this.rectangle.nativeElement,
+ // gestureName:'long-press',
+ // onStart: () => { alert('OP') },
+ // /* onMove () => {
+ // console.log('Move');
+ // }, */
+ // onEnd: () => {
+ // console.log('ENNNNNDS');
+ // },
+ // })
- gesture.enable();
+ // gesture.enable();
}
handlePress(id?:string){
@@ -426,7 +426,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
//this.loadPicture();
}
else if(res['data'] == 'add-picture'){
- this.fileService.addPictureToChat(roomId);
+ this.fileService.addPictureToChatMobile(roomId);
//this.loadPicture();
}
else if(res['data'] == 'add-document'){
diff --git a/src/app/services/file/file-loader.service.ts b/src/app/services/file/file-loader.service.ts
index c88f16544..f28298ee7 100644
--- a/src/app/services/file/file-loader.service.ts
+++ b/src/app/services/file/file-loader.service.ts
@@ -17,21 +17,23 @@ export class FileLoaderService {
createInput({accept, type = 'file'}:createInput): HTMLInputElement {
-
+
let input = document.createElement('input');
input.type = type || 'file';
input.accept = accept.join(', ')
-
+
// input.onchange = () => {
// // you can use this method to get file and perform respective operations
// let files = Array.from(input.files);
// console.log(files);
// };
+
input.click();
return input
-
+
+
}
getFirstFile(input: HTMLInputElement) {
diff --git a/src/app/services/functions/file.service.ts b/src/app/services/functions/file.service.ts
index 41a6c5e4c..cf4e11f4d 100644
--- a/src/app/services/functions/file.service.ts
+++ b/src/app/services/functions/file.service.ts
@@ -86,38 +86,114 @@ export class FileService {
}
addCameraPictureToChat(roomId){
- let data = this.takePicture();
- if(data.name != null){
+
+ const options: CameraOptions = {
+ quality: 50,
+ destinationType: this.camera.DestinationType.DATA_URL,
+ encodingType: this.camera.EncodingType.JPEG,
+ mediaType: this.camera.MediaType.PICTURE,
+ targetWidth: 720,
+ targetHeight: 720,
+ }
+
+ this.camera.getPicture(options).then((imageData) => {
+ this.capturedImage = 'data:image/png;base64,'+imageData;
+ this.capturedImageTitle = new Date().getTime() + '.jpeg';
+
let body = {
"message":
{
"rid": roomId,
"msg": "",
"attachments": [{
- "title": data.name,
+ "title": this.capturedImageTitle,
"title_link_download": false,
- "image_url": data.image,
+ "image_url": this.capturedImage,
}]
}
}
+ const loader = this.toastService.loading();
this.chatService.sendMessage(body).subscribe(res=> {
console.log(res);
+ loader.remove();
},(error) => {
-
+ loader.remove();
+ this.toastService.badRequest("Não foi possível adicionar a fotografia!");
});
- }
- else{
+
+ }, (err) => {
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
+ });
+
+ }
+
+ addPictureToChatMobile(roomId) {
+ alert('Here')
+
+ const options: CameraOptions = {
+ quality: 90,
+ sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
+ destinationType: this.camera.DestinationType.DATA_URL,
+ encodingType: this.camera.EncodingType.JPEG,
+ mediaType: this.camera.MediaType.PICTURE,
+ targetWidth: 720,
+ targetHeight: 720,
+ correctOrientation: true
}
+
+ this.camera.getPicture(options).then((imageData) => {
+ let base64Image = 'data:image/jpeg;base64,' + imageData;
+ this.capturedImage = imageData;
+ this.capturedImageTitle = new Date().getTime() + '.jpeg';
+
+ //const loader = this.toastService.loading();
+
+ let body = {
+ "message":
+ {
+ "rid": roomId,
+ "msg": "",
+ "attachments": [{
+ //"title": this.capturedImageTitle ,
+ //"text": "description",
+ "title_link_download": false,
+ "image_url": this.capturedImage,
+ }]
+ }
+ }
+
+ console.log(this.capturedImage)
+
+ this.chatService.sendMessage(body).subscribe(res=> {
+ //loader.remove();
+ //console.log(res);
+ },(error) => {
+ //loader.remove();
+ });
+
+
+ }, (err) => {
+ //console.log(err);
+ });
+
}
addPictureToChat(roomId) {
+
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
+
+ setInterval(()=>{
+ console.log(input.value)
+ }, 550)
+
+
input.onchange = async () => {
+ alert('Onchange AQUI')
+
const file = this.fileLoaderService.getFirstFile(input)
console.log(file);
diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html
index 94cbbd60c..d41eb12bb 100644
--- a/src/app/shared/chat/group-messages/group-messages.page.html
+++ b/src/app/shared/chat/group-messages/group-messages.page.html
@@ -144,7 +144,7 @@
-
+
diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html
index d1e2cc28e..8ed7ecf5b 100644
--- a/src/app/shared/chat/messages/messages.page.html
+++ b/src/app/shared/chat/messages/messages.page.html
@@ -114,7 +114,7 @@
-
+
diff --git a/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html b/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html
index e71d2f4d5..5226c4525 100644
--- a/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html
+++ b/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html
@@ -7,7 +7,7 @@