so://phie

verbal

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

blob: bc268d7fc4e3f112d097b5728d42b30a185ab3f6 (6642 bytes)[doc][blame][raw]

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

2import {http, $lang} 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 data() {

10 return {

11 open: false

12 };

13 },

14 components: {

15 VButton,

16 VIcon,

17 VImage

18 },

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.pageY

35 };

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 <div

76 @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 <div

82 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-button

88 icon="chevron-down"

89 @click="open = false"

90 ></v-button>

91 <v-button

92 icon="share"

93 ></v-button>

94 </div>

95 <div v-if="station" class="flex gap-4 items-center">

96 <v-image

97 :station="station"

98 class="w-[96px] h-[96px] min-w-[96px]"

99 ></v-image>

100 <div

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

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

103 >

104 <p

105 :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 <span

112 v-if="station.country"

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

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

115 >

116 <v-icon

117 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 <span

134 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 <span

140 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 <span

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