Moved buttons from list to formula.
This commit is contained in:
parent
8a42d53c77
commit
2400554259
4 changed files with 68 additions and 51 deletions
|
|
@ -156,41 +156,7 @@ class _FormulaListState extends State<FormulaList> {
|
|||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
PopupMenuButton(
|
||||
icon: const Icon(Icons.share),
|
||||
tooltip: 'Share or copy to clipboard',
|
||||
onSelected: (value) {
|
||||
if (value == 'share') {
|
||||
FormulaList.shareFormula(formula);
|
||||
} else if (value == 'copy') {
|
||||
FormulaList.copyFormula(context, formula);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'share',
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.share, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: Text('Share', softWrap: false)),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'copy',
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.copy, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: Text('Copy to clipboard', softWrap: false)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// TOTHINK: Add buttons here, but I don't know which ones
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// dart
|
||||
import 'package:d4rt_formulas/database/database_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown_plus_latex/flutter_markdown_plus_latex.dart';
|
||||
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
||||
|
|
@ -7,6 +8,7 @@ import '../formula_models.dart';
|
|||
import '../formula_evaluator.dart';
|
||||
import '../corpus.dart';
|
||||
import '../error_handler.dart';
|
||||
import '../service_locator.dart';
|
||||
import '../value_formatter.dart';
|
||||
import 'd4rt_editing_controller.dart';
|
||||
import 'formula_list.dart';
|
||||
|
|
@ -194,6 +196,47 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
],
|
||||
),
|
||||
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_forever),
|
||||
onPressed: () {
|
||||
print( "Borrando");
|
||||
showAlertDialog(BuildContext context) {
|
||||
// set up the buttons
|
||||
Widget cancelButton = TextButton(
|
||||
child: Text("Cancel"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
Widget deleteButton = TextButton(
|
||||
child: Text("Delete"),
|
||||
onPressed: () {
|
||||
widget.corpus.forgetFormula(formula.originalFormula);
|
||||
getDatabase().deleteFormula(formula.originalFormula.uuid);
|
||||
Navigator.of(context)
|
||||
..pop()..pop();
|
||||
},
|
||||
);
|
||||
|
||||
// set up the AlertDialog
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: Text("Delete Formula"),
|
||||
content: Text("Please confirm deletion of formula ${formula.name}"),
|
||||
actions: [
|
||||
cancelButton,
|
||||
deleteButton,
|
||||
],
|
||||
);
|
||||
return alert;
|
||||
}
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: showAlertDialog
|
||||
);
|
||||
},
|
||||
tooltip: "Delete formula"
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: formula is DerivedFormula
|
||||
|
|
|
|||
|
|
@ -275,4 +275,11 @@ class Corpus{
|
|||
return result.toList();
|
||||
}
|
||||
|
||||
void forgetFormula(Formula formula) {
|
||||
for (final tag in formula.tags) {
|
||||
_tags[tag]?.remove(formula);
|
||||
}
|
||||
_allFormulas.remove(formula.uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
|||
|
||||
String? formatOutput(dynamic result) {
|
||||
if (result == null) return null;
|
||||
return result.toString();
|
||||
|
||||
// Try to parse as number to format with commas
|
||||
if (result is num) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue