dart format

This commit is contained in:
2026-05-08 20:12:40 +02:00
parent 9e139b5704
commit 3b8da1d3d6
295 changed files with 6404 additions and 4161 deletions
@@ -9,9 +9,9 @@ class GetBreakers extends MhslApi<GetBreakersResponse> {
GetBreakers() : super('breaker/');
@override
GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw) as Map<String, dynamic>);
GetBreakersResponse assemble(String raw) =>
GetBreakersResponse.fromJson(jsonDecode(raw) as Map<String, dynamic>);
@override
Future<Response>? request(Uri uri) => http.get(uri);
}
@@ -4,11 +4,11 @@ import 'get_breakers_response.dart';
class GetBreakersCache extends SimpleCache<GetBreakersResponse> {
GetBreakersCache({super.onUpdate, super.renew})
: super(
cacheTime: RequestCache.cacheMinute,
loader: () => GetBreakers().run(),
fromJson: GetBreakersResponse.fromJson,
) {
: super(
cacheTime: RequestCache.cacheMinute,
loader: () => GetBreakers().run(),
fromJson: GetBreakersResponse.fromJson,
) {
start('breakers');
}
}
@@ -1,4 +1,3 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../api_response.dart';
@@ -12,7 +11,8 @@ class GetBreakersResponse extends ApiResponse {
GetBreakersResponse(this.global, this.regional);
factory GetBreakersResponse.fromJson(Map<String, dynamic> json) => _$GetBreakersResponseFromJson(json);
factory GetBreakersResponse.fromJson(Map<String, dynamic> json) =>
_$GetBreakersResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetBreakersResponseToJson(this);
}
@@ -23,14 +23,20 @@ class GetBreakersReponseObject {
GetBreakersReponseObject(this.areas, this.message);
factory GetBreakersReponseObject.fromJson(Map<String, dynamic> json) => _$GetBreakersReponseObjectFromJson(json);
factory GetBreakersReponseObject.fromJson(Map<String, dynamic> json) =>
_$GetBreakersReponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetBreakersReponseObjectToJson(this);
}
enum BreakerArea {
@JsonValue('GLOBAL') global,
@JsonValue('TIMETABLE') timetable,
@JsonValue('TALK') talk,
@JsonValue('FILES') files,
@JsonValue('MORE') more,
@JsonValue('GLOBAL')
global,
@JsonValue('TIMETABLE')
timetable,
@JsonValue('TALK')
talk,
@JsonValue('FILES')
files,
@JsonValue('MORE')
more,
}
@@ -8,7 +8,7 @@ import 'add_custom_timetable_event_params.dart';
class AddCustomTimetableEvent extends MhslApi<void> {
AddCustomTimetableEventParams params;
AddCustomTimetableEvent(this.params) : super('server/timetable/customEvents');
@override
@@ -11,6 +11,7 @@ class AddCustomTimetableEventParams {
AddCustomTimetableEventParams(this.user, this.event);
factory AddCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$AddCustomTimetableEventParamsFromJson(json);
factory AddCustomTimetableEventParams.fromJson(Map<String, dynamic> json) =>
_$AddCustomTimetableEventParamsFromJson(json);
Map<String, dynamic> toJson() => _$AddCustomTimetableEventParamsToJson(this);
}
@@ -20,9 +20,19 @@ class CustomTimetableEvent {
@JsonKey(toJson: MhslApi.dateTimeToJson, fromJson: MhslApi.dateTimeFromJson)
DateTime updatedAt;
CustomTimetableEvent({required this.id, required this.title, required this.description, required this.startDate,
required this.endDate, required this.color, required this.rrule, required this.createdAt, required this.updatedAt});
CustomTimetableEvent({
required this.id,
required this.title,
required this.description,
required this.startDate,
required this.endDate,
required this.color,
required this.rrule,
required this.createdAt,
required this.updatedAt,
});
factory CustomTimetableEvent.fromJson(Map<String, dynamic> json) => _$CustomTimetableEventFromJson(json);
factory CustomTimetableEvent.fromJson(Map<String, dynamic> json) =>
_$CustomTimetableEventFromJson(json);
Map<String, dynamic> toJson() => _$CustomTimetableEventToJson(this);
}
@@ -9,10 +9,12 @@ import 'get_custom_timetable_event_response.dart';
class GetCustomTimetableEvent extends MhslApi<GetCustomTimetableEventResponse> {
GetCustomTimetableEventParams params;
GetCustomTimetableEvent(this.params) : super('server/timetable/customEvents?user=${params.user}');
GetCustomTimetableEvent(this.params)
: super('server/timetable/customEvents?user=${params.user}');
@override
GetCustomTimetableEventResponse assemble(String raw) => GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
GetCustomTimetableEventResponse assemble(String raw) =>
GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
@override
Future<Response>? request(Uri uri) => http.get(uri);
@@ -3,17 +3,18 @@ import 'get_custom_timetable_event.dart';
import 'get_custom_timetable_event_params.dart';
import 'get_custom_timetable_event_response.dart';
class GetCustomTimetableEventCache extends SimpleCache<GetCustomTimetableEventResponse> {
class GetCustomTimetableEventCache
extends SimpleCache<GetCustomTimetableEventResponse> {
GetCustomTimetableEventCache(
GetCustomTimetableEventParams params, {
super.onUpdate,
super.onError,
super.renew,
}) : super(
cacheTime: RequestCache.cacheMinute,
loader: () => GetCustomTimetableEvent(params).run(),
fromJson: GetCustomTimetableEventResponse.fromJson,
) {
cacheTime: RequestCache.cacheMinute,
loader: () => GetCustomTimetableEvent(params).run(),
fromJson: GetCustomTimetableEventResponse.fromJson,
) {
start('customTimetableEvents');
}
}
@@ -8,6 +8,7 @@ class GetCustomTimetableEventParams {
GetCustomTimetableEventParams(this.user);
factory GetCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$GetCustomTimetableEventParamsFromJson(json);
factory GetCustomTimetableEventParams.fromJson(Map<String, dynamic> json) =>
_$GetCustomTimetableEventParamsFromJson(json);
Map<String, dynamic> toJson() => _$GetCustomTimetableEventParamsToJson(this);
}
@@ -11,6 +11,8 @@ class GetCustomTimetableEventResponse extends ApiResponse {
GetCustomTimetableEventResponse(this.events);
factory GetCustomTimetableEventResponse.fromJson(Map<String, dynamic> json) => _$GetCustomTimetableEventResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetCustomTimetableEventResponseToJson(this);
factory GetCustomTimetableEventResponse.fromJson(Map<String, dynamic> json) =>
_$GetCustomTimetableEventResponseFromJson(json);
Map<String, dynamic> toJson() =>
_$GetCustomTimetableEventResponseToJson(this);
}
@@ -9,11 +9,13 @@ import 'remove_custom_timetable_event_params.dart';
class RemoveCustomTimetableEvent extends MhslApi<void> {
RemoveCustomTimetableEventParams params;
RemoveCustomTimetableEvent(this.params) : super('server/timetable/customEvents');
RemoveCustomTimetableEvent(this.params)
: super('server/timetable/customEvents');
@override
void assemble(String raw) {}
@override
Future<Response>? request(Uri uri) => http.delete(uri, body: jsonEncode(params.toJson()));
Future<Response>? request(Uri uri) =>
http.delete(uri, body: jsonEncode(params.toJson()));
}
@@ -8,6 +8,9 @@ class RemoveCustomTimetableEventParams {
RemoveCustomTimetableEventParams(this.id);
factory RemoveCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$RemoveCustomTimetableEventParamsFromJson(json);
Map<String, dynamic> toJson() => _$RemoveCustomTimetableEventParamsToJson(this);
factory RemoveCustomTimetableEventParams.fromJson(
Map<String, dynamic> json,
) => _$RemoveCustomTimetableEventParamsFromJson(json);
Map<String, dynamic> toJson() =>
_$RemoveCustomTimetableEventParamsToJson(this);
}
@@ -9,11 +9,13 @@ import 'update_custom_timetable_event_params.dart';
class UpdateCustomTimetableEvent extends MhslApi<void> {
UpdateCustomTimetableEventParams params;
UpdateCustomTimetableEvent(this.params) : super('server/timetable/customEvents');
UpdateCustomTimetableEvent(this.params)
: super('server/timetable/customEvents');
@override
void assemble(String raw) {}
@override
Future<Response>? request(Uri uri) => http.patch(uri, body: jsonEncode(params.toJson()));
Future<Response>? request(Uri uri) =>
http.patch(uri, body: jsonEncode(params.toJson()));
}
@@ -1,4 +1,3 @@
import 'package:json_annotation/json_annotation.dart';
import '../custom_timetable_event.dart';
@@ -12,6 +11,9 @@ class UpdateCustomTimetableEventParams {
UpdateCustomTimetableEventParams(this.id, this.event);
factory UpdateCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$UpdateCustomTimetableEventParamsFromJson(json);
Map<String, dynamic> toJson() => _$UpdateCustomTimetableEventParamsToJson(this);
factory UpdateCustomTimetableEventParams.fromJson(
Map<String, dynamic> json,
) => _$UpdateCustomTimetableEventParamsFromJson(json);
Map<String, dynamic> toJson() =>
_$UpdateCustomTimetableEventParamsToJson(this);
}
+5 -2
View File
@@ -20,7 +20,9 @@ abstract class MhslApi<T> extends ApiRequest {
T assemble(String raw);
Future<T> run() async {
final endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
final endpoint = Uri.parse(
'https://mhsl.eu/marianum/marianummobile/$subpath',
);
final http.Response data;
try {
@@ -54,6 +56,7 @@ abstract class MhslApi<T> extends ApiRequest {
}
}
static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss');
static String dateTimeToJson(DateTime time) =>
Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss');
static DateTime dateTimeFromJson(String time) => DateTime.parse(time);
}
@@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:developer';
@@ -11,11 +10,8 @@ class NotifyRegister extends MhslApi<void> {
NotifyRegisterParams params;
NotifyRegister(this.params) : super('notify/register/');
@override
void assemble(String raw) {
}
void assemble(String raw) {}
@override
Future<http.Response> request(Uri uri) {
@@ -11,9 +11,10 @@ class NotifyRegisterParams {
NotifyRegisterParams({
required this.username,
required this.password,
required this.fcmToken
required this.fcmToken,
});
factory NotifyRegisterParams.fromJson(Map<String, dynamic> json) => _$NotifyRegisterParamsFromJson(json);
factory NotifyRegisterParams.fromJson(Map<String, dynamic> json) =>
_$NotifyRegisterParamsFromJson(json);
Map<String, dynamic> toJson() => _$NotifyRegisterParamsToJson(this);
}
@@ -6,7 +6,6 @@ import 'package:http/http.dart' as http;
import '../../mhsl_api.dart';
import 'add_feedback_params.dart';
class AddFeedback extends MhslApi<void> {
AddFeedbackParams params;
AddFeedback(this.params) : super('server/feedback');
@@ -15,5 +14,6 @@ class AddFeedback extends MhslApi<void> {
void assemble(String raw) {}
@override
Future<Response>? request(Uri uri) => http.post(uri, body: jsonEncode(params.toJson()));
Future<Response>? request(Uri uri) =>
http.post(uri, body: jsonEncode(params.toJson()));
}
@@ -9,7 +9,6 @@ class AddFeedbackParams {
String? screenshot;
int appVersion;
AddFeedbackParams({
required this.user,
required this.feedback,
@@ -17,6 +16,7 @@ class AddFeedbackParams {
required this.appVersion,
});
factory AddFeedbackParams.fromJson(Map<String, dynamic> json) => _$AddFeedbackParamsFromJson(json);
factory AddFeedbackParams.fromJson(Map<String, dynamic> json) =>
_$AddFeedbackParamsFromJson(json);
Map<String, dynamic> toJson() => _$AddFeedbackParamsToJson(this);
}
@@ -10,15 +10,15 @@ class UpdateUserIndexParams {
int appVersion;
String deviceInfo;
UpdateUserIndexParams({
required this.user,
required this.username,
required this.device,
required this.appVersion,
required this.deviceInfo
required this.deviceInfo,
});
factory UpdateUserIndexParams.fromJson(Map<String, dynamic> json) => _$UpdateUserIndexParamsFromJson(json);
factory UpdateUserIndexParams.fromJson(Map<String, dynamic> json) =>
_$UpdateUserIndexParamsFromJson(json);
Map<String, dynamic> toJson() => _$UpdateUserIndexParamsToJson(this);
}
@@ -1,4 +1,3 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
@@ -26,14 +25,18 @@ class UpdateUserIndex extends MhslApi<void> {
}
static Future<void> index() async {
unawaited(UpdateUserIndex(
UpdateUserIndexParams(
username: AccountData().getUsername(),
user: AccountData().getUserSecret(),
device: await AccountData().getDeviceId(),
appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber),
deviceInfo: jsonEncode((await DeviceInfoPlugin().deviceInfo).data).toString(),
),
).run());
unawaited(
UpdateUserIndex(
UpdateUserIndexParams(
username: AccountData().getUsername(),
user: AccountData().getUserSecret(),
device: await AccountData().getDeviceId(),
appVersion: int.parse((await PackageInfo.fromPlatform()).buildNumber),
deviceInfo: jsonEncode(
(await DeviceInfoPlugin().deviceInfo).data,
).toString(),
),
).run(),
);
}
}