Tasks: make overdue secondary text red

Also add some logic to display tasks due today as "Due today"
Tasks: fixes
master
Andrew P Maney 5 years ago committed by Tom Hacohen
parent 5eea4e89a5
commit 0b5274887f

@ -58,6 +58,7 @@ export default React.memo(function TaskListItem(props: PropsType) {
<ListItem <ListItem
primaryText={title} primaryText={title}
secondaryText={task.dueDate && `Due ${moment().to(task.dueDate.toJSDate())}`} secondaryText={task.dueDate && `Due ${moment().to(task.dueDate.toJSDate())}`}
secondaryTextColor={task.overdue ? 'error' : 'textSecondary'}
onClick={() => onClick(task)} onClick={() => onClick(task)}
leftIcon={ leftIcon={
<Checkbox <Checkbox

@ -230,6 +230,16 @@ export class TaskType extends EventType {
return this.dueDate && moment(this.dueDate.toJSDate()).isSameOrBefore(moment(), 'day'); return this.dueDate && moment(this.dueDate.toJSDate()).isSameOrBefore(moment(), 'day');
} }
get overdue() {
if (!this.dueDate) {
return false;
}
const dueDate = moment(this.dueDate.toJSDate());
const now = moment();
return (this.dueDate.isDate) ? dueDate.isBefore(now, 'day') : dueDate.isBefore(now);
}
public clone() { public clone() {
const ret = new TaskType(new ICAL.Component(this.component.toJSON())); const ret = new TaskType(new ICAL.Component(this.component.toJSON()));
ret.color = this.color; ret.color = this.color;

@ -46,6 +46,7 @@ interface ListItemPropsType {
insetChildren?: boolean; insetChildren?: boolean;
nestedItems?: React.ReactNode[]; nestedItems?: React.ReactNode[];
selected?: boolean; selected?: boolean;
secondaryTextColor?: 'initial' | 'inherit' | 'primary' | 'secondary' | 'textPrimary' | 'textSecondary' | 'error';
} }
export const ListItem = React.memo(function ListItem(_props: ListItemPropsType) { export const ListItem = React.memo(function ListItem(_props: ListItemPropsType) {
@ -62,6 +63,7 @@ export const ListItem = React.memo(function ListItem(_props: ListItemPropsType)
insetChildren, insetChildren,
nestedItems, nestedItems,
selected, selected,
secondaryTextColor,
} = _props; } = _props;
const extraProps = (onClick || href) ? { const extraProps = (onClick || href) ? {
@ -84,7 +86,7 @@ export const ListItem = React.memo(function ListItem(_props: ListItemPropsType)
{leftIcon} {leftIcon}
</ListItemIcon> </ListItemIcon>
)} )}
<ListItemText inset={insetChildren} primary={primaryText} secondary={secondaryText}> <ListItemText inset={insetChildren} primary={primaryText} secondary={secondaryText} secondaryTypographyProps={{ color: secondaryTextColor }}>
{children} {children}
</ListItemText> </ListItemText>
{rightIcon && ( {rightIcon && (

Loading…
Cancel
Save