import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:tone_snap/generated/assets.dart';
import 'package:tone_snap/modules/sidea/splash/splash_controller.dart';
import 'package:tone_snap/res/themes/app_colors.dart';

class SplashView extends StatelessWidget {
  SplashView({super.key});

  final controller = Get.find<SplashController>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          _buildImageBg(),
          _buildProgress(),
        ],
      ),
    );
  }

  Widget _buildImageBg() {
    return Image.asset(
      Assets.sideALaunchImage,
      width: 1.sw,
      height: 1.sh,
      fit: BoxFit.cover,
    );
  }

  Widget _buildProgress() {
    return Container(
      alignment: Alignment.center,
      margin: const EdgeInsets.only(bottom: 60).h,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          SizedBox(
            width: 0.5.sw,
            child: Obx(() {
              return LinearProgressIndicator(
                value: controller.processValue.value,
                backgroundColor: Colors.white,
                valueColor: const AlwaysStoppedAnimation<Color>(sideBSeedColor),
                borderRadius: BorderRadius.circular(8).r,
              );
            }),
          ),
          SizedBox(height: 14.h),
          Text(
            'Resource Loading...',
            style: TextStyle(
              color: Colors.white,
              fontSize: 12.sp,
              fontWeight: FontWeight.w500,
            ),
          ),
        ],
      ),
    );
  }
}
