VueTube/NUXT/layouts/default.vue

156 lines
3.6 KiB
Vue
Raw Normal View History

2022-01-24 22:56:57 +00:00
<template>
<v-app>
<v-card class="topNav rounded-0" style="display: flex; box-shadow: none !important;" color="accent white--text">
2022-03-07 18:38:54 +00:00
<h2 v-text="page" v-show="!search" />
2022-03-07 18:53:14 +00:00
<v-text-field
label="Search"
v-model="text"
@input="textChanged"
class="searchBar"
color="white"
v-if="search"
/>
2022-01-25 02:45:23 +00:00
<v-spacer />
2022-02-25 13:06:13 +00:00
<v-btn text class="toolbarAction mr-2 fill-height" color="white" @click="search = !search"><v-icon>mdi-magnify</v-icon></v-btn>
2022-02-25 18:57:58 +00:00
<v-menu offset-y content-class="mt-8">
2022-03-07 18:38:54 +00:00
<template v-slot:activator="{ on, attrs }"><v-btn text class="toolbarAction fill-height" v-bind="attrs" v-on="on" color="white" v-show="!search"><v-icon>mdi-dots-vertical</v-icon></v-btn></template>
2022-02-25 19:08:26 +00:00
<v-list style="min-width: 180px;">
2022-02-25 00:33:03 +00:00
<v-list-item v-for="(item, index) in dropdownMenu" :key="index">
2022-02-25 19:08:26 +00:00
<v-btn text :to="item.link" style="text-decoration: none; width: 100%;" class="info--text">{{ item.title }}</v-btn>
2022-02-25 00:33:03 +00:00
</v-list-item>
</v-list>
</v-menu>
2022-03-02 17:53:04 +00:00
2022-01-24 23:16:53 +00:00
</v-card>
<div class="accent" style="height: 100%">
2022-03-02 17:53:04 +00:00
<div class="background">
2022-03-02 19:11:16 +00:00
<nuxt v-show="!search" />
2022-03-07 18:53:14 +00:00
<div style="min-width: 180px;" v-if="search">
<v-list-item v-for="(item, index) in response" :key="index">
<v-btn text dense class="info--text searchButton text-left" @click="youtubeSearch(item)" v-text="item[0]" />
</v-list-item>
</div>
</div>
2022-02-24 19:45:36 +00:00
</div>
2022-01-24 22:56:57 +00:00
2022-03-02 13:14:52 +00:00
<bottomNavigation v-if="!search" />
2022-01-24 22:56:57 +00:00
</v-app>
</template>
2022-02-24 19:45:36 +00:00
<style>
* {
font-family: Arial, Helvetica, sans-serif !important;
}
html, body {
overflow-x: hidden;
}
2022-02-24 19:45:36 +00:00
</style>
2022-01-24 23:16:53 +00:00
<style scoped>
.toolbarAction {
min-width: 40px !important;
}
2022-01-24 23:16:53 +00:00
.topNav {
padding: 1rem;
2022-03-07 18:38:54 +00:00
position: fixed;
width: 100%;
2022-03-02 17:53:04 +00:00
top: 0;
z-index: 999;
2022-03-02 18:44:15 +00:00
/*border-radius: 0 0 1em 1em !important;*/
2022-01-24 23:16:53 +00:00
}
2022-01-25 02:45:23 +00:00
.topNavSearch {
2022-01-25 03:10:51 +00:00
margin-bottom: -10em;
2022-01-25 02:45:23 +00:00
margin-left: 2em;
2022-03-02 17:53:04 +00:00
/*transform: translateY(-2.5%);*/
}
.background {
height: 100%;
2022-03-07 18:38:54 +00:00
padding: 4em 0 4em 0; /* Account for Top/Bottom Novigation */
2022-01-25 02:45:23 +00:00
}
2022-03-07 18:53:14 +00:00
.searchBar {
margin: 0;
position: absolute;
2022-03-13 19:48:27 +00:00
transform: translateY(-10%);
width: 80%
2022-03-07 18:53:14 +00:00
}
.searchButton {
width: 100%;
justify-content: left !important;
}
2022-01-24 23:16:53 +00:00
</style>
2022-01-24 22:56:57 +00:00
<script>
2022-03-07 18:53:14 +00:00
import { App as CapacitorApp } from '@capacitor/app';
export default {
data: () => ({
search: false,
2022-03-07 18:53:14 +00:00
dropdownMenu: [
{ title: "Settings", link: "/settings" },
{ title: "Updates", link: "/updates" },
{ title: "About", link: "/about" },
{ title: "Logs", link: "/logs" }
],
text: null,
response: [],
}),
2022-03-13 19:45:48 +00:00
2022-03-07 18:53:14 +00:00
mounted() {
2022-03-13 19:45:48 +00:00
//--- Load Saved Theme ---//
const theme = this.$auth.$storage.getLocalStorage("darkTheme");
if (theme != undefined) {
this.$vuetify.theme.dark = theme;
}
//--- Back Button Listener ---//
2022-03-07 18:53:14 +00:00
CapacitorApp.addListener('backButton', ({canGoBack}) => {
2022-03-13 18:20:43 +00:00
2022-03-13 19:45:48 +00:00
//--- Back Closes Search ---//
2022-03-13 18:20:43 +00:00
if (this.search) {
this.search = false;
2022-03-13 19:45:48 +00:00
//--- Back Goes Back ---//
} else if (!canGoBack){
2022-03-07 18:53:14 +00:00
CapacitorApp.exitApp();
} else {
window.history.back();
}
2022-03-07 18:53:14 +00:00
});
},
computed: {
page: function () {
let pageName = this.$route.path.split("/")[1];
pageName = pageName.charAt(0).toUpperCase() + pageName.slice(1);
return pageName || "Home";
}
},
methods: {
textChanged() {
this.$youtube.autoComplete(this.text, (res) => {
const data = res.replace(/^.*?\(/,'').replace(/\)$/,''); //Format Response
this.response = JSON.parse(data)[1]
});
},
youtubeSearch(item) {
location.href="/search?q="+item[0];
2022-02-24 19:55:29 +00:00
}
2022-01-24 22:56:57 +00:00
}
2022-03-07 18:53:14 +00:00
}
2022-01-24 22:56:57 +00:00
</script>