A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 73f70c0cb28e96cfd10dad166e1fc99c827c6918 (6756 bytes)[doc][blame][raw]
1
import {state, SWIPE_THRESHOLD} from '../main.js';2
import {http, $lang} 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
data() {10
return {11
open: false12
};13
},14
components: {15
VButton,16
VIcon,17
VImage18
},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.pageY35
};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
<div76
@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
<div82
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-button88
icon="chevron-down"89
@click="open = false"90
></v-button>91
<v-button92
icon="share"93
></v-button>94
</div>95
<div class="flex gap-4 items-center">96
<v-image97
v-if="station"98
:station="station"99
class="w-[96px] h-[96px] min-w-[96px]"100
></v-image>101
<div102
v-if="station"103
class="flex flex-col flex-1 min-w-0"104
>105
<p106
: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
<span113
v-if="station.country"114
class="text-gray-400 inline-flex items-center gap-[5px]"115
:title="$lang('global.country')"116
>117
<v-icon118
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
<div128
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
<span138
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
<span144
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
<span150
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
}