import 'package:flutter/material.dart';
import 'package:skillcourt/game_session.dart';
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';

class GameSessionModel extends ChangeNotifier {
  final List<GameSession> _gameSessions = []; // Initialize the list
  int _pressedSessionIndex = -1; // Default value for pressed session index

  List<GameSession> get gameSessions => _gameSessions;
  int get pressedSessionIndex => _pressedSessionIndex;
  void addGameSession(GameSession gameSession) {
    _gameSessions.add(gameSession);
    notifyListeners();
  }

  void deleteGameSession(GameSession session) {
    _gameSessions.remove(session); // Remove the specified session from the list
    notifyListeners();
  }

  void removeSession(int index) {
    gameSessions.removeAt(index);
    notifyListeners();
  }

  void clearGameSessions() {
    _gameSessions.clear();
    notifyListeners();
  }

  void setPressedSessionIndex(int index, bool isPressed) {
    if (isPressed) {
      _pressedSessionIndex = index;
    } else {
      _pressedSessionIndex = -1;
    }
    notifyListeners();
  }
}
