import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'controller/home/splash_screen_controlle.dart';
import 'main.dart';

class SplashScreen extends StatelessWidget {
  const SplashScreen({super.key});

  @override
  Widget build(BuildContext context) {
    final SplashScreenController splashScreenController =
        Get.put(SplashScreenController());
    final textTheme = Theme.of(context).textTheme;
    final size = MediaQuery.of(context).size;

    // Define our new green color palette here
    const Color primaryGreen = Color(0xFF1A535C);
    const Color secondaryGreen = Color(0xFF4ECDC4);
    const Color logoBackgroundColor = Colors.white;
    const Color logoIconColor = primaryGreen;
    const Color textColor = Colors.white;

    return Scaffold(
      body: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              primaryGreen,
              secondaryGreen,
            ],
          ),
        ),
        child: Stack(
          children: [
            // Centered Logo and Slogan with Animation
            Center(
              child: AnimatedBuilder(
                animation: splashScreenController.animation,
                builder: (context, child) => FadeTransition(
                  opacity: splashScreenController.animation,
                  child: Transform.translate(
                    offset: Offset(
                        0, 50 * (1 - splashScreenController.animation.value)),
                    child: child,
                  ),
                ),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    // Elegant and Clear Logo
                    Container(
                      padding: const EdgeInsets.all(25),
                      decoration: const BoxDecoration(
                          shape: BoxShape.circle,
                          color: logoBackgroundColor,
                          boxShadow: [
                            BoxShadow(
                              color: Colors.black26,
                              blurRadius: 10,
                              offset: Offset(0, 4),
                            )
                          ]),
                      child: Image.asset('assets/images/logo.gif'),
                    ),
                    const SizedBox(height: 24),
                    // App Name - now using a variable for color
                    Text(
                      'Intaleq', // Replace with AppInformation.appName if needed
                      style: textTheme.headlineMedium?.copyWith(
                        color: textColor,
                        fontWeight: FontWeight.bold,
                        letterSpacing: 2,
                      ),
                    ),
                    const SizedBox(height: 12),
                    // Slogan - now using a variable for color
                    Text(
                      'Your Journey Begins Here'.tr,
                      style: textTheme.titleMedium?.copyWith(
                        color: textColor.withOpacity(0.9),
                      ),
                    ),
                  ],
                ),
              ),
            ),

            // Bottom Loading Bar and Version Info
            Align(
              alignment: Alignment.bottomCenter,
              child: Padding(
                padding: EdgeInsets.only(
                    bottom: size.height * 0.05, left: 40, right: 40),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Obx(() => ClipRRect(
                          borderRadius: BorderRadius.circular(10),
                          child: LinearProgressIndicator(
                            value: splashScreenController.progress.value,
                            backgroundColor: textColor.withOpacity(0.2),
                            valueColor:
                                const AlwaysStoppedAnimation<Color>(textColor),
                            minHeight: 5,
                          ),
                        )),
                    const SizedBox(height: 16),
                    Text(
                      'Version: ${box.read(BoxName.packagInfo) ?? '1.0.0'}',
                      style: textTheme.bodySmall?.copyWith(
                        color: textColor.withOpacity(0.7),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
