import 'package:bahla_front/app/app.locator.dart';
import 'package:bahla_front/app/app.router.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';

class HomeViewModel extends BaseViewModel {
  final _navigationService = locator<NavigationService>();

  List<String> items = List<String>.generate(100, (i) => 'Item $i');

  List<Event> events = [
    Event(
      name: 'Event 1',
      picture: 'images/Affiche.jpg',
      date: DateTime.now().add(Duration(days: 1)),
      organizer: 'Organizer 1',
      place: 'Place 1',
    ),
    Event(
      name: 'Event 2',
      picture: 'images/Affiche.jpg',
      date: DateTime.now().add(Duration(days: 1)),
      organizer: 'Organizer 2',
    ),
    Event(
      name: 'Event 3',
      picture: 'images/Affiche.jpg',
      date: DateTime.now().add(Duration(days: 1)),
      organizer: 'Organizer 3',
      place: 'Place 3',
    ),
  ];

  void toggleFavorite(int index) {
    events[index].isFavorite = !events[index].isFavorite;
    notifyListeners();
  }

  void onEventTap(int index) {
    // Gérer le clic sur l'événement
    print('Event tapped: ${events[index].name}');
    // Ici vous pouvez naviguer vers une page de détails, etc.

    _navigationService.navigateToEventDetailsView(eventId: index);
  }
}

class Event {
  String name;
  String picture;
  String organizer = 'Organizer';
  String? place;
  DateTime? date;
  bool isFavorite;

  Event({
    required this.name,
    required this.picture,
    required this.organizer,
    this.date,
    this.place,
    this.isFavorite = false,
  });

  @override
  String toString() {
    return 'Event{name: $name, picture: $picture}';
  }
}
