Skip to content

Commit 769700c

Browse files
committed
Gestion du manque de connexion
dans la page téléchargement d'exemples.
1 parent c00ff50 commit 769700c

24 files changed

+202
-62
lines changed

AppImageBuilder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ AppDir:
1515
id: com.loloof64.basic_chess_endgames
1616
name: BasicChessEndgames
1717
icon: icon
18-
version: 4.4.0
18+
version: 4.4.1
1919
exec: basicchessendgamestrainer
2020
exec_args: $@
2121
apt:

Basic_chess_endgames.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Desktop Entry]
22
Type=Application
3-
Version=4.4.0
3+
Version=4.4.1
44
Name=BasicChessEndgames
55
Comment=Generate a chess position and play with it
66
Exec=basicchessendgamestrainer

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.4.1
2+
3+
* Handling missing internet connection in samples loading page.
4+
15
## 4.4.0
26

37
* Added random testing feature where you can preview generated positions from your script, as well as the rejected generated position because of being illegal.

ReleaseMessage.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
* Added random testing feature where you can preview generated positions from your script, as well as the rejected generated position because of being illegal
2-
* Little improvement : giving the focus back to the user when he inserts a predefined variable in script editor
3-
* We can set the dark mode
4-
* We can download additional samples.
1+
* Handling missing internet connection in samples loading page.

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
tools:node="remove"/>
44
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
55
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
6-
<uses-permission android:name="android.permission.INTERNET" />
76

87
<application
98
android:label="@string/app_name"

ios/Flutter/Generated.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FLUTTER_APPLICATION_PATH=/home/laurent/Documents/GitHub/Basic_chess_endgames
44
COCOAPODS_PARALLEL_CODE_SIGN=true
55
FLUTTER_TARGET=lib/main.dart
66
FLUTTER_BUILD_DIR=build
7-
FLUTTER_BUILD_NAME=4.4.0
7+
FLUTTER_BUILD_NAME=4.4.1
88
FLUTTER_BUILD_NUMBER=19
99
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
1010
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7

ios/Flutter/flutter_export_environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export "FLUTTER_APPLICATION_PATH=/home/laurent/Documents/GitHub/Basic_chess_endg
55
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
66
export "FLUTTER_TARGET=lib/main.dart"
77
export "FLUTTER_BUILD_DIR=build"
8-
export "FLUTTER_BUILD_NAME=4.4.0"
8+
export "FLUTTER_BUILD_NAME=4.4.1"
99
export "FLUTTER_BUILD_NUMBER=19"
1010
export "DART_OBFUSCATION=false"
1111
export "TRACK_WIDGET_CREATION=true"

ios/Runner/GeneratedPluginRegistrant.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
#import "GeneratedPluginRegistrant.h"
88

9+
#if __has_include(<connectivity_plus/ConnectivityPlusPlugin.h>)
10+
#import <connectivity_plus/ConnectivityPlusPlugin.h>
11+
#else
12+
@import connectivity_plus;
13+
#endif
14+
915
#if __has_include(<file_picker/FilePickerPlugin.h>)
1016
#import <file_picker/FilePickerPlugin.h>
1117
#else
@@ -33,6 +39,7 @@
3339
@implementation GeneratedPluginRegistrant
3440

3541
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
42+
[ConnectivityPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"ConnectivityPlusPlugin"]];
3643
[FilePickerPlugin registerWithRegistrar:[registry registrarForPlugin:@"FilePickerPlugin"]];
3744
[FlutterNativeSplashPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterNativeSplashPlugin"]];
3845
[PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]];
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:connectivity_plus/connectivity_plus.dart';
3+
import 'package:basicchessendgamestrainer/i18n/translations.g.dart';
4+
5+
class InternetChecker extends StatefulWidget {
6+
final Widget child;
7+
final VoidCallback?
8+
onReconnect; // Callback triggered when connection is restored
9+
final VoidCallback?
10+
onDisconnect; // Callback triggered when connection is lost
11+
12+
const InternetChecker({
13+
super.key,
14+
required this.child,
15+
this.onReconnect,
16+
this.onDisconnect,
17+
});
18+
19+
@override
20+
InternetCheckerState createState() => InternetCheckerState();
21+
}
22+
23+
class InternetCheckerState extends State<InternetChecker> {
24+
late Stream<List<ConnectivityResult>> _connectivityStream;
25+
26+
@override
27+
void initState() {
28+
super.initState();
29+
_connectivityStream = Connectivity().onConnectivityChanged;
30+
_connectivityStream.listen(_handleConnectivityChange);
31+
}
32+
33+
void _handleConnectivityChange(List<ConnectivityResult> results) {
34+
// Check if all internet connections are missing
35+
bool isCompletelyOffline =
36+
results.every((result) => result == ConnectivityResult.none);
37+
38+
if (isCompletelyOffline) {
39+
if (widget.onDisconnect != null) {
40+
widget.onDisconnect!();
41+
}
42+
ScaffoldMessenger.of(context).showSnackBar(
43+
SnackBar(
44+
content: Text(t.additional_samples_page.no_internet),
45+
),
46+
);
47+
} else {
48+
// Trigger callback when the connection is restored
49+
if (widget.onReconnect != null) {
50+
widget.onReconnect!();
51+
}
52+
}
53+
}
54+
55+
@override
56+
Widget build(BuildContext context) {
57+
return widget.child;
58+
}
59+
}

lib/i18n/en.i18n.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,5 @@ additional_samples_page:
283283
confirm_download: "Download sample '$name' ?"
284284
download_success: "Sample downloaded."
285285
download_error: "Failed to download sample."
286-
download_cancelled: "Download cancelled."
286+
download_cancelled: "Download cancelled."
287+
no_internet: "You need an internet connection to download additional samples."

0 commit comments

Comments
 (0)