so://phie

verbal

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

blob: 1d406723d8c662b6ed31758a887d5aa692bf4f69 (6771 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 class="flex gap-4 items-center">

96 <v-image

97 v-if="station"

98 :station="station"

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

100 ></v-image>

101 <div

102 v-if="station"

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

104 >

105 <p

106 :title="station.name"

107 class="text-[24px] font-[600] text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"

108 >

109 {{station.name}}

110 </p>

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

112 <span

113 v-if="station.country"

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

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

116 >

117 <v-icon

118 id="map-pin"

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

120 size="100%"

121 ></v-icon>

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

123 </span>

124 </span>

125 </div>

126 </div>

127 <div

128 v-if="station"

129 class="flex flex-col gap-6 mt-8"

130 >

131 <div v-if="station.tags && station.tags.length > 0" class="flex gap-3 flex-wrap">

132 <span v-for="tag in station.tags" class="cursor-pointer text-md text-white/90 font-medium items-center gap-[5px] bg-zinc-900 hover:bg-zinc-800 rounded-[4px] text-[14px] px-[14px] inline-flex h-[34px] leading-[34px]">{{tag}}</span>

133 </div>

134 <p v-if="station.description" class="text-md text-gray-400" v-html="station.description"></p>

135 <p v-else class="text-md text-gray-400">{{$lang('detail.no-description')}}</p>

136 <div v-if="station.is_restricted || station.is_broken || station.is_no_track_info" class="flex gap-2 flex-wrap">

137 <span

138 v-if="station.is_restricted"

139 class="text-white/90 items-center gap-[5px] bg-blue-600/70 rounded-[4px] text-[14px] px-[7px] inline-flex h-[24px] leading-[24px]"

140 >

141 <p class="-mt-[1px]">Restricted</p>

142 </span>

143 <span

144 v-if="station.is_broken"

145 class="text-white/90 items-center gap-[5px] bg-red-600/70 rounded-[4px] text-[14px] px-[7px] inline-flex h-[24px] leading-[24px]"

146 >

147 <p class="-mt-[1px]">Broken</p>

148 </span>

149 <span

150 v-if="station.is_no_track_info"

151 class="text-white/90 items-center gap-[5px] bg-green-600/70 rounded-[4px] text-[14px] px-[7px] inline-flex h-[24px] leading-[24px]"

152 >

153 <p class="-mt-[1px]">No track info</p>

154 </span>

155 </div>

156 </div>

157 </div>

158 </div>

159 `

160}