Fix date format
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2020-04-27 17:02:55 +02:00
parent 14300266ef
commit 361057aa9f
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
7 changed files with 28 additions and 26 deletions

View File

@ -120,9 +120,9 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
});
return;
}
loadedCurrentUser = User(int.tryParse(currentUser), "", "", "");
loadedCurrentUser = User(int.tryParse(currentUser), "", "");
} catch (otherExceptions) {
loadedCurrentUser = User(int.tryParse(currentUser), "", "", "");
loadedCurrentUser = User(int.tryParse(currentUser), "", "");
}
setState(() {
_client = client;

View File

@ -23,8 +23,8 @@ class TaskList {
owner = User.fromJson(json['owner']),
description = json['description'],
title = json['title'],
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
updated = DateTime.parse(json['updated']),
created = DateTime.parse(json['created']),
tasks = (json['tasks'] == null ? [] : json['tasks'] as List<dynamic>)
?.map((taskJson) => Task.fromJson(taskJson))
?.toList();
@ -35,8 +35,8 @@ class TaskList {
"title": this.title,
"description": this.description,
"owner": this.owner?.toJSON(),
"created": this.created?.millisecondsSinceEpoch,
"updated": this.updated?.millisecondsSinceEpoch,
"created": this.created?.toIso8601String(),
"updated": this.updated?.toIso8601String(),
};
}
}

View File

@ -19,13 +19,13 @@ class Namespace {
: name = json['name'],
description = json['description'],
id = json['id'],
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
created = DateTime.parse(json['created']),
updated = DateTime.parse(json['updated']),
owner = User.fromJson(json['owner']);
toJSON() => {
"created": created?.millisecondsSinceEpoch,
"updated": updated?.millisecondsSinceEpoch,
"created": created?.toIso8601String(),
"updated": updated?.toIso8601String(),
"name": name,
"owner": owner?.toJSON(),
"description": description

View File

@ -22,12 +22,12 @@ class Task {
Task.fromJson(Map<String, dynamic> json)
: id = json['id'],
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
updated = DateTime.parse(json['updated']),
created = DateTime.parse(json['created']),
reminders = (json['reminderDates'] as List<dynamic>)
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
?.map((r) => DateTime.parse(r))
?.toList(),
due = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
due = DateTime.parse(json['dueDate']),
description = json['description'],
text = json['text'],
done = json['done'],
@ -35,11 +35,11 @@ class Task {
toJSON() => {
'id': id,
'updated': updated?.millisecondsSinceEpoch,
'created': created?.millisecondsSinceEpoch,
'updated': updated?.toIso8601String(),
'created': created?.toIso8601String(),
'reminderDates':
reminders?.map((date) => date.millisecondsSinceEpoch)?.toList(),
'dueDate': due?.millisecondsSinceEpoch,
reminders?.map((date) => date.toIso8601String())?.toList(),
'dueDate': due?.toIso8601String(),
'description': description,
'text': text,
'done': done ?? false,

View File

@ -1,18 +1,20 @@
import 'package:flutter/cupertino.dart';
import 'package:vikunja_app/global.dart';
class User {
final int id;
final String email, username, avatarHash;
final String email, username;
User(this.id, this.email, this.username, this.avatarHash);
User(this.id, this.email, this.username);
User.fromJson(Map<String, dynamic> json)
: id = json['id'],
email = json.containsKey('email') ? json['email'] : '',
username = json['username'],
avatarHash = json['avatarUrl'];
username = json['username'];
toJSON() => {"id": this.id, "email": this.email, "username": this.username};
String avatarUrl() {
return "https://secure.gravatar.com/avatar/" + this.avatarHash;
String avatarUrl(BuildContext context) {
return VikunjaGlobal.of(context).client.base + "/" + this.username + "/avatar";
}
}

View File

@ -101,7 +101,7 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
currentAccountPicture: currentUser == null
? null
: CircleAvatar(
backgroundImage: NetworkImage(currentUser.avatarUrl()),
backgroundImage: NetworkImage(currentUser.avatarUrl(context)),
),
decoration: BoxDecoration(
image: DecorationImage(

View File

@ -7,7 +7,7 @@ import 'package:vikunja_app/models/user.dart';
import 'package:vikunja_app/service/services.dart';
// Data for mocked services
var _users = {1: User(1, 'test@testuser.org', 'test1', '')};
var _users = {1: User(1, 'test@testuser.org', 'test1')};
var _namespaces = {
1: Namespace(