// lib/features/home/widgets/home_app_bar.dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smpn1_lengkong/core/constants/app_colors.dart';

class HomeAppBar extends StatelessWidget {
  final String studentName;
  final String className;
  final String academicYear;

  const HomeAppBar({
    super.key,
    required this.studentName,
    required this.className,
    required this.academicYear,
  });

  @override
  Widget build(BuildContext context) {
    return SliverAppBar(
      expandedHeight: 180.h,
      pinned: true,
      backgroundColor: AppColors.primaryBlue,
      flexibleSpace: FlexibleSpaceBar(
        background: Container(
          decoration: const BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
              colors: [AppColors.primaryBlue, Color(0xFF2C64B8)],
            ),
          ),
          child: Stack(
            children: [
              Positioned(
                right: -20,
                top: -20,
                child: Icon(Icons.school, size: 150.sp, color: Colors.white.withOpacity(0.1)),
              ),
              Padding(
                padding: EdgeInsets.all(24.w),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Text(
                      "Selamat Datang, Wali Murid", 
                      style: TextStyle(color: Colors.white70, fontSize: 14.sp)
                    ),
                    SizedBox(height: 4.h),
                    Text(
                      studentName, 
                      style: TextStyle(color: Colors.white, fontSize: 20.sp, fontWeight: FontWeight.bold)
                    ),
                    SizedBox(height: 8.h),
                    Container(
                      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.h),
                      decoration: BoxDecoration(
                        color: Colors.white.withOpacity(0.2), 
                        borderRadius: BorderRadius.circular(20.r)
                      ),
                      child: Text(
                        // Menampilkan data sesuai pilihan (Contoh: Kelas 9A | TA: 2025/2026)
                        "Kelas $className | TA: $academicYear", 
                        style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w500)
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}