89 lines
2.8 KiB
Dart
89 lines
2.8 KiB
Dart
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});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FloatingActionButton(
|
|
onPressed: () {
|
|
// gm.add(
|
|
// Project.validated(
|
|
// "Kimi",
|
|
// "Rust",
|
|
// "/home/arrow/Gitted/cowin",
|
|
// [],
|
|
// 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),
|
|
);
|
|
}
|
|
}
|