2022-03-07 14:36:23 +00:00
|
|
|
//--- Modules/Imports ---//
|
|
|
|
import { Http } from '@capacitor-community/http';
|
2022-03-18 11:49:47 +00:00
|
|
|
import { StatusBar, Style } from '@capacitor/status-bar';
|
2022-03-17 05:57:28 +00:00
|
|
|
import constants from '../static/constants';
|
2022-03-18 11:49:47 +00:00
|
|
|
import { hexToRgb, rgbToHex } from './utils';
|
2022-03-07 14:36:23 +00:00
|
|
|
|
|
|
|
const module = {
|
|
|
|
|
2022-03-17 05:57:28 +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)
|
|
|
|
});
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
getRuns(item, callback) {
|
|
|
|
|
|
|
|
let url = `${constants.URLS.VT_GITHUB}/commits/${item.sha}/check-runs`;
|
|
|
|
|
|
|
|
Http.request({
|
|
|
|
method: 'GET',
|
|
|
|
url: url,
|
|
|
|
params: {}
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
callback(res.data)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
callback(err)
|
|
|
|
});
|
|
|
|
|
2022-03-18 11:49:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
statusBar: {
|
|
|
|
async hide() {
|
|
|
|
return await StatusBar.hide();
|
|
|
|
},
|
|
|
|
async show() {
|
|
|
|
return await StatusBar.show();
|
|
|
|
},
|
|
|
|
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) {
|
2022-03-18 12:25:09 +00:00
|
|
|
return await StatusBar.setBackgroundColor({color: color});
|
2022-03-18 11:49:47 +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-17 05:57:28 +00:00
|
|
|
inject('vuetube', module)
|
2022-03-18 11:49:47 +00:00
|
|
|
}
|