Skip to content

Commit 55f7302

Browse files
committed
✨ Implement machine description feature
1 parent 6e0ce1e commit 55f7302

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
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/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)