import 'package:cpt_auth/modules/sing_up_success/sign_up_success_view_model.dart';
import 'package:cs_resources/generated/assets.dart';
import 'package:cs_resources/generated/l10n.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:flutter/material.dart';
import 'package:auto_route/auto_route.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:plugin_basic/provider/user_config/user_config_service.dart';
import 'package:router/ext/auto_router_extensions.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_appbar.dart';
import 'package:widgets/my_button.dart';
import 'package:widgets/my_load_image.dart';
import 'package:widgets/my_text_view.dart';
import '../../router/page/auth_page_router.dart';

@RoutePage()
class SignUpSuccessPage extends HookConsumerWidget {
  const SignUpSuccessPage({Key? key}) : super(key: key);

  //启动当前页面
  static void startInstance() {
    appRouter.pushAndPopUntil(
      const SignUpSuccessPageRoute(),
      predicate: (route) {
        return route.settings.name == AuthLoginPageRoute.name;
      },
    );
  }

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final viewModel = ref.watch(signUpSuccessViewModelProvider.notifier);
    final userConfig = UserConfigService.getState(ref: ref);

    return Scaffold(
      appBar: MyAppBar.appBar(context, ""),
      backgroundColor: context.appColors.backgroundDefault,
      body: Container(
        padding: const EdgeInsets.symmetric(horizontal: 20),
        width: double.infinity,
        child: Column(
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SingleChildScrollView(
                scrollDirection: Axis.vertical,
                physics: const BouncingScrollPhysics(),
                child: Column(
                  children: [
                    //顶部图片
                    const MyAssetImage(
                      Assets.authYyHomeSuccess,
                      width: 264,
                      height: 180,
                    ).alignCenter().marginOnly(top: 12),

                    MyTextView(
                      S.current.welcome_name(userConfig.userName ?? ""),
                      fontSize: 23,
                      marginTop: 30,
                      isFontMedium: true,
                      textColor: context.appColors.textBlack,
                    ),

                    MyTextView(
                      S.current.sign_up_success_txt1,
                      fontSize: 15,
                      marginTop: 25,
                      isFontMedium: true,
                      textColor: context.appColors.textBlack,
                    ),

                    MyTextView(
                      S.current.sign_up_success_txt2,
                      fontSize: 15,
                      marginTop: 20,
                      isFontMedium: true,
                      textColor: context.appColors.textBlack,
                    ),

                    MyTextView(
                      S.current.sign_up_success_txt3,
                      fontSize: 15,
                      marginTop: 20,
                      isFontMedium: true,
                      textColor: context.appColors.textBlack,
                    ),
                  ],
                )).expanded(),
            MyButton(
              onPressed: viewModel.gotoSelectEstatePage,
              text: S.current.get_started,
              textColor: Colors.white,
              backgroundColor: context.appColors.btnBgDefault,
              fontWeight: FontWeight.w500,
              type: ClickType.throttle,
              fontSize: 16,
              minHeight: 50,
              radius: 5,
            ).marginOnly(top: 50, bottom: 50, left: 18, right: 18),
          ],
        ),
      ),
    );
  }
}
