import 'package:flutter/material.dart';
import 'package:initial_folder/screens/home/home_screen.dart';
import 'package:initial_folder/screens/registrasi/components/get_user_data.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/login_regist/header.dart';
import 'package:flutter/gestures.dart';

class RegisSuccess extends StatelessWidget {
  static String routeName = "/regis_success";
  RegisSuccess({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    SizeConfig().init(context);
    return SafeArea(
      child: Scaffold(
        body: Center(
          child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
            Icon(
              Icons.check_rounded,
              color: Colors.greenAccent[700],
              size: getProportionateScreenWidth(60),
            ),
            SizedBox(height: getProportionateScreenHeight(24)),
            Header(
              title: false,
              text2: "Registrasi Akun Sukses",
              text:
                  'Kami telah mengirimkan notifikasi registrasi akun ke email anda',
              style: primaryTextStyle.copyWith(
                color: Theme.of(context).colorScheme.onBackground,
                fontWeight: reguler,
                fontSize: getProportionateScreenWidth(14),
                letterSpacing: 0.5,
              ),
            ),
            SizedBox(height: getProportionateScreenHeight(44)),
            Container(
              // padding: EdgeInsets.only(
              //     left: getProportionateScreenWidth(5),
              //     top: getProportionateScreenWidth(5)),
              alignment: Alignment.center,
              child: RichText(
                text: TextSpan(
                  children: <TextSpan>[
                    TextSpan(
                        text: 'Lanjut ke Halaman Beranda',
                        style: primaryTextStyle.copyWith(
                          color: primaryColor,
                          fontWeight: reguler,
                          fontSize: getProportionateScreenWidth(18),
                        ),
                        recognizer: TapGestureRecognizer()
                          ..onTap = () async {
                            await getUserData(context);

                            Navigator.of(context).pushNamedAndRemoveUntil(
                                HomeScreen.routeName,
                                (Route<dynamic> route) => false);
                            print('masuk');
                          }),
                  ],
                ),
              ),
            ),
          ]),
        ),
      ),
    );
  }
}
