Skip to content
Snippets Groups Projects
Commit ba559326 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Clean some code, fix deprecations

parent 37d5b008
No related branches found
No related tags found
1 merge request!27Resolve "Clean code"
Pipeline #2934 passed
This commit is part of merge request !27. Comments created here will be created in the context of that merge request.
......@@ -39,7 +39,7 @@ if (keystorePropertiesFile.exists()) {
}
android {
compileSdkVersion 29
compileSdkVersion 31
lintOptions {
disable 'InvalidPackage'
......
......@@ -2,5 +2,5 @@ org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
app.versionName=1.2.2
app.versionCode=13
app.versionName=1.2.3
app.versionCode=14
......@@ -36,8 +36,8 @@ class Data extends ChangeNotifier {
void _getPrefs() async {
await _sharedPrefs.init();
_gameModeValue = _sharedPrefs.gameMode ??
onlineGameMode.keys
.firstWhere((k) => onlineGameMode[k].contains(_sharedPrefs.level), orElse: () => false);
onlineGameMode.keys.firstWhere((k) => onlineGameMode[k].contains(_sharedPrefs.level),
orElse: () => false);
_levelValue = onlineGameMode[_gameModeValue].contains(_sharedPrefs.level)
? _sharedPrefs.level
: onlineGameMode[_gameModeValue].first;
......
......@@ -49,7 +49,7 @@ class Game extends StatelessWidget {
title: Text('Indice'),
content: Text(_myProvider.clue),
actions: <Widget>[
FlatButton(
TextButton(
child: Text('Revenir au jeu'),
onPressed: () => Navigator.of(context).pop(),
)
......
......@@ -12,7 +12,6 @@ class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
Orientation orientation = MediaQuery.of(context).orientation;
Data _myProvider = Provider.of<Data>(context);
void _errorWord(context) {
......@@ -23,7 +22,7 @@ class Home extends StatelessWidget {
content: Text('Erreur inattendue à la récupération d\'un mot aléatoire.\n'
'Installer une nouvelle version de l\'application pourrait corriger cette anomalie.'),
actions: <Widget>[
FlatButton(
TextButton(
child: Text('Fermer'),
onPressed: () => Navigator.of(context).pop(),
)
......@@ -64,7 +63,6 @@ class Home extends StatelessWidget {
),
),
),
Column(
children: [
Row(
......@@ -73,7 +71,8 @@ class Home extends StatelessWidget {
Text('Mode en ligne'),
Switch(
value: _myProvider.gameModeValue,
onChanged: (bool value) => _myProvider.updateGameMode = value,
onChanged: (bool value) =>
_myProvider.updateGameMode = value,
activeTrackColor: Color(board),
activeColor: Colors.greenAccent[400],
),
......@@ -84,7 +83,8 @@ class Home extends StatelessWidget {
children: [
Text('Niveau'),
DropdownButton<String>(
value: _myProvider.levelValue ?? onlineGameMode[_myProvider.gameModeValue].first,
value: _myProvider.levelValue ??
onlineGameMode[_myProvider.gameModeValue].first,
items: onlineGameMode[_myProvider.gameModeValue]
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
......@@ -92,21 +92,20 @@ class Home extends StatelessWidget {
child: Text(value),
);
}).toList(),
onChanged: (String value) => _myProvider.updateLevel = value,
onChanged: (String value) =>
_myProvider.updateLevel = value,
),
],
),
],
),
RaisedButton.icon(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0))),
color: Color(board),
textColor: Colors.white,
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
onPrimary: Colors.white,
primary: Color(board),
padding: EdgeInsets.all(10.0),
),
onPressed: () async {
Scaffold.of(context).removeCurrentSnackBar();
_myProvider.resetGame();
_myProvider.searching = true;
bool control = true;
......
......@@ -23,11 +23,13 @@ class RandomPick {
await wordFromLocal();
break;
case 'Avancé':
_url = 'https://www.palabrasaleatorias.com/mots-aleatoires.php?fs=1&fs2=0&Submit=Nouveau+mot';
_url =
'https://www.palabrasaleatorias.com/mots-aleatoires.php?fs=1&fs2=0&Submit=Nouveau+mot';
await wordFromWeb(_url);
break;
case 'Junior':
_url = 'https://www.palabrasaleatorias.com/mots-aleatoires.php?fs=1&fs2=1&Submit=Nouveau+mot';
_url =
'https://www.palabrasaleatorias.com/mots-aleatoires.php?fs=1&fs2=1&Submit=Nouveau+mot';
await wordFromWeb(_url);
break;
case 'Expert':
......
......@@ -16,11 +16,11 @@ class DialogFetchError extends StatelessWidget {
'La connexion internet est peut-être inaccessible.\n'
'Changer vers un mode de jeu hors-ligne ?'),
actions: [
FlatButton(
TextButton(
child: const Text('REVENIR'),
onPressed: () => Navigator.pop(context, false),
),
FlatButton(
TextButton(
child: const Text('ACCEPTER'),
onPressed: () => Navigator.pop(context, true),
),
......
......@@ -38,13 +38,13 @@ class DialogGameOver extends StatelessWidget {
),
),
actions: [
FlatButton(
TextButton(
child: const Text('QUITTER'),
onPressed: () {
Navigator.pushNamed(context, Home.id);
},
),
FlatButton(
TextButton(
child: const Text('REJOUER'),
onPressed: () async {
_myProvider.resetSuccessAndErrors();
......
......@@ -23,10 +23,12 @@ class LetterButtons extends StatelessWidget {
keys.add(
Padding(
padding: const EdgeInsets.all(2.0),
child: RaisedButton(
disabledColor: Colors.grey,
disabledTextColor: Colors.white,
splashColor: Color(accent),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.grey,
onPrimary: Colors.white,
shadowColor: Color(accent),
),
onPressed: _myProvider.usedLetters.contains(key)
? null
: () async {
......@@ -61,13 +63,13 @@ class LetterButtons extends StatelessWidget {
key,
textAlign: TextAlign.center,
),
color: Colors.grey[200],
),
),
);
});
return Container(
alignment: orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.center,
alignment:
orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.center,
color: Color(darkGreen),
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(top: orientation == Orientation.portrait ? 0.0 : paddingTop),
......@@ -75,7 +77,8 @@ class LetterButtons extends StatelessWidget {
padding: EdgeInsets.zero,
shrinkWrap: true,
crossAxisCount: orientation == Orientation.portrait ? 9 : 3,
childAspectRatio: orientation == Orientation.portrait ? 1 / 1 : (itemWidth / itemHeight),
childAspectRatio:
orientation == Orientation.portrait ? 1 / 1 : (itemWidth / itemHeight),
children: keys,
),
);
......
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show SystemNavigator;
import 'package:provider/provider.dart';
import '../provider/data.dart';
import '../screens/scores.dart';
class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
......@@ -14,8 +12,6 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
@override
Widget build(BuildContext context) {
Data _myProvider = Provider.of<Data>(context);
return AppBar(
title: Text('Hangman'),
automaticallyImplyLeading: false,
......@@ -27,7 +23,6 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
SystemNavigator.pop();
break;
case 'Scores':
Scaffold.of(context).removeCurrentSnackBar();
Navigator.pushNamed(context, Scores.id);
break;
}
......
......@@ -21,7 +21,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
charcode:
dependency: transitive
description:
......@@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
csslib:
dependency: transitive
description:
......@@ -63,21 +63,21 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "2.0.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.1"
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
......@@ -120,14 +120,14 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
list_french_words:
dependency: "direct main"
description:
name: list_french_words
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0+1"
version: "0.1.0+2"
matcher:
dependency: transitive
description:
......@@ -135,6 +135,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
......@@ -155,56 +162,56 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+2"
version: "2.1.7"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "2.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.5"
version: "2.1.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
version: "1.11.1"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
version: "4.2.4"
provider:
dependency: "direct main"
description:
......@@ -218,42 +225,56 @@ packages:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.12+4"
version: "2.0.15"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2+4"
version: "2.1.1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+11"
version: "2.0.4"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2+7"
version: "2.0.4"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2+3"
version: "2.1.1"
sky_engine:
dependency: transitive
description: flutter
......@@ -265,7 +286,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
......@@ -300,35 +321,35 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
version: "0.4.9"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.7.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
version: "0.2.0+1"
sdks:
dart: ">=2.13.0 <3.0.0"
flutter: ">=1.20.0"
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
......@@ -10,7 +10,7 @@ dependencies:
flutter:
sdk: flutter
provider: ^4.3.2+3
shared_preferences: ^0.5.12+4
shared_preferences: ^2.0.6
html: ^0.14.0+4
http: ^0.12.2
diacritic: ^0.1.1
......
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hangman/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
await tester.pumpWidget(Hangman());
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment