todo save, popup, dismiss show dialog
This commit is contained in:
45
lib/utils/dialog_box.dart
Normal file
45
lib/utils/dialog_box.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:todo/utils/my_button.dart';
|
||||
|
||||
class DialogBox extends StatelessWidget {
|
||||
DialogBox(
|
||||
{Key? key,
|
||||
required this.controller,
|
||||
required this.onSave,
|
||||
required this.onCancel})
|
||||
: super(key: key);
|
||||
|
||||
final controller;
|
||||
VoidCallback onSave;
|
||||
VoidCallback onCancel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
title: Text("New Task"),
|
||||
content: Container(
|
||||
height: 120,
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(), hintText: "Add new task"),
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
MyButton(text: "Cancel", onPressed: onCancel),
|
||||
MyButton(text: "Save", onPressed: onSave),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
18
lib/utils/my_button.dart
Normal file
18
lib/utils/my_button.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MyButton extends StatelessWidget {
|
||||
MyButton({Key? key, required this.text, required this.onPressed})
|
||||
: super(key: key);
|
||||
|
||||
final String text;
|
||||
VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialButton(
|
||||
onPressed: onPressed,
|
||||
color: Theme.of(context).primaryColor,
|
||||
child: Text(text),
|
||||
);
|
||||
}
|
||||
}
|
||||
45
lib/utils/todo_tile.dart
Normal file
45
lib/utils/todo_tile.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ToDoTile extends StatelessWidget {
|
||||
const ToDoTile(
|
||||
{Key? key,
|
||||
required this.taskName,
|
||||
required this.taskCompleted,
|
||||
required this.onChanged})
|
||||
: super(key: key);
|
||||
|
||||
final String taskName;
|
||||
final bool taskCompleted;
|
||||
final Function(bool?)? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(25.0, 25, 25, 0),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(24.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
taskName,
|
||||
style: TextStyle(
|
||||
decoration: taskCompleted
|
||||
? TextDecoration.lineThrough
|
||||
: TextDecoration.none),
|
||||
),
|
||||
Checkbox(
|
||||
value: taskCompleted,
|
||||
onChanged: onChanged,
|
||||
activeColor: Colors.redAccent,
|
||||
)
|
||||
],
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user