mirror of
https://github.com/go-vikunja/app
synced 2024-06-02 18:49:47 +00:00
first step of migration
This commit is contained in:
parent
6284ae56de
commit
48067d6b34
|
@ -31,7 +31,7 @@ class BucketAPIService extends APIService implements BucketService {
|
|||
|
||||
@override
|
||||
Future<Response> getAllByList(int listId,
|
||||
[Map<String, List<String>> queryParameters]) {
|
||||
[Map<String, List<String>>? queryParameters]) {
|
||||
return client
|
||||
.get('/lists/$listId/buckets', queryParameters)
|
||||
.then((response) => new Response(
|
||||
|
|
|
@ -16,15 +16,15 @@ class Client {
|
|||
GlobalKey<ScaffoldMessengerState> global;
|
||||
final JsonDecoder _decoder = new JsonDecoder();
|
||||
final JsonEncoder _encoder = new JsonEncoder();
|
||||
String _token;
|
||||
String _base;
|
||||
bool authenticated;
|
||||
String? _token;
|
||||
String? _base;
|
||||
bool authenticated = false;
|
||||
bool ignoreCertificates = false;
|
||||
|
||||
String get base => _base;
|
||||
String get token => _token;
|
||||
String? get base => _base;
|
||||
String? get token => _token;
|
||||
|
||||
String post_body;
|
||||
String? post_body;
|
||||
|
||||
//HttpClient client = new HttpClient();
|
||||
|
||||
|
@ -32,14 +32,14 @@ class Client {
|
|||
return otherClient._token == _token;
|
||||
}
|
||||
|
||||
Client(this.global, {String token, String base, bool authenticated = false}) {
|
||||
Client(this.global, {String? token, String? base, bool authenticated = false}) {
|
||||
configure(token: token, base: base, authenticated: authenticated);
|
||||
}
|
||||
|
||||
void reload_ignore_certs(bool val) {
|
||||
ignoreCertificates = val;
|
||||
HttpOverrides.global = new IgnoreCertHttpOverrides(ignoreCertificates);
|
||||
VikunjaGlobal.of(global.currentContext).settingsManager.setIgnoreCertificates(val);
|
||||
VikunjaGlobal.of(global.currentContext!).settingsManager.setIgnoreCertificates(val);
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,13 +52,10 @@ class Client {
|
|||
@override
|
||||
int get hashCode => _token.hashCode;
|
||||
|
||||
void configure({String token, String base, bool authenticated}) {
|
||||
if (token != null)
|
||||
_token = token;
|
||||
if (base != null)
|
||||
_base = base.endsWith('/api/v1') ? base : '$base/api/v1';
|
||||
if (authenticated != null)
|
||||
this.authenticated = authenticated;
|
||||
void configure({String? token, String? base, bool? authenticated}) {
|
||||
_token = token!;
|
||||
_base = base!.endsWith('/api/v1') ? base : '$base/api/v1';
|
||||
this.authenticated = authenticated!;
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +65,7 @@ class Client {
|
|||
}
|
||||
|
||||
Future<Response> get(String url,
|
||||
[Map<String, List<String>> queryParameters]) {
|
||||
[Map<String, List<String>>? queryParameters]) {
|
||||
// TODO: This could be moved to a seperate function
|
||||
var uri = Uri.parse('${this.base}$url');
|
||||
// Because these are all final values, we can't just add the queryParameters and must instead build a new Uri Object every time this method is called.
|
||||
|
|
|
@ -22,9 +22,9 @@ class LabelTaskAPIService extends APIService implements LabelTaskService {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<List<Label>> getAll(LabelTask lt, {String query}) async {
|
||||
String params =
|
||||
query == '' ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||
Future<List<Label>> getAll(LabelTask lt, {String? query}) async {
|
||||
String? params =
|
||||
query == null ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||
|
||||
return client.get('/tasks/${lt.task.id}/labels$params').then(
|
||||
(label) => convertList(label, (result) => Label.fromJson(result)));
|
||||
|
|
|
@ -28,9 +28,9 @@ class LabelAPIService extends APIService implements LabelService {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<List<Label>> getAll({String query}) {
|
||||
String params =
|
||||
query == '' ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||
Future<List<Label>> getAll({String? query}) {
|
||||
String? params =
|
||||
query == null ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||
return client.get('/labels$params').then(
|
||||
(response) => convertList(response.body, (result) => Label.fromJson(result)));
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class ListAPIService extends APIService implements ListService {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<String> getDefaultList() {
|
||||
Future<String?> getDefaultList() {
|
||||
return _storage.read(key: "default_list_id");
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class TaskAPIService extends APIService implements TaskService {
|
|||
.then((response) {
|
||||
int page_n = 0;
|
||||
if (response.headers["x-pagination-total-pages"] != null) {
|
||||
page_n = int.parse(response.headers["x-pagination-total-pages"]);
|
||||
page_n = int.parse(response.headers["x-pagination-total-pages"]!);
|
||||
} else {
|
||||
return Future.value(response.body);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class TaskAPIService extends APIService implements TaskService {
|
|||
|
||||
@override
|
||||
Future<Response> getAllByList(int listId,
|
||||
[Map<String, List<String>> queryParameters]) {
|
||||
[Map<String, List<String>>? queryParameters]) {
|
||||
return client
|
||||
.get('/lists/$listId/tasks', queryParameters).then(
|
||||
(response) => new Response(
|
||||
|
|
|
@ -11,7 +11,7 @@ class UserAPIService extends APIService implements UserService {
|
|||
UserAPIService(Client client) : super(client);
|
||||
|
||||
@override
|
||||
Future<UserTokenPair> login(String username, password, {bool rememberMe = false, String totp}) async {
|
||||
Future<UserTokenPair> login(String username, password, {bool rememberMe = false, String? totp}) async {
|
||||
var token = await client.post('/login', body: {
|
||||
'long_token': rememberMe,
|
||||
'password': password,
|
||||
|
|
|
@ -11,10 +11,10 @@ Map<NewTaskDue, Duration> newTaskDueToDuration = {
|
|||
};
|
||||
|
||||
class AddDialog extends StatefulWidget {
|
||||
final ValueChanged<String> onAdd;
|
||||
final ValueChanged<Task> onAddTask;
|
||||
final InputDecoration decoration;
|
||||
const AddDialog({Key key, this.onAdd, this.decoration, this.onAddTask}) : super(key: key);
|
||||
final ValueChanged<String>? onAdd;
|
||||
final ValueChanged<Task>? onAddTask;
|
||||
final InputDecoration? decoration;
|
||||
const AddDialog({Key? key, this.onAdd, this.decoration, this.onAddTask}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => AddDialogState();
|
||||
|
@ -23,13 +23,13 @@ class AddDialog extends StatefulWidget {
|
|||
|
||||
class AddDialogState extends State<AddDialog> {
|
||||
NewTaskDue newTaskDue = NewTaskDue.day;
|
||||
DateTime customDueDate;
|
||||
DateTime? customDueDate;
|
||||
var textController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(newTaskDue != NewTaskDue.custom)
|
||||
customDueDate = DateTime.now().add(newTaskDueToDuration[newTaskDue]);
|
||||
customDueDate = DateTime.now().add(newTaskDueToDuration[newTaskDue]!);
|
||||
return new AlertDialog(
|
||||
contentPadding: const EdgeInsets.all(16.0),
|
||||
content: new Column(
|
||||
|
@ -63,9 +63,9 @@ class AddDialogState extends State<AddDialog> {
|
|||
child: const Text('ADD'),
|
||||
onPressed: () {
|
||||
if (widget.onAdd != null && textController.text.isNotEmpty)
|
||||
widget.onAdd(textController.text);
|
||||
widget.onAdd!(textController.text);
|
||||
if(widget.onAddTask != null && textController.text.isNotEmpty) {
|
||||
widget.onAddTask(Task(id: null,
|
||||
widget.onAddTask!(Task(id: null,
|
||||
title: textController.text,
|
||||
done: false,
|
||||
createdBy: null,
|
||||
|
|
|
@ -9,22 +9,22 @@ import 'package:vikunja_app/utils/checkboxes_in_text.dart';
|
|||
|
||||
@JsonSerializable()
|
||||
class Task {
|
||||
final int id, parentTaskId, priority, listId, bucketId;
|
||||
final DateTime created, updated, dueDate, startDate, endDate;
|
||||
final List<DateTime> reminderDates;
|
||||
final String title, description, identifier;
|
||||
final bool done;
|
||||
final Color color;
|
||||
final double kanbanPosition;
|
||||
final User createdBy;
|
||||
final Duration repeatAfter;
|
||||
final List<Task> subtasks;
|
||||
final List<Label> labels;
|
||||
final List<TaskAttachment> attachments;
|
||||
final int? id, parentTaskId, priority, listId, bucketId;
|
||||
final DateTime? created, updated, dueDate, startDate, endDate;
|
||||
final List<DateTime>? reminderDates;
|
||||
final String? title, description, identifier;
|
||||
final bool? done;
|
||||
final Color? color;
|
||||
final double? kanbanPosition;
|
||||
final User? createdBy;
|
||||
final Duration? repeatAfter;
|
||||
final List<Task>? subtasks;
|
||||
final List<Label>? labels;
|
||||
final List<TaskAttachment>? attachments;
|
||||
// TODO: add position(?)
|
||||
|
||||
// // TODO: use `late final` once upgraded to current dart version
|
||||
CheckboxStatistics _checkboxStatistics;
|
||||
late final CheckboxStatistics _checkboxStatistics;
|
||||
|
||||
bool loading = false;
|
||||
|
||||
|
@ -102,25 +102,25 @@ class Task {
|
|||
'identifier': identifier,
|
||||
'done': done ?? false,
|
||||
'reminder_dates':
|
||||
reminderDates?.map((date) => date?.toUtc()?.toIso8601String())?.toList(),
|
||||
'due_date': dueDate?.toUtc()?.toIso8601String(),
|
||||
'start_date': startDate?.toUtc()?.toIso8601String(),
|
||||
'end_date': endDate?.toUtc()?.toIso8601String(),
|
||||
reminderDates?.map((date) => date.toUtc().toIso8601String()).toList(),
|
||||
'due_date': dueDate?.toUtc().toIso8601String(),
|
||||
'start_date': startDate?.toUtc().toIso8601String(),
|
||||
'end_date': endDate?.toUtc().toIso8601String(),
|
||||
'priority': priority,
|
||||
'repeat_after': repeatAfter?.inSeconds,
|
||||
'hex_color': color?.value?.toRadixString(16)?.padLeft(8, '0')?.substring(2),
|
||||
'hex_color': color?.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'kanban_position': kanbanPosition,
|
||||
'labels': labels?.map((label) => label.toJSON())?.toList(),
|
||||
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
||||
'attachments': attachments?.map((attachment) => attachment.toJSON())?.toList(),
|
||||
'labels': labels?.map((label) => label.toJSON()).toList(),
|
||||
'subtasks': subtasks?.map((subtask) => subtask.toJSON()).toList(),
|
||||
'attachments': attachments?.map((attachment) => attachment.toJSON()).toList(),
|
||||
'bucket_id': bucketId,
|
||||
'created_by': createdBy?.toJSON(),
|
||||
'updated': updated?.toUtc()?.toIso8601String(),
|
||||
'created': created?.toUtc()?.toIso8601String(),
|
||||
'updated': updated?.toUtc().toIso8601String(),
|
||||
'created': created?.toUtc().toIso8601String(),
|
||||
};
|
||||
|
||||
Color get textColor => color != null
|
||||
? color.computeLuminance() > 0.5 ? Colors.black : Colors.white
|
||||
Color? get textColor => color != null
|
||||
? color!.computeLuminance() > 0.5 ? Colors.black : Colors.white
|
||||
: null;
|
||||
|
||||
CheckboxStatistics get checkboxStatistics {
|
||||
|
|
|
@ -97,7 +97,7 @@ abstract class ListService {
|
|||
Future delete(int listId);
|
||||
Future<String> getDisplayDoneTasks(int listId);
|
||||
void setDisplayDoneTasks(int listId, String value);
|
||||
Future<String> getDefaultList();
|
||||
Future<String?> getDefaultList();
|
||||
void setDefaultList(int listId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user