import 'package:circle_app/components/my_app_bar.dart';
import 'package:circle_app/util/util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'logic.dart';

class Complete_materialPage extends StatelessWidget {
  Complete_materialPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder(builder: (Complete_materialLogic controller) {
      return Stack(
        children: [
          Container(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height,
            child: Image.asset(
              getBaseImage('bg'),
              fit: BoxFit.fill,
            ),
          ),
          Scaffold(
            appBar: MyAppBar(
              centerTitle: '完善您的个人形象',
              isBack: true,
            ),
            backgroundColor: Colors.transparent,
            body: GestureDetector(
              onTap: () {
                FocusManager.instance.primaryFocus?.unfocus();
              },
              child: SingleChildScrollView(
                child: Container(
                  width: MediaQuery.of(context).size.width,
                  color: Colors.transparent,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      SizedBox(
                        height: 20.sp,
                      ),
                      GestureDetector(
                        onTap: () {
                          controller.getImageFile();
                        },
                        child: Image.asset(
                          getLoginImage('add'),
                          width: 86.sp,
                          height: 86.sp,
                        ),
                      ),
                      SizedBox(
                        height: 15.sp,
                      ),
                      Text(
                        '数据表明95%的人对完整的兽设更感兴趣',
                        style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.w500,
                            fontSize: 16.sp),
                      ),
                      funcWidget(
                          '昵称',
                          TextField(
                            controller: controller.state.textEditingController,
                            style: TextStyle(
                                color: Colors.white,
                                fontWeight: FontWeight.w500,
                                fontSize: 14.sp),
                            decoration: InputDecoration(
                                hintText: '请输入昵称',
                                hintStyle: TextStyle(
                                    color: Colors.white,
                                    fontWeight: FontWeight.w500,
                                    fontSize: 14.sp),
                                border: InputBorder.none,
                                contentPadding: EdgeInsets.only(left: 20.sp)),
                          ),
                          () {},
                          img: 'edit'),
                      funcWidget(
                          '属性',
                          Text(
                            controller.state.sex,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 14.sp,
                                fontWeight: FontWeight.w500),
                          ),
                          () {}),
                      funcWidget(
                          '年龄',
                          Text(
                            controller.state.sex,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 14.sp,
                                fontWeight: FontWeight.w500),
                          ),
                          () {}),
                      funcWidget(
                          '角色',
                          Text(
                            controller.state.sex,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 14.sp,
                                fontWeight: FontWeight.w500),
                          ),
                          () {}),
                      funcWidget(
                          '取向',
                          Text(
                            controller.state.sex,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 14.sp,
                                fontWeight: FontWeight.w500),
                          ),
                          () {}),
                      funcWidget(
                          '兴趣',
                          Row(
                            children: [interestWdiget('JK圈')],
                          ),
                          () {}),
                      Container(
                        margin: EdgeInsets.only(
                            top: 24.sp,
                            bottom: 18.sp,
                            left: 28.sp,
                            right: 28.sp),
                        height: 116.sp,
                        child: Stack(
                          children: [
                            Image.asset(getLoginImage('desc_bg')),
                            TextField(
                              maxLines: 4,
                              controller:
                                  controller.state.descEditingController,
                              style: TextStyle(
                                  color: Colors.white,
                                  fontWeight: FontWeight.w500,
                                  fontSize: 14.sp),
                              decoration: InputDecoration(
                                  hintText: '请输入您的交友宣言',
                                  // icon: Text('交友宣言：',style: TextStyle(color: Colors.white,fontSize: 14.sp,fontWeight: FontWeight.w500),),
                                  labelText: '您的交友宣言',
                                  labelStyle: TextStyle(
                                      color: Colors.white,
                                      fontWeight: FontWeight.w600,
                                      fontSize: 16.sp),
                                  hintStyle: TextStyle(
                                      color: Colors.white,
                                      fontWeight: FontWeight.w500,
                                      fontSize: 14.sp),
                                  border: InputBorder.none,
                                  contentPadding: EdgeInsets.all(20.sp)),
                            )
                          ],
                        ),
                      ),
                      GestureDetector(
                        onTap:() {
                          controller.pushHome();
                          // controller.checkInfo();
                        },
                        child: Container(
                          alignment: Alignment.center,
                          width: 133.sp,
                          height: 56.sp,
                          decoration: BoxDecoration(
                            image: DecorationImage(
                                fit: BoxFit.fill,
                                image: AssetImage(getLoginImage('start_bg'))),
                          ),
                          child: Text(
                            '开启小圈之旅',
                            style: TextStyle(
                                color: Color(0xff00FFF4),
                                fontSize: 16.sp,
                                fontWeight: FontWeight.w600),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ),
            ),
          )
        ],
      );
    });
  }

  Widget funcWidget(
      String leftStr, Widget tipWidget, GestureTapCallback callback,
      {String img = 'down_arr'}) {
    return Container(
      width: Get.width,
      padding: EdgeInsets.only(left: 28.sp, right: 28.sp),
      height: 54.sp,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Expanded(
            child: GestureDetector(
              onTap: callback,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(leftStr,
                      style: TextStyle(
                          color: Colors.white,
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                          shadows: [
                            Shadow(color: Color(0xffF657FF), blurRadius: 4.0.sp)
                          ])),
                  Expanded(child: tipWidget),
                  Image.asset(
                    getLoginImage(img),
                    width: img == 'down_arr' ? 24.sp : 18.sp,
                  )
                ],
              ),
            ),
          ),
          lineWidget(),
        ],
      ),
    );
  }

  lineWidget() {
    return Container(
      height: 1.sp,
      width: Get.width - 28 * 2.sp,
      decoration: const BoxDecoration(
          gradient:
              SweepGradient(colors: [Color(0xff03FEFB), Color(0xffE735F4)])),
    );
  }

  interestWdiget(String interest) {
    return Container(
      height: 21.sp,
      padding: EdgeInsets.only(left: 12.sp, right: 12.sp),
      margin: EdgeInsets.only(left: 10.sp),
      alignment: Alignment.center,
      decoration: BoxDecoration(
        border: Border.all(width: 1, color: Colors.white),
        borderRadius: BorderRadius.circular(21.sp),
      ),
      child: Text(
        interest,
        style: TextStyle(
            color: Colors.white, fontSize: 11.sp, fontWeight: FontWeight.w500),
      ),
    );
  }
}
