Finished the event list tile
This commit is contained in:
parent
86742a6746
commit
2b1ac6d48c
6 changed files with 136 additions and 7 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
mixin Tile {
|
||||
BoxDecoration tileDecoration(BuildContext context) {
|
||||
BoxDecoration tileDecoration(Color color) {
|
||||
return BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
color: color,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(8),
|
||||
bottomRight: Radius.circular(8),
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ class EventModel {
|
|||
/// The amount of low priority pending tasks linked to this event.
|
||||
final int lowPriority;
|
||||
|
||||
int get pendingTasks => highPriority + mediumPriority + lowPriority;
|
||||
|
||||
EventModel({
|
||||
this.id,
|
||||
@required this.name,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,13 @@ class _EventsScreenState extends State<EventsScreen> {
|
|||
name: 'Math',
|
||||
pendigTasks: 3,
|
||||
media: <String>[],
|
||||
when: <bool>[],
|
||||
when: <bool>[
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
],
|
||||
highPriority: 2,
|
||||
mediumPriority: 1,
|
||||
lowPriority: 0,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:async';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
|
||||
import './models/event_model.dart';
|
||||
import './models/task_model.dart';
|
||||
import './services/upload_status_service.dart';
|
||||
|
||||
|
|
@ -56,6 +57,15 @@ Color getColorFromPriority(TaskPriority priority) {
|
|||
}
|
||||
}
|
||||
|
||||
Color getColorFromEvent(EventModel event) {
|
||||
if (event.highPriority != 0) {
|
||||
return kHighPriorityColor;
|
||||
} else if (event.mediumPriority != 0) {
|
||||
return kMediumPriorityColor;
|
||||
}
|
||||
return kLowPriorityColor;
|
||||
}
|
||||
|
||||
class Validators {
|
||||
final validateStringNotEmpty = StreamTransformer<String, String>.fromHandlers(
|
||||
handleData: (String string, EventSink<String> sink) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
import '../models/event_model.dart';
|
||||
import '../mixins/tile_mixin.dart';
|
||||
import '../utils.dart';
|
||||
import '../utils.dart' show kTileBigTextStyle, kBlueGradient, getColorFromEvent;
|
||||
import '../widgets/action_button.dart';
|
||||
|
||||
class EventListTile extends StatelessWidget with Tile {
|
||||
final EventModel event;
|
||||
|
|
@ -16,27 +18,136 @@ class EventListTile extends StatelessWidget with Tile {
|
|||
child: Container(
|
||||
height: 85,
|
||||
child: Stack(
|
||||
overflow: Overflow.visible,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
event.name,
|
||||
style: kTileBigTextStyle,
|
||||
),
|
||||
_OcurranceIdicator(ocurrance: event.when),
|
||||
],
|
||||
),
|
||||
Column(),
|
||||
],
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 80,
|
||||
),
|
||||
ActionButton(
|
||||
color: Colors.white,
|
||||
textColor: Colors.black,
|
||||
text: 'Resources',
|
||||
leadingIconData: FontAwesomeIcons.listAlt,
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushNamed('event/${event.name}'),
|
||||
),
|
||||
],
|
||||
),
|
||||
decoration: tileDecoration(context),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
getPriorityIndicator(),
|
||||
getTasksIndicator(),
|
||||
],
|
||||
),
|
||||
decoration: tileDecoration(Theme.of(context).cardColor),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getPriorityIndicator() {
|
||||
final color = getColorFromEvent(event);
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Container(
|
||||
width: 15,
|
||||
decoration: tileDecoration(color),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget getTasksIndicator() {
|
||||
return Positioned(
|
||||
bottom: 75,
|
||||
right: -10,
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${event.pendingTasks}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
width: 30,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
gradient: kBlueGradient,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _OcurranceIdicator extends StatelessWidget {
|
||||
static const kDayLetters = ['M', 'T', 'W', 'Th', 'F'];
|
||||
// A list that visually represents when an event occurs.
|
||||
final List<bool> ocurrance;
|
||||
|
||||
_OcurranceIdicator({@required this.ocurrance})
|
||||
: assert(ocurrance != null),
|
||||
assert(ocurrance.length == 5);
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> rowChildren = [];
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
rowChildren.add(
|
||||
Container(
|
||||
height: 25,
|
||||
width: 25,
|
||||
decoration: BoxDecoration(
|
||||
color: ocurrance[i] ? Colors.white : Colors.grey,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
kDayLetters[i],
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (i != 4) {
|
||||
rowChildren.add(
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: rowChildren,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class TaskListTile extends StatelessWidget with Tile {
|
|||
),
|
||||
],
|
||||
),
|
||||
decoration: tileDecoration(context),
|
||||
decoration: tileDecoration(Theme.of(context).cardColor),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue