diff --git a/README.md b/README.md
index 538cb95..d3f0988 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,3 @@
# pavouk
-A new Flutter project.
-
-## Getting Started
-
-This project is a starting point for a Flutter application.
-
-A few resources to get you started if this is your first Flutter project:
-
-- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
-
-For help getting started with Flutter development, view the
-[online documentation](https://docs.flutter.dev/), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
+Generátor příkladů pro subnetování sítí
diff --git a/lib/main.dart b/lib/main.dart
index 9ec63e1..3b5bd5a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -2,6 +2,23 @@ import 'package:flutter/material.dart';
import 'package:pavouk/okna/domov.dart';
import 'package:responsive_sizer/responsive_sizer.dart';
+/*
+ Copyright (C) 2022 Matyáš Caras
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
diff --git a/lib/okna/domov.dart b/lib/okna/domov.dart
index 202a5d8..63c6a0e 100644
--- a/lib/okna/domov.dart
+++ b/lib/okna/domov.dart
@@ -8,6 +8,23 @@ import 'package:pavouk/util/subnet_masky.dart';
import 'package:pavouk/util/vzhled.dart';
import 'package:responsive_sizer/responsive_sizer.dart';
+/*
+ Copyright (C) 2022 Matyáš Caras
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
class DomovskaStrana extends StatefulWidget {
const DomovskaStrana({super.key});
@@ -254,6 +271,38 @@ class _DomovskaStranaState extends State {
);
return;
}
+ var prefix = int.tryParse(_origoController.text.split("/")[1]);
+ var sub = Util.subnety()
+ .where((element) => element["prefix"]! == (prefix ?? 90))
+ .toList();
+ if (sub.isEmpty) {
+ ScaffoldMessenger.of(context).clearSnackBars();
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(
+ content: Text(
+ "Nezadali jste platný subnet prefix.",
+ style: TextStyle(fontSize: 12.sp),
+ ),
+ ),
+ );
+ return;
+ }
+ var pocet = 0;
+ for (var subPocet in subnety) {
+ pocet += subPocet;
+ }
+ if (sub[0]["hosti"]! < pocet) {
+ ScaffoldMessenger.of(context).clearSnackBars();
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(
+ content: Text(
+ "Prefix nemá tolik hostů.",
+ style: TextStyle(fontSize: 12.sp),
+ ),
+ ),
+ );
+ return;
+ }
Navigator.push(
context,
MaterialPageRoute(
@@ -281,6 +330,11 @@ class _DomovskaStranaState extends State {
),
);
}
+ var subnety = Util.subnety()
+ .where(
+ (element) => element["hosti"]! > maxPocetRealnych,
+ )
+ .toList();
Random rnd = Random();
// vytvořit zdrojovou IP
var ip = "";
@@ -301,8 +355,9 @@ class _DomovskaStranaState extends State {
}
subnetData.add(rnd.nextInt(maxPocetRealnych) + 2);
}
+ var maska = subnety[rnd.nextInt(subnety.length)];
// vložit
- _origoController.text = "$ip/22";
+ _origoController.text = "$ip/${maska['prefix']}";
generovatSubnetFieldy(pocetSubnetu, hodnoty: subnetData);
}
}
diff --git a/lib/okna/reseni.dart b/lib/okna/reseni.dart
index 74fbb41..065933e 100644
--- a/lib/okna/reseni.dart
+++ b/lib/okna/reseni.dart
@@ -4,6 +4,23 @@ import 'package:pavouk/util/subnet_masky.dart';
import 'package:pavouk/util/vzhled.dart';
import 'package:responsive_sizer/responsive_sizer.dart';
+/*
+ Copyright (C) 2022 Matyáš Caras
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
class Reseni extends StatefulWidget {
const Reseni({super.key, required this.origoIp, required this.subnety});
final String origoIp;
@@ -123,19 +140,20 @@ class _ReseniState extends State {
children: [
Text(
"Zadaná IP:",
- style: Vzhled.tableContent,
+ style: Vzhled.tableContent(context),
),
const SizedBox(
width: 20,
),
- Text(origoNetIP, style: Vzhled.tableContent)
+ Text(origoNetIP, style: Vzhled.tableContent(context))
],
),
DefaultTextStyle(
- style: Vzhled.tableContent,
+ style: Vzhled.tableContent(context),
child: Expanded(
child: Table(
- border: TableBorder.all(),
+ border: TableBorder.all(
+ color: Theme.of(context).colorScheme.inverseSurface),
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
defaultColumnWidth: FixedColumnWidth(
Device.orientation == Orientation.landscape
@@ -247,28 +265,60 @@ class _ReseniState extends State {
style: Vzhled.text, textAlign: TextAlign.center),
),
TableCell(
+ child: SizedBox(
+ height: 50,
+ child: Center(
child: Text(
- widget.subnety[i].toString(),
- textAlign: TextAlign.center,
+ widget.subnety[i].toString(),
+ textAlign: TextAlign.center,
+ ),
+ ),
)),
TableCell(
+ child: SizedBox(
+ height: 50,
+ child: Center(
child: Text((prefix["hosti"]! - 2).toString(),
- textAlign: TextAlign.center)),
+ textAlign: TextAlign.center),
+ ),
+ )),
TableCell(
- child: Text(ip, textAlign: TextAlign.center),
+ child: SizedBox(
+ height: 50,
+ child: Center(child: Text(ip, textAlign: TextAlign.center))),
),
TableCell(
- child:
- Text(prefix["prefix"]!.toString(), textAlign: TextAlign.center),
+ child: SizedBox(
+ height: 50,
+ child: Center(
+ child: Text(prefix["prefix"]!.toString(),
+ textAlign: TextAlign.center),
+ ),
+ ),
),
TableCell(
- child: Text(prvni, textAlign: TextAlign.center),
+ child: SizedBox(
+ height: 50,
+ child: Center(
+ child: Text(prvni, textAlign: TextAlign.center),
+ ),
+ ),
),
TableCell(
- child: Text(posledni, textAlign: TextAlign.center),
+ child: SizedBox(
+ height: 50,
+ child: Center(
+ child: Text(posledni, textAlign: TextAlign.center),
+ ),
+ ),
),
TableCell(
- child: Text(broadcast, textAlign: TextAlign.center),
+ child: SizedBox(
+ height: 50,
+ child: Center(
+ child: Text(broadcast, textAlign: TextAlign.center),
+ ),
+ ),
),
]));
}
diff --git a/lib/util/appbar.dart b/lib/util/appbar.dart
index c238777..1e554ca 100644
--- a/lib/util/appbar.dart
+++ b/lib/util/appbar.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
+import 'dart:html' as html;
AppBar bar(BuildContext context, {int i = 0}) => AppBar(
title: const Text('Pavouk - generátor příkladů pro výuku subnetování'),
@@ -9,12 +10,20 @@ AppBar bar(BuildContext context, {int i = 0}) => AppBar(
IconButton(
icon: const Icon(Icons.info_outline),
onPressed: () {
- PackageInfo.fromPlatform().then((v) => showAboutDialog(
- context: context,
- applicationName: "Pavouk",
- applicationVersion: v.version,
- applicationLegalese:
- "© 2022 Matyáš Caras\nVydáno pod licencí GNU AGPLv3\nVěnováno SŠTE Brno, Olomoucká"));
+ PackageInfo.fromPlatform().then(
+ (v) => showAboutDialog(
+ context: context,
+ applicationName: "Pavouk",
+ applicationVersion: v.version,
+ applicationLegalese:
+ "© 2022 Matyáš Caras\nVydáno pod licencí GNU AGPLv3\nVěnováno SŠTE Brno, Olomoucká",
+ children: [
+ TextButton(
+ onPressed: () => html.window.open(
+ "https://github.com/hernikplays/pavouk", "_blank"),
+ child: const Text("Zdrojový kód"))
+ ]),
+ );
},
)
],
diff --git a/lib/util/subnet_masky.dart b/lib/util/subnet_masky.dart
index c2176f9..db06833 100644
--- a/lib/util/subnet_masky.dart
+++ b/lib/util/subnet_masky.dart
@@ -1,5 +1,3 @@
-import 'dart:math';
-
class Util {
static List