This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import "package:flutter/material.dart";
|
||||
import "package:prod/models/editor.dart";
|
||||
import "package:prod/models/globalModel.dart";
|
||||
import "package:provider/provider.dart";
|
||||
|
||||
class EditorFAB extends StatelessWidget {
|
||||
const EditorFAB({super.key});
|
||||
@@ -17,6 +19,68 @@ class EditorFAB extends StatelessWidget {
|
||||
// true,
|
||||
// ),
|
||||
// );
|
||||
TextEditingController nameController = TextEditingController();
|
||||
TextEditingController commandController = TextEditingController();
|
||||
TextEditingController commandTemplateController =
|
||||
TextEditingController();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: Text("Add Editor"),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
autofocus: true,
|
||||
controller: nameController,
|
||||
decoration: InputDecoration(labelText: "Editor Name"),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: commandController,
|
||||
decoration: InputDecoration(labelText: "Command"),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: commandTemplateController,
|
||||
decoration: InputDecoration(labelText: "Command Template"),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
child: const Text("Example: zed -n \$path"),
|
||||
padding: const EdgeInsets.all(9.0),
|
||||
),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: .end,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text("Cancel"),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
TextButton(
|
||||
child: Text("Add"),
|
||||
onPressed: () {
|
||||
Provider.of<GlobalModel>(context, listen: false).addEdt(
|
||||
Editor.create(
|
||||
nameController.text,
|
||||
commandController.text,
|
||||
commandTemplateController.text,
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Icon(Icons.add),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user