add video share sheet to watch page

This commit is contained in:
Ethan 2022-03-22 00:47:28 -05:00
parent c9ca9ab6b6
commit 64956ea4ec
7 changed files with 33 additions and 8 deletions

View File

@ -22,7 +22,7 @@
style="padding: 0; margin: 0" style="padding: 0; margin: 0"
elevation="0" elevation="0"
:disabled="item.disabled" :disabled="item.disabled"
@click="item.action" @click="callMethodByName(item.actionName)"
> >
<v-icon v-text="item.icon" /> <v-icon v-text="item.icon" />
<div class="mt-2" style="font-size: .66rem;" v-text="item.value || item.name" /> <div class="mt-2" style="font-size: .66rem;" v-text="item.value || item.name" />
@ -79,6 +79,8 @@
</style> </style>
<script> <script>
import { Share } from "@capacitor/share";
export default { export default {
data() { data() {
return { return {
@ -86,26 +88,28 @@ export default {
{ {
name: "Likes", name: "Likes",
icon: "mdi-thumb-up-outline", icon: "mdi-thumb-up-outline",
action: null, // action: null,
value: this.likes, value: this.likes,
disabled: true, disabled: true,
}, },
{ {
name: "Dislikes", name: "Dislikes",
icon: "mdi-thumb-down-outline", icon: "mdi-thumb-down-outline",
action: this.dislike(), // action: this.dislike(),
actionName: "dislike",
value: this.dislikes, value: this.dislikes,
disabled: true, disabled: true,
}, },
{ {
name: "Share", name: "Share",
icon: "mdi-share-outline", icon: "mdi-share-outline",
action: this.share(), // action: this.share(),
disabled: true, actionName: "share",
disabled: false,
}, },
], ],
showMore: false, showMore: false,
share: false, // share: false,
title: null, title: null,
uploaded: null, uploaded: null,
vidSrc: null, vidSrc: null,
@ -144,9 +148,20 @@ export default {
}); });
}, },
methods: { methods: {
callMethodByName(name) {
// Helper function needed because of issues when directly calling method
// using item.action in the v-for loop
this[name]();
},
dislike() {}, dislike() {},
share() { async share() {
this.share = !this.share; // this.share = !this.share;
await Share.share({
title: this.title,
text: this.title,
url: 'https://youtu.be/' + this.$route.query.v,
dialogTitle: 'Share video',
});
}, },
}, },
}; };

View File

@ -13,6 +13,7 @@ dependencies {
implementation project(':capacitor-app') implementation project(':capacitor-app')
implementation project(':capacitor-browser') implementation project(':capacitor-browser')
implementation project(':capacitor-device') implementation project(':capacitor-device')
implementation project(':capacitor-share')
implementation project(':capacitor-splash-screen') implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar') implementation project(':capacitor-status-bar')

View File

@ -15,6 +15,10 @@
"pkg": "@capacitor/device", "pkg": "@capacitor/device",
"classpath": "com.capacitorjs.plugins.device.DevicePlugin" "classpath": "com.capacitorjs.plugins.device.DevicePlugin"
}, },
{
"pkg": "@capacitor/share",
"classpath": "com.capacitorjs.plugins.share.SharePlugin"
},
{ {
"pkg": "@capacitor/splash-screen", "pkg": "@capacitor/splash-screen",
"classpath": "com.capacitorjs.plugins.splashscreen.SplashScreenPlugin" "classpath": "com.capacitorjs.plugins.splashscreen.SplashScreenPlugin"

View File

@ -14,6 +14,9 @@ project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/
include ':capacitor-device' include ':capacitor-device'
project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android') project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android')
include ':capacitor-share'
project(':capacitor-share').projectDir = new File('../node_modules/@capacitor/share/android')
include ':capacitor-splash-screen' include ':capacitor-splash-screen'
project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android') project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android')

0
android/gradlew vendored Normal file → Executable file
View File

View File

@ -13,6 +13,7 @@ def capacitor_pods
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser' pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser'
pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device' pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen' pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
end end

View File

@ -7,6 +7,7 @@
"@capacitor/cli": "^3.4.0", "@capacitor/cli": "^3.4.0",
"@capacitor/core": "^3.4.0", "@capacitor/core": "^3.4.0",
"@capacitor/device": "^1.1.2", "@capacitor/device": "^1.1.2",
"@capacitor/share": "^1.1.2",
"@capacitor/splash-screen": "^1.2.2", "@capacitor/splash-screen": "^1.2.2",
"@capacitor/status-bar": "^1.0.8" "@capacitor/status-bar": "^1.0.8"
} }