import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:yumi/app_localizations.dart';
import 'package:yumi/ui_kit/components/appbar/socialchat_appbar.dart';
import 'package:yumi/ui_kit/components/sc_debounce_widget.dart';
import 'package:yumi/ui_kit/components/text/sc_text.dart';
import 'package:yumi/ui_kit/components/sc_tts.dart';
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
import 'package:yumi/modules/index/main_route.dart';
import 'package:yumi/modules/user/settings/settings_route.dart';

import 'package:yumi/ui_kit/components/dialog/dialog_base.dart';
import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:yumi/app/routes/sc_fluro_navigator.dart';
import 'package:yumi/shared/tools/sc_app_utils.dart';

///设置页面
class SettingsPage extends StatefulWidget {
  @override
  _SettingsPageState createState() => _SettingsPageState();
}

class _SettingsPageState extends State<SettingsPage> {
  String totalSize = "0";

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Image.asset(
          SCGlobalConfig.businessLogicStrategy.getSettingsPageBackgroundImage(),
          width: ScreenUtil().screenWidth,
          height: ScreenUtil().screenHeight,
          fit: BoxFit.fill,
        ),
        Scaffold(
          backgroundColor: Colors.transparent,
          resizeToAvoidBottomInset: false,
          appBar: SocialChatStandardAppBar(
            title: SCAppLocalizations.of(context)!.settings,
            actions: [],
          ),
          body: SafeArea(
            top: false,
            child: Column(
              children: [
                Container(
                  alignment: AlignmentDirectional.bottomStart,
                  margin: EdgeInsetsDirectional.only(start: 15.w),
                  child: text(
                    SCAppLocalizations.of(context)!.account,
                    textColor: SCGlobalConfig.businessLogicStrategy.getSettingsPageSecondaryTextColor(),
                    fontSize: 12.sp,
                  ),
                ),
                Container(
                  padding: EdgeInsets.symmetric(vertical: 12.w),
                  margin: EdgeInsets.symmetric(vertical: 8.w, horizontal: 15.w),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(12),
                    color: SCGlobalConfig.businessLogicStrategy.getSettingsPageMainContainerBackgroundColor(),
                    border: Border.all(color: SCGlobalConfig.businessLogicStrategy.getSettingsPageMainContainerBorderColor(), width: 1.w),
                  ),
                  child: Column(
                    children: [
                      SCDebounceWidget(
                        child: Row(
                          children: [
                            SizedBox(width: 18.w),
                            text(
                              SCAppLocalizations.of(context)!.account,
                              textColor: SCGlobalConfig.businessLogicStrategy.getSettingsPagePrimaryTextColor(),
                              fontSize: 13.sp,
                            ),
                            Spacer(),
                            Icon(
                              SCGlobalConfig.lang == "ar"
                                  ? Icons.keyboard_arrow_left
                                  : Icons.keyboard_arrow_right,
                              size: 15.w,
                              color: SCGlobalConfig.businessLogicStrategy.getSettingsPageIconColor(),
                            ),
                            SizedBox(width: 18.w),
                          ],
                        ),
                        onTap: () {
                          SCNavigatorUtils.push(
                            context,
                            SettingsRoute.account,
                            replace: false,
                          );
                        },
                      ),
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.symmetric(vertical: 12.w),
                  margin: EdgeInsets.symmetric(horizontal: 15.w),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(12),
                    color: SCGlobalConfig.businessLogicStrategy.getSettingsPageContainerBackgroundColor(),
                    border: Border.all(color: SCGlobalConfig.businessLogicStrategy.getSettingsPageContainerBorderColor(), width: 1.w),
                  ),
                  child: Column(
                    children: [
                      SCDebounceWidget(
                        child: Row(
                          children: [
                            SizedBox(width: 18.w),
                            text(
                              SCAppLocalizations.of(context)!.blockedList,
                              textColor: SCGlobalConfig.businessLogicStrategy.getSettingsPagePrimaryTextColor(),
                              fontSize: 13.sp,
                            ),
                            Spacer(),
                            Icon(
                              SCGlobalConfig.lang == "ar"
                                  ? Icons.keyboard_arrow_left
                                  : Icons.keyboard_arrow_right,
                              size: 15.w,
                              color: SCGlobalConfig.businessLogicStrategy.getSettingsPageIconColor(),
                            ),
                            SizedBox(width: 18.w),
                          ],
                        ),
                        onTap: () {
                          SCNavigatorUtils.push(
                            context,
                            SettingsRoute.blockedList,
                            replace: false,
                          );
                        },
                      ),
                    ],
                  ),
                ),
                SizedBox(height: 8.w),
                Container(
                  alignment: AlignmentDirectional.bottomStart,
                  margin: EdgeInsetsDirectional.only(start: 15.w),
                  child: text(
                    SCAppLocalizations.of(context)!.about,
                    textColor: SCGlobalConfig.businessLogicStrategy.getSettingsPageAboutTextColor(),
                    fontSize: 12.sp,
                  ),
                ),
                Container(
                  padding: EdgeInsets.symmetric(vertical: 12.w),
                  margin: EdgeInsets.symmetric(vertical: 8.w, horizontal: 15.w),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(12),
                    color: SCGlobalConfig.businessLogicStrategy.getSettingsPageContainerBackgroundColor(),
                    border: Border.all(color: SCGlobalConfig.businessLogicStrategy.getSettingsPageContainerBorderColor(), width: 1.w),
                  ),
                  child: Column(
                    children: [
                      SCDebounceWidget(
                        onTap: () {
                          SCNavigatorUtils.push(
                            context,
                            SettingsRoute.about,
                            replace: false,
                          );
                        },
                        child: Row(
                          children: [
                            SizedBox(width: 18.w),
                            text(
                              SCAppLocalizations.of(context)!.aboutUs,
                              textColor: SCGlobalConfig.businessLogicStrategy.getSettingsPagePrimaryTextColor(),
                              fontSize: 13.sp,
                            ),
                            Spacer(),
                            Icon(
                              SCGlobalConfig.lang == "ar"
                                  ? Icons.keyboard_arrow_left
                                  : Icons.keyboard_arrow_right,
                              size: 15.w,
                              color: SCGlobalConfig.businessLogicStrategy.getSettingsPageIconColor(),
                            ),
                            SizedBox(width: 18.w),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
                SizedBox(height: 45.w,),
                Row(
                  children: [
                    Expanded(
                      child: SCDebounceWidget(
                        child: Container(
                          alignment: Alignment.center,
                          padding: EdgeInsets.symmetric(vertical: 8.w),
                          margin: EdgeInsets.symmetric(
                            horizontal: 80.w,
                            vertical: 35.w,
                          ),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(25.w),
                            color: SCGlobalConfig.businessLogicStrategy.getSettingsPageButtonBackgroundColor(),
                          ),
                          child: text(
                            SCAppLocalizations.of(context)!.logout,
                            fontSize: 14.sp,
                            textColor: SCGlobalConfig.businessLogicStrategy.getSettingsPageButtonTextColor(),
                          ),
                        ),
                        onTap: () {
                          AccountStorage().logout(context);
                        },
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }
}
