import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';

class MapAddPointDialog extends GetView<MapSurveyController> {
  const MapAddPointDialog({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
          child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            TextField(
              controller: controller.pointIdController,
              autofocus: true,
              keyboardType: TextInputType.number,
              decoration: const InputDecoration(
                  border: OutlineInputBorder(), labelText: 'Azonosító'),
            ),
            const SizedBox(
              height: 20.0,
            ),
            TextField(
              controller: controller.pointDescriptionController,
              decoration: const InputDecoration(
                  border: OutlineInputBorder(), labelText: 'Leírás'),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                OutlinedButton(
                  style: OutlinedButton.styleFrom(
                      minimumSize: const Size(120.0, 40.0)),
                  child: const Text(
                    "Mégsem",
                    style: TextStyle(color: Colors.red),
                  ),
                  onPressed: () {
                    Get.back();
                  },
                ),
                OutlinedButton(
                  style: OutlinedButton.styleFrom(
                      minimumSize: const Size(120.0, 40.0)),
                  child: const Text(
                    "Ment",
                    style: TextStyle(
                        color: Colors.green, fontWeight: FontWeight.bold),
                  ),
                  onPressed: () async {
                    // pointId = int.parse(pointIdController.text);
                    // pointWithDescriptionList.add(PointWithDescription(
                    //     pointId,
                    //     gpsDateTime.value,
                    //     pointDescriptionController.text,
                    //     eov.value.Y,
                    //     eov.value.X,
                    //     gpsLatitude.value,
                    //     gpsLongitude.value,
                    //     max(gpsLatitudeError.value, gpsLongitudeError.value),
                    //     gpsAltitudeError.value));
                    // print(
                    //     "pointWithDescriptionList -> ${pointWithDescriptionList.length}");
                    // pointNotesMarker.add(Marker(
                    //     point: LatLng(gpsLatitude.value, gpsLongitude.value),
                    //     width: 15.0,
                    //     height: 15.0,
                    //     builder: (ctx) => Container(
                    //           width: 15.0,
                    //           height: 15.0,
                    //           decoration: BoxDecoration(
                    //               color: Colors.purple,
                    //               shape: BoxShape.circle,
                    //               border: Border.all(
                    //                   width: 1.0, color: Colors.black)),
                    //         )));
                    // await dataFile.writeAsString(
                    //     "$pointId;$gpsDateTime;${pointDescriptionController.text};${formatEovForFile.format(eov.value.Y)};${formatEovForFile.format(eov.value.X)};$gpsLatitude;$gpsLongitude;$gpsAltitude;${max(gpsLatitudeError.value, gpsLongitudeError.value)};$gpsAltitudeError\r\n",
                    //     mode: FileMode.append);

                    // pointId++;

                    Get.back();
                  },
                ),
              ],
            )
          ],
        ),
      )),
    );
  }
}
