<?php

namespace App\Filament\Resources\PhotoGeoData\Schemas;

use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\Schema;
use EduardoRibeiroDev\FilamentLeaflet\Fields\MapPicker;
use EduardoRibeiroDev\FilamentLeaflet\Enums\TileLayer;

class PhotoGeoDataForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                FileUpload::make('image_path')
                ->label('Bild')
                    ->required()
                    ->columnSpan('full')
                    ->disk('public')
                    ->directory('photos')
                    ->image(),
                TextInput::make('title')
                ->label('Rubrik')
                    ->columnSpan('full')
                    ->required(),
                TextInput::make('uploaded_by')
                    ->label('Uppladdat av')
                    ->columnSpan('full')
                    ->required(),
                DatePicker::make('captured_at')
                ->label('Datum då foto togs')
                    ->columnSpan('full'),
                TextInput::make('desc')
                ->label('Kort beskrivning')
                    ->columnSpan('full'),
                Textarea::make('story')
                ->label('Berättelse')
                    ->columnSpanFull(),
                MapPicker::make('location')
                ->label('Plats')
                    ->height(400)
                    ->center(57.63072, 12.847787)
                    ->zoom(15)
                    ->autoCenter()
                    ->tileLayersUrl(TileLayer::OpenStreetMap)
                    ->columnSpanFull()
                    ->latitudeFieldName('lat')
                    ->longitudeFieldName('lng'),
            ]);
    }
}
