Skip to content

Commit

Permalink
Merge branch 'main' into view_update
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/service/services.dart
  • Loading branch information
Benimautner committed Apr 29, 2024
2 parents acc91ba + d30a3cf commit 4eeb92f
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 341 deletions.
53 changes: 0 additions & 53 deletions lib/models/list.dart

This file was deleted.

53 changes: 0 additions & 53 deletions lib/models/namespace.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:vikunja_app/global.dart';
import 'package:vikunja_app/models/list.dart';
import 'package:collection/collection.dart';

import '../main.dart';
Expand Down
191 changes: 0 additions & 191 deletions lib/service/mocked_services.dart
Original file line number Diff line number Diff line change
@@ -1,202 +1,11 @@
import 'dart:async';

import 'package:vikunja_app/api/response.dart';
import 'package:vikunja_app/models/list.dart';
import 'package:vikunja_app/models/namespace.dart';
import 'package:vikunja_app/models/task.dart';
import 'package:vikunja_app/models/user.dart';
import 'package:vikunja_app/service/services.dart';

// Data for mocked services
var _users = {1: User(id: 1, username: 'test1')};

var _namespaces = {
1: Namespace(
id: 1,
title: 'Test 1',
created: DateTime.now(),
updated: DateTime.now(),
description: 'A namespace for testing purposes',
owner: _users[1]!,
)
};

var _nsLists = {
1: [1]
};

var _lists = {
1: TaskList(
id: 1,
title: 'List 1',
tasks: _tasks.values.toList(),
owner: _users[1]!,
description: 'A nice list',
created: DateTime.now(),
updated: DateTime.now(),
namespaceId: 1)
};

var _tasks = {
1: Task(
id: 1,
title: 'Task 1',
createdBy: _users[1]!,
updated: DateTime.now(),
created: DateTime.now(),
description: 'A descriptive task',
done: false,
projectId: 1,
)
};

// Mocked services

class MockedNamespaceService implements NamespaceService {
@override
Future<Namespace> create(Namespace ns) {
_namespaces[ns.id] = ns;
return Future.value(ns);
}

@override
Future delete(int namespaceId) {
_namespaces.remove(namespaceId);
return Future.value();
}

@override
Future<Namespace> get(int namespaceId) {
return Future.value(_namespaces[namespaceId]);
}

@override
Future<List<Namespace>> getAll() {
return Future.value(_namespaces.values.toList());
}

@override
Future<Namespace> update(Namespace ns) {
if (!_namespaces.containsKey(ns.id))
throw Exception('Namespace ${ns.id} does not exsists');
return create(ns);
}
}
/*
class MockedListService implements ListService {
@override
Future<TaskList> create(namespaceId, TaskList tl) {
_nsLists[namespaceId]?.add(tl.id);
return Future.value(_lists[tl.id] = tl);
}
@override
Future delete(int listId) {
_lists.remove(listId);
return Future.value();
}
@override
Future<TaskList> get(int listId) {
return Future.value(_lists[listId]);
}
@override
Future<List<TaskList>> getAll() {
return Future.value(_lists.values.toList());
}
@override
Future<List<TaskList>> getByNamespace(int namespaceId) {
return Future.value(
_nsLists[namespaceId]!.map((listId) => _lists[listId]!).toList());
}
@override
Future<TaskList> update(TaskList tl) {
if (!_lists.containsKey(tl))
throw Exception('TaskList ${tl.id} does not exists');
return Future.value(_lists[tl.id] = tl);
}
@override
Future<String> getDisplayDoneTasks(int listId) {
// TODO: implement getDisplayDoneTasks
throw UnimplementedError();
}
@override
void setDisplayDoneTasks(int listId, String value) {
// TODO: implement setDisplayDoneTasks
}
@override
Future<String> getDefaultList() {
// TODO: implement getDefaultList
throw UnimplementedError();
}
@override
void setDefaultList(int? listId) {
// TODO: implement setDefaultList
}
}*/

class MockedTaskService implements TaskService {
@override
Future delete(int taskId) {
_lists.forEach(
(_, list) => list.tasks.removeWhere((task) => task.id == taskId));
_tasks.remove(taskId);
return Future.value();
}

@override
Future<Task> update(Task task) {
_lists.forEach((_, list) {
if (list.tasks.where((t) => t.id == task.id).length > 0) {
list.tasks.removeWhere((t) => t.id == task.id);
list.tasks.add(task);
}
});
return Future.value(_tasks[task.id] = task);
}

@override
Future<Task> add(int listId, Task task) {
var id = _tasks.keys.last + 1;
_tasks[id] = task;
_lists[listId]!.tasks.add(task);
return Future.value(task);
}

@override
int get maxPages => 1;
Future<Task> get(int taskId) {
// TODO: implement get
throw UnimplementedError();
}

@override
Future<List<Task>> getByOptions(TaskServiceOptions options) {
// TODO: implement getByOptions
throw UnimplementedError();
}

@override
Future<List<Task>> getAll() {
// TODO: implement getAll
throw UnimplementedError();
}

@override
Future<Response?> getAllByProject(int projectId,
[Map<String, List<String>>? queryParameters]) {
// TODO: implement getAllByProject
return Future.value(new Response(_tasks.values.toList(), 200, {}));
}
}

class MockedUserService implements UserService {
@override
Future<UserTokenPair> login(String username, password,
Expand Down
43 changes: 0 additions & 43 deletions lib/service/services.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:vikunja_app/api/response.dart';
import 'package:vikunja_app/models/label.dart';
import 'package:vikunja_app/models/labelTask.dart';
import 'package:vikunja_app/models/namespace.dart';
import 'package:vikunja_app/models/task.dart';
import 'package:vikunja_app/models/user.dart';
import 'package:vikunja_app/models/bucket.dart';
Expand Down Expand Up @@ -152,47 +150,6 @@ abstract class ProjectService {
//void setDefaultList(int? listId);
}

abstract class ProjectViewService {
Future<ProjectView?> get(int projectId, int viewId);
Future<ProjectView?> create(ProjectView view);
Future<ProjectView?> update(ProjectView view);
Future delete(int projectId, int viewId);
}

abstract class NamespaceService {
Future<List<Namespace>?> getAll();

Future<Namespace?> get(int namespaceId);

Future<Namespace?> create(Namespace ns);

Future<Namespace?> update(Namespace ns);

Future delete(int namespaceId);
}
/*
abstract class ListService {
Future<List<TaskList>?> getAll();
Future<TaskList?> get(int listId);
Future<List<TaskList>?> getByNamespace(int namespaceId);
Future<TaskList?> create(int namespaceId, TaskList tl);
Future<TaskList?> update(TaskList tl);
Future delete(int listId);
Future<String?> getDisplayDoneTasks(int listId);
void setDisplayDoneTasks(int listId, String value);
Future<String?> getDefaultList();
//void setDefaultList(int? listId);
}
*/
abstract class TaskService {
Future<Task?> get(int taskId);

Expand Down

0 comments on commit 4eeb92f

Please sign in to comment.