A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 9fa5da0bf0fcfa9da24d6f5e7c7353eb468f2305 (3653 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
},31
template: `32
<div class="w-full gap-4 group flex items-center">33
<v-image34
:station="station"35
@click="() => setStation(station)"36
class="w-[54px] h-[54px] min-w-[54px] cursor-pointer"37
></v-image>38
<div class="flex flex-col flex-1 min-w-0 cursor-pointer">39
<p40
:title="station.name"41
class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"42
>43
{{station.name}}44
</p>45
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">46
<span47
v-if="station.country"48
class="text-gray-400 inline-flex items-center gap-[5px]"49
:title="$lang('global.country')"50
>51
<v-icon52
id="map-pin"53
class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"54
size="100%"55
></v-icon>56
<p>{{station.state ? station.state + ', ' : ''}}{{station.country}}</p>57
</span>58
<span59
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"61
>62
<p class="-mt-[1px]">Restricted</p>63
</span>64
<span65
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"67
>68
<p class="-mt-[1px]">Broken</p>69
</span>70
<span71
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"73
>74
<p class="-mt-[1px]">No track info</p>75
</span>76
</span>77
</div>78
<div class="inline-flex gap-3 sm:gap-4">79
<v-button80
:icon="[ station.is_favorite ? 'bookmark-off' : 'bookmark' ]"81
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"82
:active="station.is_favorite"83
@click="() => setLike(!station.is_favorite)"84
class="bg-zinc-900 hover:bg-white"85
></v-button>86
</div>87
</div>88
`89
}