0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-19 09:45:14 +00:00
VueTube/NUXT/plugins/vuetube.js

82 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-03-07 14:36:23 +00:00
//--- Modules/Imports ---//
2022-03-21 23:47:11 +00:00
import { Http } from "@capacitor-community/http";
import { StatusBar, Style } from "@capacitor/status-bar";
import { NavigationBar } from "@hugotomazi/capacitor-navigation-bar";
2022-03-21 23:47:11 +00:00
import constants from "./constants";
import { hexToRgb, rgbToHex } from "./utils";
2022-03-07 14:36:23 +00:00
const module = {
2022-03-21 23:47:11 +00:00
//--- Get GitHub Commits ---//
commits: new Promise((resolve, reject) => {
Http.request({
method: "GET",
url: `${constants.URLS.VT_GITHUB}/commits`,
params: {},
})
.then((res) => {
resolve(res.data);
})
.catch((err) => {
reject(err);
});
}),
2022-03-07 14:36:23 +00:00
2022-03-21 23:47:11 +00:00
getRuns(item, callback) {
let url = `${constants.URLS.VT_GITHUB}/commits/${item.sha}/check-runs`;
2022-03-21 23:47:11 +00:00
Http.request({
method: "GET",
url: url,
params: {},
})
.then((res) => {
callback(res.data);
})
.catch((err) => {
callback(err);
});
},
2022-03-21 23:47:11 +00:00
statusBar: {
async hide() {
return await StatusBar.hide();
2022-03-18 11:49:47 +00:00
},
2022-03-21 23:47:11 +00:00
async show() {
return await StatusBar.show();
2022-03-18 11:49:47 +00:00
},
2022-03-21 23:47:11 +00:00
async setLight() {
return await StatusBar.setStyle({ style: Style.Light });
},
async setDark() {
return await StatusBar.setStyle({ style: Style.Dark });
},
async setTransparent() {
return StatusBar.setOverlaysWebView({ overlay: true });
},
async setBackground(color) {
return await StatusBar.setBackgroundColor({ color: color });
},
},
2022-03-18 11:49:47 +00:00
navigationBar: {
async hide() {
return await NavigationBar.hide();
},
async show() {
return await NavigationBar.show();
},
},
2022-03-21 23:47:11 +00:00
hexToRgb(hex) {
return hexToRgb(hex);
},
rgbToHex(r, g, b) {
return rgbToHex(r, g, b);
},
};
2022-03-07 14:36:23 +00:00
//--- Start ---//
export default ({ app }, inject) => {
2022-03-21 23:47:11 +00:00
inject("vuetube", module);
};