Graphs_dart/flutter/lib/pages/drawing_page.dart

131 lines
4.1 KiB
Dart
Raw Normal View History

2021-11-05 00:35:51 +03:00
import 'dart:io';
import 'package:graphs/curve_painter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:graphs/src/graph.dart';
class DrawingPage extends StatefulWidget {
const DrawingPage({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _DrawingPageState();
}
class _DrawingPageState extends State<DrawingPage> {
Graphs data = Graphs("Data");
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Graph",
style: TextStyle(fontSize: 35, color: Colors.white)),
toolbarHeight: 110, // Set this height
flexibleSpace: Container(
color: Colors.blue,
child: Column(children: <Widget>[
/*Row(children: const <Widget>[
SizedBox(width: 25),
Text("Graph", style: TextStyle(fontSize: 23, color: Colors.white))
]),*/
const SizedBox(height: 5),
Container(
width: MediaQuery.of(context).size.width / 3 + 30,
height: 40,
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: const TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
filled: true,
fillColor: Colors.white,
prefixIcon: Icon(Icons.fiber_manual_record_outlined,
color: Colors.black),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(40))),
hintStyle: TextStyle(color: Colors.black38),
hintText: "Input dot number"),
),
),
Container(
width: MediaQuery.of(context).size.width / 3 + 30,
height: 40,
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: const TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
filled: true,
fillColor: Colors.white,
prefixIcon: Icon(Icons.arrow_right_alt_outlined,
color: Colors.black),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(40))),
hintStyle: TextStyle(color: Colors.black38),
hintText: "Input path length"),
),
),
]),
),
actions: [
Column(
children: [
addVerticalSpace(10),
createButton("\nAdd dot\n"),
addVerticalSpace(3),
createButton("\nDel dot \n"),
],
),
IconButton(
onPressed: () => closeApp(),
icon: const Icon(Icons.close),
iconSize: 50,
),
]),
body: CustomPaint(
painter: CurvePainter(),
child: const Center(),
),
));
}
ElevatedButton createButton(String txt) {
return ElevatedButton(
style: TextButton.styleFrom(
primary: Colors.blue,
),
onPressed: null,
child: Text(txt,
style: const TextStyle(
fontSize: 15,
color: Colors.white,
height: 1,
)),
);
}
SizedBox addVerticalSpace(double h) {
return SizedBox(height: h);
}
void closeApp() {
if (Platform.isWindows) {
exit(0);
}
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
}
}
class _Buttons extends StatelessWidget {
const _Buttons({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}