mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-29 02:01:40 +00:00
FIX - power lock screen flashlight from camera light
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
|
||||
import { usePhoneStore } from '@/stores/phone'
|
||||
import { nuiCall } from '@/utils/nui'
|
||||
|
||||
const emit = defineEmits<{
|
||||
camera: []
|
||||
@@ -99,6 +100,13 @@ function unlockFromWallpaper(event: MouseEvent): void {
|
||||
emit('unlock')
|
||||
}
|
||||
|
||||
async function toggleFlashlight(): Promise<void> {
|
||||
const enabled = !flashlightActive.value
|
||||
flashlightActive.value = enabled
|
||||
const response = await nuiCall('camera:setFlash', { enabled })
|
||||
if (!response.success) flashlightActive.value = !enabled
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
clockTicker = window.setInterval(() => {
|
||||
now.value = new Date()
|
||||
@@ -107,6 +115,8 @@ onMounted(() => {
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (clockTicker !== undefined) window.clearInterval(clockTicker)
|
||||
if (flashlightActive.value)
|
||||
void nuiCall('camera:setFlash', { enabled: false })
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -156,7 +166,7 @@ onBeforeUnmount(() => {
|
||||
class="lock-screen__shortcut"
|
||||
:colors="flashlightShortcutColors"
|
||||
:aria-label="phone.t('LockScreen.flashlight')"
|
||||
@click="flashlightActive = !flashlightActive"
|
||||
@click="toggleFlashlight"
|
||||
>
|
||||
<template #icon>
|
||||
<Flashlight :stroke-width="1.4" aria-hidden="true" />
|
||||
|
||||
@@ -38,12 +38,12 @@ end
|
||||
|
||||
local function set_flash_enabled(enabled)
|
||||
camera_state.flash_enabled = enabled
|
||||
if not enabled or not camera_state.active or camera_state.flash_thread then
|
||||
if not enabled or camera_state.flash_thread then
|
||||
return
|
||||
end
|
||||
camera_state.flash_thread = true
|
||||
CreateThread(function()
|
||||
while camera_state.active and camera_state.flash_enabled do
|
||||
while camera_state.flash_enabled do
|
||||
draw_flash_light()
|
||||
Wait(0)
|
||||
end
|
||||
@@ -238,7 +238,7 @@ local function set_camera_active(active)
|
||||
end)
|
||||
return
|
||||
end
|
||||
camera_state.flash_enabled = false
|
||||
set_flash_enabled(false)
|
||||
camera_state.front_camera = false
|
||||
clear_front_camera()
|
||||
clear_ultrawide_camera()
|
||||
@@ -356,11 +356,13 @@ RegisterNetEvent("sky_phone:media:delete-result", function(data)
|
||||
end)
|
||||
|
||||
AddEventHandler("sky_phone:nuiClosed", function()
|
||||
set_flash_enabled(false)
|
||||
set_camera_active(false)
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStop", function(resource_name)
|
||||
if resource_name == GetCurrentResourceName() then
|
||||
set_flash_enabled(false)
|
||||
set_camera_active(false)
|
||||
SetNuiFocusKeepInput(false)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user