A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
16
VIcon,17
VImage18
},19
watch: {20
open(value) {21
state.open = value;22
}23
},19
methods: {20
$lang,21
duration,
23
this.station = await http`get::/api/station/${stationId}`();24
this.open = true;25
},26
async setLike(is_favorite) {27
try {28
await http`${is_favorite ? 'post' : 'delete'}::/api/favorite`(this.station.id);29
this.station.is_favorite = is_favorite;30
state.app.$refs.favorites.doFetch();31
}32
catch(error) {33
console.log(error);34
}35
},36
setStation(station) {37
state.station = station;38
state.app.$refs.player.open = true;39
},40
onTouchStart(event) {41
this.touch = event.changedTouches[0];42
this.target = event.target;
49
};50
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);51
const index = state.tabs.indexOf(state.tab);43
if(this.open) {44
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {45
if(diff.y > 0 && angle >= -30 && angle <= 30) {46
this.open = false;47
}48
}52
if(state.app.$refs.player.open) {53
return;54
}51
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {52
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {53
if(!this.open && this.target === this.$refs.button?.$refs.image) {54
if(diff.y < 0 && angle >= -30 && angle <= 30) {55
this.open = true;56
}57
}55
if(Math.abs(diff.x) >= SWIPE_THRESHOLD) {56
if(this.open && diff.x > 0 && (angle <= -60 || angle >= 60)) {57
this.open = false;58
}59
}60
},
82
<div class="z-40">83
<div84
@click="open = false"85
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-modal"85
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-detail"86
:style="opacity"87
>88
</div>89
<div90
ref="modal"91
class="w-full max-w-[1200px] mx-auto flex flex-col bg-black fixed left-0 right-0 top-[100vh] h-[100vh] px-4 sm:px-10 transition-modal"92
:class="{ 'modal-active': open }"91
class="w-full max-w-[1200px] mx-auto flex flex-col bg-black fixed left-[100vh] top-0 h-[100vh] overflow-y-auto px-4 pb-12 sm:pb-[100px] sm:px-10 transition-detail"92
:class="{ 'detail-active': open }"93
>94
<div95
class="w-full absolute top-0 left-0 h-[40vh] z-[-1]"96
:style="{'background': gradient(station?.color)}"97
>98
</div>99
<div class="w-full h-[98px] py-6 flex gap-4 justify-between">99
<div class="w-full h-[98px] py-6 flex gap-4 justify-between sticky top-0">100
<v-button101
icon="chevron-down"101
icon="chevron-left"102
@click="open = false"103
></v-button>104
<v-button105
icon="share"106
></v-button>107
</div>108
<div class="flex flex-col gap-4">108
<div class="flex flex-col gap-5">109
<v-image110
v-if="station"111
:station="station"
121
>122
{{station.name}}123
</p>124
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">124
<span class="text-md text-gray-400 overflow-hidden flex gap-3 pt-1">125
<span126
v-if="station.country"127
class="text-gray-400 inline-flex items-center gap-[5px]"
134
></v-icon>135
<p>{{station.state ? station.state + ', ' : ''}}{{station.country}}</p>136
</span>137
<span138
v-if="station?.playtime && duration(station.playtime ?? 0).length > 0"139
class="text-gray-400 inline-flex items-center gap-[5px]"140
:title="$lang('detail.playtime')"141
>142
<v-icon143
id="clock"144
class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"145
size="100%"146
></v-icon>147
<p>{{duration(station.playtime ?? 0)}}</p>148
</span>149
</span>150
</div>151
</div>
156
<div v-if="station.tags && station.tags.length > 0" class="flex gap-3 flex-wrap">157
<span v-for="tag in station.tags" class="cursor-pointer text-md text-white/90 font-medium items-center gap-[5px] bg-zinc-900 hover:bg-zinc-800 rounded-[4px] text-[14px] px-[14px] inline-flex h-[34px] leading-[34px]">{{tag}}</span>158
</div>147
<p class="text-md text-gray-400">{{$lang('detail.playtime')}}: {{duration(station.playtime ?? 0)}}</p>159
<div class="flex gap-3">160
<v-button161
icon="player-play"162
@click="() => setStation(station)"163
class="bg-zinc-900 hover:bg-white"164
></v-button>165
<v-button166
:icon="[ station.is_favorite ? 'heart-off' : 'heart' ]"167
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"168
@click="() => setLike(!station.is_favorite)"169
class="bg-zinc-900 hover:bg-white"170
:text="$lang(station.is_favorite ? 'global.unlike' : 'global.like')"171
></v-button>172
</div>173
<p v-if="station.description" class="text-md text-gray-400" v-html="station.description"></p>174
<p v-else class="text-md text-gray-400">{{$lang('detail.no-description')}}</p>175
<div v-if="station.is_restricted || station.is_broken || station.is_no_track_info" class="flex gap-2 flex-wrap">
34
this.updateMediaSession();35
}36
},37
open(value) {38
state.open = value;39
},37
async title(value) {38
await this.$nextTick();39
const outer = this.$refs.songtitle;
44
},45
methods: {46
$lang,47
async openDetail(station) {48
await state.app.$refs.detail.load(station.id);49
this.open = false;50
},51
setPlaying(playing) {52
if(this.error || this.loading) {53
return;
223
class="flex flex-col flex-1 z-10 min-w-0 w-[75vw] max-w-[400px] transition-modal"224
:style="opacity"225
>225
<p class="text-xl font-semibold text-white pb-2 overflow-hidden text-ellipsis whitespace-nowrap text-center">226
<p227
class="text-xl font-semibold text-white pb-2 overflow-hidden text-ellipsis whitespace-nowrap text-center cursor-pointer"228
@click="openDetail(station)"229
>230
{{station.name}}231
</p>232
<p ref="songtitle" class="songtitle text-md text-gray-400 overflow-hidden whitespace-nowrap relative px-2" :class="{'text-center': !tooLong, 'text-animate': tooLong}">
13
},14
methods: {15
$lang,16
async setLike(is_favorite) {17
try {18
await http`${is_favorite ? 'post' : 'delete'}::/api/favorite`(this.station.id);19
this.station.is_favorite = is_favorite;20
state.app.$refs.favorites.doFetch();21
}22
catch(error) {23
console.log(error);24
}25
},16
setStation(station) {17
state.station = station;18
state.app.$refs.player.open = true;
53
</span>54
</span>55
</div>66
<div class="inline-flex gap-3 sm:gap-4">67
<v-button68
:icon="[ station.is_favorite ? 'bookmark-off' : 'bookmark' ]"69
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"70
:active="station.is_favorite"71
@click="() => setLike(!station.is_favorite)"72
class="bg-zinc-900 hover:bg-white"73
></v-button>74
</div>56
</div>57
`58
}
19
v-if="icon"20
:id="icon"21
:size="size"22
:class="[ active ? 'text-gray-100' : 'text-gray-400', text ? 'group-hover:text-gray-700' : '', animation ]"22
:class="[ active ? 'text-gray-100' : 'text-gray-400', text ? 'group-hover:text-gray-700' : '', animation, text ? '' : 'w-full' ]"23
class="hover:text-gray-800"24
></v-icon>25
<slot v-else></slot>
22
token: null,23
station: null,24
authenticated: null,25
open: false,25
version: VERSION26
};
62
state.token = null;63
}64
state.tab = 'search';66
state.open = false;65
state.station = null;66
if(state.account === null) {67
state.authenticated = false;
128
};129
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);130
const index = state.tabs.indexOf(state.tab);133
if(state.open === true) {131
if(this.$refs.player.open === true || this.$refs.detail.open === true) {132
return;133
}134
if(Math.abs(diff.x) >= SWIPE_THRESHOLD) {
86
const hours = Math.floor(seconds / 3600);87
const minutes = Math.floor((seconds - (hours * 3600)) / 60);88
seconds = seconds - (hours * 3600) - (minutes * 60);89
return `${hours > 0 ? hours + ' h ' : ''}${minutes} min`;89
return `${hours > 0 ? hours + ' h ' : ''}${minutes > 0 ? minutes + ' min' : ''}`;90
}
39
transition: all ease-in-out 250ms;40
}42
.transition-detail {43
transition: all ease-in-out 250ms;44
}46
.modal-active {47
top: 0 !important;48
}50
.detail-active {51
left: 0 !important;52
}54
.slide-hidden {55
opacity: 0;56
pointer-events: none;