forked from vikunja/app
Added method to parse the color back to hex_string
This commit is contained in:
parent
714aed4603
commit
d4b3a01a60
|
@ -32,7 +32,7 @@ class Label {
|
|||
'id': id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'hex_color': color.toString(),
|
||||
'hex_color': color.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'created_by': createdBy?.toJSON(),
|
||||
'updated': updated?.millisecondsSinceEpoch,
|
||||
'created': created?.millisecondsSinceEpoch,
|
||||
|
|
62
pubspec.lock
62
pubspec.lock
|
@ -14,7 +14,7 @@ packages:
|
|||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.35.4"
|
||||
version: "0.34.3"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -71,6 +71,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.6"
|
||||
csslib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: csslib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.14.6"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -124,7 +131,7 @@ packages:
|
|||
name: front_end
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.14"
|
||||
version: "0.1.9+1"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -132,6 +139,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.7"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: html
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.4+1"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -194,7 +208,14 @@ packages:
|
|||
name: kernel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.14"
|
||||
version: "0.3.9+1"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.11.3+2"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -243,7 +264,7 @@ packages:
|
|||
name: package_resolver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.10"
|
||||
version: "1.0.9"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -251,13 +272,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.2"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -265,6 +279,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
plugin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0+3"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -339,7 +360,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.4"
|
||||
version: "1.4.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -367,28 +388,28 @@ packages:
|
|||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.0.1"
|
||||
test:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: test
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.3"
|
||||
version: "1.5.1+1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
version: "0.2.1"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.1+1"
|
||||
version: "0.2.0+1"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -396,6 +417,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
utf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: utf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.0+5"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -439,5 +467,5 @@ packages:
|
|||
source: hosted
|
||||
version: "2.1.15"
|
||||
sdks:
|
||||
dart: ">=2.1.0 <3.0.0"
|
||||
dart: ">=2.1.0-dev.5.0 <3.0.0"
|
||||
flutter: ">=0.1.2 <2.0.0"
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vikunja_app/models/label.dart';
|
||||
|
||||
void main() {
|
||||
test('label color from json', () {
|
||||
final String json = '{"TaskID": 123,"id": 1,"title": "this","description": "","hex_color": "e8e8e8","created_by":{"id": 1,"username": "user","email": "test@example.com","created": 1537855131,"updated": 1545233325},"created": 1552903790,"updated": 1552903790}';
|
||||
final JsonDecoder _decoder = new JsonDecoder();
|
||||
Label label = Label.fromJson(_decoder.convert(json));
|
||||
|
||||
expect(label.color, Color(0xFFe8e8e8));
|
||||
});
|
||||
|
||||
test('hex color string from object', () {
|
||||
Label label = Label(id: 1, color: Color(0xFFe8e8e8));
|
||||
var json = label.toJSON();
|
||||
|
||||
expect(json.toString(), '{id: 1, title: null, description: null, hex_color: e8e8e8, created_by: null, updated: null, created: null}');
|
||||
});
|
||||
}
|
|
@ -5,7 +5,7 @@ import 'package:test/test.dart';
|
|||
|
||||
void main() {
|
||||
test('Check encoding with all values set', () {
|
||||
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": [1543834800,1544612400],"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 4,"username": "konrad","email": "vikunjatry@kolaente.de","created": 1537855131,"updated": 1545233325}}';
|
||||
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": [1543834800,1544612400],"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 1,"username": "user","email": "test@example.com","created": 1537855131,"updated": 1545233325}}';
|
||||
final JsonDecoder _decoder = new JsonDecoder();
|
||||
final task = Task.fromJson(_decoder.convert(json));
|
||||
|
||||
|
@ -29,7 +29,7 @@ void main() {
|
|||
expect(task.updated, DateTime.fromMillisecondsSinceEpoch(1552771527 * 1000));
|
||||
});
|
||||
test('Check encoding with reminder dates as null', () {
|
||||
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": null,"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 4,"username": "konrad","email": "vikunjatry@kolaente.de","created": 1537855131,"updated": 1545233325}}';
|
||||
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": null,"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 1,"username": "user","email": "test@example.com","created": 1537855131,"updated": 1545233325}}';
|
||||
final JsonDecoder _decoder = new JsonDecoder();
|
||||
final task = Task.fromJson(_decoder.convert(json));
|
||||
|
||||
|
|
Loading…
Reference in New Issue