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

class SettingsDialog extends StatelessWidget {
  final controller = Get.find<MapSurveyController>();
  SettingsDialog({super.key});

  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                IconButton(
                    onPressed: () {
                      // if (controller.ntripUsernameController.text.isNotEmpty) {
                      //   controller.ntripUserName.value =
                      //       controller.ntripUsernameController.text;
                      //   controller.saveNtripUserName(
                      //       controller.ntripUsernameController.text);
                      //   if (controller
                      //       .ntripPasswordController.text.isNotEmpty) {
                      //     controller.ntripPassword.value =
                      //         controller.ntripPasswordController.text;
                      //     controller.saveNtripPassword(
                      //         controller.ntripPasswordController.text);
                      //   }
                      // }
                      Get.back();
                    },
                    icon: const Icon(Icons.close)),
                TextButton(
                    style: ButtonStyle(
                        overlayColor:
                            MaterialStateProperty.all(Colors.transparent)),
                    onPressed: () {
                      // if (controller.ntripUsernameController.text.isNotEmpty) {
                      //   controller.ntripUserName.value =
                      //       controller.ntripUsernameController.text;
                      //   controller.saveNtripUserName(
                      //       controller.ntripUsernameController.text);
                      //   if (controller
                      //       .ntripPasswordController.text.isNotEmpty) {
                      //     controller.ntripPassword.value =
                      //         controller.ntripPasswordController.text;
                      //     controller.saveNtripPassword(
                      //         controller.ntripPasswordController.text);
                      //   }
                      // }
                      Get.back();
                    },
                    child: const Text(
                      'Bezár',
                      style: TextStyle(color: Colors.blue, fontSize: 14.0),
                    ))
              ],
            ),
          ),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 40.0),
            child: Text(
              'Beállítások',
              style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
            ),
          ),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 40.0),
            child: Text(
              'GPS vevő',
              style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500),
            ),
          ),
          // Obx(() => Column(children: [
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-BE6A'),
          //           value: '10:06:1C:97:BE:6A',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-BE6A';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-BE6A');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-1DC6'),
          //           value: 'E8:31:CD:16:1D:C6',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-1DC6';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-1DC6');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-9C3A'),
          //           value: '08:3A:8D:14:9C:3A',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-9C3A';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-9C3A');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-72C2'),
          //           value: '10:06:1C:97:72:C2',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-72C2';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-72C2');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-FE16'),
          //           value: '10:06:1C:9F:FE:16',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-FE16';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-FE16');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-3B0A'),
          //           value: '10:C6:1C:9E:3B:0A',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-3B0A';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-3B0A');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-7FEA'),
          //           value: '10:06:1C:9C:7F:EA',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-7FEA';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-7FEA');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-A39E'),
          //           value: '10:06:1C:97:A3:9E',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-A39E';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-A39E');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-FF4E'),
          //           value: '98:CD:AC:62:FF:4E',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-FF4E';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-FF4E');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-8BB2'),
          //           value: 'E8:31:CD:14:8B:B2',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-8BB2';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-8BB2');
          //           }),
          //       RadioListTile(
          //           title: Text('TiGNSS Rover-FF36'),
          //           value: '98:CD:AC:62:FF:36',
          //           groupValue: controller.gpsAddress.value,
          //           onChanged: (value) {
          //             controller.gpsAddress.value = value!;
          //             controller.gpsName.value = 'TiGNSS Rover-FF36';
          //             controller.saveGpsAddress(value);
          //             controller.saveGpsName('TiGNSS Rover-FF36');
          //           })
          //     ])),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20),
            child: Divider(
              height: 5,
            ),
          ),
          // const SizedBox(height: 5),
          // const Padding(
          //   padding: EdgeInsets.symmetric(horizontal: 40.0),
          //   child: Text(
          //     'Bemért pont azonosítója:',
          //     style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500),
          //   ),
          // ),
          // const SizedBox(height: 4),
          // Padding(
          //   padding: const EdgeInsets.symmetric(horizontal: 40),
          //   child: Row(
          //     children: [
          //       Flexible(
          //         child: TextField(
          //           controller: controller.pointPrefixController,
          //           decoration: const InputDecoration(
          //               border: OutlineInputBorder(), labelText: 'Előtag'),
          //         ),
          //       ),
          //       const Padding(
          //         padding: EdgeInsets.symmetric(horizontal: 10.0),
          //         child: Text(
          //           'Eredeti azonosító',
          //           style: TextStyle(fontSize: 12.0),
          //         ),
          //       ),
          //       Flexible(
          //         child: TextField(
          //           controller: controller.pointPostfixController,
          //           decoration: const InputDecoration(
          //               border: OutlineInputBorder(), labelText: 'Utótag'),
          //         ),
          //       ),
          //     ],
          //   ),
          // ),
          const SizedBox(height: 5),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20.0),
            child: Text(
              'Mérés iránya:',
              style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500),
            ),
          ),
          Obx(
            () => Column(children: [
              RadioListTile<bool>(
                  title: Text('Növekvő'),
                  value: true,
                  groupValue: controller.pointMeasuringDirectionForward.value,
                  onChanged: (value) {
                    controller.pointMeasuringDirectionForward.value = value!;
                  }),
              RadioListTile<bool>(
                  title: Text('Csökkenő'),
                  value: false,
                  groupValue: controller.pointMeasuringDirectionForward.value,
                  onChanged: (value) {
                    controller.pointMeasuringDirectionForward.value = value!;
                  })
            ]),
          ),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20),
            child: Divider(
              height: 5,
            ),
          ),
          const SizedBox(height: 5),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20.0),
            child: Text(
              'Kitűzött pont azonostója:',
              style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500),
            ),
          ),
          const SizedBox(height: 4),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 20),
            child: SizedBox(
              height: 32,
              width: double.infinity,
              child: Row(
                children: [
                  Flexible(
                    child: TextField(
                      controller: controller.pointPrefixController,
                      decoration: const InputDecoration(
                          border: OutlineInputBorder(), labelText: 'Előtag'),
                    ),
                  ),
                  const Padding(
                    padding: EdgeInsets.symmetric(horizontal: 10.0),
                    child: Text(
                      'Eredeti azonosító',
                      style: TextStyle(fontSize: 12.0),
                    ),
                  ),
                  Flexible(
                    child: TextField(
                      controller: controller.pointPostfixController,
                      decoration: const InputDecoration(
                          border: OutlineInputBorder(), labelText: 'Utótag'),
                    ),
                  ),
                ],
              ),
            ),
          ),
          const Padding(
              padding: EdgeInsets.only(left: 20, top: 8),
              child: Text(
                  'Például: előtag: 6, utótag: -bp, eredeti azonositó: 1002 -> 61002-bp',
                  style: TextStyle(fontSize: 10, fontWeight: FontWeight.w400))),
          const SizedBox(height: 15),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20),
            child: Divider(
              height: 5,
            ),
          ),
          const SizedBox(height: 5),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20.0),
            child: Text(
              'Ntrip szolgáltatás:',
              style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500),
            ),
          ),
          const SizedBox(height: 5),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 20.0),
            child: Column(children: [
              SizedBox(
                height: 40,
                child: TextField(
                  //controller: NtripService.to.usernameController,
                  enableSuggestions: false,
                  autocorrect: false,
                  decoration: InputDecoration(
                      floatingLabelBehavior: FloatingLabelBehavior.never,
                      isDense: true,
                      filled: true,
                      fillColor: Colors.grey.shade300,
                      border: OutlineInputBorder(
                          borderSide: BorderSide.none,
                          borderRadius: BorderRadius.circular(12)),
                      labelText: 'Felhasználónév',
                      prefixIcon: Icon(Icons.account_circle_rounded)),
                ),
              ),
              const SizedBox(height: 10),
              Obx(
                () => SizedBox(
                  height: 40,
                  child: TextField(
                    keyboardType: TextInputType.visiblePassword,
                    obscureText: controller.isShowPassword.value,
                    //focusNode: controller.passwordFieldFocusNode,
                    enableSuggestions: false,
                    autocorrect: false,
                    //controller: NtripService.to.passwordController,
                    decoration: InputDecoration(
                        floatingLabelBehavior: FloatingLabelBehavior.never,
                        isDense: true,
                        filled: true,
                        fillColor: Colors.grey.shade300,
                        border: OutlineInputBorder(
                            borderSide: BorderSide.none,
                            borderRadius: BorderRadius.circular(12)),
                        labelText: 'Jelszó',
                        prefixIcon: Icon(
                          Icons.lock_rounded,
                          size: 24,
                        ),
                        suffixIcon: Padding(
                            padding: const EdgeInsets.fromLTRB(0, 0, 4, 0),
                            child: GestureDetector(
                                //onTap: controller.toggleShowPassword,
                                child: Icon(
                                    controller.isShowPassword.value
                                        ? Icons.visibility_rounded
                                        : Icons.visibility_off_rounded,
                                    size: 24)))),
                  ),
                ),
              ),
              const SizedBox(height: 20)
            ]),
          ),
        ],
      ),
    );
  }
}
