A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
51
console.log(error);52
}53
},54
onTouchStart(event) {55
this.touch = event.changedTouches[0];56
this.target = event.target;57
},58
onTouchEnd(event) {59
const touch = event.changedTouches[0];60
const diff = {61
x: touch.pageX - this.touch.pageX,62
y: touch.pageY - this.touch.pageY63
};64
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);65
const index = state.tabs.indexOf(state.tab);66
if(state.app.$refs.player.open) {67
return;68
}69
if(Math.abs(diff.x) >= SWIPE_THRESHOLD) {70
if(this.open && diff.x > 0 && (angle <= -60 || angle >= 60)) {71
this.open = false;72
}73
}74
},54
gradient(color) {55
return `linear-gradient(to bottom, ${color ?? 'transparent'}, transparent)`;56
},
80
this.show({ id });81
}82
},104
created() {105
document.body.addEventListener('touchstart', this.onTouchStart);106
document.body.addEventListener('touchend', this.onTouchEnd);107
},108
onUnmounted() {109
document.body.removeEventListener('touchstart', this.onTouchStart);110
document.body.removeEventListener('touchend', this.onTouchEnd);111
},112
computed: {113
opacity() {114
return {115
'opacity': `${this.open === true ? 1 : 0}`,116
'pointer-events': `${this.open === true ? 'all' : 'none'}`117
};118
}119
},83
template: `84
<v-tab id="detail" :tab="state.tab">85
<div class="z-40">86
<div124
@click="open = false"125
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-detail"126
:style="opacity"127
>128
</div>129
<div87
ref="modal"88
class="w-full mx-auto flex flex-col bg-black fixed left-[100vw] top-0 h-[100vh] overflow-y-auto pb-12 sm:pb-[100px] transition-detail"89
:class="{ 'detail-active': open }"
20
'^\/favorites$': 'favorites',21
'^\/account$': 'account',22
'^\/station\/(\\d+)$': 'detail',23
'^@not-found$': 'not-found'23
'^@not-found$': 'not-found',24
'^@auth$': 'auth'25
};27
export const state = reactive({
78
state.station = null;79
if(state.account === null) {80
state.authenticated = false;81
$route('@auth', { update: false });82
return;83
}84
state.authenticated = true;
1
import {$lang, http} from '../utils.js';1
import {$lang, $route, http} from '../utils.js';2
import VTab from '../component/tab.js';3
import VSelect from '../component/select.js';4
import VButton from '../element/button.js';
20
},21
methods: {22
$lang,23
$route,24
async register() {25
try {26
localStorage.removeItem('verbal-token');
30
});31
localStorage.setItem('verbal-token', device.uid);32
this.state.app.init();33
$route('/');34
}35
catch(err) {36
console.error(err);
41
localStorage.setItem('verbal-token', this.token);42
await http`get::/api/account`();43
this.state.app.init();44
$route('/');45
}46
catch(err) {47
localStorage.removeItem('verbal-token');
50
}51
},52
template: `50
<v-tab id="account" :tab="state.tab">53
<v-tab id="auth" :tab="state.tab">54
<div class="flex flex-col items-center justify-center h-screen min-h-screen">55
<div v-if="method === null">56
<h3 class="text-white text-[34px] font-bold pb-4 -mt-14 text-center">{{$lang('global.brand')}}</h3>