diff --git a/flutter/lib/curve_painter.dart b/flutter/lib/curve_painter.dart index 379fbee..0a334e5 100644 --- a/flutter/lib/curve_painter.dart +++ b/flutter/lib/curve_painter.dart @@ -8,9 +8,13 @@ class CurvePainter extends CustomPainter { Key? key, required this.graphData, required this.bfsPath, + required this.dfsStart, + required this.dfsAccessTable, }); List? bfsPath; + List? dfsAccessTable; + int? dfsStart; Graphs graphData; final double dotRad = 6; final double lineWidth = 2; diff --git a/flutter/lib/pages/drawing_page.dart b/flutter/lib/pages/drawing_page.dart index 449eaa6..f166d71 100644 --- a/flutter/lib/pages/drawing_page.dart +++ b/flutter/lib/pages/drawing_page.dart @@ -25,6 +25,8 @@ class _DrawingPageState extends State { double screenSize = 0; Graphs graphData = getGraph(); List? bfsPath; + List? dfsAccessTable; + int? dfsStartDot; final _textNameController = TextEditingController(); final _textNumbController = TextEditingController(); @@ -86,20 +88,24 @@ class _DrawingPageState extends State { ), actions: [ IconButton( - onPressed: clearScreen, + onPressed: () => graphData.flushData(), icon: const Icon(Icons.delete_sweep), iconSize: 60, ), ]), body: CustomPaint( - painter: CurvePainter(graphData: graphData, bfsPath: bfsPath), + painter: CurvePainter( + graphData: graphData, + bfsPath: bfsPath, + dfsStart: dfsStartDot, + dfsAccessTable: dfsAccessTable), child: Align( alignment: Alignment.topRight, child: ButtonBar( mainAxisSize: MainAxisSize.min, children: [ createButton("Bfs", bfsPushed), - createButton("Dfs", () {}), + createButton("Dfs", dfsPushed), createButton("Clear dfs or bfs", () => bfsPath = null), createButton(graphData.getUseLengthStr(), changeLength), createButton(graphData.getDoubleSidedStr(), changeOriented), @@ -357,6 +363,8 @@ class _DrawingPageState extends State { void bfsPushed() { setState(() { + dfsAccessTable = null; + bfsPath = null; if (_textNumbController.text == "") { showPopUp("Error", "No number in \"Dot number\" box"); } else if (_textDestController.text == "") { @@ -379,6 +387,27 @@ class _DrawingPageState extends State { }); } - void clearScreen() => graphData.flushData(); + void dfsPushed() { + setState(() { + bfsPath = null; + bfsPath = null; + if (_textNumbController.text == "") { + showPopUp("Error", "No number in \"Dot number\" box"); + } else { + int? from = int.tryParse(_textNumbController.text); + if (from == null) { + showPopUp("Error", + "Can't parse input.\nInts only allowed in \"Dot number\"."); + } else { + dfsAccessTable = graphData.dfsIterative(from); + if (dfsAccessTable == null) { + showPopUp("Err", "report this error."); + } + print(dfsAccessTable); + } + } + clearTextControllers(); + }); + } //*********ButtonsFunctions********* } diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index b29645c..f34f096 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 0.5.0+1 environment: sdk: ">=2.15.0-100.0.dev<3.0.0" diff --git a/flutter/windows/runner/main.cpp b/flutter/windows/runner/main.cpp index 179d7ab..24bb2b1 100644 --- a/flutter/windows/runner/main.cpp +++ b/flutter/windows/runner/main.cpp @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.CreateAndShow(L"grafs", origin, size)) { + if (!window.CreateAndShow(L"graphs", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true);