import 'package:flutter/material.dart';
import 'package:flutter_elinux/common/widgets/floating_menu_button.dart';
import 'package:flutter_elinux/common/widgets/scaffold_with_statusbar.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:simple_tiles_map/simple_tiles_map.dart';

class MapBenchmarkScreen extends StatefulWidget {
  const MapBenchmarkScreen({super.key});

  @override
  State<MapBenchmarkScreen> createState() => _MapBenchmarkScreenState();
}

class _MapBenchmarkScreenState extends State<MapBenchmarkScreen> {
  TypeMap _typeMap = TypeMap.osm;

  @override
  Widget build(BuildContext context) {
    MapOptions mapOptions = MapOptions(
      maxZoom: 19,
      minZoom: 5,
    );
    return ScaffoldWithStatusbar(
      body: Stack(children: [
        Column(
          children: [
            SimpleTilesMap(
              typeMap: _typeMap,
              mapOptions: mapOptions,
            ),
          ],
        ),
        FloatingMenuButton(
          popupMenuButton: PopupMenuButton(
            itemBuilder: (BuildContext context) {
              return [
                PopupMenuItem(
                  value: TypeMap.google,
                  enabled: (_typeMap != TypeMap.google),
                  child: const Text('Google'),
                ),
                PopupMenuItem(
                  value: TypeMap.googleHybrid,
                  enabled: (_typeMap != TypeMap.googleHybrid),
                  child: const Text('Google Hybrid'),
                ),
                PopupMenuItem(
                  value: TypeMap.googleSatellite,
                  enabled: (_typeMap != TypeMap.googleSatellite),
                  child: const Text('Google Satellite'),
                ),
                PopupMenuItem(
                  value: TypeMap.osm,
                  enabled: (_typeMap != TypeMap.osm),
                  child: const Text('Open Street Map'),
                ),
                PopupMenuItem(
                  value: TypeMap.cartoMapPositron,
                  enabled: (_typeMap != TypeMap.cartoMapPositron),
                  child: const Text('Carto Map Positron'),
                ),
                PopupMenuItem(
                  value: TypeMap.cartoMapDark,
                  enabled: (_typeMap != TypeMap.cartoMapDark),
                  child: const Text('Carto Map Dark'),
                ),
                PopupMenuItem(
                  value: TypeMap.esriSatellite,
                  enabled: (_typeMap != TypeMap.esriSatellite),
                  child: const Text('Esri Satellite'),
                ),
                PopupMenuItem(
                  value: TypeMap.esriStreets,
                  enabled: (_typeMap != TypeMap.esriStreets),
                  child: const Text('Esri Streets'),
                ),
                PopupMenuItem(
                  value: TypeMap.esriTopo,
                  enabled: (_typeMap != TypeMap.esriTopo),
                  child: const Text('Esri Topo'),
                ),
              ];
            },
            onSelected: (dynamic value) {
              setState(() {
                _typeMap = value;
              });
            },
          ),
        ),
      ]),
    );
  }
}
