Compare commits

...

121 Commits

Author SHA1 Message Date
9d0cf8e313 bumped version 2025-04-16 13:16:49 +02:00
f0009dad88 renamed files back to localized string 2025-04-16 13:15:31 +02:00
905206f242 added missing implementation of "note to self", disabled breakers in debug environments 2025-03-11 16:22:02 +01:00
769fbc1b6a added timetable color substitute teachers 2025-02-14 19:31:46 +01:00
8daf57bcee #75 pinned timetable to german timezone 2025-02-13 22:28:45 +01:00
33d488946a updated android configuration files 2025-02-09 20:42:47 +01:00
41a5e021c5 Merge pull request 'made app modules movable in their order' (#84) from develop-reorderableAppModules into develop
Reviewed-on: #84
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2025-02-09 17:36:20 +00:00
8f58893553 Merge branch 'develop' into develop-reorderableAppModules 2025-02-09 17:36:12 +00:00
626d3d5564 added minimum message drag distance for chat reply 2025-02-09 15:16:02 +01:00
d833cdb733 made app modules movable in their order 2025-02-09 15:06:14 +01:00
8868914a76 restructured settings and devtools 2025-02-08 23:21:20 +01:00
70e6f82b10 updated chat images loading animation 2025-02-08 22:53:14 +01:00
6651613331 fixed files cache not working correctly 2025-02-08 22:35:20 +01:00
9ad0f624de Merge remote-tracking branch 'origin/develop' into develop 2025-02-08 21:40:49 +01:00
82c143f847 bumped version 2025-02-08 21:40:39 +01:00
1fdf731b81 Merge pull request 'added option for timetable naming modes' (#83) from feature-timetableNamingSetting into develop
Reviewed-on: #83
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2025-01-24 22:27:06 +00:00
2d3ccd25b4 Merge branch 'develop' into feature-timetableNamingSetting 2025-01-24 22:26:52 +00:00
385ee806d6 updated feedback info text 2025-01-24 13:53:12 +01:00
92aef41031 updated room plan image 2025-01-24 11:54:35 +01:00
65b29ec4b8 added option for timetable naming modes 2025-01-24 11:50:14 +01:00
9f51d68531 updated build runner tasks 2025-01-24 11:02:03 +01:00
5bc4ba6332 replaced version wildcard with version range 2025-01-23 23:39:01 +01:00
e9739ac2d5 updated app badger 2025-01-23 22:41:22 +01:00
4d3a33dd9b updated project 2025-01-23 11:20:08 +01:00
ddeeaeaeac Merge pull request 'develop-bloc-holidays' (#72) from develop-bloc-holidays into develop
Reviewed-on: #72
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2024-06-23 21:00:45 +00:00
c8e31b896b added eof linebreak 2024-06-23 22:59:26 +02:00
c443a1d567 fixed disclaimer not showing on first visit 2024-06-23 20:31:43 +02:00
08ef784f57 Merge remote-tracking branch 'origin/develop' into develop-bloc-holidays 2024-06-22 16:47:15 +02:00
999e30ab3a added le-r10-certificate and removed/added some logging 2024-06-22 16:45:43 +02:00
c4c882a77d updated app screenshots 2024-06-14 22:20:54 +02:00
fe93a94fc6 bloc for holidays 2024-06-12 15:53:13 +02:00
a33c4ddac5 wip: fixed state not updating correctly 2024-05-27 22:28:42 +02:00
634fe41e78 wip: bloc for holidays 2024-05-14 14:54:01 +02:00
328c4f410c removed unused code and files 2024-05-12 20:45:00 +02:00
43471fcf3d Merge pull request 'develop-bloc' (#68) from develop-bloc into develop
Reviewed-on: #68
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2024-05-12 13:12:22 +00:00
e78e2b8cd4 Merge remote-tracking branch 'origin/develop' into develop-bloc 2024-05-12 15:11:00 +02:00
a57f42d4ed resolved pr comments 2024-05-12 15:07:57 +02:00
8ff993bf19 removed old marianum message structure 2024-05-12 14:44:12 +02:00
8968e53e5c removed test page 2024-05-12 14:38:06 +02:00
430f2fe603 Merge pull request 'develop-replyToMessages' (#67) from develop-replyToMessages into develop
Reviewed-on: #67
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2024-05-12 12:36:14 +00:00
d00592c3e7 Merge branch 'develop' into develop-replyToMessages 2024-05-12 12:35:52 +00:00
3fb48b5bcf added option to reply on long press (and better possibilities to play with chat bubble drag) 2024-05-12 14:30:41 +02:00
69fc98ad45 automatic updating of last timestamp for bloc cache 2024-05-12 14:27:16 +02:00
76a1f65083 Merge remote-tracking branch 'origin/develop' into develop-bloc 2024-05-12 14:01:57 +02:00
ed35e91d59 Merge pull request 'updated localstore collection to global constant' (#69) from develop-fixLogoutCache into develop
Reviewed-on: #69
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2024-05-12 11:27:17 +00:00
ebbb70dc96 added timestamp to bloc cache, showing age in offline mode 2024-05-12 02:39:35 +02:00
3281b134e0 moved message pdf view 2024-05-12 00:36:24 +02:00
2056be23cd added minimum duration of loading animation 2024-05-12 00:31:23 +02:00
e57a1a915e implemented marianum message dataloader 2024-05-11 19:29:12 +02:00
181682a424 moved reload actions out of error context 2024-05-11 17:52:53 +02:00
9fa711e460 loadable error screen, reload actions, autoreload 2024-05-11 14:20:00 +02:00
1f30e2d97f not replyable messages are no longer swipable 2024-05-10 22:29:40 +02:00
0f84257eba saving message references in draft 2024-05-10 22:27:24 +02:00
b171fef348 repository and data provider concept 2024-05-07 22:15:56 +02:00
81f5b662b7 added support for rich object messages 2024-05-07 11:01:46 +02:00
7a393bf630 refactored answer references and added animation 2024-05-07 10:51:46 +02:00
fc72391a75 fixed bug when changing accounts 2024-05-07 09:01:30 +02:00
6ad8203b6a implemented new loadable state concept 2024-05-05 22:58:40 +02:00
f58a2ec8cd revamp on bloc approach 2024-05-05 15:48:26 +02:00
91ef689d2a replies now get displayed 2024-05-01 17:37:03 +02:00
ee6af2bc07 Merge remote-tracking branch 'origin/develop-bloc' into develop-bloc
# Conflicts:
#	lib/state/widgets/components/error_bar.dart
2024-04-24 19:40:42 +02:00
2db3b29359 added content position animation when error bar is displayed 2024-04-24 19:39:59 +02:00
107a5bdbf8 added content position animation when error bar is displayed 2024-04-24 19:23:32 +02:00
3802e4a5b9 fixed missing animation on error bar 2024-04-24 18:45:10 +02:00
04e8ce9c0a loadable state is now detecting device connection status on failure 2024-04-23 22:40:18 +02:00
450c26b187 WIP state management loadable errorbar 2024-04-23 14:48:12 +02:00
7129c0dee8 wip basics for bloc based state management 2024-04-22 23:02:03 +02:00
ae6b6511d7 parent message gets shown in chat bubble 2024-04-19 18:55:07 +02:00
232a767312 Merge remote-tracking branch 'origin/develop' into develop-replyToMessages 2024-04-19 16:23:59 +02:00
f5407d2477 updated localstore collection to global constant 2024-04-16 14:39:20 +02:00
19aca8f97f updated version 2024-04-11 20:55:38 +02:00
c4a7533315 added option to react to messages 2024-04-11 18:22:55 +02:00
d067ee702a Merge pull request 'feedback dialog is now scrollable' (#64) from develop-scrollableFeedbackWidget into develop
Reviewed-on: #64
Reviewed-by: Elias Müller <elias@elias-mueller.com>
2024-04-10 10:14:31 +00:00
dfd9459922 feedback dialog is now scrollable 2024-04-10 12:10:57 +02:00
51373fe7a2 Merge pull request 'double tap on messages to show options' (#63) from develop-doubleTapMessages into develop
Reviewed-on: #63
Reviewed-by: Elias Müller <elias@elias-mueller.com>
2024-04-09 18:37:28 +00:00
cafa1248d5 resolved issue with merge 2024-04-09 19:46:00 +02:00
ed710b3c2e Merge branch 'develop' into develop-doubleTapMessages
# Conflicts:
#	lib/view/pages/talk/components/chatBubble.dart
2024-04-09 19:42:51 +02:00
8dd3ca9eae double tap on messages to show options 2024-04-09 19:34:45 +02:00
07ffa374fe Merge pull request '#53 fixed misplaced profile pictures' (#62) from develop-fixSwappedProfilePictures into develop
Reviewed-on: #62
Reviewed-by: Pupsi <larslukasneuhaus@gmx.de>
2024-04-09 17:22:08 +00:00
0302c10fcd #53 fixed misplaced profile pictures 2024-04-09 18:53:56 +02:00
92361ec455 Merge pull request 'added upload with multiple files' (#61) from develop-uploadMultipleFiles into develop
Reviewed-on: #61
2024-04-09 08:21:54 +00:00
cf4dea566e solved pr comments; picking multiple Images from Gallery is now possible 2024-04-08 22:39:28 +02:00
d8c72a5d28 solved most pr comments and a bug 2024-04-07 16:48:38 +02:00
9803b06af1 merged to origin/devlop 2024-04-07 15:58:51 +02:00
8131ccae1e solved some pr comments 2024-04-07 15:49:43 +02:00
e901f139d6 solved some pr comments 2024-04-06 13:34:52 +02:00
02dd659d1d fixed typos 2024-04-06 11:40:48 +02:00
277b3366f9 added upload with multiple files 2024-04-05 18:19:49 +02:00
b4defb9eda added upload with multiple files 2024-04-05 18:16:12 +02:00
4c7f53e309 updated project style guidelines 2024-04-03 19:18:17 +02:00
27618f4404 added min/ max-scale to fileViewer 2024-04-02 19:16:49 +02:00
8bf5e5a06a disabled gestureNavigation on bottomNavigation 2024-04-02 19:12:28 +02:00
bc60362984 Merge pull request 'added option to choose more emoji reactions' (#55) from develop-moreEmojiReactions into develop
Reviewed-on: #55
2024-04-02 16:51:32 +00:00
74c7c16877 changed a standard emoji to eyes looking around 2024-04-02 18:30:13 +02:00
0a577b5f48 Merge branch 'develop' into develop-moreEmojiReactions 2024-04-02 16:26:33 +00:00
57ddee2dc9 removed search option and action bar 2024-04-02 18:24:12 +02:00
8ae8c97b41 made emojis in emoji picker bigger 2024-04-02 18:10:54 +02:00
883db8d7ef Merge pull request 'develop-unfocusTextField' (#56) from develop-unfocusTextField into develop
Reviewed-on: #56
2024-04-02 14:55:35 +00:00
6450b292a7 resolved pr comments 2024-04-02 16:45:43 +02:00
65d15ffd4e removed commented code 2024-04-02 15:51:06 +02:00
07401d0864 resolved pr comments and fixed a bug 2024-04-02 15:47:55 +02:00
21411e1517 added unfocus at textfields for custon events and feedback 2024-04-02 15:03:37 +02:00
339d402422 added unfocus when tapping outside textfield 2024-04-02 14:41:36 +02:00
c54a42aa43 added unfocus when tapping on background image 2024-04-02 14:34:35 +02:00
42574583ed added unfocus when tapping on background image 2024-04-02 14:32:37 +02:00
9aa3f7c058 added option to choose more emoji reactions 2024-04-02 14:11:48 +02:00
1b407562df Merge pull request 'old cache gets deleted' (#52) from develop-removeOldCache into develop
Reviewed-on: #52
2024-04-02 07:34:05 +00:00
f86c97dcf0 Merge branch 'develop' into develop-removeOldCache 2024-04-02 07:33:13 +00:00
6b4d6a1c8c Merge pull request 'develop-biggerFeedbackWidget' (#51) from develop-biggerFeedbackWidget into develop
Reviewed-on: #51
2024-04-02 07:32:51 +00:00
20dfe2c2e6 Merge branch 'develop' into develop-removeOldCache 2024-04-01 12:20:49 +00:00
6c2c305f1c old cache gets deleted 2024-04-01 14:18:23 +02:00
dbbf6f6c5c Merge branch 'develop' into develop-biggerFeedbackWidget 2024-04-01 10:57:52 +00:00
07b32f1e32 added option to attach image to feedback 2024-04-01 12:57:27 +02:00
ea329d8d64 added option to attach image to feedback 2024-03-31 21:02:47 +02:00
f45848331e added bigger feedback dialog widget 2024-03-31 15:35:12 +02:00
a1ad6aa582 updated version and dependencies 2024-03-31 14:37:08 +02:00
3e3e2579f0 Merge pull request 'added connected double lessons with own setting' (#49) from develop-connectedDoubleLessons into develop
Reviewed-on: #49
2024-03-31 10:50:58 +00:00
681b5e42c3 removed spaces 2024-03-31 12:31:53 +02:00
a0c025b58b code fixes, added isSameOrAfter for DateTime objects, added check for teacher room and status 2024-03-30 23:01:37 +01:00
20d7b16ede Merge branch 'develop' into develop-connectedDoubleLessons 2024-03-30 22:05:54 +01:00
afdc02f2a4 added connected double lessons with own setting 2024-03-30 18:26:33 +01:00
311 changed files with 5931 additions and 2761 deletions

16
.gitignore vendored
View File

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

View File

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

View File

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

0
android/app/proguard-rules.pro vendored Normal file
View File

View File

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

View File

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

View File

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

View File

@ -0,0 +1,29 @@
-----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: 108 KiB

After

Width:  |  Height:  |  Size: 101 KiB

7
build.yaml Normal file
View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
import 'dart:io'; import 'dart:io';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../model/accountData.dart'; import '../../../model/accountData.dart';
import '../../../model/endpointData.dart'; import '../../../model/endpointData.dart';
@ -9,12 +8,12 @@ import 'fileSharingApiParams.dart';
class FileSharingApi { class FileSharingApi {
Future<void> share(FileSharingApiParams query) async { Future<void> share(FileSharingApiParams query) async {
Map<String, String> headers = {}; var headers = <String, String>{};
headers.putIfAbsent('Accept', () => 'application/json'); headers.putIfAbsent('Accept', () => 'application/json');
headers.putIfAbsent('OCS-APIRequest', () => 'true'); headers.putIfAbsent('OCS-APIRequest', () => 'true');
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()))); 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())));
Response response = await http.post(endpoint, headers: headers); var response = await http.post(endpoint, headers: headers);
if(response.statusCode != HttpStatus.ok) { if(response.statusCode != HttpStatus.ok) {
throw Exception('Api call failed with ${response.statusCode}: ${response.body}'); throw Exception('Api call failed with ${response.statusCode}: ${response.body}');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,9 +10,7 @@ class CreateRoom extends TalkApi {
CreateRoom(this.params) : super('v4/room', params); CreateRoom(this.params) : super('v4/room', params);
@override @override
assemble(String raw) { assemble(String raw) => null;
return null;
}
@override @override
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) { 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 _$CreateRoomParamsFromJson(Map<String, dynamic> json) =>
CreateRoomParams( CreateRoomParams(
roomType: json['roomType'] as int, roomType: (json['roomType'] as num).toInt(),
invite: json['invite'] as String, invite: json['invite'] as String,
source: json['source'] as String?, source: json['source'] as String?,
roomName: json['roomName'] as String?, roomName: json['roomName'] as String?,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,9 +10,7 @@ class SendMessage extends TalkApi {
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params); SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
@override @override
assemble(String raw) { assemble(String raw) => null;
return null;
}
@override @override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) { 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) @JsonSerializable(explicitToJson: true, includeIfNull: false)
class SendMessageParams extends ApiParams { class SendMessageParams extends ApiParams {
String message; String message;
int? replyTo; String? replyTo;
SendMessageParams(this.message, {this.replyTo}); SendMessageParams(this.message, {this.replyTo});

View File

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

View File

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

View File

@ -15,9 +15,7 @@ class SetReadMarker extends TalkApi {
} }
@override @override
assemble(String raw) { assemble(String raw) => null;
return null;
}
@override @override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) { 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 _$SetReadMarkerParamsFromJson(Map<String, dynamic> json) =>
SetReadMarkerParams( SetReadMarkerParams(
lastReadMessage: json['lastReadMessage'] as int?, lastReadMessage: (json['lastReadMessage'] as num?)?.toInt(),
); );
Map<String, dynamic> _$SetReadMarkerParamsToJson( Map<String, dynamic> _$SetReadMarkerParamsToJson(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,21 +0,0 @@
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

@ -1,21 +0,0 @@
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

@ -1,28 +0,0 @@
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

@ -1,49 +0,0 @@
// 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); T assemble(String raw);
Future<T> run() async { Future<T> run() async {
Uri endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath'); var endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
http.Response? data = await request(endpoint); var data = await request(endpoint);
if(data == null) { if(data == null) {
throw ApiError('Request could not be dispatched!'); throw ApiError('Request could not be dispatched!');
} }
@ -31,5 +31,4 @@ 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); static DateTime dateTimeFromJson(String time) => DateTime.parse(time);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ UpdateUserIndexParams _$UpdateUserIndexParamsFromJson(
user: json['user'] as String, user: json['user'] as String,
username: json['username'] as String, username: json['username'] as String,
device: json['device'] as String, device: json['device'] as String,
appVersion: json['appVersion'] as int, appVersion: (json['appVersion'] as num).toInt(),
deviceInfo: json['deviceInfo'] as String, 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:device_info_plus/device_info_plus.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:package_info/package_info.dart'; import 'package:package_info_plus/package_info_plus.dart';
import '../../../../../model/accountData.dart'; import '../../../../../model/accountData.dart';
import '../../../mhslApi.dart'; import '../../../mhslApi.dart';
@ -19,12 +19,12 @@ class UpdateUserIndex extends MhslApi<void> {
@override @override
Future<http.Response> request(Uri uri) { Future<http.Response> request(Uri uri) {
String data = jsonEncode(params.toJson()); var data = jsonEncode(params.toJson());
log('Updating userindex:\n $data'); log('Updating userindex: ${data.length}');
return http.post(uri, body: data); return http.post(uri, body: data);
} }
static void index() async { static Future<void> index() async {
UpdateUserIndex( UpdateUserIndex(
UpdateUserIndexParams( UpdateUserIndexParams(
username: AccountData().getUsername(), username: AccountData().getUsername(),

View File

@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:localstore/localstore.dart'; import 'package:localstore/localstore.dart';
import 'apiResponse.dart'; import 'apiResponse.dart';
import 'webuntis/webuntisError.dart';
abstract class RequestCache<T extends ApiResponse?> { abstract class RequestCache<T extends ApiResponse?> {
static const int cacheNothing = 0; static const int cacheNothing = 0;
@ -11,6 +10,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static const int cacheHour = 60 * 60; static const int cacheHour = 60 * 60;
static const int cacheDay = 60 * 60 * 24; static const int cacheDay = 60 * 60 * 24;
static String collection = 'MarianumMobile';
int maxCacheTime; int maxCacheTime;
Function(T) onUpdate; Function(T) onUpdate;
Function(Exception) onError; Function(Exception) onError;
@ -20,8 +21,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static void ignore(Exception e) {} static void ignore(Exception e) {}
void start(String file, String document) async { Future<void> start(String document) async {
Map<String, dynamic>? tableData = await Localstore.instance.collection(file).doc(document).get(); var tableData = await Localstore.instance.collection(collection).doc(document).get();
if(tableData != null) { if(tableData != null) {
onUpdate(onLocalData(tableData['json'])); onUpdate(onLocalData(tableData['json']));
} }
@ -31,14 +32,14 @@ abstract class RequestCache<T extends ApiResponse?> {
} }
try { try {
T newValue = await onLoad(); var newValue = await onLoad();
onUpdate(newValue); onUpdate(newValue);
Localstore.instance.collection(file).doc(document).set({ Localstore.instance.collection(collection).doc(document).set({
'json': jsonEncode(newValue), 'json': jsonEncode(newValue),
'lastupdate': DateTime.now().millisecondsSinceEpoch 'lastupdate': DateTime.now().millisecondsSinceEpoch
}); });
} on WebuntisError catch(e) { } on Exception catch(e) {
onError(e); onError(e);
} }
} }

View File

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

View File

@ -10,27 +10,19 @@ AuthenticateResponse _$AuthenticateResponseFromJson(
Map<String, dynamic> json) => Map<String, dynamic> json) =>
AuthenticateResponse( AuthenticateResponse(
json['sessionId'] as String, json['sessionId'] as String,
json['personType'] as int, (json['personType'] as num).toInt(),
json['personId'] as int, (json['personId'] as num).toInt(),
json['klasseId'] as int, (json['klasseId'] as num).toInt(),
)..headers = (json['headers'] as Map<String, dynamic>?)?.map( )..headers = (json['headers'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String), (k, e) => MapEntry(k, e as String),
); );
Map<String, dynamic> _$AuthenticateResponseToJson( Map<String, dynamic> _$AuthenticateResponseToJson(
AuthenticateResponse instance) { AuthenticateResponse instance) =>
final val = <String, dynamic>{}; <String, dynamic>{
if (instance.headers case final value?) 'headers': value,
void writeNotNull(String key, dynamic value) { 'sessionId': instance.sessionId,
if (value != null) { 'personType': instance.personType,
val[key] = value; 'personId': instance.personId,
} 'klasseId': instance.klasseId,
} };
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 @override
Future<GetHolidaysResponse> run() async { Future<GetHolidaysResponse> run() async {
String rawAnswer = await query(this); var rawAnswer = await query(this);
return finalize(GetHolidaysResponse.fromJson(jsonDecode(rawAnswer))); 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); time = DateTime(time.year, time.month, time.day, 0, 0, 0, 0, 0);
for (var element in holidaysResponse.result) { for (var element in holidaysResponse.result) {
DateTime start = DateTime.parse(element.startDate.toString()); var start = DateTime.parse(element.startDate.toString());
DateTime end = DateTime.parse(element.endDate.toString()); var end = DateTime.parse(element.endDate.toString());
if(!start.isAfter(time) && !end.isBefore(time)) return element; if(!start.isAfter(time) && !end.isBefore(time)) return element;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,35 +5,33 @@ import 'dart:developer';
import 'package:easy_debounce/easy_throttle.dart'; import 'package:easy_debounce/easy_throttle.dart';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.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:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:badges/badges.dart' as badges;
import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart'; import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
import 'api/mhsl/server/userIndex/update/updateUserindex.dart'; import 'api/mhsl/server/userIndex/update/updateUserindex.dart';
import 'main.dart';
import 'model/breakers/Breaker.dart'; import 'model/breakers/Breaker.dart';
import 'model/breakers/BreakerProps.dart'; import 'model/breakers/BreakerProps.dart';
import 'model/chatList/chatListProps.dart'; import 'model/chatList/chatListProps.dart';
import 'model/dataCleaner.dart';
import 'model/timetable/timetableProps.dart'; import 'model/timetable/timetableProps.dart';
import 'notification/notificationController.dart'; import 'notification/notificationController.dart';
import 'notification/notificationTasks.dart'; import 'notification/notificationTasks.dart';
import 'notification/notifyUpdater.dart'; import 'notification/notifyUpdater.dart';
import 'storage/base/settingsProvider.dart'; import 'storage/base/settingsProvider.dart';
import 'view/pages/files/files.dart';
import 'view/pages/overhang.dart'; import 'view/pages/overhang.dart';
import 'view/pages/talk/chatList.dart';
import 'view/pages/timetable/timetable.dart';
class App extends StatefulWidget { class App extends StatefulWidget {
const App({super.key}); const App({super.key});
static PersistentTabController bottomNavigator = PersistentTabController(initialIndex: 0);
@override @override
State<App> createState() => _AppState(); State<App> createState() => _AppState();
} }
class _AppState extends State<App> with WidgetsBindingObserver { class _AppState extends State<App> with WidgetsBindingObserver {
late Timer refetchChats; late Timer refetchChats;
late Timer updateTimings; late Timer updateTimings;
@ -57,6 +55,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
Main.bottomNavigator = PersistentTabController(initialIndex: 0);
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Provider.of<BreakerProps>(context, listen: false).run(); Provider.of<BreakerProps>(context, listen: false).run();
@ -87,63 +86,22 @@ class _AppState extends State<App> with WidgetsBindingObserver {
FirebaseMessaging.onMessageOpenedApp.listen((message) => NotificationController.onAppOpenedByNotification(message, context)); FirebaseMessaging.onMessageOpenedApp.listen((message) => NotificationController.onAppOpenedByNotification(message, context));
FirebaseMessaging.instance.getInitialMessage().then((message) => message == null ? null : NotificationController.onAppOpenedByNotification(message, context)); FirebaseMessaging.instance.getInitialMessage().then((message) => message == null ? null : NotificationController.onAppOpenedByNotification(message, context));
DataCleaner.cleanOldCache();
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => Consumer<SettingsProvider>(builder: (context, settings, child) => PersistentTabView(
return PersistentTabView( controller: Main.bottomNavigator,
controller: App.bottomNavigator,
gestureNavigationEnabled: true,
navBarOverlap: const NavBarOverlap.none(), navBarOverlap: const NavBarOverlap.none(),
backgroundColor: Theme.of(context).colorScheme.primary, backgroundColor: Theme.of(context).colorScheme.primary,
handleAndroidBackButtonPress: false,
screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)), screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)),
tabs: [ tabs: [
PersistentTabConfig( ...AppModule.getBottomBarModules(context).map((e) => e.toBottomTab(context)),
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( PersistentTabConfig(
screen: const Breaker(breaker: BreakerArea.more, child: Overhang()), screen: const Breaker(breaker: BreakerArea.more, child: Overhang()),
item: ItemConfig( item: ItemConfig(
@ -161,8 +119,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
), ),
), ),
); ));
}
@override @override
void dispose() { void dispose() {

View File

@ -1,19 +1,20 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
extension IsSameDay on DateTime { extension IsSameDay on DateTime {
bool isSameDay(DateTime other) { bool isSameDay(DateTime other) => year == other.year && month == other.month && day == other.day;
return 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;
} }
DateTime nextWeekday(int day) { bool isSameOrAfter(DateTime other) => isSameDateTime(other) || isAfter(other);
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,5 +1,3 @@
extension RenderNotNullExt<T> on T? { extension RenderNotNullExt<T> on T? {
R? wrapNullable<R>(R Function(T data) defaultValueCallback) { R? wrapNullable<R>(R Function(T data) defaultValueCallback) => this != null ? defaultValueCallback(this as T) : null;
return this != null ? defaultValueCallback(this as T) : null;
}
} }

View File

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

View File

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

View File

@ -7,10 +7,13 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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:jiffy/jiffy.dart';
import 'package:loader_overlay/loader_overlay.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:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart'; import 'api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
import 'app.dart'; import 'app.dart';
@ -23,7 +26,6 @@ import 'model/chatList/chatListProps.dart';
import 'model/chatList/chatProps.dart'; import 'model/chatList/chatProps.dart';
import 'model/files/filesProps.dart'; import 'model/files/filesProps.dart';
import 'model/holidays/holidaysProps.dart'; import 'model/holidays/holidaysProps.dart';
import 'model/message/messageProps.dart';
import 'model/timetable/timetableProps.dart'; import 'model/timetable/timetableProps.dart';
import 'storage/base/settingsProvider.dart'; import 'storage/base/settingsProvider.dart';
import 'theming/darkAppTheme.dart'; import 'theming/darkAppTheme.dart';
@ -32,27 +34,38 @@ import 'view/login/login.dart';
import 'widget/placeholderView.dart'; import 'widget/placeholderView.dart';
Future<void> main() async { Future<void> main() async {
log('MarianumMobile started');
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
try { addCertificateAsTrusted(ByteData certificate) => SecurityContext.defaultContext.setTrustedCertificatesBytes(certificate.buffer.asUint8List());
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'); var initialisationTasks = [
SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List()); 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) { if(kReleaseMode) {
ErrorWidget.builder = (error) { ErrorWidget.builder = (error) => PlaceholderView(
return PlaceholderView( icon: Icons.phonelink_erase_rounded,
icon: Icons.phonelink_erase_rounded, text: error.toStringShort(),
text: error.toStringShort(), );
);
};
} }
log('running app...');
runApp( runApp(
MultiProvider( MultiProvider(
providers: [ providers: [
@ -66,7 +79,6 @@ Future<void> main() async {
ChangeNotifierProvider(create: (context) => ChatProps()), ChangeNotifierProvider(create: (context) => ChatProps()),
ChangeNotifierProvider(create: (context) => FilesProps()), ChangeNotifierProvider(create: (context) => FilesProps()),
ChangeNotifierProvider(create: (context) => MessageProps()),
ChangeNotifierProvider(create: (context) => HolidaysProps()), ChangeNotifierProvider(create: (context) => HolidaysProps()),
], ],
child: const Main(), child: const Main(),
@ -76,6 +88,8 @@ Future<void> main() async {
class Main extends StatefulWidget { class Main extends StatefulWidget {
const Main({super.key}); const Main({super.key});
static PersistentTabController bottomNavigator = PersistentTabController(initialIndex: 0);
@override @override
State<Main> createState() => _MainState(); State<Main> createState() => _MainState();
@ -101,8 +115,7 @@ class _MainState extends State<Main> {
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => Directionality(
return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Consumer<SettingsProvider>( child: Consumer<SettingsProvider>(
builder: (context, settings, child) { builder: (context, settings, child) {
@ -146,7 +159,6 @@ class _MainState extends State<Main> {
}, },
), ),
); );
}
@override @override
void dispose() { void dispose() {

View File

@ -17,9 +17,7 @@ class AccountData {
final Future<SharedPreferences> _storage = SharedPreferences.getInstance(); final Future<SharedPreferences> _storage = SharedPreferences.getInstance();
Completer<void> _populated = Completer(); Completer<void> _populated = Completer();
factory AccountData() { factory AccountData() => _instance;
return _instance;
}
AccountData._construct() { AccountData._construct() {
_updateFromStorage(); _updateFromStorage();
@ -38,16 +36,12 @@ class AccountData {
return _password!; return _password!;
} }
String getUserSecret() { String getUserSecret() => sha512.convert(utf8.encode('${AccountData().getUsername()}:${AccountData().getPassword()}')).toString();
return sha512.convert(utf8.encode('${AccountData().getUsername()}:${AccountData().getPassword()}')).toString();
}
Future<String> getDeviceId() async { Future<String> getDeviceId() async => sha512.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}')).toString();
return sha512.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}')).toString();
}
Future<void> setData(String username, String password) async { Future<void> setData(String username, String password) async {
SharedPreferences storage = await _storage; var storage = await _storage;
storage.setString(_usernameField, username); storage.setString(_usernameField, username);
storage.setString(_passwordField, password); storage.setString(_passwordField, password);
@ -59,13 +53,13 @@ class AccountData {
if(context != null) Provider.of<AccountModel>(context, listen: false).setState(AccountModelState.loggedOut); if(context != null) Provider.of<AccountModel>(context, listen: false).setState(AccountModelState.loggedOut);
SharedPreferences storage = await _storage; var storage = await _storage;
await storage.remove(_usernameField); await storage.remove(_usernameField);
await storage.remove(_passwordField); await storage.remove(_passwordField);
} }
Future<void> _updateFromStorage() async { Future<void> _updateFromStorage() async {
SharedPreferences storage = await _storage; var storage = await _storage;
//await storage.reload(); // This line was the cause of the first rejected google play upload :( //await storage.reload(); // This line was the cause of the first rejected google play upload :(
if(storage.containsKey(_usernameField) && storage.containsKey(_passwordField)) { if(storage.containsKey(_usernameField) && storage.containsKey(_passwordField)) {
_username = storage.getString(_usernameField); _username = storage.getString(_usernameField);
@ -79,9 +73,7 @@ class AccountData {
return isPopulated(); return isPopulated();
} }
bool isPopulated() { bool isPopulated() => _username != null && _password != null;
return _username != null && _password != null;
}
String buildHttpAuthString() { String buildHttpAuthString() {
if(!isPopulated()) throw Exception('AccountData (e.g. username or password) is not initialized!'); if(!isPopulated()) throw Exception('AccountData (e.g. username or password) is not initialized!');

View File

@ -19,16 +19,18 @@ class Breaker extends StatefulWidget {
class _BreakerState extends State<Breaker> { class _BreakerState extends State<Breaker> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => Consumer<BreakerProps>(
return Consumer<BreakerProps>(
builder: (context, value, child) { builder: (context, value, child) {
String? blocked = value.isBlocked(widget.breaker); var blocked = value.isBlocked(widget.breaker);
if(blocked != null) { if(blocked != null) {
return PlaceholderView(icon: Icons.security_outlined, text: "Die App/ Dieser Bereich wurde als Schutzmaßnahme deaktiviert!\n\n${blocked.isEmpty ? "Es wurde vom Server kein Grund übermittelt." : blocked}"); return PlaceholderView(
icon: Icons.app_blocking_outlined,
text: 'Die App / Dieser Bereich ist zurzeit nicht verfügbar!\n\n'
"${blocked.isEmpty ? "Es wurde vom Server kein Grund übermittelt.\nAktualisiere die App und versuche es später erneut" : blocked}"
);
} }
return widget.child; return widget.child;
}, },
); );
}
} }

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