diff --git a/android/gradle.properties b/android/gradle.properties index c0b881d1dd585e55b5d7819caee1bafac587748e..142ae7bb643e141eab9405dc204c1c1bd653816f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.1.17 -app.versionCode=66 +app.versionName=0.1.18 +app.versionCode=67 diff --git a/fastlane/metadata/android/en-US/changelogs/67.txt b/fastlane/metadata/android/en-US/changelogs/67.txt new file mode 100644 index 0000000000000000000000000000000000000000..ea389ac235abea58840c3465e5fe8e53fcf19994 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/67.txt @@ -0,0 +1 @@ +Add a timer after use of "help" button. diff --git a/fastlane/metadata/android/fr-FR/changelogs/67.txt b/fastlane/metadata/android/fr-FR/changelogs/67.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b856d8dfa6c121e74df8e1a2a10b7fb1353cb20 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/67.txt @@ -0,0 +1 @@ +Ajout d'une temporisation pour réactiver le bouton "aide" après usage. diff --git a/lib/provider/data.dart b/lib/provider/data.dart index 64585c0117478b18cee5e868cbf04042b5064a93..0ad2253bac79978469fa31c7f717283cfddf0f89 100644 --- a/lib/provider/data.dart +++ b/lib/provider/data.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:flutter/foundation.dart'; @@ -54,6 +55,7 @@ class Data extends ChangeNotifier { int? _selectedCellValue; bool _showConflicts = false; int _givenTipsCount = 0; + int _givenTipsCountEnableCountdown = 0; String _currentSavedState = ''; void updateParameterLevel(String parameterLevel) { @@ -246,23 +248,45 @@ class Data extends ChangeNotifier { notifyListeners(); } + int get givenTipsCountEnableCountdown => _givenTipsCountEnableCountdown; + int get givenTipsCount => _givenTipsCount; - increaseGivenTipsCount() { + void increaseGivenTipsCount() { _givenTipsCount = _givenTipsCount + 1; + _givenTipsCountEnableCountdown = 60; + const Duration interval = Duration(milliseconds: 500); + Timer.periodic( + interval, + (Timer timer) { + if (_givenTipsCountEnableCountdown == 0) { + timer.cancel(); + notifyListeners(); + } else { + _givenTipsCountEnableCountdown--; + notifyListeners(); + } + }, + ); + saveCurrentGameState(); notifyListeners(); } - setGivenTipsCount(int value) { + void setGivenTipsCount(int value) { _givenTipsCount = value; + _givenTipsCountEnableCountdown = 0; notifyListeners(); } - resetGivenTipsCount() { + bool canGiveTip() { + return (_givenTipsCountEnableCountdown == 0); + } + + void resetGivenTipsCount() { setGivenTipsCount(0); } - selectCell(int? col, int? row) { + void selectCell(int? col, int? row) { _selectedCellCol = col; _selectedCellRow = row; _selectedCellValue = null; @@ -291,7 +315,7 @@ class Data extends ChangeNotifier { _boardConflicts = conflictsCount; } - updateCellValue(int? col, int? row, int value) { + void updateCellValue(int? col, int? row, int value) { if ((col != null) && (row != null)) { if (!_board[row][col].isFixed) { _board[row][col] = Cell( diff --git a/lib/ui/screens/home.dart b/lib/ui/screens/home.dart index af2cfa1f08d8c050725e7bf1425b56e9115d9f5d..3b86e93a33d36f4f319655a41c9eeac189abeba1 100644 --- a/lib/ui/screens/home.dart +++ b/lib/ui/screens/home.dart @@ -117,13 +117,16 @@ class HomeState extends State<Home> { myProvider.givenTipsCount == 0 ? '' : myProvider.givenTipsCount.toString(), style: const TextStyle(color: Colors.white), ), - child: const Image( - image: AssetImage('assets/icons/button_help.png'), - fit: BoxFit.fill, + child: Container( + padding: EdgeInsets.all(myProvider.givenTipsCountEnableCountdown / 4), + child: const Image( + image: AssetImage('assets/icons/button_help.png'), + fit: BoxFit.fill, + ), ), ), ), - onPressed: () => GameUtils.showTip(myProvider), + onPressed: () => myProvider.canGiveTip() ? GameUtils.showTip(myProvider) : null, )); menuActions.add(const Spacer()); menuActions.add(TextButton( diff --git a/pubspec.yaml b/pubspec.yaml index e4e9a93338de0349d8a000d521a06c44834b5092..9c7e81f30e99d0d95ee2f2e8439789911cf4e51a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: sudoku description: A sudoku game application. publish_to: 'none' -version: 0.1.17+66 +version: 0.1.18+67 environment: sdk: '^3.0.0'