import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:step_progress_indicator/step_progress_indicator.dart';
import 'package:tone_snap/generated/assets.dart';
import 'package:tone_snap/modules/launch/launch_controller.dart';
import 'package:tone_snap/res/themes/app_colors.dart';

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

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

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

  Widget _buildImageBg() {
    return Image.asset(
      Assets.sideALaunchBg,
      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.6.sw,
            child: Obx(() {
              return ClipRRect(
                borderRadius: BorderRadius.circular(8).r,
                child: StepProgressIndicator(
                  totalSteps: controller.timeTotal,
                  currentStep: controller.currentProcess.value,
                  size: 6,
                  padding: 0,
                  unselectedColor: Colors.white,
                  roundedEdges: const Radius.circular(8).r,
                  selectedGradientColor: const LinearGradient(
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                    colors: [
                      Color(0xffAC42FF),
                      Color(0xff5738D3),
                      Color(0xffC1ED02),
                    ],
                  ),
                ),
              );
            }),
          ),
          SizedBox(height: 10.h),
          Text(
            'Resource Loading...',
            style: TextStyle(
              color: Colors.white,
              fontSize: 12.sp,
              fontWeight: FontWeight.w500,
            ),
          ),
        ],
      ),
    );
  }
}
