Skip to content

Commit 569d11f

Browse files
authored
Merge pull request #10 from nikhil-RGB/nn/feat/autoRun
Adding auto-run feature
2 parents 6f02f74 + 55f7302 commit 569d11f

File tree

7 files changed

+393
-119
lines changed

7 files changed

+393
-119
lines changed

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void main() async {
2727
Hive.registerAdapter(ActionsAdapter());
2828
Hive.registerAdapter(ActionTypeAdapter());
2929
Hive.registerAdapter(TuringMachineModelAdapter());
30+
// await Hive.deleteBoxFromDisk("turing_machines");
3031
await Hive.openBox<TuringMachineModel>("turing_machines");
3132

3233
runApp(const MyApp());
@@ -38,7 +39,6 @@ class MyApp extends StatelessWidget {
3839
// This widget is the root of your application.
3940
@override
4041
Widget build(BuildContext context) {
41-
4242
return MaterialApp(
4343
title: 'Turing Machine Generator',
4444
debugShowCheckedModeBanner: false,

lib/models/TuringMachineModel.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@ class TuringMachineModel {
1616
List<Configuration> configs;
1717
@HiveField(2)
1818
List<Behaviour> behaviours;
19+
@HiveField(3)
20+
String description;
1921
TuringMachineModel(
2022
{required this.initial_config,
2123
required this.configs,
22-
required this.behaviours});
24+
required this.behaviours,
25+
required this.description});
2326
//Factory constructor for Model to save this machine object
2427
factory TuringMachineModel.fromMachine({required TuringMachine machine}) {
2528
//Construct object from machine object.
2629
return TuringMachineModel(
2730
initial_config: machine.initial_config,
2831
configs: machine.machine.keys.toList(),
2932
behaviours: machine.machine.values.toList(),
33+
description: machine.description,
3034
);
3135
//LinkedHashMap to List.
3236
}
@@ -40,6 +44,7 @@ class TuringMachineModel {
4044
);
4145
machine.current_config = initial_config;
4246
machine.iterations = 0;
47+
machine.description = description;
4348

4449
return machine;
4550
}

lib/models/TuringMachineModel.g.dart

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/TuringMachines.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ class TuringMachine {
1919

2020
Tape tape;
2121

22+
String description;
23+
2224
late LinkedHashMap<Configuration, Behaviour> machine;
2325
TuringMachine(List<Configuration> configurations, List<Behaviour> behaviours,
2426
{required this.tape, required this.initial_config})
2527
: machine = LinkedHashMap(),
26-
current_config = initial_config {
28+
current_config = initial_config,
29+
description = "Enter a description for this turing machine here" {
2730
//Write code to convert ordered entires into hashmap key-pair values
2831
// ignore: unnecessary_this
2932
for (int i = 0; i < configurations.length; i++) {

lib/screens/TableScreen.dart

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ class _TableScreenState extends State<TableScreen> {
100100
appBar: AppBar(
101101
title: const Text("TableScreen"),
102102
actions: [
103+
IconButton(
104+
onPressed: () {
105+
_showInfoSheet();
106+
},
107+
icon: const Icon(Icons.info_outlined)),
108+
const Gap(5),
103109
IconButton(
104110
onPressed: () {
105111
_showInputSheet(context);
@@ -714,4 +720,70 @@ class _TableScreenState extends State<TableScreen> {
714720
);
715721
});
716722
}
723+
724+
void _showInfoSheet() {
725+
TextEditingController controller =
726+
TextEditingController(text: widget.machine.description);
727+
728+
showModalBottomSheet(
729+
useSafeArea: true,
730+
isScrollControlled: true,
731+
context: context,
732+
isDismissible: true,
733+
enableDrag: false,
734+
builder: (context) {
735+
return Padding(
736+
padding: EdgeInsets.only(
737+
bottom: MediaQuery.of(context).viewInsets.bottom,
738+
),
739+
child: Container(
740+
height: 320,
741+
padding: const EdgeInsets.only(
742+
bottom: 8.0, top: 15, left: 15, right: 15),
743+
child: Center(
744+
child: Column(
745+
children: [
746+
const Text(
747+
"Description ",
748+
style:
749+
TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
750+
),
751+
const Gap(20),
752+
TextField(
753+
maxLength: 500,
754+
controller: controller,
755+
maxLines: 5,
756+
),
757+
const Gap(5),
758+
Padding(
759+
padding: const EdgeInsets.only(left: 5.0),
760+
child: Row(
761+
crossAxisAlignment: CrossAxisAlignment.center,
762+
mainAxisAlignment: MainAxisAlignment.end,
763+
children: [
764+
ElevatedButton(
765+
onPressed: () {
766+
Navigator.pop(context);
767+
},
768+
child: const Text("Cancel"),
769+
),
770+
const Gap(7.0),
771+
ElevatedButton(
772+
onPressed: () {
773+
//saving code here
774+
widget.machine.description = controller.text;
775+
Navigator.pop(context);
776+
},
777+
child: const Text("Okay"),
778+
)
779+
],
780+
),
781+
),
782+
],
783+
),
784+
),
785+
),
786+
);
787+
});
788+
}
717789
}

0 commit comments

Comments
 (0)