import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:todoapp/elems/todo.dart'; import 'package:todoapp/providers/todoprovider.dart'; class EditListModal { 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().renameList(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().renameList(title, tempValue); } else if (p0.last == "Delete") { context.read().removeList(title); } Navigator.pop(context); }, ) ], ), ), ); } }