A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
1
import {state, SWIPE_THRESHOLD} from '../main.js';2
import {http, $lang} from '../utils.js';3
import VButton from '../element/button.js';4
import VIcon from '../element/icon.js';5
import VImage from '../element/image.js';7
export default {8
props: ['station'],9
data() {10
return {11
open: false12
};13
},14
components: {15
VButton,16
VIcon,17
VImage18
},19
watch: {20
open(value) {21
state.open = value;22
}23
},24
methods: {25
$lang,26
onTouchStart(event) {27
this.touch = event.changedTouches[0];28
this.target = event.target;29
},30
onTouchEnd(event) {31
const touch = event.changedTouches[0];32
const diff = {33
x: touch.pageX - this.touch.pageX,34
y: touch.pageY - this.touch.pageY35
};36
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);37
const index = state.tabs.indexOf(state.tab);38
if(this.open) {39
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {40
if(diff.y > 0 && angle >= -30 && angle <= 30) {41
this.open = false;42
}43
}44
return;45
}46
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {47
if(Math.abs(diff.y) >= SWIPE_THRESHOLD) {48
if(!this.open && this.target === this.$refs.button?.$refs.image) {49
if(diff.y < 0 && angle >= -30 && angle <= 30) {50
this.open = true;51
}52
}53
}54
}55
}56
},57
created() {58
document.body.addEventListener('touchstart', this.onTouchStart);59
document.body.addEventListener('touchend', this.onTouchEnd);60
},61
onUnmounted() {62
document.body.removeEventListener('touchstart', this.onTouchStart);63
document.body.removeEventListener('touchend', this.onTouchEnd);64
},65
computed: {66
opacity() {67
return {68
'opacity': `${this.open === true ? 1 : 0}`,69
'pointer-events': `${this.open === true ? 'all' : 'none'}`70
};71
}72
},73
template: `74
<div class="z-40">75
<div76
@click="open = false"77
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-modal"78
:style="opacity"79
>80
</div>81
<div82
ref="modal"83
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"84
:class="{ 'modal-active': open }"85
>86
<div class="w-full h-[98px] py-6 flex gap-4 justify-between">87
<v-button88
icon="chevron-down"89
@click="open = false"90
></v-button>91
<v-button92
icon="share"93
></v-button>94
</div>95
<div v-if="station" class="flex gap-4 items-center">96
<v-image97
:station="station"98
class="w-[96px] h-[96px] min-w-[96px]"99
></v-image>100
<div101
class="flex flex-col flex-1 min-w-0 cursor-pointer"102
@click="() => openDetail(station)"103
>104
<p105
:title="station.name"106
class="text-[24px] font-[600] text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"107
>108
{{station.name}}109
</p>110
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">111
<span112
v-if="station.country"113
class="text-gray-400 inline-flex items-center gap-[5px]"114
:title="$lang('global.country')"115
>116
<v-icon117
id="map-pin"118
class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"119
size="100%"120
></v-icon>121
<p>{{station.state ? station.state + ', ' : ''}}{{station.country}}</p>122
</span>123
</span>124
</div>125
</div>126
<div class="flex flex-col gap-6 mt-8">127
<div v-if="station.tags && station.tags.length > 0" class="flex gap-2 flex-wrap">128
<span v-for="tag in station.tags" class="text-white/90 items-center gap-[5px] bg-zinc-900 rounded-[4px] text-[14px] px-[10px] inline-flex h-[28px] leading-[28px]">{{tag}}</span>129
</div>130
<p v-if="station.description" class="text-sm text-gray-400" v-html="station.description"></p>131
<p v-else class="text-sm text-gray-400">{{$lang('detail.no-description')}}</p>132
<div v-if="station.is_restricted || station.is_broken || station.is_no_track_info" class="flex gap-2 flex-wrap">133
<span134
v-if="station.is_restricted"135
class="text-white/90 items-center gap-[5px] bg-blue-600/70 rounded-[4px] text-[14px] px-[7px] inline-flex h-[24px] leading-[24px]"136
>137
<p class="-mt-[1px]">Restricted</p>138
</span>139
<span140
v-if="station.is_broken"141
class="text-white/90 items-center gap-[5px] bg-red-600/70 rounded-[4px] text-[14px] px-[7px] inline-flex h-[24px] leading-[24px]"142
>143
<p class="-mt-[1px]">Broken</p>144
</span>145
<span146
v-if="station.is_no_track_info"147
class="text-white/90 items-center gap-[5px] bg-green-600/70 rounded-[4px] text-[14px] px-[7px] inline-flex h-[24px] leading-[24px]"148
>149
<p class="-mt-[1px]">No track info</p>150
</span>151
</div>152
</div>153
</div>154
</div>155
`156
}
162
}163
},164
template: `165
<div class="z-30">165
<div class="z-50">166
<div167
@click="open = false"168
class="fixed top-0 bottom-0 left-0 right-0 bg-black/60 transition-modal"
26
setStation(station) {27
state.station = station;28
state.app.$refs.player.open = true;29
},30
openDetail(station) {31
state.app.$refs.detail.station = station;32
state.app.$refs.detail.open = true;33
}34
},35
template: `
39
@click="() => setStation(station)"40
class="w-[54px] h-[54px] min-w-[54px] cursor-pointer"41
></v-image>38
<div class="flex flex-col flex-1 min-w-0 cursor-pointer">42
<div43
class="flex flex-col flex-1 min-w-0 cursor-pointer"44
@click="() => openDetail(station)"45
>46
<p47
:title="station.name"48
class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"
64
</span>65
<span66
v-if="station.is_restricted"60
class="text-white/90 items-center gap-[5px] bg-blue-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex"67
class="text-white/90 items-center gap-[5px] bg-blue-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex leading-[24px]"68
>69
<p class="-mt-[1px]">Restricted</p>70
</span>71
<span72
v-if="station.is_broken"66
class="text-white/90 items-center gap-[5px] bg-red-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex"73
class="text-white/90 items-center gap-[5px] bg-red-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex leading-[24px]"74
>75
<p class="-mt-[1px]">Broken</p>76
</span>77
<span78
v-if="station.is_no_track_info"72
class="text-white/90 items-center gap-[5px] bg-green-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex"79
class="text-white/90 items-center gap-[5px] bg-green-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex leading-[24px]"80
>81
<p class="-mt-[1px]">No track info</p>82
</span>
6
import VSearch from './page/search.js';7
import VFavorites from './page/favorites.js';8
import VAccount from './page/account.js';9
import VDetail from './component/detail.js';11
export const VERSION = '{{version}}';12
export const SWIPE_THRESHOLD = 70;
40
VFavorites,41
VAccount,42
VPlayer,42
VPopup43
VPopup,44
VDetail45
},46
mounted() {47
document.body.style.display = '';
162
<v-account v-if="state.authenticated" :state="state"></v-account>163
</div>164
<v-player ref="player" v-if="state.authenticated" :station="state.station"></v-player>165
<v-detail ref="detail" v-if="state.authenticated" :station="state.station"></v-detail>166
<v-popup ref="popup"></v-popup>167
</div>168
`
11
country TEXT,12
state TEXT,13
languages TEXT[],14
score INTEGER14
score INTEGER,15
description TEXT16
);18
/* ### station status ### */
27
pub uid: String,28
pub name: String,29
pub url: String,30
pub description: Option<String>,31
pub icon: Option<String>,32
pub homepage: Option<String>,33
pub tags: Option<Vec<String>>,
42
"account.devices": "Devices",43
"account.devices.unknown": "Unknown device",44
"account.devices.current": "Current",45
"account.devices.add": "Add device"45
"account.devices.add": "Add device",46
"detail.no-description": "No description available"47
},48
"de": {49
"global.none": "-",
88
"account.devices": "Geräte",89
"account.devices.unknown": "Unbekanntes Gerät",90
"account.devices.current": "Aktuelles",90
"account.devices.add": "Gerät hinzufügen"91
"account.devices.add": "Gerät hinzufügen",92
"detail.no-description": "Keine Beschreibung vorhanden"93
}94
}