FL:Del dot working
GR:DelDot return error string
This commit is contained in:
		
							parent
							
								
									bbba3a65e8
								
							
						
					
					
						commit
						e31e774115
					
				| @ -27,12 +27,12 @@ class _DrawingPageState extends State<DrawingPage> { | |||||||
|   Graphs data = getGraph(); |   Graphs data = getGraph(); | ||||||
| 
 | 
 | ||||||
|   final _textNameController = TextEditingController(); |   final _textNameController = TextEditingController(); | ||||||
|   final _textInptController = TextEditingController(); |   final _textNumbController = TextEditingController(); | ||||||
|   final _textDistController = TextEditingController(); |   final _textDistController = TextEditingController(); | ||||||
|   final _textLnthController = TextEditingController(); |   final _textLnthController = TextEditingController(); | ||||||
|   void clearTextControllers() { |   void clearTextControllers() { | ||||||
|     _textDistController.clear(); |     _textDistController.clear(); | ||||||
|     _textInptController.clear(); |     _textNumbController.clear(); | ||||||
|     _textLnthController.clear(); |     _textLnthController.clear(); | ||||||
|     _textNameController.clear(); |     _textNameController.clear(); | ||||||
|   } |   } | ||||||
| @ -51,14 +51,14 @@ class _DrawingPageState extends State<DrawingPage> { | |||||||
|             child: Column(children: <Widget>[ |             child: Column(children: <Widget>[ | ||||||
|               const SizedBox(height: 5), |               const SizedBox(height: 5), | ||||||
|               Row(children: [ |               Row(children: [ | ||||||
|                 addSpaceW(screenSize / 8 - 20), |                 addSpaceW(screenSize / 8), | ||||||
|                 createButton("\nAdd dot\n", addDotPushed), |                 createButton("\nAdd dot\n", addDotPushed), | ||||||
|                 createInputBox("Dot name", screenSize / 4 - 25, Icons.label, |                 createInputBox("Dot name", screenSize / 4 - 25, Icons.label, | ||||||
|                     _textNameController), |                     _textNameController), | ||||||
|                 addSpaceW(20), |                 addSpaceW(20), | ||||||
|                 createButton("\nDel dot \n", delDotPushed), |                 createButton("\nDel dot \n", delDotPushed), | ||||||
|                 createInputBox("Dot number", screenSize / 4 - 25, |                 createInputBox("Dot number", screenSize / 4 - 25, | ||||||
|                     Icons.fiber_manual_record, _textInptController), |                     Icons.fiber_manual_record, _textNumbController), | ||||||
|               ]), |               ]), | ||||||
|               addSpaceH(3), |               addSpaceH(3), | ||||||
|               Row(children: [ |               Row(children: [ | ||||||
| @ -69,27 +69,27 @@ class _DrawingPageState extends State<DrawingPage> { | |||||||
|                 createInputBox("Input length", screenSize / 4 - 5, |                 createInputBox("Input length", screenSize / 4 - 5, | ||||||
|                     Icons.arrow_right_alt_outlined, _textLnthController), |                     Icons.arrow_right_alt_outlined, _textLnthController), | ||||||
|               ]), |               ]), | ||||||
|               //createInputBox("Input path length", screenSize / 3 + 30, Icons.arrow_right_alt_outlined, _textLenController), |  | ||||||
|             ]), |             ]), | ||||||
|           ), |           ), | ||||||
|           actions: [ |           actions: [ | ||||||
|             /*Column( |  | ||||||
|               children: [ |  | ||||||
|                 addSpaceH(10), |  | ||||||
|                 createButton("\nAdd dot\n", addDotPushed), |  | ||||||
|                 addSpaceH(3), |  | ||||||
|                 createButton("\nDel dot \n", addLenPushed), |  | ||||||
|               ], |  | ||||||
|             ),*/ |  | ||||||
|             IconButton( |             IconButton( | ||||||
|               onPressed: () => flushData(), |               onPressed: flushData, | ||||||
|               icon: const Icon(Icons.delete_sweep), |               icon: const Icon(Icons.delete_sweep), | ||||||
|               iconSize: 60, |               iconSize: 60, | ||||||
|             ), |             ), | ||||||
|           ]), |           ]), | ||||||
|       body: CustomPaint( |       body: CustomPaint( | ||||||
|         painter: CurvePainter(gr: data), |         painter: CurvePainter(gr: data), | ||||||
|         child: const Center(), |         child: Align( | ||||||
|  |           alignment: Alignment.topRight, | ||||||
|  |           child: ButtonBar( | ||||||
|  |             mainAxisSize: MainAxisSize.min, | ||||||
|  |             children: <Widget>[ | ||||||
|  |               createButton("Hello", () {}), | ||||||
|  |               createButton("Hi", () {}), | ||||||
|  |             ], | ||||||
|  |           ), | ||||||
|  |         ), | ||||||
|       ), |       ), | ||||||
|     )); |     )); | ||||||
|   } |   } | ||||||
| @ -97,9 +97,6 @@ class _DrawingPageState extends State<DrawingPage> { | |||||||
|   // ignore: avoid_types_as_parameter_names, non_constant_identifier_names, use_function_type_syntax_for_parameters |   // ignore: avoid_types_as_parameter_names, non_constant_identifier_names, use_function_type_syntax_for_parameters | ||||||
|   ElevatedButton createButton(String txt, void onPressing()) { |   ElevatedButton createButton(String txt, void onPressing()) { | ||||||
|     return ElevatedButton( |     return ElevatedButton( | ||||||
|       /*style: TextButton.styleFrom( |  | ||||||
|         primary: Colors.blue, |  | ||||||
|       ),*/ |  | ||||||
|       onPressed: onPressing, |       onPressed: onPressing, | ||||||
|       child: Text(txt, |       child: Text(txt, | ||||||
|           style: const TextStyle( |           style: const TextStyle( | ||||||
| @ -156,21 +153,26 @@ class _DrawingPageState extends State<DrawingPage> { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void delDotPushed() { |   void delDotPushed() { | ||||||
|     if (_textNameController.text == "") { |     if (_textNumbController.text == "") { | ||||||
|       showPopUp("Error", "No name in \"Dot name\" box"); |       showPopUp("Error", "No number in \"Dot number\" box"); | ||||||
|     } else { |     } else { | ||||||
|       String? res = data.addIsolated(_textNameController.text); |       int? dot = int.tryParse(_textNumbController.text); | ||||||
|  |       if (dot == null) { | ||||||
|  |         showPopUp("Error", "Can't parse input.\nInts only allowed"); | ||||||
|  |       } else { | ||||||
|  |         String? res = data.delDot(dot); | ||||||
|         if (res != null) { |         if (res != null) { | ||||||
|           showPopUp("Error", res); |           showPopUp("Error", res); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|     clearTextControllers(); |     clearTextControllers(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void addLenPushed() { |   void addLenPushed() { | ||||||
|     //data.delDot() |     //data.delDot() | ||||||
|     print( |     print( | ||||||
|         "${_textInptController.text} -> ${_textDistController.text} = ${_textLnthController.text}"); |         "${_textNumbController.text} -> ${_textDistController.text} = ${_textLnthController.text}"); | ||||||
|     clearTextControllers(); |     clearTextControllers(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -157,7 +157,10 @@ class Graphs { | |||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   bool delDot(int inn) { |   String? delDot(int inn) { | ||||||
|  |     if (inn > _amount || inn < 1) { | ||||||
|  |       return "Index out of range. Allowed 1..$_amount"; | ||||||
|  |     } | ||||||
|     List<int> toDel = <int>[]; |     List<int> toDel = <int>[]; | ||||||
|     for (int i in _dots[inn - 1].getL().keys) { |     for (int i in _dots[inn - 1].getL().keys) { | ||||||
|       toDel.add(i); |       toDel.add(i); | ||||||
| @ -169,7 +172,7 @@ class Graphs { | |||||||
|     _syncNum(); |     _syncNum(); | ||||||
|     _syncNameTable(); |     _syncNameTable(); | ||||||
|     _fixAfterDel(inn); |     _fixAfterDel(inn); | ||||||
|     return true; |     return null; | ||||||
|   } |   } | ||||||
|   //*********Delete********* |   //*********Delete********* | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user