Compare commits

..

7 Commits

Author SHA1 Message Date
5d264f7651 added notes for next tasks 2024-03-30 18:33:52 +01:00
a6f7c09671 wip 2024-03-29 21:58:51 +01:00
eaf6d9f547 updated new linter rules 2024-03-29 18:47:54 +01:00
5b34afd6cb Merge branch 'develop' into feature-highEduGraduationCalculator
# Conflicts:
#	lib/view/pages/overhang.dart
2024-03-29 18:32:59 +01:00
25d901d093 WIP lk select dialog 2024-03-29 17:29:31 +01:00
6237a2e9cf Merge branch 'develop' into feature-highEduGraduationCalculator
# Conflicts:
#	lib/view/pages/overhang.dart
2024-03-24 14:21:01 +01:00
c4f5be2205 WIP high education graduation calculator 2024-03-23 15:42:31 +01:00
322 changed files with 3232 additions and 5933 deletions

16
.gitignore vendored
View File

@ -48,14 +48,14 @@ lib/generated_plugin_registrant.dart
#pubspec.lock
# Android related
materials/screenshots/android/**/gradle-wrapper.jar
materials/screenshots/android/.gradle
materials/screenshots/android/captures/
materials/screenshots/android/gradlew
materials/screenshots/android/gradlew.bat
materials/screenshots/android/key.properties
materials/screenshots/android/local.properties
materials/screenshots/android/**/GeneratedPluginRegistrant.java
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/key.properties
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3

View File

@ -9,10 +9,6 @@
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
analyzer:
errors:
invalid_annotation_target: ignore
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
@ -32,13 +28,6 @@ linter:
prefer_relative_imports: true
unnecessary_lambdas: true
prefer_single_quotes: true
prefer_if_elements_to_conditional_expressions: true
prefer_expression_function_bodies: true
omit_local_variable_types: true
eol_at_end_of_file: true
cast_nullable_to_non_nullable: true
avoid_void_async: true
avoid_multiple_declarations_per_line: true
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -25,10 +25,9 @@ if (flutterVersionName == null) {
android {
namespace "eu.mhsl.marianum.mobile.client"
compileSdk flutter.compileSdkVersion
ndkVersion "27.0.12077973"
ndkVersion flutter.ndkVersion
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
@ -42,8 +41,11 @@ android {
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "eu.mhsl.marianum.mobile.client"
minSdkVersion 26
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
@ -64,6 +66,5 @@ flutter {
}
dependencies {
implementation 'com.android.support:multidex:2.0.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
implementation 'com.android.support:multidex:1.0.3'
}

View File

View File

@ -1,6 +1,3 @@
org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false

View File

@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -19,8 +19,8 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.7.3' apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}
include ":app"

View File

@ -1,29 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIFBTCCAu2gAwIBAgIQS6hSk/eaL6JzBkuoBI110DANBgkqhkiG9w0BAQsFADBP
MQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFy
Y2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBYMTAeFw0yNDAzMTMwMDAwMDBa
Fw0yNzAzMTIyMzU5NTlaMDMxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBF
bmNyeXB0MQwwCgYDVQQDEwNSMTAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQDPV+XmxFQS7bRH/sknWHZGUCiMHT6I3wWd1bUYKb3dtVq/+vbOo76vACFL
YlpaPAEvxVgD9on/jhFD68G14BQHlo9vH9fnuoE5CXVlt8KvGFs3Jijno/QHK20a
/6tYvJWuQP/py1fEtVt/eA0YYbwX51TGu0mRzW4Y0YCF7qZlNrx06rxQTOr8IfM4
FpOUurDTazgGzRYSespSdcitdrLCnF2YRVxvYXvGLe48E1KGAdlX5jgc3421H5KR
mudKHMxFqHJV8LDmowfs/acbZp4/SItxhHFYyTr6717yW0QrPHTnj7JHwQdqzZq3
DZb3EoEmUVQK7GH29/Xi8orIlQ2NAgMBAAGjgfgwgfUwDgYDVR0PAQH/BAQDAgGG
MB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATASBgNVHRMBAf8ECDAGAQH/
AgEAMB0GA1UdDgQWBBS7vMNHpeS8qcbDpHIMEI2iNeHI6DAfBgNVHSMEGDAWgBR5
tFnme7bl5AFzgAiIyBpY9umbbjAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAKG
Fmh0dHA6Ly94MS5pLmxlbmNyLm9yZy8wEwYDVR0gBAwwCjAIBgZngQwBAgEwJwYD
VR0fBCAwHjAcoBqgGIYWaHR0cDovL3gxLmMubGVuY3Iub3JnLzANBgkqhkiG9w0B
AQsFAAOCAgEAkrHnQTfreZ2B5s3iJeE6IOmQRJWjgVzPw139vaBw1bGWKCIL0vIo
zwzn1OZDjCQiHcFCktEJr59L9MhwTyAWsVrdAfYf+B9haxQnsHKNY67u4s5Lzzfd
u6PUzeetUK29v+PsPmI2cJkxp+iN3epi4hKu9ZzUPSwMqtCceb7qPVxEbpYxY1p9
1n5PJKBLBX9eb9LU6l8zSxPWV7bK3lG4XaMJgnT9x3ies7msFtpKK5bDtotij/l0
GaKeA97pb5uwD9KgWvaFXMIEt8jVTjLEvwRdvCn294GPDF08U8lAkIv7tghluaQh
1QnlE4SEN4LOECj8dsIGJXpGUk3aU3KkJz9icKy+aUgA+2cP21uh6NcDIS3XyfaZ
QjmDQ993ChII8SXWupQZVBiIpcWO4RqZk3lr7Bz5MUCwzDIA359e57SSq5CCkY0N
4B6Vulk7LktfwrdGNVI5BsC9qqxSwSKgRJeZ9wygIaehbHFHFhcBaMDKpiZlBHyz
rsnnlFXCb5s8HKn5LsUgGvB24L7sGNZP2CX7dhHov+YhD+jozLW2p9W4959Bz2Ei
RmqDtmiXLnzqTpXbI+suyCsohKRg6Un0RC47+cpiVwHiXZAW+cn8eiNIjqbVgXLx
KPpdzvvtTnOPlC7SQZSYmdunr3Bf9b77AiC/ZidstK36dRILKz7OA54=
-----END CERTIFICATE-----

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -1,7 +0,0 @@
targets:
$default:
builders:
json_serializable:
options:
explicit_to_json: false
generic_argument_factories: true

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -4,5 +4,7 @@ class ApiError {
ApiError(this.message);
@override
String toString() => 'ApiError: $message';
String toString() {
return 'ApiError: $message';
}
}

View File

@ -5,5 +5,5 @@ abstract class ApiResponse {
late http.Response rawResponse;
@JsonKey(includeIfNull: false)
Map<String, String>? headers;
late Map<String, String>? headers;
}

View File

@ -1,15 +1,17 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'getHolidaysResponse.dart';
class GetHolidays {
Future<GetHolidaysResponse> query() async {
var response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
var data = jsonDecode(response) as List<dynamic>;
String response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
return GetHolidaysResponse(
List<GetHolidaysResponseObject>.from(
data.map<GetHolidaysResponseObject>((e) => GetHolidaysResponseObject.fromJson(e as Map<String, dynamic>))
jsonDecode(response).map<GetHolidaysResponseObject>(
GetHolidaysResponseObject.fromJson
)
)
);
}

View File

@ -6,21 +6,24 @@ import 'getHolidaysResponse.dart';
class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
GetHolidaysCache({onUpdate, renew}) : super(RequestCache.cacheDay, onUpdate, renew: renew) {
start('state-holidays');
start('MarianumMobile', 'state-holidays');
}
@override
GetHolidaysResponse onLocalData(String json) {
List<dynamic> parsedListJson = jsonDecode(json)['data'];
return GetHolidaysResponse(
List<GetHolidaysResponseObject>.from(
parsedListJson.map<GetHolidaysResponseObject>(
(i) => GetHolidaysResponseObject.fromJson(i as Map<String, dynamic>)
List<GetHolidaysResponseObject>.from(
parsedListJson.map<GetHolidaysResponseObject>(
// ignore: unnecessary_lambdas
(dynamic i) => GetHolidaysResponseObject.fromJson(i)
)
)
)
);
}
@override
Future<GetHolidaysResponse> onLoad() => GetHolidays().query();
Future<GetHolidaysResponse> onLoad() {
return GetHolidays().query();
}
}

View File

@ -16,19 +16,26 @@ GetHolidaysResponse _$GetHolidaysResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetHolidaysResponseToJson(
GetHolidaysResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'data': instance.data.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$GetHolidaysResponseToJson(GetHolidaysResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['data'] = instance.data.map((e) => e.toJson()).toList();
return val;
}
GetHolidaysResponseObject _$GetHolidaysResponseObjectFromJson(
Map<String, dynamic> json) =>
GetHolidaysResponseObject(
start: json['start'] as String,
end: json['end'] as String,
year: (json['year'] as num).toInt(),
year: json['year'] as int,
stateCode: json['stateCode'] as String,
name: json['name'] as String,
slug: json['slug'] as String,

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../model/accountData.dart';
import '../../../model/endpointData.dart';
@ -9,7 +10,7 @@ import 'autocompleteResponse.dart';
class AutocompleteApi {
Future<AutocompleteResponse> find(String query) async {
var getParameters = <String, dynamic>{
Map<String, dynamic> getParameters = {
'search': query,
'itemType': ' ',
'itemId': ' ',
@ -17,15 +18,15 @@ class AutocompleteApi {
'limit': '10',
};
var headers = <String, String>{};
Map<String, String> headers = {};
headers.putIfAbsent('Accept', () => 'application/json');
headers.putIfAbsent('OCS-APIRequest', () => 'true');
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters);
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters);
var response = await http.get(endpoint, headers: headers);
Response response = await http.get(endpoint, headers: headers);
if(response.statusCode != HttpStatus.ok) throw Exception('Api call failed with ${response.statusCode}: ${response.body}');
var result = response.body;
String result = response.body;
return AutocompleteResponse.fromJson(jsonDecode(result)['ocs']);
}

View File

@ -1,6 +1,7 @@
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../model/accountData.dart';
import '../../../model/endpointData.dart';
@ -8,12 +9,12 @@ import 'fileSharingApiParams.dart';
class FileSharingApi {
Future<void> share(FileSharingApiParams query) async {
var headers = <String, String>{};
Map<String, String> headers = {};
headers.putIfAbsent('Accept', () => 'application/json');
headers.putIfAbsent('OCS-APIRequest', () => 'true');
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString())));
var response = await http.post(endpoint, headers: headers);
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString())));
Response response = await http.post(endpoint, headers: headers);
if(response.statusCode != HttpStatus.ok) {
throw Exception('Api call failed with ${response.statusCode}: ${response.body}');

View File

@ -9,7 +9,7 @@ part of 'fileSharingApiParams.dart';
FileSharingApiParams _$FileSharingApiParamsFromJson(
Map<String, dynamic> json) =>
FileSharingApiParams(
shareType: (json['shareType'] as num).toInt(),
shareType: json['shareType'] as int,
shareWith: json['shareWith'] as String,
path: json['path'] as String,
referenceId: json['referenceId'] as String?,

View File

@ -14,9 +14,13 @@ class GetChat extends TalkApi<GetChatResponse> {
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
@override
assemble(String raw) => GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
assemble(String raw) {
return GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
}
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
return http.get(uri, headers: headers);
}
}

View File

@ -9,11 +9,12 @@ class GetChatCache extends RequestCache<GetChatResponse> {
String chatToken;
GetChatCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
start('nc-chat-$chatToken');
start('MarianumMobile', 'nc-chat-$chatToken');
}
@override
Future<GetChatResponse> onLoad() => GetChat(
Future<GetChatResponse> onLoad() {
return GetChat(
chatToken,
GetChatParams(
lookIntoFuture: GetChatParamsSwitch.off,
@ -21,8 +22,11 @@ class GetChatCache extends RequestCache<GetChatResponse> {
limit: 200,
)
).run();
}
@override
GetChatResponse onLocalData(String json) => GetChatResponse.fromJson(jsonDecode(json));
GetChatResponse onLocalData(String json) {
return GetChatResponse.fromJson(jsonDecode(json));
}
}

View File

@ -10,32 +10,37 @@ GetChatParams _$GetChatParamsFromJson(Map<String, dynamic> json) =>
GetChatParams(
lookIntoFuture:
$enumDecode(_$GetChatParamsSwitchEnumMap, json['lookIntoFuture']),
limit: (json['limit'] as num?)?.toInt(),
lastKnownMessageId: (json['lastKnownMessageId'] as num?)?.toInt(),
lastCommonReadId: (json['lastCommonReadId'] as num?)?.toInt(),
timeout: (json['timeout'] as num?)?.toInt(),
limit: json['limit'] as int?,
lastKnownMessageId: json['lastKnownMessageId'] as int?,
lastCommonReadId: json['lastCommonReadId'] as int?,
timeout: json['timeout'] as int?,
setReadMarker: $enumDecodeNullable(
_$GetChatParamsSwitchEnumMap, json['setReadMarker']),
includeLastKnown: $enumDecodeNullable(
_$GetChatParamsSwitchEnumMap, json['includeLastKnown']),
);
Map<String, dynamic> _$GetChatParamsToJson(GetChatParams instance) =>
<String, dynamic>{
'lookIntoFuture': _$GetChatParamsSwitchEnumMap[instance.lookIntoFuture]!,
if (instance.limit case final value?) 'limit': value,
if (instance.lastKnownMessageId case final value?)
'lastKnownMessageId': value,
if (instance.lastCommonReadId case final value?)
'lastCommonReadId': value,
if (instance.timeout case final value?) 'timeout': value,
if (_$GetChatParamsSwitchEnumMap[instance.setReadMarker]
case final value?)
'setReadMarker': value,
if (_$GetChatParamsSwitchEnumMap[instance.includeLastKnown]
case final value?)
'includeLastKnown': value,
};
Map<String, dynamic> _$GetChatParamsToJson(GetChatParams instance) {
final val = <String, dynamic>{
'lookIntoFuture': _$GetChatParamsSwitchEnumMap[instance.lookIntoFuture]!,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('limit', instance.limit);
writeNotNull('lastKnownMessageId', instance.lastKnownMessageId);
writeNotNull('lastCommonReadId', instance.lastCommonReadId);
writeNotNull('timeout', instance.timeout);
writeNotNull(
'setReadMarker', _$GetChatParamsSwitchEnumMap[instance.setReadMarker]);
writeNotNull('includeLastKnown',
_$GetChatParamsSwitchEnumMap[instance.includeLastKnown]);
return val;
}
const _$GetChatParamsSwitchEnumMap = {
GetChatParamsSwitch.on: 1,

View File

@ -16,7 +16,7 @@ class GetChatResponse extends ApiResponse {
Map<String, dynamic> toJson() => _$GetChatResponseToJson(this);
List<GetChatResponseObject> sortByTimestamp() {
var sorted = data.toList();
List<GetChatResponseObject> sorted = data.toList();
sorted.sort((a, b) => a.timestamp.compareTo(b.timestamp));
return sorted;
}
@ -38,7 +38,6 @@ class GetChatResponseObject {
Map<String, int>? reactions;
List<String>? reactionsSelf;
@JsonKey(fromJson: _fromJson) Map<String, RichObjectString>? messageParameters;
GetChatResponseObject? parent;
GetChatResponseObject(
this.id,
@ -54,19 +53,19 @@ class GetChatResponseObject {
this.message,
this.messageParameters,
this.reactions,
this.reactionsSelf,
this.parent,
this.reactionsSelf
);
factory GetChatResponseObject.fromJson(Map<String, dynamic> json) => _$GetChatResponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
static GetChatResponseObject getDateDummy(int timestamp) {
var elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy'));
}
static GetChatResponseObject getTextDummy(String text) => GetChatResponseObject(
static GetChatResponseObject getTextDummy(String text) {
return GetChatResponseObject(
0,
'',
GetRoomResponseObjectMessageActorType.user,
@ -80,15 +79,15 @@ class GetChatResponseObject {
text,
null,
null,
null,
null,
null
);
}
}
Map<String, RichObjectString>? _fromJson(json) {
if(json is Map<String, dynamic>) {
var data = <String, RichObjectString>{};
Map<String, RichObjectString> data = {};
for (var element in json.keys) {
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element]));
}

View File

@ -15,22 +15,30 @@ GetChatResponse _$GetChatResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetChatResponseToJson(GetChatResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'data': instance.data.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$GetChatResponseToJson(GetChatResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['data'] = instance.data.map((e) => e.toJson()).toList();
return val;
}
GetChatResponseObject _$GetChatResponseObjectFromJson(
Map<String, dynamic> json) =>
GetChatResponseObject(
(json['id'] as num).toInt(),
json['id'] as int,
json['token'] as String,
$enumDecode(
_$GetRoomResponseObjectMessageActorTypeEnumMap, json['actorType']),
json['actorId'] as String,
json['actorDisplayName'] as String,
(json['timestamp'] as num).toInt(),
json['timestamp'] as int,
json['systemMessage'] as String,
$enumDecode(
_$GetRoomResponseObjectMessageTypeEnumMap, json['messageType']),
@ -39,15 +47,11 @@ GetChatResponseObject _$GetChatResponseObjectFromJson(
json['message'] as String,
_fromJson(json['messageParameters']),
(json['reactions'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, (e as num).toInt()),
(k, e) => MapEntry(k, e as int),
),
(json['reactionsSelf'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
json['parent'] == null
? null
: GetChatResponseObject.fromJson(
json['parent'] as Map<String, dynamic>),
);
Map<String, dynamic> _$GetChatResponseObjectToJson(
@ -70,7 +74,6 @@ Map<String, dynamic> _$GetChatResponseObjectToJson(
'reactionsSelf': instance.reactionsSelf,
'messageParameters':
instance.messageParameters?.map((k, e) => MapEntry(k, e.toJson())),
'parent': instance.parent?.toJson(),
};
const _$GetRoomResponseObjectMessageActorTypeEnumMap = {

View File

@ -10,7 +10,9 @@ class CreateRoom extends TalkApi {
CreateRoom(this.params) : super('v4/room', params);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {

View File

@ -8,7 +8,7 @@ part of 'createRoomParams.dart';
CreateRoomParams _$CreateRoomParamsFromJson(Map<String, dynamic> json) =>
CreateRoomParams(
roomType: (json['roomType'] as num).toInt(),
roomType: json['roomType'] as int,
invite: json['invite'] as String,
source: json['source'] as String?,
roomName: json['roomName'] as String?,

View File

@ -10,9 +10,13 @@ class DeleteMessage extends TalkApi {
DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.delete(uri, headers: headers);
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
return http.delete(uri, headers: headers);
}
}

View File

@ -11,7 +11,9 @@ class DeleteReactMessage extends TalkApi {
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {

View File

@ -10,9 +10,13 @@ class GetParticipants extends TalkApi<GetParticipantsResponse> {
GetParticipants(this.token) : super('v4/room/$token/participants', null);
@override
GetParticipantsResponse assemble(String raw) => GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
GetParticipantsResponse assemble(String raw) {
return GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
}
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) {
return http.get(uri, headers: headers);
}
}

View File

@ -8,15 +8,19 @@ class GetParticipantsCache extends RequestCache<GetParticipantsResponse> {
String chatToken;
GetParticipantsCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
start('nc-chat-participants-$chatToken');
start('MarianumMobile', 'nc-chat-participants-$chatToken');
}
@override
Future<GetParticipantsResponse> onLoad() => GetParticipants(
Future<GetParticipantsResponse> onLoad() {
return GetParticipants(
chatToken,
).run();
}
@override
GetParticipantsResponse onLocalData(String json) => GetParticipantsResponse.fromJson(jsonDecode(json));
GetParticipantsResponse onLocalData(String json) {
return GetParticipantsResponse.fromJson(jsonDecode(json));
}
}

View File

@ -18,26 +18,34 @@ GetParticipantsResponse _$GetParticipantsResponseFromJson(
);
Map<String, dynamic> _$GetParticipantsResponseToJson(
GetParticipantsResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'data': instance.data.map((e) => e.toJson()).toList(),
};
GetParticipantsResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['data'] = instance.data.map((e) => e.toJson()).toList();
return val;
}
GetParticipantsResponseObject _$GetParticipantsResponseObjectFromJson(
Map<String, dynamic> json) =>
GetParticipantsResponseObject(
(json['attendeeId'] as num).toInt(),
json['attendeeId'] as int,
json['actorType'] as String,
json['actorId'] as String,
json['displayName'] as String,
$enumDecode(_$GetParticipantsResponseObjectParticipantTypeEnumMap,
json['participantType']),
(json['lastPing'] as num).toInt(),
json['lastPing'] as int,
$enumDecode(_$GetParticipantsResponseObjectParticipantsInCallFlagsEnumMap,
json['inCall']),
(json['permissions'] as num).toInt(),
(json['attendeePermissions'] as num).toInt(),
json['permissions'] as int,
json['attendeePermissions'] as int,
json['sessionId'] as String?,
(json['sessionIds'] as List<dynamic>).map((e) => e as String).toList(),
json['status'] as String?,

View File

@ -13,9 +13,13 @@ class GetReactions extends TalkApi<GetReactionsResponse> {
GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null);
@override
assemble(String raw) => GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
assemble(String raw) {
return GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
}
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.get(uri, headers: headers);
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
return http.get(uri, headers: headers);
}
}

View File

@ -22,12 +22,20 @@ GetReactionsResponse _$GetReactionsResponseFromJson(
);
Map<String, dynamic> _$GetReactionsResponseToJson(
GetReactionsResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'data': instance.data
.map((k, e) => MapEntry(k, e.map((e) => e.toJson()).toList())),
};
GetReactionsResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['data'] = instance.data
.map((k, e) => MapEntry(k, e.map((e) => e.toJson()).toList()));
return val;
}
GetReactionsResponseObject _$GetReactionsResponseObjectFromJson(
Map<String, dynamic> json) =>
@ -36,7 +44,7 @@ GetReactionsResponseObject _$GetReactionsResponseObjectFromJson(
_$GetReactionsResponseObjectActorTypeEnumMap, json['actorType']),
json['actorId'] as String,
json['actorDisplayName'] as String,
(json['timestamp'] as num).toInt(),
json['timestamp'] as int,
);
Map<String, dynamic> _$GetReactionsResponseObjectToJson(

View File

@ -9,8 +9,12 @@ class LeaveRoom extends TalkApi {
LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.delete(uri, headers: headers);
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
return http.delete(uri, headers: headers);
}
}

View File

@ -11,7 +11,9 @@ class ReactMessage extends TalkApi {
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {

View File

@ -14,9 +14,13 @@ class GetRoom extends TalkApi<GetRoomResponse> {
@override
GetRoomResponse assemble(String raw) => GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
GetRoomResponse assemble(String raw) {
return GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
}
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) {
return http.get(uri, headers: headers);
}
}

View File

@ -8,16 +8,20 @@ import 'getRoomResponse.dart';
class GetRoomCache extends RequestCache<GetRoomResponse> {
GetRoomCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('nc-rooms');
start('MarianumMobile', 'nc-rooms');
}
@override
GetRoomResponse onLocalData(String json) => GetRoomResponse.fromJson(jsonDecode(json));
GetRoomResponse onLocalData(String json) {
return GetRoomResponse.fromJson(jsonDecode(json));
}
@override
Future<GetRoomResponse> onLoad() => GetRoom(
Future<GetRoomResponse> onLoad() {
return GetRoom(
GetRoomParams(
includeStatus: true,
)
).run();
}
}

View File

@ -11,7 +11,7 @@ GetRoomParams _$GetRoomParamsFromJson(Map<String, dynamic> json) =>
noStatusUpdate: $enumDecodeNullable(
_$GetRoomParamsStatusUpdateEnumMap, json['noStatusUpdate']),
includeStatus: json['includeStatus'] as bool?,
modifiedSince: (json['modifiedSince'] as num?)?.toInt(),
modifiedSince: json['modifiedSince'] as int?,
);
Map<String, dynamic> _$GetRoomParamsToJson(GetRoomParams instance) =>

View File

@ -110,7 +110,6 @@ enum GetRoomResponseObjectConversationType {
@JsonValue(3) public,
@JsonValue(4) changelog,
@JsonValue(5) deleted,
@JsonValue(6) noteToSelf,
}
enum GetRoomResponseObjectParticipantNotificationLevel {

View File

@ -15,42 +15,50 @@ GetRoomResponse _$GetRoomResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetRoomResponseToJson(GetRoomResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'data': instance.data.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$GetRoomResponseToJson(GetRoomResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['data'] = instance.data.map((e) => e.toJson()).toList();
return val;
}
GetRoomResponseObject _$GetRoomResponseObjectFromJson(
Map<String, dynamic> json) =>
GetRoomResponseObject(
(json['id'] as num).toInt(),
json['id'] as int,
json['token'] as String,
$enumDecode(_$GetRoomResponseObjectConversationTypeEnumMap, json['type']),
json['name'] as String,
json['displayName'] as String,
json['description'] as String,
(json['participantType'] as num).toInt(),
(json['participantFlags'] as num).toInt(),
(json['readOnly'] as num).toInt(),
(json['listable'] as num).toInt(),
(json['lastPing'] as num).toInt(),
json['participantType'] as int,
json['participantFlags'] as int,
json['readOnly'] as int,
json['listable'] as int,
json['lastPing'] as int,
json['sessionId'] as String,
json['hasPassword'] as bool,
json['hasCall'] as bool,
(json['callFlag'] as num).toInt(),
json['callFlag'] as int,
json['canStartCall'] as bool,
json['canDeleteConversation'] as bool,
json['canLeaveConversation'] as bool,
(json['lastActivity'] as num).toInt(),
json['lastActivity'] as int,
json['isFavorite'] as bool,
$enumDecode(_$GetRoomResponseObjectParticipantNotificationLevelEnumMap,
json['notificationLevel']),
(json['unreadMessages'] as num).toInt(),
json['unreadMessages'] as int,
json['unreadMention'] as bool,
json['unreadMentionDirect'] as bool,
(json['lastReadMessage'] as num).toInt(),
(json['lastCommonReadMessage'] as num).toInt(),
json['lastReadMessage'] as int,
json['lastCommonReadMessage'] as int,
GetChatResponseObject.fromJson(
json['lastMessage'] as Map<String, dynamic>),
json['status'] as String?,
@ -102,7 +110,6 @@ const _$GetRoomResponseObjectConversationTypeEnumMap = {
GetRoomResponseObjectConversationType.public: 3,
GetRoomResponseObjectConversationType.changelog: 4,
GetRoomResponseObjectConversationType.deleted: 5,
GetRoomResponseObjectConversationType.noteToSelf: 6,
};
const _$GetRoomResponseObjectParticipantNotificationLevelEnumMap = {

View File

@ -10,7 +10,9 @@ class SendMessage extends TalkApi {
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {

View File

@ -7,7 +7,7 @@ part 'sendMessageParams.g.dart';
@JsonSerializable(explicitToJson: true, includeIfNull: false)
class SendMessageParams extends ApiParams {
String message;
String? replyTo;
int? replyTo;
SendMessageParams(this.message, {this.replyTo});

View File

@ -9,11 +9,20 @@ part of 'sendMessageParams.dart';
SendMessageParams _$SendMessageParamsFromJson(Map<String, dynamic> json) =>
SendMessageParams(
json['message'] as String,
replyTo: json['replyTo'] as String?,
replyTo: json['replyTo'] as int?,
);
Map<String, dynamic> _$SendMessageParamsToJson(SendMessageParams instance) =>
<String, dynamic>{
'message': instance.message,
if (instance.replyTo case final value?) 'replyTo': value,
};
Map<String, dynamic> _$SendMessageParamsToJson(SendMessageParams instance) {
final val = <String, dynamic>{
'message': instance.message,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('replyTo', instance.replyTo);
return val;
}

View File

@ -11,7 +11,9 @@ class SetFavorite extends TalkApi {
SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null);
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {

View File

@ -15,7 +15,9 @@ class SetReadMarker extends TalkApi {
}
@override
assemble(String raw) => null;
assemble(String raw) {
return null;
}
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {

View File

@ -8,7 +8,7 @@ part of 'setReadMarkerParams.dart';
SetReadMarkerParams _$SetReadMarkerParamsFromJson(Map<String, dynamic> json) =>
SetReadMarkerParams(
lastReadMessage: (json['lastReadMessage'] as num?)?.toInt(),
lastReadMessage: json['lastReadMessage'] as int?,
);
Map<String, dynamic> _$SetReadMarkerParamsToJson(

View File

@ -34,7 +34,7 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
getParameters?.update(key, (value) => value.toString());
});
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
headers ??= {};
headers?.putIfAbsent('Accept', () => 'application/json');
@ -58,9 +58,11 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
assembled?.headers = data.headers;
return assembled;
} catch (e) {
var message = 'Error assembling Talk API ${T.toString()} message: ${e.toString()} response with request body: $body and request headers: ${headers.toString()}';
log(message);
throw Exception(message);
// TODO report error
log('Error assembling Talk API ${T.toString()} message: ${e.toString()} response on ${endpoint.path} with request body: $body and request headers: ${headers.toString()}');
}
throw Exception('Error assembling Talk API response');
}
}

View File

@ -6,5 +6,7 @@ class TalkError {
TalkError(this.status, this.code, this.message);
@override
String toString() => 'Talk - $status - ($code): $message';
String toString() {
return 'Talk - $status - ($code): $message';
}
}

View File

@ -12,7 +12,7 @@ CacheableFile _$CacheableFileFromJson(Map<String, dynamic> json) =>
isDirectory: json['isDirectory'] as bool,
name: json['name'] as String,
mimeType: json['mimeType'] as String?,
size: (json['size'] as num?)?.toInt(),
size: json['size'] as int?,
eTag: json['eTag'] as String?,
createdAt: json['createdAt'] == null
? null

View File

@ -13,8 +13,8 @@ class ListFiles extends WebdavApi<ListFilesParams> {
@override
Future<ListFilesResponse> run() async {
var davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles();
var files = davFiles.map(CacheableFile.fromDavFile).toSet();
List<WebDavFile> davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles();
Set<CacheableFile> files = davFiles.map(CacheableFile.fromDavFile).toSet();
// webdav handles subdirectories wrong, this is a fix
// currently this fix is not needed anymore

View File

@ -11,17 +11,19 @@ class ListFilesCache extends RequestCache<ListFilesResponse> {
ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
var bytes = utf8.encode('MarianumMobile-$path');
var cacheName = md5.convert(bytes).toString();
start('wd-folder-$cacheName');
String cacheName = md5.convert(bytes).toString();
start('MarianumMobile', 'wd-folder-$cacheName');
}
@override
Future<ListFilesResponse> onLoad() async {
var data = await ListFiles(ListFilesParams(path)).run();
ListFilesResponse data = await ListFiles(ListFilesParams(path)).run();
return data;
}
@override
ListFilesResponse onLocalData(String json) => ListFilesResponse.fromJson(jsonDecode(json));
ListFilesResponse onLocalData(String json) {
return ListFilesResponse.fromJson(jsonDecode(json));
}
}

View File

@ -15,8 +15,16 @@ ListFilesResponse _$ListFilesResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$ListFilesResponseToJson(ListFilesResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'files': instance.files.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$ListFilesResponseToJson(ListFilesResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['files'] = instance.files.map((e) => e.toJson()).toList();
return val;
}

View File

@ -17,7 +17,11 @@ abstract class WebdavApi<T> extends ApiRequest {
static Future<WebDavClient> webdav = establishWebdavConnection();
static Future<String> webdavConnectString = buildWebdavConnectString();
static Future<WebDavClient> establishWebdavConnection() async => NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav;
static Future<WebDavClient> establishWebdavConnection() async {
return NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav;
}
static Future<String> buildWebdavConnectString() async => 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/';
static Future<String> buildWebdavConnectString() async {
return 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/';
}
}

View File

@ -9,9 +9,13 @@ class GetBreakers extends MhslApi<GetBreakersResponse> {
GetBreakers() : super('breaker/');
@override
GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw));
GetBreakersResponse assemble(String raw) {
return GetBreakersResponse.fromJson(jsonDecode(raw));
}
@override
Future<Response>? request(Uri uri) => http.get(uri);
Future<Response>? request(Uri uri) {
return http.get(uri);
}
}

View File

@ -6,12 +6,16 @@ import 'getBreakersResponse.dart';
class GetBreakersCache extends RequestCache<GetBreakersResponse> {
GetBreakersCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('breakers');
start('MarianumMobile', 'breakers');
}
@override
GetBreakersResponse onLocalData(String json) => GetBreakersResponse.fromJson(jsonDecode(json));
GetBreakersResponse onLocalData(String json) {
return GetBreakersResponse.fromJson(jsonDecode(json));
}
@override
Future<GetBreakersResponse> onLoad() => GetBreakers().run();
Future<GetBreakersResponse> onLoad() {
return GetBreakers().run();
}
}

View File

@ -17,13 +17,20 @@ GetBreakersResponse _$GetBreakersResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetBreakersResponseToJson(
GetBreakersResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'global': instance.global.toJson(),
'regional': instance.regional.map((k, e) => MapEntry(k, e.toJson())),
};
Map<String, dynamic> _$GetBreakersResponseToJson(GetBreakersResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['global'] = instance.global.toJson();
val['regional'] = instance.regional.map((k, e) => MapEntry(k, e.toJson()));
return val;
}
GetBreakersReponseObject _$GetBreakersReponseObjectFromJson(
Map<String, dynamic> json) =>

View File

@ -16,7 +16,7 @@ class AddCustomTimetableEvent extends MhslApi<void> {
@override
Future<Response>? request(Uri uri) {
var body = jsonEncode(params.toJson());
String body = jsonEncode(params.toJson());
return http.post(uri, body: body);
}
}

View File

@ -12,8 +12,12 @@ class GetCustomTimetableEvent extends MhslApi<GetCustomTimetableEventResponse> {
GetCustomTimetableEvent(this.params) : super('server/timetable/customEvents?user=${params.user}');
@override
GetCustomTimetableEventResponse assemble(String raw) => GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
GetCustomTimetableEventResponse assemble(String raw) {
return GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
}
@override
Future<Response>? request(Uri uri) => http.get(uri);
Future<Response>? request(Uri uri) {
return http.get(uri);
}
}

View File

@ -9,12 +9,16 @@ class GetCustomTimetableEventCache extends RequestCache<GetCustomTimetableEventR
GetCustomTimetableEventParams params;
GetCustomTimetableEventCache(this.params, {onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('customTimetableEvents');
start('MarianumMobile', 'customTimetableEvents');
}
@override
Future<GetCustomTimetableEventResponse> onLoad() => GetCustomTimetableEvent(params).run();
Future<GetCustomTimetableEventResponse> onLoad() {
return GetCustomTimetableEvent(params).run();
}
@override
GetCustomTimetableEventResponse onLocalData(String json) => GetCustomTimetableEventResponse.fromJson(jsonDecode(json));
GetCustomTimetableEventResponse onLocalData(String json) {
return GetCustomTimetableEventResponse.fromJson(jsonDecode(json));
}
}

View File

@ -17,8 +17,16 @@ GetCustomTimetableEventResponse _$GetCustomTimetableEventResponseFromJson(
);
Map<String, dynamic> _$GetCustomTimetableEventResponseToJson(
GetCustomTimetableEventResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'events': instance.events,
};
GetCustomTimetableEventResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['events'] = instance.events;
return val;
}

View File

@ -15,5 +15,7 @@ class RemoveCustomTimetableEvent extends MhslApi<void> {
void assemble(String raw) {}
@override
Future<Response>? request(Uri uri) => http.delete(uri, body: jsonEncode(params.toJson()));
Future<Response>? request(Uri uri) {
return http.delete(uri, body: jsonEncode(params.toJson()));
}
}

View File

@ -15,5 +15,7 @@ class UpdateCustomTimetableEvent extends MhslApi<void> {
void assemble(String raw) {}
@override
Future<Response>? request(Uri uri) => http.patch(uri, body: jsonEncode(params.toJson()));
Future<Response>? request(Uri uri) {
return http.patch(uri, body: jsonEncode(params.toJson()));
}
}

View File

@ -0,0 +1,21 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../../mhslApi.dart';
import 'getMessagesResponse.dart';
class GetMessages extends MhslApi<GetMessagesResponse> {
GetMessages() : super('message/messages.json');
@override
GetMessagesResponse assemble(String raw) {
return GetMessagesResponse.fromJson(jsonDecode(raw));
}
@override
Future<http.Response> request(Uri uri) {
return http.get(uri);
}
}

View File

@ -0,0 +1,21 @@
import 'dart:convert';
import '../../../requestCache.dart';
import 'getMessages.dart';
import 'getMessagesResponse.dart';
class GetMessagesCache extends RequestCache<GetMessagesResponse> {
GetMessagesCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
start('MarianumMobile', 'message');
}
@override
GetMessagesResponse onLocalData(String json) {
return GetMessagesResponse.fromJson(jsonDecode(json));
}
@override
Future<GetMessagesResponse> onLoad() {
return GetMessages().run();
}
}

View File

@ -0,0 +1,28 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
part 'getMessagesResponse.g.dart';
@JsonSerializable(explicitToJson: true)
class GetMessagesResponse extends ApiResponse {
String base;
Set<GetMessagesResponseObject> messages;
GetMessagesResponse(this.base, this.messages);
factory GetMessagesResponse.fromJson(Map<String, dynamic> json) => _$GetMessagesResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetMessagesResponseToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GetMessagesResponseObject {
String name;
String date;
String url;
GetMessagesResponseObject(this.name, this.date, this.url);
factory GetMessagesResponseObject.fromJson(Map<String, dynamic> json) => _$GetMessagesResponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetMessagesResponseObjectToJson(this);
}

View File

@ -0,0 +1,49 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getMessagesResponse.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
GetMessagesResponse _$GetMessagesResponseFromJson(Map<String, dynamic> json) =>
GetMessagesResponse(
json['base'] as String,
(json['messages'] as List<dynamic>)
.map((e) =>
GetMessagesResponseObject.fromJson(e as Map<String, dynamic>))
.toSet(),
)..headers = (json['headers'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetMessagesResponseToJson(GetMessagesResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['base'] = instance.base;
val['messages'] = instance.messages.map((e) => e.toJson()).toList();
return val;
}
GetMessagesResponseObject _$GetMessagesResponseObjectFromJson(
Map<String, dynamic> json) =>
GetMessagesResponseObject(
json['name'] as String,
json['date'] as String,
json['url'] as String,
);
Map<String, dynamic> _$GetMessagesResponseObjectToJson(
GetMessagesResponseObject instance) =>
<String, dynamic>{
'name': instance.name,
'date': instance.date,
'url': instance.url,
};

View File

@ -15,9 +15,9 @@ abstract class MhslApi<T> extends ApiRequest {
T assemble(String raw);
Future<T> run() async {
var endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
Uri endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
var data = await request(endpoint);
http.Response? data = await request(endpoint);
if(data == null) {
throw ApiError('Request could not be dispatched!');
}
@ -31,4 +31,5 @@ abstract class MhslApi<T> extends ApiRequest {
static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss');
static DateTime dateTimeFromJson(String time) => DateTime.parse(time);
}

View File

@ -19,8 +19,8 @@ class NotifyRegister extends MhslApi<void> {
@override
Future<http.Response> request(Uri uri) {
var requestString = jsonEncode(params.toJson());
log('register at push proxy with username ${params.username}');
String requestString = jsonEncode(params.toJson());
log(requestString);
return http.post(uri, body: requestString);
}
}

View File

@ -15,5 +15,7 @@ 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) {
return http.post(uri, body: jsonEncode(params.toJson()));
}
}

View File

@ -6,14 +6,12 @@ part 'addFeedbackParams.g.dart';
class AddFeedbackParams {
String user;
String feedback;
String? screenshot;
int appVersion;
AddFeedbackParams({
required this.user,
required this.feedback,
this.screenshot,
required this.appVersion,
});

View File

@ -10,14 +10,12 @@ AddFeedbackParams _$AddFeedbackParamsFromJson(Map<String, dynamic> json) =>
AddFeedbackParams(
user: json['user'] as String,
feedback: json['feedback'] as String,
screenshot: json['screenshot'] as String?,
appVersion: (json['appVersion'] as num).toInt(),
appVersion: json['appVersion'] as int,
);
Map<String, dynamic> _$AddFeedbackParamsToJson(AddFeedbackParams instance) =>
<String, dynamic>{
'user': instance.user,
'feedback': instance.feedback,
'screenshot': instance.screenshot,
'appVersion': instance.appVersion,
};

View File

@ -12,7 +12,7 @@ UpdateUserIndexParams _$UpdateUserIndexParamsFromJson(
user: json['user'] as String,
username: json['username'] as String,
device: json['device'] as String,
appVersion: (json['appVersion'] as num).toInt(),
appVersion: json['appVersion'] as int,
deviceInfo: json['deviceInfo'] as String,
);

View File

@ -4,7 +4,7 @@ import 'dart:developer';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:http/http.dart' as http;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:package_info/package_info.dart';
import '../../../../../model/accountData.dart';
import '../../../mhslApi.dart';
@ -19,12 +19,12 @@ class UpdateUserIndex extends MhslApi<void> {
@override
Future<http.Response> request(Uri uri) {
var data = jsonEncode(params.toJson());
log('Updating userindex: ${data.length}');
String data = jsonEncode(params.toJson());
log('Updating userindex:\n $data');
return http.post(uri, body: data);
}
static Future<void> index() async {
static void index() async {
UpdateUserIndex(
UpdateUserIndexParams(
username: AccountData().getUsername(),

View File

@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:developer';
import 'package:localstore/localstore.dart';
@ -10,8 +11,6 @@ abstract class RequestCache<T extends ApiResponse?> {
static const int cacheHour = 60 * 60;
static const int cacheDay = 60 * 60 * 24;
static String collection = 'MarianumMobile';
int maxCacheTime;
Function(T) onUpdate;
Function(Exception) onError;
@ -21,8 +20,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static void ignore(Exception e) {}
Future<void> start(String document) async {
var tableData = await Localstore.instance.collection(collection).doc(document).get();
void start(String file, String document) async {
Map<String, dynamic>? tableData = await Localstore.instance.collection(file).doc(document).get();
if(tableData != null) {
onUpdate(onLocalData(tableData['json']));
}
@ -31,16 +30,18 @@ abstract class RequestCache<T extends ApiResponse?> {
if(renew == null || !renew!) return;
}
T? newValue;
try {
var newValue = await onLoad();
onUpdate(newValue);
newValue = await onLoad();
onUpdate(newValue as T);
Localstore.instance.collection(collection).doc(document).set({
Localstore.instance.collection(file).doc(document).set({
'json': jsonEncode(newValue),
'lastupdate': DateTime.now().millisecondsSinceEpoch
});
} on Exception catch(e) {
onError(e);
} catch(e) {
log("Error while fetching/ parsing. Raw server response: ${newValue?.rawResponse.body ?? "no response"}");
onError(Exception(e.toString()));
}
}

View File

@ -14,7 +14,7 @@ class Authenticate extends WebuntisApi {
@override
Future<AuthenticateResponse> run() async {
awaitingResponse = true;
var rawAnswer = await query(this);
String rawAnswer = await query(this);
AuthenticateResponse response = finalize(AuthenticateResponse.fromJson(jsonDecode(rawAnswer)['result']));
_lastResponse = response;
if(!awaitedResponse.isCompleted) awaitedResponse.complete();

View File

@ -10,19 +10,27 @@ AuthenticateResponse _$AuthenticateResponseFromJson(
Map<String, dynamic> json) =>
AuthenticateResponse(
json['sessionId'] as String,
(json['personType'] as num).toInt(),
(json['personId'] as num).toInt(),
(json['klasseId'] as num).toInt(),
json['personType'] as int,
json['personId'] as int,
json['klasseId'] as int,
)..headers = (json['headers'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$AuthenticateResponseToJson(
AuthenticateResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'sessionId': instance.sessionId,
'personType': instance.personType,
'personId': instance.personId,
'klasseId': instance.klasseId,
};
AuthenticateResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['sessionId'] = instance.sessionId;
val['personType'] = instance.personType;
val['personId'] = instance.personId;
val['klasseId'] = instance.klasseId;
return val;
}

View File

@ -8,7 +8,7 @@ class GetHolidays extends WebuntisApi {
@override
Future<GetHolidaysResponse> run() async {
var rawAnswer = await query(this);
String rawAnswer = await query(this);
return finalize(GetHolidaysResponse.fromJson(jsonDecode(rawAnswer)));
}
@ -17,8 +17,8 @@ class GetHolidays extends WebuntisApi {
time = DateTime(time.year, time.month, time.day, 0, 0, 0, 0, 0);
for (var element in holidaysResponse.result) {
var start = DateTime.parse(element.startDate.toString());
var end = DateTime.parse(element.endDate.toString());
DateTime start = DateTime.parse(element.startDate.toString());
DateTime end = DateTime.parse(element.endDate.toString());
if(!start.isAfter(time) && !end.isBefore(time)) return element;
}

View File

@ -6,12 +6,16 @@ import 'getHolidaysResponse.dart';
class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
GetHolidaysCache({onUpdate}) : super(RequestCache.cacheDay, onUpdate) {
start('wu-holidays');
start('MarianumMobile', 'wu-holidays');
}
@override
Future<GetHolidaysResponse> onLoad() => GetHolidays().run();
Future<GetHolidaysResponse> onLoad() {
return GetHolidays().run();
}
@override
GetHolidaysResponse onLocalData(String json) => GetHolidaysResponse.fromJson(jsonDecode(json));
GetHolidaysResponse onLocalData(String json) {
return GetHolidaysResponse.fromJson(jsonDecode(json));
}
}

View File

@ -16,21 +16,28 @@ GetHolidaysResponse _$GetHolidaysResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetHolidaysResponseToJson(
GetHolidaysResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'result': instance.result.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$GetHolidaysResponseToJson(GetHolidaysResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['result'] = instance.result.map((e) => e.toJson()).toList();
return val;
}
GetHolidaysResponseObject _$GetHolidaysResponseObjectFromJson(
Map<String, dynamic> json) =>
GetHolidaysResponseObject(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longName'] as String,
(json['startDate'] as num).toInt(),
(json['endDate'] as num).toInt(),
json['startDate'] as int,
json['endDate'] as int,
);
Map<String, dynamic> _$GetHolidaysResponseObjectToJson(

View File

@ -9,7 +9,7 @@ class GetRooms extends WebuntisApi {
@override
Future<GetRoomsResponse> run() async {
var rawAnswer = await query(this);
String rawAnswer = await query(this);
try {
return finalize(GetRoomsResponse.fromJson(jsonDecode(rawAnswer)));
} catch(e, trace) {

View File

@ -6,13 +6,17 @@ import 'getRoomsResponse.dart';
class GetRoomsCache extends RequestCache<GetRoomsResponse> {
GetRoomsCache({onUpdate}) : super(RequestCache.cacheHour, onUpdate) {
start('wu-rooms');
start('MarianumMobile', 'wu-rooms');
}
@override
Future<GetRoomsResponse> onLoad() => GetRooms().run();
Future<GetRoomsResponse> onLoad() {
return GetRooms().run();
}
@override
GetRoomsResponse onLocalData(String json) => GetRoomsResponse.fromJson(jsonDecode(json));
GetRoomsResponse onLocalData(String json) {
return GetRoomsResponse.fromJson(jsonDecode(json));
}
}

View File

@ -16,16 +16,24 @@ GetRoomsResponse _$GetRoomsResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetRoomsResponseToJson(GetRoomsResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'result': instance.result.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$GetRoomsResponseToJson(GetRoomsResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['result'] = instance.result.map((e) => e.toJson()).toList();
return val;
}
GetRoomsResponseObject _$GetRoomsResponseObjectFromJson(
Map<String, dynamic> json) =>
GetRoomsResponseObject(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longName'] as String,
json['active'] as bool,

View File

@ -8,7 +8,7 @@ class GetSubjects extends WebuntisApi {
@override
Future<GetSubjectsResponse> run() async {
var rawAnswer = await query(this);
String rawAnswer = await query(this);
return finalize(GetSubjectsResponse.fromJson(jsonDecode(rawAnswer)));
}
}

View File

@ -6,13 +6,17 @@ import 'getSubjectsResponse.dart';
class GetSubjectsCache extends RequestCache<GetSubjectsResponse> {
GetSubjectsCache({onUpdate}) : super(RequestCache.cacheHour, onUpdate) {
start('wu-subjects');
start('MarianumMobile', 'wu-subjects');
}
@override
Future<GetSubjectsResponse> onLoad() => GetSubjects().run();
Future<GetSubjectsResponse> onLoad() {
return GetSubjects().run();
}
@override
onLocalData(String json) => GetSubjectsResponse.fromJson(jsonDecode(json));
onLocalData(String json) {
return GetSubjectsResponse.fromJson(jsonDecode(json));
}
}

View File

@ -16,17 +16,24 @@ GetSubjectsResponse _$GetSubjectsResponseFromJson(Map<String, dynamic> json) =>
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetSubjectsResponseToJson(
GetSubjectsResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'result': instance.result.map((e) => e.toJson()).toList(),
};
Map<String, dynamic> _$GetSubjectsResponseToJson(GetSubjectsResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['result'] = instance.result.map((e) => e.toJson()).toList();
return val;
}
GetSubjectsResponseObject _$GetSubjectsResponseObjectFromJson(
Map<String, dynamic> json) =>
GetSubjectsResponseObject(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longName'] as String,
json['alternateName'] as String,

View File

@ -11,7 +11,7 @@ class GetTimetable extends WebuntisApi {
@override
Future<GetTimetableResponse> run() async {
var rawAnswer = await query(this);
String rawAnswer = await query(this);
return finalize(GetTimetableResponse.fromJson(jsonDecode(rawAnswer)));
}

View File

@ -11,14 +11,17 @@ class GetTimetableCache extends RequestCache<GetTimetableResponse> {
int enddate;
GetTimetableCache({required onUpdate, onError, required this.startdate, required this.enddate}) : super(RequestCache.cacheMinute, onUpdate, onError: onError) {
start('wu-timetable-$startdate-$enddate');
start('MarianumMobile', 'wu-timetable-$startdate-$enddate');
}
@override
GetTimetableResponse onLocalData(String json) => GetTimetableResponse.fromJson(jsonDecode(json));
GetTimetableResponse onLocalData(String json) {
return GetTimetableResponse.fromJson(jsonDecode(json));
}
@override
Future<GetTimetableResponse> onLoad() async => GetTimetable(
Future<GetTimetableResponse> onLoad() async {
return GetTimetable(
GetTimetableParams(
options: GetTimetableParamsOptions(
element: GetTimetableParamsOptionsElement(
@ -35,4 +38,5 @@ class GetTimetableCache extends RequestCache<GetTimetableResponse> {
)
)
).run();
}
}

View File

@ -22,8 +22,8 @@ GetTimetableParamsOptions _$GetTimetableParamsOptionsFromJson(
GetTimetableParamsOptions(
element: GetTimetableParamsOptionsElement.fromJson(
json['element'] as Map<String, dynamic>),
startDate: (json['startDate'] as num?)?.toInt(),
endDate: (json['endDate'] as num?)?.toInt(),
startDate: json['startDate'] as int?,
endDate: json['endDate'] as int?,
onlyBaseTimetable: json['onlyBaseTimetable'] as bool?,
showBooking: json['showBooking'] as bool?,
showInfo: json['showInfo'] as bool?,
@ -46,41 +46,48 @@ GetTimetableParamsOptions _$GetTimetableParamsOptionsFromJson(
);
Map<String, dynamic> _$GetTimetableParamsOptionsToJson(
GetTimetableParamsOptions instance) =>
<String, dynamic>{
'element': instance.element.toJson(),
if (instance.startDate case final value?) 'startDate': value,
if (instance.endDate case final value?) 'endDate': value,
if (instance.onlyBaseTimetable case final value?)
'onlyBaseTimetable': value,
if (instance.showBooking case final value?) 'showBooking': value,
if (instance.showInfo case final value?) 'showInfo': value,
if (instance.showSubstText case final value?) 'showSubstText': value,
if (instance.showLsText case final value?) 'showLsText': value,
if (instance.showLsNumber case final value?) 'showLsNumber': value,
if (instance.showStudentgroup case final value?)
'showStudentgroup': value,
if (instance.klasseFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'klasseFields': value,
if (instance.roomFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'roomFields': value,
if (instance.subjectFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'subjectFields': value,
if (instance.teacherFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'teacherFields': value,
};
GetTimetableParamsOptions instance) {
final val = <String, dynamic>{
'element': instance.element.toJson(),
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('startDate', instance.startDate);
writeNotNull('endDate', instance.endDate);
writeNotNull('onlyBaseTimetable', instance.onlyBaseTimetable);
writeNotNull('showBooking', instance.showBooking);
writeNotNull('showInfo', instance.showInfo);
writeNotNull('showSubstText', instance.showSubstText);
writeNotNull('showLsText', instance.showLsText);
writeNotNull('showLsNumber', instance.showLsNumber);
writeNotNull('showStudentgroup', instance.showStudentgroup);
writeNotNull(
'klasseFields',
instance.klasseFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
writeNotNull(
'roomFields',
instance.roomFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
writeNotNull(
'subjectFields',
instance.subjectFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
writeNotNull(
'teacherFields',
instance.teacherFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
return val;
}
const _$GetTimetableParamsOptionsFieldsEnumMap = {
GetTimetableParamsOptionsFields.id: 'id',
@ -92,21 +99,29 @@ const _$GetTimetableParamsOptionsFieldsEnumMap = {
GetTimetableParamsOptionsElement _$GetTimetableParamsOptionsElementFromJson(
Map<String, dynamic> json) =>
GetTimetableParamsOptionsElement(
id: (json['id'] as num).toInt(),
type: (json['type'] as num).toInt(),
id: json['id'] as int,
type: json['type'] as int,
keyType: $enumDecodeNullable(
_$GetTimetableParamsOptionsElementKeyTypeEnumMap, json['keyType']),
);
Map<String, dynamic> _$GetTimetableParamsOptionsElementToJson(
GetTimetableParamsOptionsElement instance) =>
<String, dynamic>{
'id': instance.id,
'type': instance.type,
if (_$GetTimetableParamsOptionsElementKeyTypeEnumMap[instance.keyType]
case final value?)
'keyType': value,
};
GetTimetableParamsOptionsElement instance) {
final val = <String, dynamic>{
'id': instance.id,
'type': instance.type,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('keyType',
_$GetTimetableParamsOptionsElementKeyTypeEnumMap[instance.keyType]);
return val;
}
const _$GetTimetableParamsOptionsElementKeyTypeEnumMap = {
GetTimetableParamsOptionsElementKeyType.id: 'id',

View File

@ -18,25 +18,33 @@ GetTimetableResponse _$GetTimetableResponseFromJson(
);
Map<String, dynamic> _$GetTimetableResponseToJson(
GetTimetableResponse instance) =>
<String, dynamic>{
if (instance.headers case final value?) 'headers': value,
'result': instance.result.map((e) => e.toJson()).toList(),
};
GetTimetableResponse instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('headers', instance.headers);
val['result'] = instance.result.map((e) => e.toJson()).toList();
return val;
}
GetTimetableResponseObject _$GetTimetableResponseObjectFromJson(
Map<String, dynamic> json) =>
GetTimetableResponseObject(
id: (json['id'] as num).toInt(),
date: (json['date'] as num).toInt(),
startTime: (json['startTime'] as num).toInt(),
endTime: (json['endTime'] as num).toInt(),
id: json['id'] as int,
date: json['date'] as int,
startTime: json['startTime'] as int,
endTime: json['endTime'] as int,
lstype: json['lstype'] as String?,
code: json['code'] as String?,
info: json['info'] as String?,
substText: json['substText'] as String?,
lstext: json['lstext'] as String?,
lsnumber: (json['lsnumber'] as num?)?.toInt(),
lsnumber: json['lsnumber'] as int?,
statflags: json['statflags'] as String?,
activityType: json['activityType'] as String?,
sg: json['sg'] as String?,
@ -102,7 +110,7 @@ GetTimetableResponseObjectFieldsObject
_$GetTimetableResponseObjectFieldsObjectFromJson(
Map<String, dynamic> json) =>
GetTimetableResponseObjectFieldsObject(
id: (json['id'] as num?)?.toInt(),
id: json['id'] as int?,
name: json['name'] as String?,
longname: json['longname'] as String?,
externalkey: json['externalkey'] as String?,
@ -120,7 +128,7 @@ Map<String, dynamic> _$GetTimetableResponseObjectFieldsObjectToJson(
GetTimetableResponseObjectClass _$GetTimetableResponseObjectClassFromJson(
Map<String, dynamic> json) =>
GetTimetableResponseObjectClass(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longname'] as String,
json['externalkey'] as String?,
@ -138,10 +146,10 @@ Map<String, dynamic> _$GetTimetableResponseObjectClassToJson(
GetTimetableResponseObjectTeacher _$GetTimetableResponseObjectTeacherFromJson(
Map<String, dynamic> json) =>
GetTimetableResponseObjectTeacher(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longname'] as String,
(json['orgid'] as num?)?.toInt(),
json['orgid'] as int?,
json['orgname'] as String?,
json['externalkey'] as String?,
);
@ -160,7 +168,7 @@ Map<String, dynamic> _$GetTimetableResponseObjectTeacherToJson(
GetTimetableResponseObjectSubject _$GetTimetableResponseObjectSubjectFromJson(
Map<String, dynamic> json) =>
GetTimetableResponseObjectSubject(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longname'] as String,
);
@ -176,7 +184,7 @@ Map<String, dynamic> _$GetTimetableResponseObjectSubjectToJson(
GetTimetableResponseObjectRoom _$GetTimetableResponseObjectRoomFromJson(
Map<String, dynamic> json) =>
GetTimetableResponseObjectRoom(
(json['id'] as num).toInt(),
json['id'] as int,
json['name'] as String,
json['longname'] as String,
);

View File

@ -20,13 +20,13 @@ abstract class WebuntisApi extends ApiRequest {
Future<String> query(WebuntisApi untis) async {
var query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
String query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
var sessionId = '0';
String sessionId = '0';
if(authenticatedResponse) {
sessionId = (await Authenticate.getSession()).sessionId;
}
var data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'});
http.Response data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'});
response = data;
dynamic jsonData = jsonDecode(data.body);
@ -48,12 +48,16 @@ abstract class WebuntisApi extends ApiRequest {
Future<ApiResponse> run();
String _body() => genericParam == null ? '{}' : jsonEncode(genericParam);
String _body() {
return genericParam == null ? '{}' : jsonEncode(genericParam);
}
Future<http.Response> post(String data, Map<String, String>? headers) async => await http
Future<http.Response> post(String data, Map<String, String>? headers) async {
return await http
.post(endpoint, body: data, headers: headers)
.timeout(
const Duration(seconds: 10),
onTimeout: () => throw WebuntisError('Timeout', 1)
);
}
}

View File

@ -5,5 +5,7 @@ class WebuntisError implements Exception {
WebuntisError(this.message, this.code);
@override
String toString() => 'WebUntis ($code): $message';
String toString() {
return 'WebUntis ($code): $message';
}
}

View File

@ -5,33 +5,35 @@ import 'dart:developer';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'state/app/modules/app_modules.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
import 'package:provider/provider.dart';
import 'package:badges/badges.dart' as badges;
import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
import 'api/mhsl/server/userIndex/update/updateUserindex.dart';
import 'main.dart';
import 'model/breakers/Breaker.dart';
import 'model/breakers/BreakerProps.dart';
import 'model/chatList/chatListProps.dart';
import 'model/dataCleaner.dart';
import 'model/timetable/timetableProps.dart';
import 'notification/notificationController.dart';
import 'notification/notificationTasks.dart';
import 'notification/notifyUpdater.dart';
import 'storage/base/settingsProvider.dart';
import 'view/pages/files/files.dart';
import 'view/pages/overhang.dart';
import 'view/pages/talk/chatList.dart';
import 'view/pages/timetable/timetable.dart';
class App extends StatefulWidget {
const App({super.key});
static PersistentTabController bottomNavigator = PersistentTabController(initialIndex: 0);
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> with WidgetsBindingObserver {
late Timer refetchChats;
late Timer updateTimings;
@ -55,7 +57,6 @@ class _AppState extends State<App> with WidgetsBindingObserver {
@override
void initState() {
Main.bottomNavigator = PersistentTabController(initialIndex: 0);
WidgetsBinding.instance.addObserver(this);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Provider.of<BreakerProps>(context, listen: false).run();
@ -86,22 +87,63 @@ class _AppState extends State<App> with WidgetsBindingObserver {
FirebaseMessaging.onMessageOpenedApp.listen((message) => NotificationController.onAppOpenedByNotification(message, context));
FirebaseMessaging.instance.getInitialMessage().then((message) => message == null ? null : NotificationController.onAppOpenedByNotification(message, context));
DataCleaner.cleanOldCache();
super.initState();
}
@override
Widget build(BuildContext context) => Consumer<SettingsProvider>(builder: (context, settings, child) => PersistentTabView(
controller: Main.bottomNavigator,
Widget build(BuildContext context) {
return PersistentTabView(
controller: App.bottomNavigator,
gestureNavigationEnabled: true,
navBarOverlap: const NavBarOverlap.none(),
backgroundColor: Theme.of(context).colorScheme.primary,
handleAndroidBackButtonPress: false,
screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)),
tabs: [
...AppModule.getBottomBarModules(context).map((e) => e.toBottomTab(context)),
PersistentTabConfig(
screen: const Breaker(breaker: BreakerArea.timetable, child: Timetable()),
item: ItemConfig(
activeForegroundColor: Theme.of(context).primaryColor,
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
icon: const Icon(Icons.calendar_month),
title: 'Vertretung'
),
),
PersistentTabConfig(
screen: const Breaker(breaker: BreakerArea.talk, child: ChatList()),
item: ItemConfig(
activeForegroundColor: Theme.of(context).primaryColor,
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
icon: Consumer<ChatListProps>(
builder: (context, value, child) {
if(value.primaryLoading()) return const Icon(Icons.chat);
int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b);
return badges.Badge(
showBadge: messages > 0,
position: badges.BadgePosition.topEnd(top: -3, end: -3),
stackFit: StackFit.loose,
badgeStyle: badges.BadgeStyle(
padding: const EdgeInsets.all(3),
badgeColor: Theme.of(context).primaryColor,
elevation: 1,
),
badgeContent: Text('$messages', style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold)),
child: const Icon(Icons.chat),
);
},
),
title: 'Talk',
),
),
PersistentTabConfig(
screen: const Breaker(breaker: BreakerArea.files, child: Files([])),
item: ItemConfig(
activeForegroundColor: Theme.of(context).primaryColor,
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
icon: const Icon(Icons.folder),
title: 'Dateien'
),
),
PersistentTabConfig(
screen: const Breaker(breaker: BreakerArea.more, child: Overhang()),
item: ItemConfig(
@ -119,7 +161,8 @@ class _AppState extends State<App> with WidgetsBindingObserver {
color: Theme.of(context).colorScheme.surface,
),
),
));
);
}
@override
void dispose() {

View File

@ -1,20 +1,19 @@
import 'package:flutter/material.dart';
extension IsSameDay on DateTime {
bool isSameDay(DateTime other) => year == other.year && month == other.month && day == other.day;
DateTime nextWeekday(int day) => add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
DateTime withTime(TimeOfDay time) => copyWith(hour: time.hour, minute: time.minute);
TimeOfDay toTimeOfDay() => TimeOfDay(hour: hour, minute: minute);
bool isSameDateTime(DateTime other) {
var isSameDay = this.isSameDay(other);
var isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay());
return isSameDay && isSameTimeOfDay;
bool isSameDay(DateTime other) {
return year == other.year && month == other.month && day == other.day;
}
bool isSameOrAfter(DateTime other) => isSameDateTime(other) || isAfter(other);
DateTime nextWeekday(int day) {
return add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
}
DateTime withTime(TimeOfDay time) {
return copyWith(hour: time.hour, minute: time.minute);
}
TimeOfDay toTimeOfDay() {
return TimeOfDay(hour: hour, minute: minute);
}
}

View File

@ -1,3 +1,5 @@
extension RenderNotNullExt<T> on T? {
R? wrapNullable<R>(R Function(T data) defaultValueCallback) => this != null ? defaultValueCallback(this as T) : null;
R? wrapNullable<R>(R Function(T data) defaultValueCallback) {
return this != null ? defaultValueCallback(this as T) : null;
}
}

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
extension TextExt on Text {
Size get size {
final textPainter = TextPainter(
final TextPainter textPainter = TextPainter(
text: TextSpan(text: data, style: style),
maxLines: 1,
textDirection: TextDirection.ltr

View File

@ -1,9 +1,15 @@
import 'package:flutter/material.dart';
extension TimeOfDayExt on TimeOfDay {
bool isBefore(TimeOfDay other) => hour < other.hour && minute < other.minute;
bool isBefore(TimeOfDay other) {
return hour < other.hour && minute < other.minute;
}
bool isAfter(TimeOfDay other) => hour > other.hour && minute > other.minute;
bool isAfter(TimeOfDay other) {
return hour > other.hour && minute > other.minute;
}
TimeOfDay add({int hours = 0, int minutes = 0}) => replacing(hour: hour + hours, minute: minute + minutes);
TimeOfDay add({int hours = 0, int minutes = 0}) {
return replacing(hour: hour + hours, minute: minute + minutes);
}
}

View File

@ -7,13 +7,10 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:jiffy/jiffy.dart';
import 'package:loader_overlay/loader_overlay.dart';
import 'package:path_provider/path_provider.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
import 'package:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
import 'app.dart';
@ -26,46 +23,37 @@ import 'model/chatList/chatListProps.dart';
import 'model/chatList/chatProps.dart';
import 'model/files/filesProps.dart';
import 'model/holidays/holidaysProps.dart';
import 'model/message/messageProps.dart';
import 'model/timetable/timetableProps.dart';
import 'storage/base/settingsProvider.dart';
import 'theming/darkAppTheme.dart';
import 'theming/lightAppTheme.dart';
import 'view/login/login.dart';
import 'view/pages/more/abiturCalculator/models/abiturCalculatorModel.dart';
import 'widget/placeholderView.dart';
Future<void> main() async {
log('MarianumMobile started');
WidgetsFlutterBinding.ensureInitialized();
addCertificateAsTrusted(ByteData certificate) => SecurityContext.defaultContext.setTrustedCertificatesBytes(certificate.buffer.asUint8List());
var initialisationTasks = [
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
.then((value) async => log("Firebase token: ${await FirebaseMessaging.instance.getToken() ?? "Error: no Firebase token!"}"))
.onError((error, stackTrace) => log('Error initializing Firebase: $error')),
PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem').then(addCertificateAsTrusted),
PlatformAssetBundle().load('assets/ca/lets-encrypt-r10.pem').then(addCertificateAsTrusted),
Future(() async {
await HydratedStorage.build(
storageDirectory: HydratedStorageDirectory((await getTemporaryDirectory()).path)
).then((storage) => HydratedBloc.storage = storage);
})
];
log('starting app initialisation...');
await Future.wait(initialisationTasks);
log('app initialisation done!');
if(kReleaseMode) {
ErrorWidget.builder = (error) => PlaceholderView(
icon: Icons.phonelink_erase_rounded,
text: error.toStringShort(),
);
try {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
log("Firebase token: ${await FirebaseMessaging.instance.getToken() ?? "Error: no Firebase token!"}");
} catch (e) {
log('Error initializing Firebase app!');
}
ByteData data = await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem');
SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List());
if(kReleaseMode) {
ErrorWidget.builder = (error) {
return PlaceholderView(
icon: Icons.phonelink_erase_rounded,
text: error.toStringShort(),
);
};
}
log('running app...');
runApp(
MultiProvider(
providers: [
@ -79,7 +67,10 @@ Future<void> main() async {
ChangeNotifierProvider(create: (context) => ChatProps()),
ChangeNotifierProvider(create: (context) => FilesProps()),
ChangeNotifierProvider(create: (context) => MessageProps()),
ChangeNotifierProvider(create: (context) => HolidaysProps()),
ChangeNotifierProvider(create: (context) => AbiturCalculatorModel()),
],
child: const Main(),
)
@ -88,8 +79,6 @@ Future<void> main() async {
class Main extends StatefulWidget {
const Main({super.key});
static PersistentTabController bottomNavigator = PersistentTabController(initialIndex: 0);
@override
State<Main> createState() => _MainState();
@ -115,7 +104,8 @@ class _MainState extends State<Main> {
}
@override
Widget build(BuildContext context) => Directionality(
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.ltr,
child: Consumer<SettingsProvider>(
builder: (context, settings, child) {
@ -159,6 +149,7 @@ class _MainState extends State<Main> {
},
),
);
}
@override
void dispose() {

Some files were not shown because too many files have changed in this diff Show More