Initial commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:todoapp/modals/editlistmodal.dart';
|
||||
import 'package:todoapp/providers/todoprovider.dart';
|
||||
|
||||
class TodoListWidget extends StatefulWidget {
|
||||
const TodoListWidget({super.key, required this.title});
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<TodoListWidget> createState() => _TodoListWidgetState();
|
||||
}
|
||||
|
||||
class _TodoListWidgetState extends State<TodoListWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ButtonStyle buttonStyle = context
|
||||
.read<TodoProvider>()
|
||||
.selectedList == widget.title ? const ButtonStyle() : const ButtonStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(Color(0x00000000)));
|
||||
|
||||
return FilledButton.tonal(
|
||||
onPressed: () {
|
||||
context.read<TodoProvider>().changeList(widget.title);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onLongPress: () {
|
||||
EditListModal.add(context, widget.title);
|
||||
},
|
||||
style: buttonStyle,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(Icons.list),
|
||||
const SizedBox(width: 10),
|
||||
Text(widget.title)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user