Show archived/deleted
This commit is contained in:
parent
04f50a1034
commit
c9794f5717
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
|
|
@ -49,135 +48,8 @@ class _TaskViewState extends State<TaskView> {
|
|||
Widget build(BuildContext context) {
|
||||
final viewModel = widget.viewModel;
|
||||
final task = viewModel.task;
|
||||
final project = viewModel.project;
|
||||
final client = viewModel.client;
|
||||
final company = viewModel.company;
|
||||
final invoice = viewModel.state.invoiceState.map[task.invoiceId];
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
final Map<String, String> fields = {};
|
||||
|
||||
// TODO Remove isNotEmpty check in v2
|
||||
if (company.taskStatusMap.isNotEmpty && (task.taskStatusId ?? 0) > 0) {
|
||||
fields[localization.status] =
|
||||
company.taskStatusMap[task.taskStatusId]?.name ?? '';
|
||||
}
|
||||
|
||||
if (task.customValue1.isNotEmpty) {
|
||||
final label1 = company.getCustomFieldLabel(CustomFieldType.task1);
|
||||
fields[label1] = task.customValue1;
|
||||
}
|
||||
if (task.customValue2.isNotEmpty) {
|
||||
final label2 = company.getCustomFieldLabel(CustomFieldType.task2);
|
||||
fields[label2] = task.customValue2;
|
||||
}
|
||||
|
||||
List<Widget> _buildView() {
|
||||
final widgets = <Widget>[
|
||||
TwoValueHeader(
|
||||
backgroundColor: task.isInvoiced
|
||||
? Colors.green
|
||||
: task.isRunning ? Colors.blue : null,
|
||||
label1: localization.duration,
|
||||
value1: formatDuration(task.calculateDuration),
|
||||
label2: localization.amount,
|
||||
value2: formatNumber(
|
||||
task.calculateAmount(taskRateSelector(
|
||||
company: company, project: project, client: client)),
|
||||
context,
|
||||
roundToTwo: true),
|
||||
),
|
||||
];
|
||||
|
||||
if (client != null) {
|
||||
widgets.addAll([
|
||||
Material(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListTile(
|
||||
title: EntityStateTitle(entity: client),
|
||||
leading: Icon(getEntityIcon(EntityType.client), size: 18.0),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
onTap: () => viewModel.onClientPressed(context),
|
||||
onLongPress: () => viewModel.onClientPressed(context, true),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (project != null) {
|
||||
widgets.addAll([
|
||||
Material(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListTile(
|
||||
title: EntityStateTitle(entity: project),
|
||||
leading: Icon(getEntityIcon(EntityType.project), size: 18.0),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
onTap: () => viewModel.onProjectPressed(context),
|
||||
onLongPress: () => viewModel.onProjectPressed(context, true),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (invoice != null) {
|
||||
widgets.addAll([
|
||||
Material(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListTile(
|
||||
title: EntityStateTitle(entity: invoice),
|
||||
leading: Icon(getEntityIcon(EntityType.invoice), size: 18.0),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
onTap: () => viewModel.onInvoicePressed(context),
|
||||
onLongPress: () => viewModel.onInvoicePressed(context, true),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (task.description.isNotEmpty) {
|
||||
widgets.addAll([
|
||||
IconMessage(task.description),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (fields.isNotEmpty) {
|
||||
widgets.addAll([
|
||||
FieldGrid(fields),
|
||||
]);
|
||||
}
|
||||
|
||||
final items = task.taskTimes;
|
||||
items.reversed.forEach((taskTime) {
|
||||
widgets.addAll([
|
||||
TaskTimeListTile(
|
||||
task: task,
|
||||
taskTime: taskTime,
|
||||
onTap: (BuildContext context) => company.user.canEditEntity(task)
|
||||
? viewModel.onEditPressed(context, taskTime)
|
||||
: null,
|
||||
)
|
||||
]);
|
||||
});
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
viewModel.onBackPressed();
|
||||
|
|
@ -189,6 +61,142 @@ class _TaskViewState extends State<TaskView> {
|
|||
),
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final project = viewModel.project;
|
||||
final client = viewModel.client;
|
||||
final company = viewModel.company;
|
||||
final invoice = viewModel.state.invoiceState.map[task.invoiceId];
|
||||
|
||||
final Map<String, String> fields = {};
|
||||
|
||||
// TODO Remove isNotEmpty check in v2
|
||||
if (company.taskStatusMap.isNotEmpty &&
|
||||
(task.taskStatusId ?? 0) > 0) {
|
||||
fields[localization.status] =
|
||||
company.taskStatusMap[task.taskStatusId]?.name ?? '';
|
||||
}
|
||||
|
||||
if (task.customValue1.isNotEmpty) {
|
||||
final label1 = company.getCustomFieldLabel(CustomFieldType.task1);
|
||||
fields[label1] = task.customValue1;
|
||||
}
|
||||
if (task.customValue2.isNotEmpty) {
|
||||
final label2 = company.getCustomFieldLabel(CustomFieldType.task2);
|
||||
fields[label2] = task.customValue2;
|
||||
}
|
||||
|
||||
List<Widget> _buildView() {
|
||||
final widgets = <Widget>[
|
||||
TwoValueHeader(
|
||||
backgroundColor: task.isInvoiced
|
||||
? Colors.green
|
||||
: task.isRunning ? Colors.blue : null,
|
||||
label1: localization.duration,
|
||||
value1: formatDuration(task.calculateDuration),
|
||||
label2: localization.amount,
|
||||
value2: formatNumber(
|
||||
task.calculateAmount(taskRateSelector(
|
||||
company: company, project: project, client: client)),
|
||||
context,
|
||||
roundToTwo: true),
|
||||
),
|
||||
];
|
||||
|
||||
if (client != null) {
|
||||
widgets.addAll([
|
||||
Material(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListTile(
|
||||
title: EntityStateTitle(entity: client),
|
||||
leading:
|
||||
Icon(getEntityIcon(EntityType.client), size: 18.0),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
onTap: () => viewModel.onClientPressed(context),
|
||||
onLongPress: () =>
|
||||
viewModel.onClientPressed(context, true),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (project != null) {
|
||||
widgets.addAll([
|
||||
Material(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListTile(
|
||||
title: EntityStateTitle(entity: project),
|
||||
leading:
|
||||
Icon(getEntityIcon(EntityType.project), size: 18.0),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
onTap: () => viewModel.onProjectPressed(context),
|
||||
onLongPress: () =>
|
||||
viewModel.onProjectPressed(context, true),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (invoice != null) {
|
||||
widgets.addAll([
|
||||
Material(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListTile(
|
||||
title: EntityStateTitle(entity: invoice),
|
||||
leading:
|
||||
Icon(getEntityIcon(EntityType.invoice), size: 18.0),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
onTap: () => viewModel.onInvoicePressed(context),
|
||||
onLongPress: () =>
|
||||
viewModel.onInvoicePressed(context, true),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (task.description.isNotEmpty) {
|
||||
widgets.addAll([
|
||||
IconMessage(task.description),
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
height: 12.0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (fields.isNotEmpty) {
|
||||
widgets.addAll([
|
||||
FieldGrid(fields),
|
||||
]);
|
||||
}
|
||||
|
||||
final items = task.taskTimes;
|
||||
items.reversed.forEach((taskTime) {
|
||||
widgets.addAll([
|
||||
TaskTimeListTile(
|
||||
task: task,
|
||||
taskTime: taskTime,
|
||||
onTap: (BuildContext context) =>
|
||||
company.user.canEditEntity(task)
|
||||
? viewModel.onEditPressed(context, taskTime)
|
||||
: null,
|
||||
)
|
||||
]);
|
||||
});
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => viewModel.onRefreshed(context),
|
||||
child: Container(
|
||||
|
|
|
|||
Loading…
Reference in New Issue