import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:uco_mobile_poc/app/core/constants/app_assets.dart';
import 'package:uco_mobile_poc/app/core/utils/logs_utils.dart';
import 'package:uco_mobile_poc/app/res/app_colors.dart';
import 'package:uco_mobile_poc/app/res/app_dimensions.dart';
import 'package:uco_mobile_poc/app/routes/app_pages.dart';

class SplashScreenView extends StatefulWidget {
  const SplashScreenView({Key? key}) : super(key: key);

  @override
  State<SplashScreenView> createState() => _SplashScreenViewState();
}

class _SplashScreenViewState extends State<SplashScreenView> {
  @override
  void initState() {
    super.initState();
    Timer(const Duration(seconds: 4), () => Get.offAllNamed(Routes.INTRO_SCREEN));
  }

  @override
  Widget build(BuildContext context) {
    dp("Width int splash", {MediaQuery.sizeOf(Get.context!).width});
    dp("Height init splash  ", MediaQuery.sizeOf(Get.context!).height);
    return Scaffold(
      backgroundColor: AppColors.colorPrimary,
      body: Padding(
        padding: EdgeInsets.symmetric(
            horizontal: AppDimensions.screenHorizontalPadding,
            vertical: AppDimensions.screenVerticalPadding),
        child: Center(
          child: AnimatedCrossFade(
              duration: const Duration(milliseconds: 2000),
              firstChild: SvgPicture.asset(AppAssets.lg_uco_logo_white),
              secondChild: const Text(
                '',
              ),
              alignment: Alignment.center,
              crossFadeState: CrossFadeState.showFirst),
        ),
      ),
    );
  }
}
