mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 17:23:25 +00:00
MERGE - integrate latest dev changes
This commit is contained in:
@@ -37,9 +37,19 @@ const wrapperStyle = computed<CSSProperties>(() => ({ zoom: props.zoom }))
|
||||
>
|
||||
<section
|
||||
class="phone-device phone-device--notification"
|
||||
:class="{
|
||||
'phone-app--light': !isDarkMode,
|
||||
[`phone-app--${preferences.settings.graphicsMode}`]: true,
|
||||
}"
|
||||
:aria-label="device.name"
|
||||
>
|
||||
<div class="phone-screen">
|
||||
<div
|
||||
class="phone-screen"
|
||||
:class="{
|
||||
'phone-app--light': !isDarkMode,
|
||||
[`phone-app--${preferences.settings.graphicsMode}`]: true,
|
||||
}"
|
||||
>
|
||||
<k-app
|
||||
theme="ios"
|
||||
:dark="isDarkMode"
|
||||
@@ -48,6 +58,7 @@ const wrapperStyle = computed<CSSProperties>(() => ({ zoom: props.zoom }))
|
||||
:class="{
|
||||
dark: isDarkMode,
|
||||
'phone-app--light': !isDarkMode,
|
||||
[`phone-app--${preferences.settings.graphicsMode}`]: true,
|
||||
}"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { kFab } from 'konsta/vue'
|
||||
import {
|
||||
BatteryMedium,
|
||||
Camera,
|
||||
Flashlight,
|
||||
LockKeyhole,
|
||||
Signal,
|
||||
Wifi,
|
||||
} from 'lucide-vue-next'
|
||||
import { Camera, Flashlight, LockKeyhole } from 'lucide-vue-next'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
|
||||
import PhoneStatusIndicators from '@/components/PhoneStatusIndicators.vue'
|
||||
import { usePhoneStore } from '@/stores/phone'
|
||||
import { nuiCall } from '@/utils/nui'
|
||||
|
||||
@@ -41,7 +35,8 @@ const date = computed(() =>
|
||||
)
|
||||
const time = computed(() =>
|
||||
new Intl.DateTimeFormat(phone.lang, {
|
||||
hour: 'numeric',
|
||||
hour: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
minute: '2-digit',
|
||||
})
|
||||
.formatToParts(now.value)
|
||||
@@ -140,11 +135,7 @@ onBeforeUnmount(() => {
|
||||
<div class="lock-screen__shade" aria-hidden="true"></div>
|
||||
|
||||
<header class="lock-screen__status">
|
||||
<div class="lock-screen__indicators" aria-hidden="true">
|
||||
<Signal :size="12" :stroke-width="2.5" />
|
||||
<Wifi :size="13" :stroke-width="2.5" />
|
||||
<BatteryMedium :size="17" :stroke-width="2.4" />
|
||||
</div>
|
||||
<PhoneStatusIndicators class="lock-screen__indicators" />
|
||||
</header>
|
||||
<LockKeyhole
|
||||
class="lock-screen__lock"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { BatteryMedium, Plane, Signal, Wifi } from 'lucide-vue-next'
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import PhoneStatusIndicators from '@/components/PhoneStatusIndicators.vue'
|
||||
import { usePhoneStore } from '@/stores/phone'
|
||||
|
||||
const phone = usePhoneStore()
|
||||
@@ -13,7 +13,8 @@ let intervalId: number | undefined
|
||||
|
||||
function updateTime(): void {
|
||||
time.value = new Intl.DateTimeFormat([], {
|
||||
hour: 'numeric',
|
||||
hour: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
minute: '2-digit',
|
||||
}).format(new Date())
|
||||
}
|
||||
@@ -30,7 +31,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<header class="phone-status-bar" :aria-label="phone.t('Common.phoneStatus')">
|
||||
<time>{{ time }}</time>
|
||||
<time class="phone-status-bar__time">{{ time }}</time>
|
||||
<button
|
||||
class="phone-status-bar__indicators"
|
||||
type="button"
|
||||
@@ -38,28 +39,11 @@ onBeforeUnmount(() => {
|
||||
:aria-expanded="controlCenterOpened"
|
||||
@click.stop="emit('controlCenter')"
|
||||
>
|
||||
<Plane
|
||||
v-if="phone.preferences.settings.airplaneMode"
|
||||
:size="12"
|
||||
:stroke-width="2.5"
|
||||
aria-hidden="true"
|
||||
<PhoneStatusIndicators
|
||||
:airplane-mode="phone.preferences.settings.airplaneMode"
|
||||
:cellular-enabled="phone.preferences.settings.cellularEnabled"
|
||||
:wifi-enabled="phone.preferences.settings.wifiEnabled"
|
||||
/>
|
||||
<Signal
|
||||
v-else-if="phone.preferences.settings.cellularEnabled"
|
||||
:size="12"
|
||||
:stroke-width="2.5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Wifi
|
||||
v-if="
|
||||
phone.preferences.settings.wifiEnabled &&
|
||||
!phone.preferences.settings.airplaneMode
|
||||
"
|
||||
:size="13"
|
||||
:stroke-width="2.5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<BatteryMedium :size="16" :stroke-width="2.4" />
|
||||
</button>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<script setup lang="ts">
|
||||
import { Plane } from 'lucide-vue-next'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
airplaneMode?: boolean
|
||||
cellularEnabled?: boolean
|
||||
wifiEnabled?: boolean
|
||||
}>(),
|
||||
{
|
||||
airplaneMode: false,
|
||||
cellularEnabled: true,
|
||||
wifiEnabled: true,
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="phone-status-indicators" aria-hidden="true">
|
||||
<Plane
|
||||
v-if="airplaneMode"
|
||||
:size="18"
|
||||
:stroke-width="2.6"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<svg
|
||||
v-else-if="cellularEnabled"
|
||||
class="phone-status-indicators__signal"
|
||||
viewBox="0 0 20 16"
|
||||
>
|
||||
<rect x="0" y="11" width="3.5" height="5" rx="1.75" />
|
||||
<rect x="5.5" y="8" width="3.5" height="8" rx="1.75" />
|
||||
<rect x="11" y="4" width="3.5" height="12" rx="1.75" />
|
||||
<rect x="16.5" width="3.5" height="16" rx="1.75" opacity="0.42" />
|
||||
</svg>
|
||||
<svg
|
||||
v-if="wifiEnabled && !airplaneMode"
|
||||
class="phone-status-indicators__wifi"
|
||||
viewBox="0 0 22 17"
|
||||
fill="none"
|
||||
>
|
||||
<path d="M1.5 5.4a14.2 14.2 0 0 1 19 0" />
|
||||
<path d="M5 9.2a9 9 0 0 1 12 0" />
|
||||
<path d="M8.5 13a3.8 3.8 0 0 1 5 0" />
|
||||
<circle cx="11" cy="15.3" r="1.45" />
|
||||
</svg>
|
||||
<svg class="phone-status-indicators__battery" viewBox="0 0 29 16">
|
||||
<rect x="0.75" y="0.75" width="25" height="14.5" rx="4" />
|
||||
<rect x="3" y="3" width="14.5" height="10" rx="2.25" />
|
||||
<rect x="26.6" y="5" width="2.4" height="6" rx="1.2" />
|
||||
</svg>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.phone-status-indicators {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.phone-status-indicators > svg {
|
||||
display: block;
|
||||
flex: 0 0 auto;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.phone-status-indicators__signal {
|
||||
width: 18px;
|
||||
height: 14px;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.phone-status-indicators__wifi {
|
||||
width: 19px;
|
||||
height: 15px;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2.2;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
|
||||
.phone-status-indicators__wifi circle {
|
||||
fill: currentColor;
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.phone-status-indicators__battery {
|
||||
width: 25px;
|
||||
height: 14px;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.phone-status-indicators__battery rect:first-child {
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,324 @@
|
||||
<script setup lang="ts">
|
||||
import { Headphones } from 'lucide-vue-next'
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
|
||||
import type { RadioHudConfig, RadioHudMember } from '@/types/radio'
|
||||
|
||||
type RadioHudEntry = RadioHudMember & {
|
||||
state: 'recent' | 'talking'
|
||||
}
|
||||
|
||||
type RadioHudMessage = {
|
||||
data?: Partial<RadioHudConfig> | { members?: RadioHudMember[] }
|
||||
type?: string
|
||||
}
|
||||
|
||||
const config = reactive<RadioHudConfig>({
|
||||
enabled: false,
|
||||
horizontal: 'right',
|
||||
horizontalOffset: 2,
|
||||
speakerPersistMilliseconds: 3000,
|
||||
vertical: 'top',
|
||||
verticalOffset: 30,
|
||||
})
|
||||
const entries = ref(new Map<number, RadioHudEntry>())
|
||||
const removalTimers = new Map<number, number>()
|
||||
const visibleEntries = computed(() =>
|
||||
Array.from(entries.value.values()).sort((left, right) =>
|
||||
left.name.localeCompare(right.name),
|
||||
),
|
||||
)
|
||||
const positionStyle = computed(() => ({
|
||||
'--radio-hud-horizontal-offset': `${config.horizontalOffset}vh`,
|
||||
'--radio-hud-vertical-offset': `${config.verticalOffset}vh`,
|
||||
}))
|
||||
|
||||
function clearRemovalTimer(id: number): void {
|
||||
const timer = removalTimers.get(id)
|
||||
if (timer !== undefined) window.clearTimeout(timer)
|
||||
removalTimers.delete(id)
|
||||
}
|
||||
|
||||
function setEntry(entry: RadioHudEntry): void {
|
||||
const next = new Map(entries.value)
|
||||
next.set(entry.id, entry)
|
||||
entries.value = next
|
||||
}
|
||||
|
||||
function removeEntry(id: number): void {
|
||||
clearRemovalTimer(id)
|
||||
const next = new Map(entries.value)
|
||||
next.delete(id)
|
||||
entries.value = next
|
||||
}
|
||||
|
||||
function clearEntries(): void {
|
||||
for (const timer of removalTimers.values()) window.clearTimeout(timer)
|
||||
removalTimers.clear()
|
||||
entries.value = new Map()
|
||||
}
|
||||
|
||||
function scheduleRemoval(id: number): void {
|
||||
clearRemovalTimer(id)
|
||||
const duration = Math.max(
|
||||
0,
|
||||
Math.min(10_000, config.speakerPersistMilliseconds),
|
||||
)
|
||||
removalTimers.set(
|
||||
id,
|
||||
window.setTimeout(() => {
|
||||
if (entries.value.get(id)?.state === 'recent') removeEntry(id)
|
||||
}, duration),
|
||||
)
|
||||
}
|
||||
|
||||
function updateMembers(members: RadioHudMember[]): void {
|
||||
const currentIds = new Set<number>()
|
||||
for (const member of members) {
|
||||
if (!Number.isInteger(member.id) || member.id <= 0) continue
|
||||
currentIds.add(member.id)
|
||||
const existing = entries.value.get(member.id)
|
||||
const normalized = {
|
||||
badge: String(member.badge ?? ''),
|
||||
channel: member.channel === 2 ? 2 : 1,
|
||||
id: member.id,
|
||||
name: String(member.name || `ID ${member.id}`),
|
||||
talking: member.talking === true,
|
||||
} satisfies RadioHudMember
|
||||
|
||||
if (normalized.talking) {
|
||||
clearRemovalTimer(member.id)
|
||||
setEntry({ ...normalized, state: 'talking' })
|
||||
} else if (existing?.state === 'talking') {
|
||||
setEntry({ ...normalized, state: 'recent' })
|
||||
scheduleRemoval(member.id)
|
||||
} else if (existing) {
|
||||
setEntry({ ...normalized, state: existing.state })
|
||||
}
|
||||
}
|
||||
|
||||
for (const id of entries.value.keys()) {
|
||||
if (!currentIds.has(id)) removeEntry(id)
|
||||
}
|
||||
}
|
||||
|
||||
function updateConfig(value: Partial<RadioHudConfig>): void {
|
||||
config.enabled = value.enabled === true
|
||||
config.horizontal = value.horizontal === 'left' ? 'left' : 'right'
|
||||
config.vertical = value.vertical === 'bottom' ? 'bottom' : 'top'
|
||||
config.horizontalOffset = Math.max(
|
||||
0,
|
||||
Math.min(100, Number(value.horizontalOffset) || 0),
|
||||
)
|
||||
config.verticalOffset = Math.max(
|
||||
0,
|
||||
Math.min(100, Number(value.verticalOffset) || 0),
|
||||
)
|
||||
config.speakerPersistMilliseconds = Math.max(
|
||||
0,
|
||||
Math.min(10_000, Number(value.speakerPersistMilliseconds) || 0),
|
||||
)
|
||||
if (!config.enabled) clearEntries()
|
||||
}
|
||||
|
||||
function onMessage(event: MessageEvent<RadioHudMessage>): void {
|
||||
if (event.data?.type === 'radio:hud-config' && event.data.data) {
|
||||
updateConfig(event.data.data as Partial<RadioHudConfig>)
|
||||
} else if (event.data?.type === 'radio:hud-update' && event.data.data) {
|
||||
const data = event.data.data as { members?: RadioHudMember[] }
|
||||
updateMembers(Array.isArray(data.members) ? data.members : [])
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('message', onMessage)
|
||||
if (
|
||||
import.meta.env.DEV &&
|
||||
new URLSearchParams(window.location.search).has('radioHudPreview')
|
||||
) {
|
||||
updateConfig({
|
||||
enabled: true,
|
||||
horizontal: 'right',
|
||||
horizontalOffset: 2,
|
||||
speakerPersistMilliseconds: 3000,
|
||||
vertical: 'top',
|
||||
verticalOffset: 30,
|
||||
})
|
||||
updateMembers([
|
||||
{
|
||||
badge: '231',
|
||||
channel: 1,
|
||||
id: 21,
|
||||
name: 'Unit 21',
|
||||
talking: true,
|
||||
},
|
||||
{
|
||||
badge: '12',
|
||||
channel: 2,
|
||||
id: 12,
|
||||
name: 'Unit 12',
|
||||
talking: true,
|
||||
},
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('message', onMessage)
|
||||
clearEntries()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
v-if="config.enabled"
|
||||
class="radio-hud"
|
||||
:data-horizontal="config.horizontal"
|
||||
:data-vertical="config.vertical"
|
||||
:style="positionStyle"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<TransitionGroup
|
||||
name="radio-hud-member"
|
||||
tag="div"
|
||||
class="radio-hud__members"
|
||||
>
|
||||
<div
|
||||
v-for="entry in visibleEntries"
|
||||
:key="entry.id"
|
||||
class="radio-hud__member"
|
||||
:class="[
|
||||
`radio-hud__member--${entry.state}`,
|
||||
{ 'radio-hud__member--secondary': entry.channel === 2 },
|
||||
]"
|
||||
>
|
||||
<Headphones class="radio-hud__icon" aria-hidden="true" />
|
||||
<span v-if="entry.badge" class="radio-hud__badge">
|
||||
[{{ entry.badge }}]
|
||||
</span>
|
||||
<span class="radio-hud__name">{{ entry.name }}</span>
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.radio-hud {
|
||||
position: fixed;
|
||||
z-index: 40;
|
||||
display: flex;
|
||||
pointer-events: none;
|
||||
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
|
||||
}
|
||||
|
||||
.radio-hud[data-horizontal='left'] {
|
||||
right: auto;
|
||||
left: var(--radio-hud-horizontal-offset);
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.radio-hud[data-horizontal='right'] {
|
||||
right: var(--radio-hud-horizontal-offset);
|
||||
left: auto;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.radio-hud[data-vertical='bottom'] {
|
||||
top: auto;
|
||||
bottom: var(--radio-hud-vertical-offset);
|
||||
}
|
||||
|
||||
.radio-hud[data-vertical='top'] {
|
||||
top: var(--radio-hud-vertical-offset);
|
||||
bottom: auto;
|
||||
}
|
||||
|
||||
.radio-hud__members {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6vh;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.radio-hud[data-horizontal='left'] .radio-hud__members {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.radio-hud__member {
|
||||
display: flex;
|
||||
max-width: 32vw;
|
||||
align-items: center;
|
||||
gap: 0.7vh;
|
||||
color: #4ade80;
|
||||
font-size: clamp(12px, 1.25vh, 16px);
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
filter: drop-shadow(0 2px 4px rgb(0 0 0 / 80%));
|
||||
}
|
||||
|
||||
.radio-hud__member--secondary {
|
||||
color: #facc15;
|
||||
}
|
||||
|
||||
.radio-hud__member--recent {
|
||||
color: rgb(255 255 255 / 90%);
|
||||
}
|
||||
|
||||
.radio-hud__icon {
|
||||
width: 1.8vh;
|
||||
min-width: 14px;
|
||||
height: 1.8vh;
|
||||
min-height: 14px;
|
||||
animation: radio-hud-pulse 0.8s ease-in-out infinite;
|
||||
filter: drop-shadow(0 0 6px currentColor);
|
||||
}
|
||||
|
||||
.radio-hud__member--recent .radio-hud__icon {
|
||||
animation: none;
|
||||
filter: none;
|
||||
}
|
||||
|
||||
.radio-hud__badge {
|
||||
opacity: 0.75;
|
||||
white-space: nowrap;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.radio-hud__name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.radio-hud-member-enter-active,
|
||||
.radio-hud-member-leave-active {
|
||||
transition:
|
||||
opacity 0.3s ease,
|
||||
transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
.radio-hud-member-enter-from,
|
||||
.radio-hud-member-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(2vh);
|
||||
}
|
||||
|
||||
.radio-hud[data-horizontal='left'] .radio-hud-member-enter-from,
|
||||
.radio-hud[data-horizontal='left'] .radio-hud-member-leave-to {
|
||||
transform: translateX(-2vh);
|
||||
}
|
||||
|
||||
@keyframes radio-hud-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 0.55;
|
||||
transform: scale(0.86);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -48,7 +48,11 @@ function close(): void {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="sim-picker-backdrop" @click.self="close">
|
||||
<div
|
||||
class="sim-picker-backdrop"
|
||||
:class="`phone-app--${phone.preferences.settings.graphicsMode}`"
|
||||
@click.self="close"
|
||||
>
|
||||
<section class="sim-picker" aria-modal="true" role="dialog">
|
||||
<div class="sim-picker__glow sim-picker__glow--top" />
|
||||
<div class="sim-picker__glow sim-picker__glow--bottom" />
|
||||
|
||||
@@ -154,6 +154,7 @@ function avatar(name: string): string {
|
||||
function formatForecastHour(timestamp: number): string {
|
||||
return new Intl.DateTimeFormat(phone.lang, {
|
||||
hour: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
minute: '2-digit',
|
||||
}).format(timestamp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user