Finished text section of the task list tile
This commit is contained in:
parent
7d708f328a
commit
660856317f
4 changed files with 100 additions and 28 deletions
|
|
@ -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',
|
||||
|
|
|
|||
18
lib/src/utils.dart
Normal file
18
lib/src/utils.dart
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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: <Widget>[
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue