import 'package:flutter/foundation.dart'; class Data extends ChangeNotifier { // Configuration available values List _availableDifficultyLevels = ['easy', 'medium', 'hard']; List _availableSizes = ['2x2', '3x2', '3x3']; List _availableSkins = ['default', 'food', 'nature']; List get availableDifficultyLevels => _availableDifficultyLevels; List get availableSizes => _availableSizes; List get availableSkins => _availableSkins; // Application default configuration String _level = 'medium'; String _size = '3x3'; String _skin = 'default'; bool _showConflicts = false; // Game data bool _stateRunning = false; int _blockSizeVertical = null; int _blockSizeHorizontal = null; List _cells = []; int _currentCellCol = null; int _currentCellRow = null; int _currentCellValue = null; String get level => _level; set updateLevel(String level) { _level = level; notifyListeners(); } String get size => _size; int get blockSizeVertical => _blockSizeVertical; int get blockSizeHorizontal => _blockSizeHorizontal; set updateSize(String size) { _size = size; _blockSizeHorizontal = int.parse(_size.split('x')[0]); _blockSizeVertical = int.parse(_size.split('x')[1]); notifyListeners(); } String get skin => _skin; set updateSkin(String skin) { _skin = skin; notifyListeners(); } bool get showConflicts => _showConflicts; set updateShowConflicts(bool showConflicts) { _showConflicts = showConflicts; notifyListeners(); } getParameterValue(String parameterCode) { switch(parameterCode) { case 'difficulty': { return _level; } break; case 'size': { return _size; } break; case 'skin': { return _skin; } break; } } List getParameterAvailableValues(String parameterCode) { switch(parameterCode) { case 'difficulty': { return _availableDifficultyLevels; } break; case 'size': { return _availableSizes; } break; case 'skin': { return _availableSkins; } break; } } setParameterValue(String parameterCode, String parameterValue) { switch(parameterCode) { case 'difficulty': { updateLevel = parameterValue; } break; case 'size': { updateSize = parameterValue; } break; case 'skin': { updateSkin = parameterValue; } break; } } List get cells => _cells; set updateCells(List cells) { _cells = cells; notifyListeners(); } int get currentCellCol => _currentCellCol; set updateCurrentCellCol(int currentCellCol) { _currentCellCol = currentCellCol; notifyListeners(); } int get currentCellRow => _currentCellRow; set updateCurrentCellRow(int currentCellRow) { _currentCellRow = currentCellRow; notifyListeners(); } int get currentCellValue => _currentCellValue; set updateCurrentCellValue(int currentCellValue) { _currentCellValue = currentCellValue; notifyListeners(); } selectCell(int col, int row) { _currentCellCol = col; _currentCellRow = row; _currentCellValue = null; if (row != null && col != null) { if (_cells[row][col].value != 0) { _currentCellValue = _cells[row][col].value; } } notifyListeners(); } updateCellValue(int col, int row, int value) { _cells[row][col].value = value; notifyListeners(); } bool get stateRunning => _stateRunning; set updateStateRunning(bool stateRunning) { _stateRunning = stateRunning; notifyListeners(); } }