import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constants/asset_constants.dart';
import '../../view/authentication/login_view.dart';

/// Data modules for each intro slide
class IntroSlide {
  final String title;
  final String description;
  final String imageAsset;
  final String chipLabel;
  final Color bgColor;
  final Color accentColor;

  const IntroSlide({
    required this.title,
    required this.description,
    required this.imageAsset,
    required this.chipLabel,
    required this.bgColor,
    required this.accentColor,
  });
}

class IntroScreenController extends GetxController {
  late final PageController pageController;
  late final List<IntroSlide> slides;

  int _currentPage = 0;
  int get currentPage => _currentPage;
  bool get isLastPage => _currentPage == slides.length - 1;

  @override
  void onInit() {
    super.onInit();
    pageController = PageController();

    slides = [
      const IntroSlide(
        title: "Fresh Essentials\nEvery Day",
        description:
        "Get farm-fresh fruits and vegetables directly from our storage to your home.",
        imageAsset: AssetConstants.introNew_1,
        chipLabel: "🌿  FARM TO DOOR",
        bgColor: Color(0xFFECF8F0),
        accentColor: Color(0xFF2D9B5A),
      ),
      const IntroSlide(
        title: "Fast & Reliable\nDelivery",
        description:
        "We store, pack, and deliver from our own facility to ensure quality and speed.",
        imageAsset: AssetConstants.introNew_2,
        chipLabel: "⚡  LIGHTNING FAST",
        bgColor: Color(0xFFFFF7E6),
        accentColor: Color(0xFFE8931A),
      ),
      const IntroSlide(
        title: "Just a Click\nAway",
        description:
        "Quick tomato run or a full veggie basket — shopping made easy and convenient.",
        imageAsset: AssetConstants.intro3,
        chipLabel: "🛒  SUPER CONVENIENT",
        bgColor: Color(0xFFEEF4FF),
        accentColor: Color(0xFF4A7FD4),
      ),
    ];
  }

  @override
  void onClose() {
    pageController.dispose();
    super.onClose();
  }

  void onPageChanged(int index) {
    _currentPage = index;
    update();
  }

  void nextPage() {
    pageController.nextPage(
      duration: const Duration(milliseconds: 400),
      curve: Curves.easeInOut,
    );
  }

  void onDonePress() {
    Get.off(() => Login_view());
  }
}