don't let user continue if not connected to the internet, fixed #4

pull/2/head
axtlos 3 years ago
parent 597b106c34
commit a353275efe
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'dart:io';
Widget welcome(next) {
Widget welcome(next, connected) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@ -74,7 +74,7 @@ Widget welcome(next) {
elevation: 0,
padding: EdgeInsets.zero,
),
onPressed: next,
onPressed: connected ? next : null,
child: Container(
width: 500,
height: 500,
@ -93,21 +93,31 @@ Widget welcome(next) {
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const [
SizedBox(height: 20),
Text("Start the installation",
children: [
const SizedBox(height: 20),
const Text("Start the installation",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white)),
SizedBox(height: 5),
Image(
const SizedBox(height: 5),
const Image(
image: AssetImage(
'assets/jade_logo.png',
),
height: 400,
fit: BoxFit.scaleDown,
),
Visibility(
visible: !connected,
child: const Text(
"You are not connected to the internet!",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.red),
),
),
],
),
),

@ -37,6 +37,18 @@ Future<void> checkIsEfi(
}
}
Future<void> checkConnected(
setState,
) async {
final String scriptOutput =
await Process.run("/opt/jade_gui/scripts/checkNetwork.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
bool connected = scriptOutput.contains("disconnected") ? false : true;
setState(connected);
}
Future<void> writeToLog(String message) async {
await File('${env["HOME"]}/jade_log.txt')
.readAsString()
@ -85,6 +97,7 @@ class _JadeguiState extends State<Jadegui> {
bool isEfi = false;
bool ipv6 = false;
bool enableTimeshift = true;
bool connected = false;
bool running = false;
bool runningInfo = false;
bool runningPart = false;
@ -108,6 +121,13 @@ class _JadeguiState extends State<Jadegui> {
@override
Widget build(BuildContext context) {
setWindowSize();
checkConnected(
(value) {
setState(() {
connected = value;
});
},
);
return Scaffold(
backgroundColor: const Color.fromARGB(255, 23, 23, 23),
body: Row(
@ -305,11 +325,14 @@ class _JadeguiState extends State<Jadegui> {
child: SizedBox(
width: logicWidth,
height: logicHeight,
child: welcome(() {
setState(() {
_selectedIndex = _selectedIndex + 1;
});
}),
child: welcome(
() {
setState(() {
_selectedIndex = _selectedIndex + 1;
});
},
connected,
),
),
),
);

@ -0,0 +1,7 @@
#!/usr/bin/env bash
ping -c1 getcryst.al -q > /dev/null
if [[ $? -eq 0 ]]; then
echo "connected"
else
echo "disconnected"
fi
Loading…
Cancel
Save