Tasks
This commit is contained in:
parent
42854daf1b
commit
c6219345aa
|
|
@ -190,8 +190,7 @@ abstract class TaskEntity extends Object
|
||||||
..invoiceId = null
|
..invoiceId = null
|
||||||
..isRunning = false
|
..isRunning = false
|
||||||
..duration = 0
|
..duration = 0
|
||||||
..timeLog = '[]'
|
..timeLog = '[]');
|
||||||
..description = '');
|
|
||||||
|
|
||||||
TaskEntity toggle() => isRunning ? stop() : start();
|
TaskEntity toggle() => isRunning ? stop() : start();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,15 +240,11 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final String entityId = matches[index];
|
final String entityId = matches[index];
|
||||||
final task = state.taskState.map[entityId];
|
final task = state.taskState.map[entityId];
|
||||||
final project = state.projectState.map[task.projectId];
|
|
||||||
final client = state.clientState.map[task.clientId];
|
|
||||||
return TaskListItem(
|
return TaskListItem(
|
||||||
userCompany: state.userCompany,
|
user: state.user,
|
||||||
onCheckboxChanged: (checked) => _toggleEntity(task),
|
onCheckboxChanged: (checked) => _toggleEntity(task),
|
||||||
isChecked: _selected.contains(task),
|
isChecked: _selected.contains(task),
|
||||||
project: project,
|
|
||||||
task: task,
|
task: task,
|
||||||
client: client,
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_selected.isNotEmpty) {
|
if (_selected.isNotEmpty) {
|
||||||
_toggleEntity(task);
|
_toggleEntity(task);
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,20 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/actions_menu_button.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/dismissible_entity.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/entity_state_label.dart';
|
import 'package:invoiceninja_flutter/ui/app/entity_state_label.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/live_text.dart';
|
import 'package:invoiceninja_flutter/ui/app/live_text.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/app/dismissible_entity.dart';
|
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
|
||||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||||
|
|
||||||
class TaskListItem extends StatelessWidget {
|
class TaskListItem extends StatelessWidget {
|
||||||
const TaskListItem({
|
const TaskListItem({
|
||||||
@required this.userCompany,
|
@required this.user,
|
||||||
@required this.client,
|
|
||||||
@required this.project,
|
|
||||||
@required this.task,
|
@required this.task,
|
||||||
@required this.filter,
|
@required this.filter,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
|
|
@ -24,43 +23,29 @@ class TaskListItem extends StatelessWidget {
|
||||||
this.isChecked = false,
|
this.isChecked = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final UserCompanyEntity userCompany;
|
final UserEntity user;
|
||||||
final ClientEntity client;
|
|
||||||
final ProjectEntity project;
|
|
||||||
final GestureTapCallback onTap;
|
final GestureTapCallback onTap;
|
||||||
final GestureTapCallback onLongPress;
|
final GestureTapCallback onLongPress;
|
||||||
final Function(bool) onCheckboxChanged;
|
|
||||||
final bool isChecked;
|
|
||||||
final TaskEntity task;
|
final TaskEntity task;
|
||||||
final String filter;
|
final String filter;
|
||||||
|
final Function(bool) onCheckboxChanged;
|
||||||
|
final bool isChecked;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final state = StoreProvider.of<AppState>(context).state;
|
final store = StoreProvider.of<AppState>(context);
|
||||||
|
final state = store.state;
|
||||||
final uiState = state.uiState;
|
final uiState = state.uiState;
|
||||||
final taskUIState = uiState.taskUIState;
|
final taskUIState = uiState.taskUIState;
|
||||||
|
final client = state.clientState.get(task.clientId);
|
||||||
final CompanyEntity company = state.company;
|
|
||||||
final taskStatus = company.taskStatusMap[task.taskStatusId];
|
|
||||||
|
|
||||||
final localization = AppLocalization.of(context);
|
|
||||||
final filterMatch = filter != null && filter.isNotEmpty
|
final filterMatch = filter != null && filter.isNotEmpty
|
||||||
? task.matchesFilterValue(filter)
|
? (task.matchesFilterValue(filter) ?? client.matchesFilterValue(filter))
|
||||||
: null;
|
: null;
|
||||||
final listUIState = taskUIState.listUIState;
|
final listUIState = taskUIState.listUIState;
|
||||||
final isInMultiselect = listUIState.isInMultiselect();
|
final isInMultiselect = listUIState.isInMultiselect();
|
||||||
final showCheckbox = onCheckboxChanged != null || isInMultiselect;
|
final showCheckbox = onCheckboxChanged != null || isInMultiselect;
|
||||||
|
final textStyle = TextStyle(fontSize: 16);
|
||||||
//final subtitle = filterMatch ?? client?.displayName ?? task.description;
|
final subtitle = client.displayName;
|
||||||
String subtitle;
|
|
||||||
if (filterMatch != null) {
|
|
||||||
subtitle = filterMatch;
|
|
||||||
} else if (client != null) {
|
|
||||||
subtitle = client.displayName;
|
|
||||||
if (project != null) {
|
|
||||||
subtitle += ' • ' + project.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DismissibleEntity(
|
return DismissibleEntity(
|
||||||
isSelected: isDesktop(context) &&
|
isSelected: isDesktop(context) &&
|
||||||
|
|
@ -68,82 +53,140 @@ class TaskListItem extends StatelessWidget {
|
||||||
(uiState.isEditing
|
(uiState.isEditing
|
||||||
? taskUIState.editing.id
|
? taskUIState.editing.id
|
||||||
: taskUIState.selectedId),
|
: taskUIState.selectedId),
|
||||||
userCompany: userCompany,
|
userCompany: store.state.userCompany,
|
||||||
entity: task,
|
entity: task,
|
||||||
child: ListTile(
|
child: LayoutBuilder(
|
||||||
onTap: () => onTap != null
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
? onTap()
|
return constraints.maxWidth > kTableListWidthCutoff
|
||||||
: selectEntity(entity: task, context: context),
|
? InkWell(
|
||||||
onLongPress: () => onLongPress != null
|
onTap: () => onTap != null
|
||||||
? onLongPress()
|
? onTap()
|
||||||
: selectEntity(entity: task, context: context, longPress: true),
|
: selectEntity(entity: task, context: context),
|
||||||
leading: showCheckbox
|
onLongPress: () => onLongPress != null
|
||||||
? IgnorePointer(
|
? onLongPress()
|
||||||
ignoring: listUIState.isInMultiselect(),
|
: selectEntity(
|
||||||
child: Checkbox(
|
entity: task, context: context, longPress: true),
|
||||||
value: isChecked,
|
child: Padding(
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
padding: const EdgeInsets.only(
|
||||||
onChanged: (value) => onCheckboxChanged(value),
|
left: 10,
|
||||||
activeColor: Theme.of(context).accentColor,
|
right: 28,
|
||||||
|
top: 4,
|
||||||
|
bottom: 4,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 16),
|
||||||
|
child: showCheckbox
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 20),
|
||||||
|
child: IgnorePointer(
|
||||||
|
ignoring: listUIState.isInMultiselect(),
|
||||||
|
child: Checkbox(
|
||||||
|
value: isChecked,
|
||||||
|
materialTapTargetSize:
|
||||||
|
MaterialTapTargetSize.shrinkWrap,
|
||||||
|
onChanged: (value) =>
|
||||||
|
onCheckboxChanged(value),
|
||||||
|
activeColor: Theme.of(context).accentColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ActionMenuButton(
|
||||||
|
entityActions: task.getActions(
|
||||||
|
userCompany: state.userCompany),
|
||||||
|
isSaving: false,
|
||||||
|
entity: task,
|
||||||
|
onSelected: (context, action) =>
|
||||||
|
handleEntityAction(context, task, action),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
if (!task.isActive) EntityStateLabel(task)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
width: 120,
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
task.description +
|
||||||
|
(task.documents.isNotEmpty ? ' 📎' : ''),
|
||||||
|
style: textStyle),
|
||||||
|
Text(
|
||||||
|
subtitle ?? filterMatch,
|
||||||
|
maxLines: 3,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.subtitle2,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
LiveText(() {
|
||||||
|
return formatNumber(task.listDisplayAmount, context,
|
||||||
|
formatNumberType: FormatNumberType.duration);
|
||||||
|
}, style: Theme.of(context).textTheme.headline6),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: ListTile(
|
||||||
title: Container(
|
onTap: () => onTap != null
|
||||||
width: MediaQuery.of(context).size.width,
|
? onTap()
|
||||||
child: Row(
|
: selectEntity(entity: task, context: context),
|
||||||
children: <Widget>[
|
onLongPress: () => onLongPress != null
|
||||||
Expanded(
|
? onLongPress()
|
||||||
child: Text(
|
: selectEntity(
|
||||||
task.description.isNotEmpty
|
entity: task, context: context, longPress: true),
|
||||||
? task.description
|
leading: showCheckbox
|
||||||
: formatDate(convertTimestampToDateString(task.updatedAt),
|
? IgnorePointer(
|
||||||
context),
|
ignoring: listUIState.isInMultiselect(),
|
||||||
overflow: TextOverflow.ellipsis,
|
child: Checkbox(
|
||||||
style: Theme.of(context).textTheme.headline6,
|
value: isChecked,
|
||||||
|
materialTapTargetSize:
|
||||||
|
MaterialTapTargetSize.shrinkWrap,
|
||||||
|
onChanged: (value) => onCheckboxChanged(value),
|
||||||
|
activeColor: Theme.of(context).accentColor,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
title: Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
task.description + (task.documents.isNotEmpty ? ' 📎' : ''),
|
||||||
|
style: Theme.of(context).textTheme.headline6,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
LiveText(() {
|
||||||
|
return formatNumber(task.listDisplayAmount, context,
|
||||||
|
formatNumberType: FormatNumberType.duration);
|
||||||
|
}, style: Theme.of(context).textTheme.headline6),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
subtitle: Column(
|
||||||
LiveText(() {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
return formatNumber(task.listDisplayAmount, context,
|
children: <Widget>[
|
||||||
formatNumberType: FormatNumberType.duration);
|
Text(
|
||||||
}, style: Theme.of(context).textTheme.headline6),
|
subtitle ?? filterMatch,
|
||||||
],
|
maxLines: 3,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
subtitle: Column(
|
EntityStateLabel(task),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
],
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: subtitle != null && subtitle.isNotEmpty
|
|
||||||
? Text(
|
|
||||||
subtitle,
|
|
||||||
maxLines: 3,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
),
|
),
|
||||||
Text(
|
);
|
||||||
task.isInvoiced
|
}),
|
||||||
? localization.invoiced
|
|
||||||
: task.isRunning
|
|
||||||
? localization.running
|
|
||||||
: taskStatus != null
|
|
||||||
? taskStatus.name
|
|
||||||
: localization.logged,
|
|
||||||
style: TextStyle(
|
|
||||||
color: task.isInvoiced
|
|
||||||
? Colors.green
|
|
||||||
: task.isRunning
|
|
||||||
? Colors.blue
|
|
||||||
: Colors.grey,
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
EntityStateLabel(task),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,10 @@ class TaskListBuilder extends StatelessWidget {
|
||||||
final isInMultiselect = listUIState.isInMultiselect();
|
final isInMultiselect = listUIState.isInMultiselect();
|
||||||
|
|
||||||
return TaskListItem(
|
return TaskListItem(
|
||||||
userCompany: viewModel.state.userCompany,
|
|
||||||
filter: viewModel.filter,
|
filter: viewModel.filter,
|
||||||
task: task,
|
task: task,
|
||||||
client: viewModel.clientMap[task.clientId] ?? ClientEntity(),
|
|
||||||
project: viewModel.state.projectState.map[task.projectId],
|
|
||||||
isChecked: isInMultiselect && listUIState.isSelected(task.id),
|
isChecked: isInMultiselect && listUIState.isSelected(task.id),
|
||||||
|
user: state.user,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue