()
| 396 | // tile asks for it here, from the tap. The tile only turns on once it's granted. |
| 397 | const [lockPhoneError, setLockPhoneError] = useState<string | null>(null); |
| 398 | const toggleLockPhone = async () => { |
| 399 | setLockPhoneError(null); |
| 400 | if (selectedTools.has('lock_phone')) { toggleTool('lock_phone'); return; } |
| 401 | try { |
| 402 | let status = await getPhoneLockStatus(); |
| 403 | if (!status.supported) { setLockPhoneError('Needs iOS 16 or later.'); return; } |
| 404 | if (!status.authorized) status = await requestPhoneLockPermission(); |
| 405 | if (status.authorized) toggleTool('lock_phone'); |
| 406 | else setLockPhoneError(`Needs ${phoneLockPermissionName()}. Tap again to allow it.`); |
| 407 | } catch { |
| 408 | setLockPhoneError(`Needs ${phoneLockPermissionName()}. Tap again to allow it.`); |
| 409 | } |
| 410 | }; |
| 411 | |
| 412 | // --- MODIFIED: toggleTool now handles showing/hiding warnings --- |
| 413 | const toggleTool = (tool: SimpleTool) => { |
nothing calls this directly
no test coverage detected