// home_tab.dart
// This file contains the HomeTab widget, which displays a welcome message, a featured image, favorite categories, and exercise suggestions.

import 'package:flutter/material.dart';
import '../widgets/category_circle.dart';
import '../widgets/exercise_card.dart';
import '../models/categories.dart';

/// The HomeTab displays a welcome message, featured image, favorite categories, and exercise suggestions.
class HomeTab extends StatelessWidget {
  const HomeTab({super.key});

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            // Welcome message
            const Center(
              child: Text(
                'Hallo Trainer!',
                style: TextStyle(
                  fontSize: 32,
                  fontWeight: FontWeight.bold,
                  color: Colors.pink,
                ),
              ),
            ),
            const SizedBox(height: 20),
            // Featured image with title overlay
            Container(
              height: 200,
              width: double.infinity,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(12),
                image: const DecorationImage(
                  image: AssetImage('images/training_bg.jpg'),
                  fit: BoxFit.cover,
                  colorFilter: ColorFilter.mode(
                    Colors.black26,
                    BlendMode.darken,
                  ),
                ),
              ),
              child: Center(
                child: Text(
                  'Dein nächstes Training',
                  style: TextStyle(
                    color: Colors.blueAccent,
                    fontSize: 24,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ),
            const SizedBox(height: 20),
            // Favorite categories section
            const Text(
              'Favoriten',
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 10),
            SizedBox(
              height: 100,
              child: ListView(
                scrollDirection: Axis.horizontal,
                children: kTrainingCategories.map((cat) => CategoryCircle(title: cat.name, icon: cat.icon)).toList(),
              ),
            ),
            const SizedBox(height: 20),
            // Suggestions section
            const Text(
              'Vorschläge',
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 10),
            SizedBox(
              height: 180,
              child: Stack(
                alignment: Alignment.center,
                children: [
                  // PageView with exercise suggestion cards
                  PageView(
                    children: const [
                      ExerciseCard(
                        title: 'Wurf',
                        category: 'Wurf',
                        icon: Icons.sports_handball,
                      ),
                      ExerciseCard(
                        title: 'Doppelpass',
                        category: 'Passen',
                        icon: Icons.sports_volleyball,
                      ),
                      ExerciseCard(
                        title: 'Torhüter Training',
                        category: 'Torhüter',
                        icon: Icons.sports_soccer,
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
