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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
mixin Tile {
|
mixin Tile {
|
||||||
BoxDecoration tileDecoration(BuildContext context) {
|
BoxDecoration tileDecoration(Color color) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: Theme.of(context).cardColor,
|
color: color,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topRight: Radius.circular(8),
|
topRight: Radius.circular(8),
|
||||||
bottomRight: Radius.circular(8),
|
bottomRight: Radius.circular(8),
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ class EventModel {
|
||||||
/// The amount of low priority pending tasks linked to this event.
|
/// The amount of low priority pending tasks linked to this event.
|
||||||
final int lowPriority;
|
final int lowPriority;
|
||||||
|
|
||||||
|
int get pendingTasks => highPriority + mediumPriority + lowPriority;
|
||||||
|
|
||||||
EventModel({
|
EventModel({
|
||||||
this.id,
|
this.id,
|
||||||
@required this.name,
|
@required this.name,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,13 @@ class _EventsScreenState extends State<EventsScreen> {
|
||||||
name: 'Math',
|
name: 'Math',
|
||||||
pendigTasks: 3,
|
pendigTasks: 3,
|
||||||
media: <String>[],
|
media: <String>[],
|
||||||
when: <bool>[],
|
when: <bool>[
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
],
|
||||||
highPriority: 2,
|
highPriority: 2,
|
||||||
mediumPriority: 1,
|
mediumPriority: 1,
|
||||||
lowPriority: 0,
|
lowPriority: 0,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
import 'package:rxdart/rxdart.dart';
|
||||||
|
|
||||||
|
import './models/event_model.dart';
|
||||||
import './models/task_model.dart';
|
import './models/task_model.dart';
|
||||||
import './services/upload_status_service.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 {
|
class Validators {
|
||||||
final validateStringNotEmpty = StreamTransformer<String, String>.fromHandlers(
|
final validateStringNotEmpty = StreamTransformer<String, String>.fromHandlers(
|
||||||
handleData: (String string, EventSink<String> sink) {
|
handleData: (String string, EventSink<String> sink) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
import '../models/event_model.dart';
|
import '../models/event_model.dart';
|
||||||
import '../mixins/tile_mixin.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 {
|
class EventListTile extends StatelessWidget with Tile {
|
||||||
final EventModel event;
|
final EventModel event;
|
||||||
|
|
@ -16,27 +18,136 @@ class EventListTile extends StatelessWidget with Tile {
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 85,
|
height: 85,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
overflow: Overflow.visible,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
event.name,
|
event.name,
|
||||||
style: kTileBigTextStyle,
|
style: kTileBigTextStyle,
|
||||||
),
|
),
|
||||||
|
_OcurranceIdicator(ocurrance: event.when),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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}'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Column(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
getPriorityIndicator(),
|
||||||
|
getTasksIndicator(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
decoration: tileDecoration(context),
|
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