add clipboard support and limit share option to android devices

This commit is contained in:
Morgan McMillian 2018-11-21 07:42:18 -08:00
parent 7177f63b27
commit 1e0d8a2af0
4 changed files with 35 additions and 2 deletions

17
package-lock.json generated
View file

@ -5742,6 +5742,23 @@
"resolved": "https://registry.npmjs.org/ng2-cordova-oauth/-/ng2-cordova-oauth-0.0.8.tgz",
"integrity": "sha1-SW+rlufBraHuskNX36wvjP/p80I="
},
"ngx-clipboard": {
"version": "11.1.9",
"resolved": "https://registry.npmjs.org/ngx-clipboard/-/ngx-clipboard-11.1.9.tgz",
"integrity": "sha512-xF54Ibt/04g2B5SnYylNz7ESP1/thuC7odo+0bKkgbCC873NaqP1VTVx/umh/cnezlXKu8zuWNzzg05tvfgaJg==",
"requires": {
"ngx-window-token": "1.0.2",
"tslib": "1.9.0"
}
},
"ngx-window-token": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ngx-window-token/-/ngx-window-token-1.0.2.tgz",
"integrity": "sha512-bFgvi7MYSK1p4b3Mqvn9+biXaO8QDEbpP2sEMSwr0Zgrwh6zCO3F92a6SIIzusqpZBAhxyfVSqj3mO5qIxlM5Q==",
"requires": {
"tslib": "1.9.0"
}
},
"no-case": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",

View file

@ -47,6 +47,7 @@
"ionicons": "4.2.4",
"moment": "^2.18.1",
"ng2-cordova-oauth": "0.0.8",
"ngx-clipboard": "^11.1.9",
"pnut-butter": "^0.21.0",
"run": "^1.4.0",
"rxjs": "5.5.8",

View file

@ -23,6 +23,7 @@ import { FilePath } from '@ionic-native/file-path';
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
import { TimeagoPipe } from '../pipes/timeago/timeago';
import { ParserPipe } from '../pipes/parser/parser';
import { ClipboardModule } from 'ngx-clipboard';
@NgModule({
declarations: [
@ -45,6 +46,7 @@ import { ParserPipe } from '../pipes/parser/parser';
BrowserModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot(),
ClipboardModule,
],
bootstrap: [IonicApp],
entryComponents: [

View file

@ -1,6 +1,8 @@
import { Component } from '@angular/core';
import { ViewController, NavParams, ToastController } from 'ionic-angular';
import { Events } from 'ionic-angular';
import { Device } from '@ionic-native/device';
import { ClipboardService } from 'ngx-clipboard';
import * as pnut from 'pnut-butter';
@ -8,7 +10,8 @@ import * as pnut from 'pnut-butter';
template: `
<ion-list>
<button ion-item (click)="browse()">Open in Browser</button>
<button ion-item (click)="share()">Share</button>
<button ion-item *ngIf="showShareBtn" (click)="share()">Share</button>
<button ion-item (click)="copy()">Copy to clipboard</button>
<button ion-item *ngIf="showDelBtn" (click)="delete()">Delete</button>
</ion-list>
`
@ -16,14 +19,18 @@ import * as pnut from 'pnut-butter';
export class PostMenu {
showDelBtn: boolean = false;
showShareBtn: boolean = false;
constructor(public navParams: NavParams, public viewCtrl: ViewController, public toastCtrl: ToastController,
public events: Events) {
public events: Events, private clipboardSrv: ClipboardService, private device: Device) {
if (navParams.data.me == navParams.data.post.user.username) {
this.showDelBtn = true;
} else {
this.showDelBtn = false;
}
if (this.device.platform === "Android" || this.device.platform === "amazon-fireos") {
this.showShareBtn = true;
}
}
browse() {
@ -42,6 +49,12 @@ export class PostMenu {
this.close();
}
copy() {
this.clipboardSrv.copyFromContent(this.navParams.data.post.content.text);
this.presentToast('Post copied');
this.close();
}
delete() {
pnut.deletePost(this.navParams.data.post.id).then(res => {
console.log(res);