import 'dart:async';

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hris_selfservice_mobile/Screens/Login/login_screen.dart';
import 'package:lottie/lottie.dart';
import '../Splash/background.dart';

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

  @override
  _SplashState createState() => _SplashState();
}

class _SplashState extends State<Splash> {
  @override
  void initState() {
    super.initState();
    Timer(
        Duration(seconds: 10),
        () => Navigator.pushReplacement(
            context, MaterialPageRoute(builder: (context) => LoginView())));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: false,
        body: Stack(
          children: <Widget>[
            Background(),
            SplashScreen(),
          ],
        ));
  }
}

class SplashScreen extends StatelessWidget {
  const SplashScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Container(
      width: double.infinity,
      height: double.infinity,
      decoration: BoxDecoration(
          gradient: LinearGradient(
              begin: Alignment.topRight,
              end: Alignment.bottomRight,
              colors: [
            Color(0xFFD21404),
            Color(0xFFFD7267),
          ])),
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              /*decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: Colors.white
              ),*/
              child: SizedBox(
                width: 250,
                height: 250,
                child: LottieBuilder.asset('assets/animation/animation_1.json',
                    repeat: true),
              ),
            ),
            Text('Lottie Animation\nby Lottiefiles.com',
                style: GoogleFonts.knewave(fontSize: 17, color: Colors.white))
          ],
        ),
      ),
    ));
  }
}
