Initial commit

This commit is contained in:
brausjonas
2024-09-15 17:03:37 +02:00
commit 8740525457
42 changed files with 1515 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:todoapp/elems/todo.dart';
import 'package:todoapp/providers/todoprovider.dart';
class EditTodoModal {
static String tempValue = "";
static void add(BuildContext context, String title) {
showModalBottomSheet(
context: context,
showDragHandle: true,
useSafeArea: true,
scrollControlDisabledMaxHeightRatio: 1,
builder: (context) => Padding(
padding: const EdgeInsets.only(left: 30, right: 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
autofocus: true,
initialValue: title,
decoration: const InputDecoration(labelText: "Title"),
onChanged: (value) => tempValue = value,
onFieldSubmitted: (value) {
context.read<TodoProvider>().updateTodo(title, value);
Navigator.pop(context);
},
),
const SizedBox(height: 20,),
SegmentedButton(
segments: const [
ButtonSegment(
value: "Delete",
label: Text("Delete"),
icon: Icon(Icons.delete)
),
ButtonSegment(
value: "Cancel",
label: Text("Cancel"),
icon: Icon(Icons.cancel)
),
ButtonSegment(
value: "Save",
label: Text("Save"),
icon: Icon(Icons.save)
),
],
selected: const {"None"},
style: ButtonStyle(iconColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.primary)),
onSelectionChanged: (p0) {
if (p0.last == "Save") {
context.read<TodoProvider>().updateTodo(title, tempValue);
} else if (p0.last == "Delete") {
context.read<TodoProvider>().removeTodo(title);
}
Navigator.pop(context);
},
)
],
),
),
);
}
}