A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 4bd85b6583c57a92fe2ce81446df2224c9f0a7de (3921 bytes)[doc][blame][raw]
1
import {state} from '../main.js';2
import {$lang, http} 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
components: {10
VButton,11
VIcon,12
VImage13
},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
},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: `36
<div class="w-full gap-4 group flex items-center">37
<v-image38
:station="station"39
@click="() => setStation(station)"40
class="w-[54px] h-[54px] min-w-[54px] cursor-pointer"41
></v-image>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"49
>50
{{station.name}}51
</p>52
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">53
<span54
v-if="station.country"55
class="text-gray-400 inline-flex items-center gap-[5px]"56
:title="$lang('global.country')"57
>58
<v-icon59
id="map-pin"60
class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"61
size="100%"62
></v-icon>63
<p>{{station.state ? station.state + ', ' : ''}}{{station.country}}</p>64
</span>65
<span66
v-if="station.is_restricted"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"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"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>83
</span>84
</div>85
<div class="inline-flex gap-3 sm:gap-4">86
<v-button87
:icon="[ station.is_favorite ? 'bookmark-off' : 'bookmark' ]"88
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"89
:active="station.is_favorite"90
@click="() => setLike(!station.is_favorite)"91
class="bg-zinc-900 hover:bg-white"92
></v-button>93
</div>94
</div>95
`96
}