-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from dwyl/completed-tasks-#25
Completed tasks
- Loading branch information
Showing
9 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:todolist/models/todoList.dart'; | ||
|
||
class CompletedTasks extends StatelessWidget { | ||
final TodoListModel todoList; | ||
|
||
CompletedTasks({this.todoList}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('Completed Items'), | ||
), | ||
body: ListView( | ||
children: todoList.getCompletedTasks().map((t) { | ||
return Container( | ||
height: 50, | ||
child: Center(child: Text(t.text, style: TextStyle(fontSize: 20)))); | ||
}).toList())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
import 'package:provider/provider.dart'; | ||
import 'package:todolist/models/todoList.dart'; | ||
import 'package:todolist/screens/completed_tasks/completed_tasks.dart'; | ||
import 'package:todolist/screens/tasks/todolist.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class Tasks extends StatelessWidget { | ||
// display completed tasks screen | ||
void _goToCompletedTasks(context, todoList) { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => CompletedTasks(todoList: todoList))); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// get tasks from shared preferences | ||
final TodoListModel todoList = TodoListModel(); | ||
// getTasksFromSharedPrefs call notifyListeners | ||
todoList.getTasksFromSharedPrefs(); | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('TodoList'), | ||
actions: [ | ||
Padding( | ||
padding: EdgeInsets.only(right: 20.0), | ||
child: IconButton( | ||
icon: Icon(Icons.check), | ||
onPressed: () => _goToCompletedTasks(context, todoList))) | ||
], | ||
), | ||
body: ChangeNotifierProvider.value( | ||
value: todoList, | ||
child: TodoListWidget() ,) | ||
); | ||
child: TodoListWidget(), | ||
)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:todolist/models/task.dart'; | ||
import 'package:todolist/models/todoList.dart'; | ||
import 'package:todolist/screens/completed_tasks/completed_tasks.dart'; | ||
|
||
void main() { | ||
testWidgets('Test Todolist widget', (WidgetTester tester) async { | ||
final todoList = TodoListModel(); | ||
final task = TaskModel(text: "task 1"); | ||
final task2 = TaskModel(text: "task 2"); | ||
final task3 = TaskModel(text: "task 3", completed: true); | ||
todoList.addTaks(task); | ||
todoList.addTaks(task2); | ||
todoList.addTaks(task3); | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: CompletedTasks(todoList: todoList ) | ||
), | ||
); | ||
|
||
final textTask1 = find.text('task 1'); | ||
final textTask2 = find.text('task 2'); | ||
final textTask3 = find.text('task 3'); | ||
expect(textTask1, findsNothing); | ||
expect(textTask2, findsNothing); | ||
expect(textTask3, findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters