import 'package:date_format/date_format.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/constants/data.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
import 'package:sk_base_mobile/widgets/my_avatar.dart';

import 'userinfo.controller.dart';

class UserInfoPage extends StatelessWidget {
  final _controller = Get.put<UserInfoController>(UserInfoController());
  UserInfoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
          elevation: 0,
          actions: [
            TextButton(
                onPressed: () {
                  _controller.saveUserInfo();
                },
                child: Text(
                  'Save',
                  style: TextStyle(
                      color: const Color(0xFFB0F320),
                      fontSize: ScreenAdaper.sp(18)),
                )),
            SizedBox(
              width: ScreenAdaper.width(5),
            )
          ],
          backgroundColor: Colors.transparent),
      body: _buildBody(),
    ));
  }

  Widget _buildBody() {
    return Column(
      children: [
        SizedBox(
          height: ScreenAdaper.height(50),
        ),
        Center(
          child: MyAvatarWidget(),
        ),
        TextFormField(
          controller: _controller.nickNameController,
          cursorColor: const Color.fromARGB(255, 87, 86, 86),
          style: TextStyle(fontSize: ScreenAdaper.sp(18), color: Colors.black),
          decoration: InputDecoration(
            contentPadding: EdgeInsets.fromLTRB(
                ScreenAdaper.width(12), 0, ScreenAdaper.width(12), 0),
            labelText: "Nick Name",
            labelStyle: TextStyle(
                color: const Color.fromARGB(255, 136, 136, 136),
                fontSize: ScreenAdaper.sp(18)),
            enabledBorder: const UnderlineInputBorder(
              borderSide: BorderSide(
                color: Color.fromARGB(153, 191, 190, 190),
              ),
            ),
            focusedBorder: const UnderlineInputBorder(
              borderSide: BorderSide(
                color: Color.fromARGB(153, 191, 190, 190),
              ),
            ),
          ),
        ),
        SizedBox(
          height: ScreenAdaper.height(15),
        ),
        // TextFormField(
        //     controller: _controller.birthdayController,
        //     decoration: InputDecoration(
        //       contentPadding: EdgeInsets.fromLTRB(
        //           ScreenAdaper.width(12), 0, ScreenAdaper.width(12), 0),
        //       labelText: "Date of birth",
        //       labelStyle: TextStyle(
        //           color: const Color.fromARGB(255, 136, 136, 136),
        //           fontSize: ScreenAdaper.sp(18)),
        //       enabledBorder: const UnderlineInputBorder(
        //         borderSide: BorderSide(
        //           color: Color.fromARGB(153, 191, 190, 190),
        //         ),
        //       ),
        //       focusedBorder: const UnderlineInputBorder(
        //         borderSide: BorderSide(
        //           color: Color.fromARGB(153, 191, 190, 190),
        //         ),
        //       ),
        //     ),
        //     onTap: () async {
        //       await showCupertinoModalPopup(
        //           context: Get.context!,
        //           builder: (context) => Container(
        //                 color: Colors.white,
        //                 height: 300,
        //                 child: CupertinoDatePicker(
        //                     initialDateTime: DateTime.parse(
        //                         _controller.birthdayController.text),
        //                     minimumDate: DateTime(1900),
        //                     maximumDate: DateTime.now()
        //                         .subtract(const Duration(days: 18 * 365)),
        //                     minimumYear: DateTime(1900).year,
        //                     maximumYear: DateTime.now()
        //                         .subtract(const Duration(days: 18 * 365))
        //                         .year,
        //                     mode: CupertinoDatePickerMode.date,
        //                     onDateTimeChanged: (pickeddate) {
        //                       _controller.birthdayController.text =
        //                           formatDate(pickeddate, [
        //                         yyyy,
        //                         '-',
        //                         mm,
        //                         '-',
        //                         dd,
        //                       ]);
        //                     }),
        //               ));
        //     },
        //     style:
        //         TextStyle(fontSize: ScreenAdaper.sp(18), color: Colors.black),
        //     cursorColor: const Color.fromARGB(255, 87, 86, 86)),
        SizedBox(
          height: ScreenAdaper.height(15),
        ),
        // TextFormField(
        //     controller: _controller.countryController,
        //     decoration: InputDecoration(
        //       contentPadding: EdgeInsets.fromLTRB(
        //           ScreenAdaper.width(12), 0, ScreenAdaper.width(12), 0),
        //       labelText: "Country",
        //       labelStyle: TextStyle(
        //           color: const Color.fromARGB(255, 136, 136, 136),
        //           fontSize: ScreenAdaper.sp(18)),
        //       enabledBorder: const UnderlineInputBorder(
        //         borderSide: BorderSide(
        //           color: Color.fromARGB(153, 191, 190, 190),
        //         ),
        //       ),
        //       focusedBorder: const UnderlineInputBorder(
        //         borderSide: BorderSide(
        //           color: Color.fromARGB(153, 191, 190, 190),
        //         ),
        //       ),
        //     ),
        //     onTap: () async {
        //       await showCupertinoModalPopup(
        //           context: Get.context!,
        //           builder: (context) => Container(
        //               color: Colors.white,
        //               height: 300,
        //               child: CupertinoPicker(
        //                 itemExtent: 50,
        //                 onSelectedItemChanged: (index) {
        //                   _controller.countryController.text =
        //                       Data.countryCodes[index];
        //                 },
        //                 children: Data.countryCodes
        //                     .map((e) => Container(
        //                           height: ScreenAdaper.height(50),
        //                           alignment: Alignment.center,
        //                           child: Text(
        //                             e,
        //                             style: TextStyle(
        //                                 fontSize: ScreenAdaper.sp(30)),
        //                           ),
        //                         ))
        //                     .toList(),
        //               )));
        //     },
        //     style:
        //         TextStyle(fontSize: ScreenAdaper.sp(18), color: Colors.black),
        //     cursorColor: const Color.fromARGB(255, 87, 86, 86))
      ],
    );
  }
}
