Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
Expand Down
8 changes: 2 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import 'package:flutter/material.dart';
import 'package:workshop_task/screen/todo_screen.dart';

void main() {
runApp(const MyApp());
runApp(const MaterialApp(home: TodoScreen()));
}

class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// is not restarted.
primarySwatch: Colors.blue,
),
//GO to correct screen.
home: Container(),
);
}
}
6 changes: 3 additions & 3 deletions lib/models/todo_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ class TodoList {
final List<Todo> _allTodos = [];

List<Todo> allTodos() {
//TODO:Add logic to complete
return _allTodos;
}

void addTodo(Todo todo) {
//TODO:Add logic to add a todo
_allTodos.add(todo);
}

void deleteTodo(Todo todo) {
//TODO:Add logic to delete todo
_allTodos.remove(todo);
}
}
92 changes: 81 additions & 11 deletions lib/screen/todo_screen.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,96 @@
import 'package:flutter/material.dart';
import 'package:workshop_task/models/todo.dart';
import 'package:workshop_task/models/todo_list.dart';
import 'package:workshop_task/widgets/add_todo_dialogue.dart';
import 'package:workshop_task/widgets/todo_list_item.dart';

class TodoScreen extends StatefulWidget {
const TodoScreen({Key key}) : super(key: key);

@override
_TodoScreenState createState() => _TodoScreenState();
}

class _TodoScreenState extends State<TodoScreen> {
final TextEditingController titlecontroller = TextEditingController();
final TextEditingController desccontroller = TextEditingController();
Widget taskdisplay = Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
Center(
child: Center(child: Text("Yay! No Pending Tasks")),
)
],
);
TodoList todoList = TodoList();

Todo content;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Your Todos"),
),
//TODO: Add todo button with this icon => "+".
floatingActionButton: const FloatingActionButton(),
body: //TODO: Add list view displaying all todo.
Container(),
);
var scaffold = Scaffold(
appBar: AppBar(
title: const Text("My Tasks"),
),
floatingActionButton: FloatingActionButton(
child: const Icon(
Icons.add,
size: 35,
color: Colors.black,
),
backgroundColor: Colors.amber,
onPressed: () {
showDialog(
context: context,
builder: (context) {
return const AddTodoDialogue();
}).then((value) {
if (value != null) {
setState(() {
todoList.addTodo(value);
});
}
});
},
),
body: todoList.allTodos().isEmpty
? taskdisplay
: ListView.builder(
itemBuilder: ((context, index) {
return GestureDetector(
onDoubleTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text("DELETE TASK"),
content: const Text(
"Are you sure you want to delete this task"),
actions: [
TextButton(
child: const Text("Yes"),
onPressed: () {
setState(() {
todoList.deleteTodo(
todoList.allTodos()[index]);
Navigator.of(context).pop();
});
}),
TextButton(
child: const Text("No"),
onPressed: () {
Navigator.of(context).pop();
})
],
);
});
},
child: TodoListItem(
index: index,
todo: todoList.allTodos()[index],
),
);
}),
itemCount: todoList.allTodos().length,
));
return scaffold;
}
}
66 changes: 53 additions & 13 deletions lib/widgets/add_todo_dialogue.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:workshop_task/models/todo.dart';
import 'package:workshop_task/models/todo_list.dart';

class AddTodoDialogue extends StatefulWidget {
const AddTodoDialogue({Key key}) : super(key: key);
Expand All @@ -8,20 +10,58 @@ class AddTodoDialogue extends StatefulWidget {
}

class _AddTodoDialogueState extends State<AddTodoDialogue> {
final TextEditingController titlecontroller = TextEditingController();
final TextEditingController desccontroller = TextEditingController();
TodoList listItem = TodoList();
Widget taskdisplay = Row(
children: const [
Center(
child: Center(child: Text("Yay! No Pending Tasks")),
)
],
);

@override
Widget build(BuildContext context) {
return Container(
width: 200,
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
//TODO: Take input of title. and description.
TextField(),
TextField(),
TextButton(),
],
),
);
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
child: SizedBox(
height: 300,
width: 300,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: "Enter title",
),
controller: titlecontroller,
),
TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: "Enter description",
),
controller: desccontroller,
),
TextButton(
child: const Text("Add"),
onPressed: () {
if (titlecontroller.text.isNotEmpty &&
desccontroller.text.isNotEmpty) {
setState(() {
Todo content = Todo(
title: titlecontroller.text,
description: desccontroller.text);
Navigator.of(context).pop(content);
});
}
}),
],
),
)));
}
}
6 changes: 4 additions & 2 deletions lib/widgets/todo_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class TodoListItem extends StatelessWidget {

@override
Widget build(BuildContext context) {
//TODO: display title and description of todo.
return Container();
return ListTile(
title: Text(todo.title),
subtitle: Text(todo.description),
);
}
}
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -228,13 +235,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -337,21 +337,21 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.17.12"
version: "1.19.5"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
version: "0.4.8"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
version: "0.4.9"
typed_data:
dependency: transitive
description:
Expand Down