import 'package:cpt_auth/modules/setting/setting_state.dart';
import 'package:cs_resources/generated/assets.dart';
import 'package:flutter/material.dart';
import 'package:plugin_basic/base/base_stateless_page.dart';
import 'package:plugin_basic/basic_export.dart';
import 'package:plugin_basic/service/app_config_service.dart';
import 'package:plugin_basic/utils/ext_get_nav.dart';
import 'package:router/path/router_path.dart';
import 'package:shared/utils/screen_util.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_appbar.dart';
import 'package:widgets/shatter/setting_item_container.dart';

import 'setting_controller.dart';

class SettingPage extends BaseStatelessPage<SettingController> {
  SettingPage({Key? key}) : super(key: key);

  //启动当前页面
  static void startInstance() {
    return Get.start(RouterPath.settings);
  }

  late SettingState state;

  @override
  void initState() {
    state = controller.state;
  }

  @override
  SettingController createRawController() {
    return SettingController();
  }

  @override
  Widget buildWidget(BuildContext context) {
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: MyAppBar.appBar(context, "Settings".tr),
      body: SafeArea(
        bottom: MediaQuery.of(context).padding.bottom > 38,
        top: false,
        child: Container(
          width: double.infinity,
          height: double.infinity,
          padding: EdgeInsets.only(top: kToolbarHeight + ScreenUtil.getStatusBarH(context) + 1),
          decoration: const BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Color(0xFF091D44),
                Color(0xFF245A8A),
                Color(0xFF7F7CEC),
              ],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
            ),
          ),
          child: Column(children: [
            const SizedBox(height: 10),

          ConfigService.to.selectCountry.value == 3  ||  ConfigService.to.selectCountry.value == 5 ?
          SettingItemContainer(iconPath: Assets.mainSettingSwitchProject, title: "Switch Projects".tr).onTap(() {
              controller.switchProjects();
            }) : const SizedBox(),

            ConfigService.to.selectCountry.value != 3 &&  ConfigService.to.selectCountry.value != 5 ? SettingItemContainer(iconPath: Assets.mainSettingResetPassword, title: "Reset Password".tr).onTap(() {
              controller.gotoResetPasswordPage();
            }): const SizedBox(),

            ConfigService.to.selectCountry.value != 3 &&  ConfigService.to.selectCountry.value != 5 ? SettingItemContainer(iconPath: Assets.mainSettingAccountDelectivation, title: "Account Deactivation".tr).onTap(() {
              controller.doAccountDelete();
            }): const SizedBox(),

            SettingItemContainer(iconPath: Assets.mainSettingLogOut, title: "Logout".tr).onTap(() {
              controller.doLogout();
            }),
          ]),
        ),
      ),
    );
  }
}
