diff --git a/lib/src/models/task_model.dart b/lib/src/models/task_model.dart index ada744f..371ffc3 100644 --- a/lib/src/models/task_model.dart +++ b/lib/src/models/task_model.dart @@ -54,7 +54,8 @@ class TaskModel { static TaskModel sample() { return TaskModel( id: '1', - text: 'A task', + text: + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.', done: false, ownerUsername: 'testUser', event: 'testEvent', diff --git a/lib/src/utils.dart b/lib/src/utils.dart new file mode 100644 index 0000000..21e5ca3 --- /dev/null +++ b/lib/src/utils.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +// TODO: migrate to enum https://github.com/AYM1607/do_more/issues/4 +Color getColorFromPriority(int priority) { + switch (priority) { + case 0: + return Color(0xFF06AD12); + break; + case 1: + return Color(0xFFF6A93B); + break; + case 2: + return Color(0xFFF42850); + break; + default: + return Colors.white; + } +} diff --git a/lib/src/widgets/task_list_tile.dart b/lib/src/widgets/task_list_tile.dart index 5555e28..9e8b0fa 100644 --- a/lib/src/widgets/task_list_tile.dart +++ b/lib/src/widgets/task_list_tile.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import '../models/task_model.dart'; +import '../utils.dart'; class TaskListTile extends StatelessWidget { final TaskModel task; + static const _badgeHeight = 25.0; TaskListTile({@required this.task}); @@ -14,33 +16,91 @@ class TaskListTile extends StatelessWidget { height: 116, child: Stack( children: [ - Positioned( - top: 0, - left: 0, - child: Container( - width: 88, - height: 25, - decoration: BoxDecoration( - color: Colors.pink, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(14), + buildBadge(), + Row( + children: [ + SizedBox( + width: 9, + ), + buildTextSection(), + Expanded( + flex: 5, + child: Center( + child: Text('section2'), ), ), - child: Center( - child: Text(task.getPriorityText()), + SizedBox( + width: 9, ), - ), - ) + ], + ), ], ), - decoration: BoxDecoration( - color: Theme.of(context).cardColor, - borderRadius: BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8), + decoration: tileDecoration(context), + ), + ); + } + + Widget buildTextSection() { + return Expanded( + flex: 6, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: _badgeHeight + 4, ), + Text( + task.event, + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + Text( + task.text, + style: TextStyle( + color: Colors.white, + fontSize: 10, + fontWeight: FontWeight.w300, + ), + ), + ], + ), + ); + } + + Widget buildBadge() { + final badgeColor = getColorFromPriority(task.priority); + return Container( + alignment: Alignment.topLeft, + width: 88, + height: _badgeHeight, + decoration: BoxDecoration( + color: badgeColor, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(14), ), ), + child: Center( + child: Text(task.getPriorityText(), + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 13, + color: Colors.white, + )), + ), + ); + } + + BoxDecoration tileDecoration(BuildContext context) { + return BoxDecoration( + color: Theme.of(context).cardColor, + borderRadius: BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8), + ), ); } } diff --git a/test/src/resources/firestore_provider_test.dart b/test/src/resources/firestore_provider_test.dart index cf4ab29..1ffc823 100644 --- a/test/src/resources/firestore_provider_test.dart +++ b/test/src/resources/firestore_provider_test.dart @@ -10,14 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; main() { - final task = TaskModel( - id: '1', - text: 'A task', - done: false, - ownerUsername: 'testUser', - event: 'testEvent', - priority: 1, - ); + final task = TaskModel.sample(); final event = EventModel( id: '1',