import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';

import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/color/appFontsize.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';

class DeletedAccountPage extends GetView {
  BoxConstraints? bodysize;
  final scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(builder: (context, cc) {
      bodysize = cc;

      return GestureDetector(
          onTap: () => FocusScope.of(context).unfocus(),
          child: Container(
            decoration: const BoxDecoration(
              image: DecorationImage(
                image: AssetImage('assets/images/new_background.png'), // 本地图片
                fit: BoxFit.fill, // 填满整个 Container
              ),
            ),
            child: Scaffold(
              appBar: AppBar(
                backgroundColor: Colors.transparent,
                automaticallyImplyLeading: false,
                iconTheme: const IconThemeData(color: Colors.white),
                titleSpacing: 0,
                title: SizedBox(
                  width: double.infinity,
                  height: 180.rpx,
                  child: Stack(
                    alignment: Alignment.center,
                    children: [
                      // 中间居中的标题
                      Text(
                        '注销账号',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 30.rpx,
                        ),
                      ),
                      // 左侧图标
                      Positioned(
                        left: 0.rpx,
                        child: returnIconButtomNew,
                      ),
                    ],
                  ),
                ),
                centerTitle: false,
              ),
              key: scaffoldKey,
              backgroundColor: Colors.transparent,
              body: Container(
                width: bodysize!.maxWidth,
                height: bodysize!.maxHeight * 1,
                decoration: const BoxDecoration(),
                child: Column(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Expanded(
                      child: Container(
                        width: MediaQuery.sizeOf(context).width,
                        height: 100,
                        child: SingleChildScrollView(
                          child: Column(
                            mainAxisSize: MainAxisSize.max,
                            children: [
                              Padding(
                                padding: const EdgeInsetsDirectional.fromSTEB(
                                    15, 33, 15, 0),
                                child: Container(
                                  width: MediaQuery.sizeOf(context).width,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(12),
                                  ),
                                  child: Padding(
                                    padding:
                                        const EdgeInsetsDirectional.fromSTEB(
                                            21, 0, 22, 0),
                                    child: Container(
                                      width: MediaQuery.sizeOf(context).width,
                                      child: SingleChildScrollView(
                                        child: Column(
                                          mainAxisSize: MainAxisSize.max,
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          crossAxisAlignment:
                                              CrossAxisAlignment.center,
                                          children: [
                                            Container(
                                              width: 50,
                                              height: 50,
                                              child: Image.asset(
                                                'assets/images/delete_account.png',
                                                fit: BoxFit.cover,
                                                color: Color(0XFF84F5FF),
                                              ),
                                            ),
                                            const Text(
                                              "注销智慧眠花糖账号",
                                              style: TextStyle(
                                                fontSize: 20, // 设置字体大小
                                                color: Color(0xFFFFFFFF),
                                                // decoration: TextDecoration.underline, // 添加下划线
                                              ),
                                            ),
                                            Container(
                                                child: Column(
                                              mainAxisAlignment:
                                                  MainAxisAlignment
                                                      .spaceBetween,
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.start,
                                              children: [
                                                RichText(
                                                  text: TextSpan(
                                                    text: "账号注销后，你将无法使用以下功能，",
                                                    style: TextStyle(
                                                      fontSize: AppFontsize
                                                          .normal_text_size, // 设置字体大小
                                                      color: Color(
                                                          0xFF9AA0B3), // 默认颜色
                                                    ),
                                                    children: [
                                                      TextSpan(
                                                        text:
                                                            "并且当前有绑定以及被分享的智能床、智能床垫等设备的账号不能注销",
                                                        style: TextStyle(
                                                          fontSize: AppFontsize
                                                              .normal_text_size,
                                                          color: const Color(
                                                              0xFFFF7159), // 设置为#E45E91的颜色
                                                        ),
                                                      ),
                                                      TextSpan(
                                                        text:
                                                            "，可先进行解绑后再进行注销操作。",
                                                        style: TextStyle(
                                                          fontSize: AppFontsize
                                                              .normal_text_size,
                                                          color:
                                                              Color(0xFF9AA0B3),
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                                const SizedBox(
                                                  height: 24,
                                                ),
                                                Text(
                                                  "无法控制智能床、智能床垫等设备",
                                                  style: TextStyle(
                                                    fontSize: AppFontsize
                                                        .title_size, // 设置字体大小
                                                    color:
                                                        const Color(0xFFFFFFFF),
                                                  ),
                                                ),
                                                const SizedBox(
                                                  height: 6,
                                                ),
                                                Text(
                                                  "你将无法控制你的智能床、智能床垫等设备，以及与其相关的各种操作。",
                                                  style: TextStyle(
                                                    fontSize: AppFontsize
                                                        .normal_text_size, // 设置字体大小
                                                    color: Color(0xFF9AA0B3),
                                                  ),
                                                ),
                                                const SizedBox(
                                                  height: 24,
                                                ),
                                                Text(
                                                  "无法查询睡眠报告和体征数据",
                                                  style: TextStyle(
                                                    fontSize: AppFontsize
                                                        .title_size, // 设置字体大小
                                                    color:
                                                        const Color(0xFFFFFFFF),
                                                  ),
                                                ),
                                                const SizedBox(
                                                  height: 6,
                                                ),
                                                Text(
                                                  "注销账号后你将查询不到你以前的睡眠报告和实时数据。",
                                                  style: TextStyle(
                                                    fontSize: AppFontsize
                                                        .normal_text_size, // 设置字体大小
                                                    color: Color(0xFF9AA0B3),
                                                  ),
                                                ),
                                                const SizedBox(
                                                  height: 24,
                                                ),
                                                Text(
                                                  "无法使用的其他功能",
                                                  style: TextStyle(
                                                    fontSize: AppFontsize
                                                        .title_size, // 设置字体大小
                                                    color:
                                                        const Color(0xFFFFFFFF),
                                                  ),
                                                ),
                                                const SizedBox(
                                                  height: 6,
                                                ),
                                                Text(
                                                  "包含设备报修、门店体验预约等。",
                                                  style: TextStyle(
                                                    fontSize: AppFontsize
                                                        .normal_text_size, // 设置字体大小
                                                    color: Color(0xFF9AA0B3),
                                                  ),
                                                ),
                                              ],
                                            )),
                                          ]
                                              .divide(
                                                  const SizedBox(height: 24))
                                              .addToStart(
                                                  const SizedBox(height: 14))
                                              .addToEnd(
                                                  const SizedBox(height: 17)),
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsetsDirectional.fromSTEB(
                          15, 0, 15, AppConstants.page_button_bottom_padding),
                      child: Container(
                        width: bodysize!.maxWidth,
                        height: bodysize!.maxHeight * 0.056,
                        // decoration: BoxDecoration(
                        //   color:
                        //       FlutterFlowTheme.of(context).secondaryBackground,
                        // ),
                        child: Container(
                          width: bodysize!.maxWidth,
                          height: bodysize!.maxHeight * 0.056,
                          decoration: BoxDecoration(
                            // color: FlutterFlowTheme.of(context)
                            //     .secondaryBackground,
                            borderRadius: BorderRadius.circular(12),
                          ),
                          child: FFButtonWidget(
                            onPressed: () async {
                              // showCustomConfirmDialog(context, "是否确认注销?")
                              //     .then((v) async {
                              //   if (v != "confirm") {
                              //     return;
                              //   }
                              //   LoginController loginController = Get.find();
                              //   UserInfoController userInfoController =
                              //       Get.find<UserInfoController>();
                              //   var code = await loginController.deletedAccount();
                              //   if (code != null && code == 1) {
                              //     final box = GetStorage();
                              //     box.remove('user');
                              //     box.remove('token');
                              //     userInfoController.model.token = null;
                              //     userInfoController.model.user = null;
                              //     userInfoController.model.login = 0;
                              //     userInfoController.model.message = 0;
                              //     GlobalController globalController =
                              //         Get.find<GlobalController>();
                              //     globalController.resetParmAll();
                              //     Get.offAllNamed("/loginPage");
                              //   }
                              // });
                            },
                            text: '注销账号',
                            options: FFButtonOptions(
                              height: 40,
                              padding: const EdgeInsetsDirectional.fromSTEB(
                                  24, 0, 24, 0),
                              iconPadding: const EdgeInsetsDirectional.fromSTEB(
                                  0, 0, 0, 0),
                              color: const Color(0xFFFF7159),
                              textStyle: TextStyle(
                                fontFamily: 'Readex Pro',
                                color: Colors.white,
                                fontSize: AppFontsize.normal_text_size,
                                letterSpacing: 0,
                              ),
                              elevation: 0,
                              borderSide: const BorderSide(
                                color: Colors.transparent,
                                width: 1,
                              ),
                              borderRadius: BorderRadius.circular(8),
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ));
    });
  }

  Future<void> _copyToClipboard(String text) async {
    await Clipboard.setData(ClipboardData(text: text));
  }
}
