mirror of
https://github.com/go-vikunja/app
synced 2024-06-05 20:19:51 +00:00
added priority to task subtitle
This commit is contained in:
parent
b7246cf433
commit
347bd6cd66
|
@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
|
|||
import 'package:vikunja_app/models/task.dart';
|
||||
import 'package:vikunja_app/utils/misc.dart';
|
||||
import 'package:vikunja_app/pages/list/task_edit.dart';
|
||||
import 'package:vikunja_app/utils/priority.dart';
|
||||
|
||||
import '../stores/project_store.dart';
|
||||
|
||||
|
@ -34,6 +35,31 @@ class TaskTile extends StatefulWidget {
|
|||
TaskTileState createState() => TaskTileState(this.task);
|
||||
}
|
||||
|
||||
Widget? _buildTaskSubtitle(Task? task, bool showInfo) {
|
||||
Duration? durationUntilDue = task?.dueDate?.difference(DateTime.now());
|
||||
|
||||
if(task == null)
|
||||
return null;
|
||||
|
||||
List<TextSpan> texts = [];
|
||||
|
||||
if(showInfo && task.hasDueDate) {
|
||||
texts.add(TextSpan(text: "Due " + durationToHumanReadable(durationUntilDue!), style: durationUntilDue.isNegative ? TextStyle(color: Colors.red) : null));
|
||||
}
|
||||
if(task.priority != null && task.priority != 0) {
|
||||
texts.add(TextSpan(text: " !" + priorityToString(task.projectId), style: TextStyle(color: Colors.orange)));
|
||||
}
|
||||
|
||||
if(texts.isEmpty && task.description.isNotEmpty) {
|
||||
return Text(task.description);
|
||||
}
|
||||
|
||||
if(texts.isNotEmpty) {
|
||||
return RichText(text: TextSpan(children: texts));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
||||
Task _currentTask;
|
||||
|
||||
|
@ -43,7 +69,6 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
|||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final taskState = Provider.of<ProjectProvider>(context);
|
||||
Duration? durationUntilDue = _currentTask.dueDate?.difference(DateTime.now());
|
||||
if (_currentTask.loading) {
|
||||
return ListTile(
|
||||
leading: Padding(
|
||||
|
@ -65,7 +90,17 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
|||
),
|
||||
);
|
||||
}
|
||||
return CheckboxListTile(
|
||||
return
|
||||
IntrinsicHeight(child:
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
width: 4.0, // Adjust the width of the red line
|
||||
color: widget.task.color,
|
||||
//margin: EdgeInsets.only(left: 10.0),
|
||||
),
|
||||
Flexible(child: CheckboxListTile(
|
||||
title: widget.showInfo ?
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
|
@ -82,11 +117,7 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
|||
) : Text(_currentTask.title),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: _currentTask.done,
|
||||
subtitle: widget.showInfo && _currentTask.hasDueDate ?
|
||||
Text("Due " + durationToHumanReadable(durationUntilDue!), style: durationUntilDue.isNegative ? TextStyle(color: Colors.red) : null,)
|
||||
: _currentTask.description.isEmpty
|
||||
? null
|
||||
: Text(_currentTask.description),
|
||||
subtitle: _buildTaskSubtitle(widget.task, widget.showInfo),
|
||||
secondary:
|
||||
IconButton(icon: Icon(Icons.settings), onPressed: () {
|
||||
Navigator.push<Task>(
|
||||
|
@ -102,7 +133,7 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
|||
})).whenComplete(() => widget.onEdit());
|
||||
}),
|
||||
onChanged: _change,
|
||||
);
|
||||
))]));
|
||||
}
|
||||
|
||||
void _change(bool? value) async {
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:vikunja_app/global.dart';
|
|||
import 'package:vikunja_app/models/label.dart';
|
||||
import 'package:vikunja_app/models/task.dart';
|
||||
import 'package:vikunja_app/utils/repeat_after_parse.dart';
|
||||
import 'package:vikunja_app/utils/priority.dart';
|
||||
|
||||
import '../../stores/project_store.dart';
|
||||
|
||||
|
@ -270,12 +271,12 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
border: InputBorder.none,
|
||||
),
|
||||
child: new DropdownButton<String>(
|
||||
value: _priorityToString(_priority),
|
||||
value: priorityToString(_priority),
|
||||
isExpanded: true,
|
||||
isDense: true,
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
_priority = _priorityFromString(newValue);
|
||||
_priority = priorityFromString(newValue);
|
||||
});
|
||||
},
|
||||
items: [
|
||||
|
@ -557,43 +558,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
});
|
||||
}
|
||||
|
||||
// FIXME: Move the following two functions to an extra class or type.
|
||||
_priorityFromString(String? priority) {
|
||||
switch (priority) {
|
||||
case 'Low':
|
||||
return 1;
|
||||
case 'Medium':
|
||||
return 2;
|
||||
case 'High':
|
||||
return 3;
|
||||
case 'Urgent':
|
||||
return 4;
|
||||
case 'DO NOW':
|
||||
return 5;
|
||||
default:
|
||||
// unset
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
_priorityToString(int? priority) {
|
||||
switch (priority) {
|
||||
case 0:
|
||||
return 'Unset';
|
||||
case 1:
|
||||
return 'Low';
|
||||
case 2:
|
||||
return 'Medium';
|
||||
case 3:
|
||||
return 'High';
|
||||
case 4:
|
||||
return 'Urgent';
|
||||
case 5:
|
||||
return 'DO NOW';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_onColorEdit() {
|
||||
_pickerColor = _resetColor || (_color ?? widget.task.color) == null
|
||||
|
|
38
lib/utils/priority.dart
Normal file
38
lib/utils/priority.dart
Normal file
|
@ -0,0 +1,38 @@
|
|||
priorityToString(int? priority) {
|
||||
switch (priority) {
|
||||
case 0:
|
||||
return 'Unset';
|
||||
case 1:
|
||||
return 'Low';
|
||||
case 2:
|
||||
return 'Medium';
|
||||
case 3:
|
||||
return 'High';
|
||||
case 4:
|
||||
return 'Urgent';
|
||||
case 5:
|
||||
return 'DO NOW';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Move the following two functions to an extra class or type.
|
||||
priorityFromString(String? priority) {
|
||||
switch (priority) {
|
||||
case 'Low':
|
||||
return 1;
|
||||
case 'Medium':
|
||||
return 2;
|
||||
case 'High':
|
||||
return 3;
|
||||
case 'Urgent':
|
||||
return 4;
|
||||
case 'DO NOW':
|
||||
return 5;
|
||||
default:
|
||||
// unset
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user