Added due date setting
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
e6f789af0f
commit
e732927e75
|
@ -2,6 +2,7 @@ import 'package:meta/meta.dart';
|
|||
|
||||
import 'package:vikunja_app/models/label.dart';
|
||||
import 'package:vikunja_app/models/user.dart';
|
||||
import 'package:vikunja_app/utils/datetime_to_unix.dart';
|
||||
|
||||
class Task {
|
||||
final int id, parentTaskID, priority;
|
||||
|
@ -38,11 +39,11 @@ class Task {
|
|||
description = json['description'],
|
||||
done = json['done'],
|
||||
reminderDates = (json['reminderDates'] as List<dynamic>)
|
||||
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
|
||||
?.map((milli) => dateTimeFromUnixTimestamp(milli))
|
||||
?.toList(),
|
||||
dueDate = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
|
||||
startDate = DateTime.fromMillisecondsSinceEpoch(json['startDate']),
|
||||
endDate = DateTime.fromMillisecondsSinceEpoch(json['endDate']),
|
||||
dueDate = dateTimeFromUnixTimestamp(json['dueDate']),
|
||||
startDate = dateTimeFromUnixTimestamp(json['startDate']),
|
||||
endDate = dateTimeFromUnixTimestamp(json['endDate']),
|
||||
parentTaskID = json['parentTaskID'],
|
||||
priority = json['priority'],
|
||||
repeatAfter = Duration(seconds: json['repeatAfter']),
|
||||
|
@ -52,8 +53,8 @@ class Task {
|
|||
subtasks = (json['subtasks'] as List<dynamic>)
|
||||
?.map((subtask) => Task.fromJson(subtask))
|
||||
?.toList(),
|
||||
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||
updated = dateTimeFromUnixTimestamp(json['updated']),
|
||||
created = dateTimeFromUnixTimestamp(json['created']),
|
||||
createdBy = User.fromJson(json['createdBy']);
|
||||
|
||||
toJSON() => {
|
||||
|
@ -61,17 +62,18 @@ class Task {
|
|||
'text': text,
|
||||
'description': description,
|
||||
'done': done ?? false,
|
||||
'reminderDates':
|
||||
reminderDates?.map((date) => date.millisecondsSinceEpoch)?.toList(),
|
||||
'dueDate': dueDate?.millisecondsSinceEpoch,
|
||||
'startDate': startDate?.millisecondsSinceEpoch,
|
||||
'endDate': endDate?.millisecondsSinceEpoch,
|
||||
'reminderDates': reminderDates
|
||||
?.map((date) => datetimeToUnixTimestamp(date))
|
||||
?.toList(),
|
||||
'dueDate': datetimeToUnixTimestamp(dueDate),
|
||||
'startDate': datetimeToUnixTimestamp(startDate),
|
||||
'endDate': datetimeToUnixTimestamp(endDate),
|
||||
'priority': priority,
|
||||
'repeatAfter': repeatAfter.inSeconds,
|
||||
'repeatAfter': repeatAfter?.inSeconds,
|
||||
'labels': labels?.map((label) => label.toJSON())?.toList(),
|
||||
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
||||
'createdBy': createdBy?.toJSON(),
|
||||
'updated': updated?.millisecondsSinceEpoch,
|
||||
'created': created?.millisecondsSinceEpoch,
|
||||
'updated': datetimeToUnixTimestamp(updated),
|
||||
'created': datetimeToUnixTimestamp(created),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:vikunja_app/global.dart';
|
||||
import 'package:vikunja_app/models/label.dart';
|
||||
import 'package:vikunja_app/models/task.dart';
|
||||
import 'package:vikunja_app/theme/button.dart';
|
||||
import 'package:vikunja_app/theme/buttonText.dart';
|
||||
import 'package:vikunja_app/theme/constants.dart';
|
||||
|
||||
class TaskEditPage extends StatefulWidget {
|
||||
final Task task;
|
||||
|
@ -16,8 +21,15 @@ class TaskEditPage extends StatefulWidget {
|
|||
class _TaskEditPageState extends State<TaskEditPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _loading = false;
|
||||
String _title, _description;
|
||||
List<DateTime> _reminders;
|
||||
final dateFormat = DateFormat("EEEE, MMMM d, yyyy 'at' h:mma");
|
||||
|
||||
int _parentTaskID, _priority;
|
||||
DateTime _dueDate, _startDate, _endDate;
|
||||
List<DateTime> _reminderDates;
|
||||
String _text, _description;
|
||||
Duration _repeatAfter;
|
||||
List<Task> _subtasks;
|
||||
List<Label> _labels;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
|
@ -38,15 +50,15 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
maxLines: null,
|
||||
keyboardType: TextInputType.multiline,
|
||||
initialValue: widget.task.text,
|
||||
onSaved: (title) => _title = title,
|
||||
validator: (title) {
|
||||
if (title.length < 3 || title.length > 250) {
|
||||
return 'The title needs to have between 3 and 250 characters.';
|
||||
onSaved: (text) => _text = text,
|
||||
validator: (text) {
|
||||
if (text.length < 3 || text.length > 250) {
|
||||
return 'The text needs to have between 3 and 250 characters.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
decoration: new InputDecoration(
|
||||
labelText: 'Title',
|
||||
labelText: 'Text',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
|
@ -70,6 +82,17 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: DateTimePickerFormField(
|
||||
dateOnly: false,
|
||||
format: vDateFormatLong,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Due Date',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onSaved: (duedate) => _dueDate = duedate,
|
||||
)),
|
||||
Builder(
|
||||
builder: (context) => Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||
|
@ -99,11 +122,16 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
// aka updating the existing task we got from context (setters?)
|
||||
Task updatedTask = Task(
|
||||
id: widget.task.id,
|
||||
done: widget.task.done,
|
||||
text: _title,
|
||||
text: _text,
|
||||
description: _description,
|
||||
reminderDates: null,
|
||||
createdBy: widget.task.createdBy,
|
||||
done: widget.task.done,
|
||||
reminderDates: _reminderDates,
|
||||
dueDate: _dueDate,
|
||||
startDate: _startDate,
|
||||
endDate: _endDate,
|
||||
priority: _priority,
|
||||
repeatAfter: _repeatAfter,
|
||||
labels: _labels,
|
||||
);
|
||||
|
||||
VikunjaGlobal.of(context).taskService.update(updatedTask).then((_) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
/////////
|
||||
// Colors
|
||||
|
@ -23,3 +24,5 @@ const vButtonShadow = Color(0xFFb2d9ff);
|
|||
const vStandardVerticalPadding = EdgeInsets.symmetric(vertical: 5.0);
|
||||
const vStandardHorizontalPadding = EdgeInsets.symmetric(horizontal: 5.0);
|
||||
const vStandardPadding = EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0);
|
||||
|
||||
var vDateFormatLong = DateFormat("EEEE, MMMM d, yyyy 'at' h:mma");
|
|
@ -0,0 +1,11 @@
|
|||
datetimeToUnixTimestamp(DateTime dt) {
|
||||
return dt?.millisecondsSinceEpoch == null
|
||||
? null
|
||||
: (dt.millisecondsSinceEpoch / 1000).round();
|
||||
}
|
||||
|
||||
dateTimeFromUnixTimestamp(int timestamp) {
|
||||
return timestamp == null
|
||||
? 0
|
||||
: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
}
|
15
pubspec.lock
15
pubspec.lock
|
@ -73,6 +73,13 @@ packages:
|
|||
url: "https://github.com/MarkOSullivan94/dart_config.git"
|
||||
source: git
|
||||
version: "0.5.0"
|
||||
datetime_picker_formfield:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: datetime_picker_formfield
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.8"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -118,6 +125,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.7"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.15.7"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -230,3 +244,4 @@ packages:
|
|||
version: "2.1.15"
|
||||
sdks:
|
||||
dart: ">=2.0.0 <3.0.0"
|
||||
flutter: ">=0.1.2 <2.0.0"
|
||||
|
|
|
@ -20,6 +20,7 @@ dev_dependencies:
|
|||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_launcher_icons: "^0.6.1"
|
||||
datetime_picker_formfield: ^0.1.8
|
||||
|
||||
flutter_icons:
|
||||
image_path: "assets/vikunja_logo.png"
|
||||
|
|
Reference in New Issue