<?php

// Public-facing standalone Rider App — installable PWA for delivery riders.
class RiderAppController extends Controller
{
    public function index(): void
    {
        $logoPath = setting('logo_path', '');
        $this->view('rider_app.index', [
            'pageTitle'   => setting('company_name', 'CurryPot.lk') . ' — Rider App',
            'companyName' => setting('company_name', 'CurryPot.lk'),
            'logoUrl'     => $logoPath ? BASE_URL . '/' . $logoPath : null,
        ], null); // standalone — no admin layout
    }

    public function manifest(): void
    {
        $name = setting('company_name', 'CurryPot.lk');
        header('Content-Type: application/manifest+json');
        echo json_encode([
            'name'             => $name . ' Rider App',
            'short_name'       => 'Rider App',
            'description'      => 'Manage your assigned deliveries for ' . $name . '.',
            'start_url'        => BASE_URL . '/rider-app',
            'scope'            => BASE_URL . '/',
            'display'          => 'standalone',
            'orientation'      => 'portrait',
            'background_color' => '#F4F6FB',
            'theme_color'      => '#1D7A8C',
            'icons' => [
                ['src' => BASE_URL . '/assets/icons/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'any maskable'],
                ['src' => BASE_URL . '/assets/icons/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'any maskable'],
            ],
        ]);
        exit;
    }
}
