parent
bbba3a65e8
commit
e31e774115
|
@ -27,12 +27,12 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||
Graphs data = getGraph();
|
||||
|
||||
final _textNameController = TextEditingController();
|
||||
final _textInptController = TextEditingController();
|
||||
final _textNumbController = TextEditingController();
|
||||
final _textDistController = TextEditingController();
|
||||
final _textLnthController = TextEditingController();
|
||||
void clearTextControllers() {
|
||||
_textDistController.clear();
|
||||
_textInptController.clear();
|
||||
_textNumbController.clear();
|
||||
_textLnthController.clear();
|
||||
_textNameController.clear();
|
||||
}
|
||||
|
@ -51,14 +51,14 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||
child: Column(children: <Widget>[
|
||||
const SizedBox(height: 5),
|
||||
Row(children: [
|
||||
addSpaceW(screenSize / 8 - 20),
|
||||
addSpaceW(screenSize / 8),
|
||||
createButton("\nAdd dot\n", addDotPushed),
|
||||
createInputBox("Dot name", screenSize / 4 - 25, Icons.label,
|
||||
_textNameController),
|
||||
addSpaceW(20),
|
||||
createButton("\nDel dot \n", delDotPushed),
|
||||
createInputBox("Dot number", screenSize / 4 - 25,
|
||||
Icons.fiber_manual_record, _textInptController),
|
||||
Icons.fiber_manual_record, _textNumbController),
|
||||
]),
|
||||
addSpaceH(3),
|
||||
Row(children: [
|
||||
|
@ -69,27 +69,27 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||
createInputBox("Input length", screenSize / 4 - 5,
|
||||
Icons.arrow_right_alt_outlined, _textLnthController),
|
||||
]),
|
||||
//createInputBox("Input path length", screenSize / 3 + 30, Icons.arrow_right_alt_outlined, _textLenController),
|
||||
]),
|
||||
),
|
||||
actions: [
|
||||
/*Column(
|
||||
children: [
|
||||
addSpaceH(10),
|
||||
createButton("\nAdd dot\n", addDotPushed),
|
||||
addSpaceH(3),
|
||||
createButton("\nDel dot \n", addLenPushed),
|
||||
],
|
||||
),*/
|
||||
IconButton(
|
||||
onPressed: () => flushData(),
|
||||
onPressed: flushData,
|
||||
icon: const Icon(Icons.delete_sweep),
|
||||
iconSize: 60,
|
||||
),
|
||||
]),
|
||||
body: CustomPaint(
|
||||
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
|
||||
ElevatedButton createButton(String txt, void onPressing()) {
|
||||
return ElevatedButton(
|
||||
/*style: TextButton.styleFrom(
|
||||
primary: Colors.blue,
|
||||
),*/
|
||||
onPressed: onPressing,
|
||||
child: Text(txt,
|
||||
style: const TextStyle(
|
||||
|
@ -156,12 +153,17 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||
}
|
||||
|
||||
void delDotPushed() {
|
||||
if (_textNameController.text == "") {
|
||||
showPopUp("Error", "No name in \"Dot name\" box");
|
||||
if (_textNumbController.text == "") {
|
||||
showPopUp("Error", "No number in \"Dot number\" box");
|
||||
} else {
|
||||
String? res = data.addIsolated(_textNameController.text);
|
||||
if (res != null) {
|
||||
showPopUp("Error", res);
|
||||
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) {
|
||||
showPopUp("Error", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
clearTextControllers();
|
||||
|
@ -170,7 +172,7 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||
void addLenPushed() {
|
||||
//data.delDot()
|
||||
print(
|
||||
"${_textInptController.text} -> ${_textDistController.text} = ${_textLnthController.text}");
|
||||
"${_textNumbController.text} -> ${_textDistController.text} = ${_textLnthController.text}");
|
||||
clearTextControllers();
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,10 @@ class Graphs {
|
|||
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>[];
|
||||
for (int i in _dots[inn - 1].getL().keys) {
|
||||
toDel.add(i);
|
||||
|
@ -169,7 +172,7 @@ class Graphs {
|
|||
_syncNum();
|
||||
_syncNameTable();
|
||||
_fixAfterDel(inn);
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
//*********Delete*********
|
||||
|
||||
|
|
Loading…
Reference in New Issue