<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class ScannerController extends AbstractController
{
    private const SCANNER_PATH = '/scanner/';

    #[Route('/scanner/', name: 'app_scanner', methods: ['GET'])]
    public function index(): Response
    {
        return $this->render('scanner/index.html.twig');
    }

    #[Route('/scanner/manifest.json', name: 'app_scanner_manifest', methods: ['GET'])]
    public function manifest(): Response
    {
        $manifest = [
            'name' => 'E-Ticket Scanner',
            'short_name' => 'Scanner',
            'description' => 'Application de scan de billets pour organisateurs',
            'start_url' => self::SCANNER_PATH,
            'scope' => self::SCANNER_PATH,
            'display' => 'standalone',
            'orientation' => 'portrait',
            'theme_color' => '#111827',
            'background_color' => '#111827',
            'lang' => 'fr',
            'icons' => [
                ['src' => '/logo.png', 'sizes' => '512x512', 'type' => 'image/png'],
            ],
        ];

        return new Response(
            json_encode($manifest, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES),
            200,
            ['Content-Type' => 'application/manifest+json'],
        );
    }
}
