so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 0f23e54fb818d0ad1b0f3fea98713dd30bddeef9 (2839 bytes)[doc][blame][raw]

1import {state} from '../main.js';

2import {$lang, http} from '../utils.js';

3import VButton from '../element/button.js';

4import VIcon from '../element/icon.js';

5import VImage from '../element/image.js';

6

7export default {

8 props: ['station'],

9 components: {

10 VButton,

11 VIcon,

12 VImage

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 },

26 setStation(station) {

27 state.station = station;

28 state.app.$refs.player.open = true;

29 },

30 openDetail(station) {

31 state.app.$refs.detail.load(station.id);

32 }

33 },

34 template: `

35 <div class="w-full gap-4 group flex items-center">

36 <v-image

37 :station="station"

38 @click="() => setStation(station)"

39 class="w-[54px] h-[54px] min-w-[54px] cursor-pointer"

40 ></v-image>

41 <div

42 class="flex flex-col flex-1 min-w-0 cursor-pointer"

43 @click="() => openDetail(station)"

44 >

45 <p

46 :title="station.name"

47 class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"

48 >

49 {{station.name}}

50 </p>

51 <span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">

52 <span

53 v-if="station.country"

54 class="text-gray-400 inline-flex items-center gap-[5px]"

55 :title="$lang('global.country')"

56 >

57 <v-icon

58 id="map-pin"

59 class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"

60 size="100%"

61 ></v-icon>

62 <p>{{station.state ? station.state + ', ' : ''}}{{station.country}}</p>

63 </span>

64 </span>

65 </div>

66 <div class="inline-flex gap-3 sm:gap-4">

67 <v-button

68 :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>

75 </div>

76 `

77}