59 Commits

Author SHA1 Message Date
a4700e9ec5 widget rendering tweaks 2025-09-10 20:22:39 +02:00
4cbbad6c1a Merge branch 'develop' into develop-widgets
# Conflicts:
#	lib/view/pages/timetable/timetable.dart
#	pubspec.yaml
2025-09-07 11:06:49 +02:00
859b85ab2c Revert "Upgraded Gradle and Android Gradle Plugin"
This reverts commit bd1101c348.
2025-09-06 18:51:00 +02:00
bd1101c348 Upgraded Gradle and Android Gradle Plugin
Upgraded Gradle from 8.9 to 8.13 and the Android Gradle Plugin from 8.7.3 to 8.13.0.
2025-09-06 17:35:41 +02:00
f29c84d05c fixed timetable subject name requirement 2025-09-06 17:03:01 +02:00
7dbd6038f3 prevent common "change" tiles in timetable, more robust parsing 2025-09-06 16:47:47 +02:00
877633f4de Merge pull request 'develop-groupedParticipants' (#89) from develop-groupedParticipants into develop
Reviewed-on: #89
Reviewed-by: Elias Müller <elias@elias-mueller.com>
2025-09-06 14:12:10 +00:00
22d3d18a17 changed naming for participants 2025-09-06 16:09:47 +02:00
d65e61c297 Merge branch 'develop' into develop-groupedParticipants 2025-09-06 13:58:08 +00:00
467b0e0dd8 Merge remote-tracking branch 'origin/develop' into develop 2025-09-06 15:57:19 +02:00
25a6ef37fa Merge branch 'develop' into develop-groupedParticipants 2025-09-06 13:57:10 +00:00
34763ace4a Merge remote-tracking branch 'origin/develop' into develop 2025-09-06 15:57:08 +02:00
590a70c623 Merge remote-tracking branch 'origin/develop' into develop 2025-09-06 15:56:51 +02:00
9b58412ca7 fixed missing no reaction text
fixed loading indicator being delayed on file download
2025-09-06 15:56:46 +02:00
a6c16e41c2 fixed missing no reaction text
fixed loading indicator being delayed on file download
2025-09-06 15:56:28 +02:00
117434a5e3 Merge branch 'develop' into develop-groupedParticipants 2025-09-06 13:54:40 +00:00
e4582eaac5 removed commented code 2025-09-06 15:46:55 +02:00
430d5b8dc7 Merge remote-tracking branch 'origin/develop' into develop-groupedParticipants
# Conflicts:
#	pubspec.yaml
2025-09-06 15:36:12 +02:00
9177c30d6e fixed display dimensions of messages with files 2025-09-06 15:33:14 +02:00
344f8f6d2c Merge branch 'develop' into develop-fileMessagesWithText 2025-09-06 15:13:15 +02:00
46971a8d46 upgraded syncfusion dependencies 2025-09-06 14:51:14 +02:00
f330ef3f56 updated project dependencies and sdk. Comptaible with Flutter 3.35.3 2025-09-06 14:47:08 +02:00
85f9988453 renamed timetable in ui 2025-09-06 14:12:13 +02:00
f3de0bc165 centered file preview, made text copyable 2025-06-24 15:09:37 +02:00
421ee9179d grouped the participants list 2025-06-24 14:18:14 +02:00
0a66858d93 Merge pull request 'sorted participants list alphabetically' (#87) from develop-sortedParticipants into develop
Reviewed-on: #87
Reviewed-by: Elias Müller <elias@elias-mueller.com>
2025-06-24 10:47:07 +00:00
49428680de Merge branch 'develop' into develop-sortedParticipants 2025-06-24 10:46:58 +00:00
0c676dc3d6 made perticipants list stateless 2025-06-23 17:54:12 +02:00
c702b610c5 removed logging 2025-06-23 11:17:59 +02:00
5938c6b3c3 fixed chat search 2025-06-23 11:16:39 +02:00
8000475c1f aligned text to the left 2025-06-16 16:07:04 +02:00
da772f17cc changed file messages to show their text or their file name 2025-06-10 21:35:12 +02:00
c44b0464a4 sorted participants list alphabetically 2025-06-10 20:19:44 +02:00
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
6bbc75fa94 implemented scheduled updates for widgets 2025-03-11 15:50:02 +01:00
b0bbad7f97 added timetable widget for android devices 2025-02-16 18:08:04 +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
112 changed files with 1828 additions and 1565 deletions

View File

@@ -25,15 +25,16 @@ 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 {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_17
coreLibraryDesugaringEnabled true
} }
kotlinOptions { kotlinOptions {
jvmTarget = '1.8' jvmTarget = '17'
} }
sourceSets { sourceSets {
@@ -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 21
targetSdkVersion flutter.targetSdkVersion targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
@@ -59,6 +57,9 @@ android {
signingConfig signingConfigs.debug signingConfig signingConfigs.debug
} }
} }
buildFeatures {
viewBinding true
}
} }
flutter { flutter {
@@ -66,5 +67,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.1.4'
} }

View File

@@ -1,45 +1,73 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<!--
Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin.
-->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain" />
</intent>
</queries>
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:label="Marianum Fulda" tools:replace="android:label"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher"
android:label="Marianum Fulda">
<receiver
android:name=".TimetableWidget"
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/timetable_widget_info" />
</receiver>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true" android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
<!--
Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. --> to determine the Window background behind the Flutter UI.
-->
<meta-data <meta-data
android:name="io.flutter.embedding.android.NormalTheme" android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" android:resource="@style/NormalTheme" />
/>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<!-- Don't delete the meta-data below. <!--
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
-->
<meta-data <meta-data
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest> </manifest>

View File

@@ -0,0 +1,39 @@
package eu.mhsl.marianum.mobile.client
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetPlugin
import android.util.Base64
/**
* Implementation of App Widget functionality.
*/
class TimetableWidget : AppWidgetProvider() {
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray,
) {
for (appWidgetId in appWidgetIds) {
val widgetData = HomeWidgetPlugin.getData(context)
val views = RemoteViews(context.packageName, R.layout.timetable_widget).apply {
val imageBase64 = widgetData.getString("screen", null) ?: return@apply
val imageBytes = Base64.decode(imageBase64, Base64.DEFAULT);
val imageBitmap: Bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
setImageViewBitmap(R.id.widget_image, imageBitmap)
}
val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
val pendingIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(R.id.background, pendingIntent)
appWidgetManager.updateAppWidget(appWidgetId, views)
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><!--
Background for widgets to make the rounded corners based on the
appWidgetRadius attribute value
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="?attr/appWidgetRadius" />
<solid android:color="?android:attr/colorBackground" />
</shape>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><!--
Background for views inside widgets to make the rounded corners based on the
appWidgetInnerRadius attribute value
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="?attr/appWidgetInnerRadius" />
<solid android:color="?android:attr/colorAccent" />
</shape>

View File

@@ -0,0 +1,26 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/background"
style="@style/Widget.Android.AppWidget.Container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:padding="0dp"
android:theme="@style/Theme.Android.AppWidgetContainer">
<ImageView
android:id="@+id/widget_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:layout_weight="1"
android:adjustViewBounds="false"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/timetable_widget_default"
android:visibility="visible"
tools:visibility="visible" />
</RelativeLayout>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Having themes.xml for night-v31 because of the priority order of the resource qualifiers.
-->
<style name="Theme.Android.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="appWidgetRadius">@android:dimen/system_app_widget_background_radius</item>
<item name="appWidgetInnerRadius">@android:dimen/system_app_widget_inner_radius</item>
</style>
</resources>

View File

@@ -0,0 +1,14 @@
<resources>
<style name="Widget.Android.AppWidget.Container" parent="android:Widget">
<item name="android:id">@android:id/background</item>
<item name="android:padding">?attr/appWidgetPadding</item>
<item name="android:background">@drawable/app_widget_background</item>
</style>
<style name="Widget.Android.AppWidget.InnerView" parent="android:Widget">
<item name="android:padding">?attr/appWidgetPadding</item>
<item name="android:background">@drawable/app_widget_inner_view_background</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
</resources>

View File

@@ -18,4 +18,18 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item> <item name="android:windowBackground">?android:colorBackground</item>
</style> </style>
<style name="Widget.Android.AppWidget.Container" parent="android:Widget">
<item name="android:id">@android:id/background</item>
<item name="android:padding">?attr/appWidgetPadding</item>
<item name="android:background">@drawable/app_widget_background</item>
<item name="android:clipToOutline">true</item>
</style>
<style name="Widget.Android.AppWidget.InnerView" parent="android:Widget">
<item name="android:padding">?attr/appWidgetPadding</item>
<item name="android:background">@drawable/app_widget_inner_view_background</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:clipToOutline">true</item>
</style>
</resources> </resources>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Having themes.xml for v31 variant because @android:dimen/system_app_widget_background_radius
and @android:dimen/system_app_widget_internal_padding requires API level 31
-->
<style name="Theme.Android.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="appWidgetRadius">@android:dimen/system_app_widget_background_radius</item>
<item name="appWidgetInnerRadius">@android:dimen/system_app_widget_inner_radius</item>
</style>
</resources>

View File

@@ -0,0 +1,7 @@
<resources>
<declare-styleable name="AppWidgetAttrs">
<attr name="appWidgetPadding" format="dimension" />
<attr name="appWidgetInnerRadius" format="dimension" />
<attr name="appWidgetRadius" format="dimension" />
</declare-styleable>
</resources>

View File

@@ -0,0 +1,6 @@
<resources>
<color name="light_blue_50">#FFE1F5FE</color>
<color name="light_blue_200">#FF81D4FA</color>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
</resources>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Refer to App Widget Documentation for margin information
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
-->
<dimen name="widget_margin">0dp</dimen>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="appwidget_text">Marianum Vertretungsplan</string>
<string name="add_widget">Hinzufügen</string>
<string name="app_widget_description">Übersicht zum Vertretungsplan</string>
</resources>

View File

@@ -19,4 +19,14 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item> <item name="android:windowBackground">?android:colorBackground</item>
</style> </style>
<style name="Widget.Android.AppWidget.Container" parent="android:Widget">
<item name="android:id">@android:id/background</item>
<item name="android:background">?android:attr/colorBackground</item>
</style>
<style name="Widget.Android.AppWidget.InnerView" parent="android:Widget">
<item name="android:background">?android:attr/colorBackground</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
</resources> </resources>

View File

@@ -0,0 +1,17 @@
<resources>
<style name="Theme.Android.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault">
<!-- Radius of the outer bound of widgets to make the rounded corners -->
<item name="appWidgetRadius">16dp</item>
<!--
Radius of the inner view's bound of widgets to make the rounded corners.
It needs to be 8dp or less than the value of appWidgetRadius
-->
<item name="appWidgetInnerRadius">8dp</item>
</style>
<style name="Theme.Android.AppWidgetContainer" parent="Theme.Android.AppWidgetContainerParent">
<!-- Apply padding to avoid the content of the widget colliding with the rounded corners -->
<item name="appWidgetPadding">16dp</item>
</style>
</resources>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/app_widget_description"
android:initialKeyguardLayout="@layout/timetable_widget"
android:initialLayout="@layout/timetable_widget"
android:minWidth="220dp"
android:minHeight="294dp"
android:minResizeWidth="110dp"
android:minResizeHeight="147dp"
android:previewImage="@drawable/timetable_widget_preview"
android:previewLayout="@layout/timetable_widget"
android:resizeMode="horizontal|vertical"
android:targetCellWidth="3"
android:targetCellHeight="4"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen" />

View File

@@ -2,6 +2,21 @@ allprojects {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
// [required] background_fetch
maven {
url "${project(':background_fetch').projectDir}/libs"
}
}
}
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10'
} }
} }

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.8.10" apply false id "org.jetbrains.kotlin.android" version "2.1.10" apply false
} }
include ":app" include ":app"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 101 KiB

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

@@ -16,19 +16,12 @@ 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) =>

View File

@@ -18,7 +18,7 @@ class AutocompleteResponseObject {
String label; String label;
String? icon; String? icon;
String? source; String? source;
List<String>? status; String? status;
String? subline; String? subline;
String? shareWithDisplayNameUniqe; String? shareWithDisplayNameUniqe;

View File

@@ -28,7 +28,7 @@ AutocompleteResponseObject _$AutocompleteResponseObjectFromJson(
json['label'] as String, json['label'] as String,
json['icon'] as String?, json['icon'] as String?,
json['source'] as String?, json['source'] as String?,
(json['status'] as List<dynamic>?)?.map((e) => e as String).toList(), json['status'] as String?,
json['subline'] as String?, json['subline'] as String?,
json['shareWithDisplayNameUniqe'] as String?, json['shareWithDisplayNameUniqe'] as String?,
); );

View File

@@ -20,28 +20,23 @@ GetChatParams _$GetChatParamsFromJson(Map<String, dynamic> json) =>
_$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?)
'lastKnownMessageId': value,
if (instance.lastCommonReadId case final value?)
'lastCommonReadId': value,
if (instance.timeout case final value?) 'timeout': value,
if (_$GetChatParamsSwitchEnumMap[instance.setReadMarker]
case final value?)
'setReadMarker': value,
if (_$GetChatParamsSwitchEnumMap[instance.includeLastKnown]
case final value?)
'includeLastKnown': value,
}; };
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('limit', instance.limit);
writeNotNull('lastKnownMessageId', instance.lastKnownMessageId);
writeNotNull('lastCommonReadId', instance.lastCommonReadId);
writeNotNull('timeout', instance.timeout);
writeNotNull(
'setReadMarker', _$GetChatParamsSwitchEnumMap[instance.setReadMarker]);
writeNotNull('includeLastKnown',
_$GetChatParamsSwitchEnumMap[instance.includeLastKnown]);
return val;
}
const _$GetChatParamsSwitchEnumMap = { const _$GetChatParamsSwitchEnumMap = {
GetChatParamsSwitch.on: 1, GetChatParamsSwitch.on: 1,
GetChatParamsSwitch.off: 0, GetChatParamsSwitch.off: 0,

View File

@@ -15,19 +15,11 @@ 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) =>

View File

@@ -55,12 +55,15 @@ class GetParticipantsResponseObject {
} }
enum GetParticipantsResponseObjectParticipantType { enum GetParticipantsResponseObjectParticipantType {
@JsonValue(1) owner, @JsonValue(1) owner('Besitzer'),
@JsonValue(2) moderator, @JsonValue(2) moderator('Moderator'),
@JsonValue(3) user, @JsonValue(3) user('Teilnehmer'),
@JsonValue(4) guest, @JsonValue(4) guest('Gast'),
@JsonValue(5) userFollowingPublicLink, @JsonValue(5) userFollowingPublicLink('Teilnehmer über Link'),
@JsonValue(6) guestWithModeratorPermissions @JsonValue(6) guestWithModeratorPermissions('Gast Moderator');
const GetParticipantsResponseObjectParticipantType(this.prettyName);
final String prettyName;
} }
enum GetParticipantsResponseObjectParticipantsInCallFlags { enum GetParticipantsResponseObjectParticipantsInCallFlags {

View File

@@ -18,19 +18,11 @@ 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) =>

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) =>

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,19 +15,11 @@ 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) =>
@@ -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

@@ -12,17 +12,8 @@ SendMessageParams _$SendMessageParamsFromJson(Map<String, dynamic> json) =>
replyTo: json['replyTo'] as String?, 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

@@ -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

@@ -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,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

@@ -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

@@ -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';

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;
@@ -40,7 +39,7 @@ abstract class RequestCache<T extends ApiResponse?> {
'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

@@ -18,19 +18,11 @@ AuthenticateResponse _$AuthenticateResponseFromJson(
); );
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

@@ -16,19 +16,12 @@ 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) =>

View File

@@ -16,19 +16,11 @@ 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) =>

View File

@@ -16,19 +16,12 @@ 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) =>

View File

@@ -46,49 +46,42 @@ 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,
if (instance.onlyBaseTimetable case final value?)
'onlyBaseTimetable': value,
if (instance.showBooking case final value?) 'showBooking': value,
if (instance.showInfo case final value?) 'showInfo': value,
if (instance.showSubstText case final value?) 'showSubstText': value,
if (instance.showLsText case final value?) 'showLsText': value,
if (instance.showLsNumber case final value?) 'showLsNumber': value,
if (instance.showStudentgroup case final value?)
'showStudentgroup': value,
if (instance.klasseFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'klasseFields': value,
if (instance.roomFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'roomFields': value,
if (instance.subjectFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'subjectFields': value,
if (instance.teacherFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList()
case final value?)
'teacherFields': value,
}; };
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('startDate', instance.startDate);
writeNotNull('endDate', instance.endDate);
writeNotNull('onlyBaseTimetable', instance.onlyBaseTimetable);
writeNotNull('showBooking', instance.showBooking);
writeNotNull('showInfo', instance.showInfo);
writeNotNull('showSubstText', instance.showSubstText);
writeNotNull('showLsText', instance.showLsText);
writeNotNull('showLsNumber', instance.showLsNumber);
writeNotNull('showStudentgroup', instance.showStudentgroup);
writeNotNull(
'klasseFields',
instance.klasseFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
writeNotNull(
'roomFields',
instance.roomFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
writeNotNull(
'subjectFields',
instance.subjectFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
writeNotNull(
'teacherFields',
instance.teacherFields
?.map((e) => _$GetTimetableParamsOptionsFieldsEnumMap[e]!)
.toList());
return val;
}
const _$GetTimetableParamsOptionsFieldsEnumMap = { const _$GetTimetableParamsOptionsFieldsEnumMap = {
GetTimetableParamsOptionsFields.id: 'id', GetTimetableParamsOptionsFields.id: 'id',
GetTimetableParamsOptionsFields.name: 'name', GetTimetableParamsOptionsFields.name: 'name',
@@ -106,23 +99,15 @@ GetTimetableParamsOptionsElement _$GetTimetableParamsOptionsElementFromJson(
); );
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?)
'keyType': value,
}; };
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('keyType',
_$GetTimetableParamsOptionsElementKeyTypeEnumMap[instance.keyType]);
return val;
}
const _$GetTimetableParamsOptionsElementKeyTypeEnumMap = { const _$GetTimetableParamsOptionsElementKeyTypeEnumMap = {
GetTimetableParamsOptionsElementKeyType.id: 'id', GetTimetableParamsOptionsElementKeyType.id: 'id',
GetTimetableParamsOptionsElementKeyType.name: 'name', GetTimetableParamsOptionsElementKeyType.name: 'name',

View File

@@ -18,19 +18,11 @@ 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) =>

View File

@@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
import 'state/app/modules/app_modules.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';
@@ -25,6 +24,7 @@ import 'storage/base/settingsProvider.dart';
import 'view/pages/overhang.dart'; import 'view/pages/overhang.dart';
class App extends StatefulWidget { class App extends StatefulWidget {
static GlobalKey appContext = GlobalKey();
const App({super.key}); const App({super.key});
@override @override
@@ -32,7 +32,6 @@ class App extends StatefulWidget {
} }
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;
@@ -93,38 +92,15 @@ class _AppState extends State<App> with WidgetsBindingObserver {
} }
@override @override
Widget build(BuildContext context) => PersistentTabView( Widget build(BuildContext context) => Consumer<SettingsProvider>(builder: (context, settings, child) => PersistentTabView(
controller: Main.bottomNavigator, controller: Main.bottomNavigator,
navBarOverlap: const NavBarOverlap.none(), navBarOverlap: const NavBarOverlap.none(),
backgroundColor: Theme.of(context).colorScheme.primary, backgroundColor: Theme.of(context).colorScheme.primary,
handleAndroidBackButtonPress: true, handleAndroidBackButtonPress: false,
screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)), screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)),
tabs: [ tabs: [
AppModule.getModule(Modules.timetable).toBottomTab(context), ...AppModule.getBottomBarModules(context).map((e) => e.toBottomTab(context)),
AppModule.getModule(Modules.talk).toBottomTab(
context,
itemBuilder: (icon) => Consumer<ChatListProps>(
builder: (context, value, child) {
if(value.primaryLoading()) return Icon(icon);
var 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: Icon(icon),
);
},
),
),
AppModule.getModule(Modules.blocFiles).toBottomTab(context),
AppModule.getModule(Modules.files).toBottomTab(context),
PersistentTabConfig( PersistentTabConfig(
screen: const Breaker(breaker: BreakerArea.more, child: Overhang()), screen: const Breaker(breaker: BreakerArea.more, child: Overhang()),
@@ -143,7 +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

@@ -0,0 +1,64 @@
import 'dart:developer';
import 'package:background_fetch/background_fetch.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../app.dart';
import '../homescreen_widgets/timetable/timetableHomeWidget.dart';
class ScheduledTask {
static final String fetchApiLastRunTimestampKey = 'fetchApiLastRunTimestamp';
static Future<void> configure() async {
var status = await BackgroundFetch.configure(BackgroundFetchConfig(
minimumFetchInterval: 15,
stopOnTerminate: false,
enableHeadless: true,
requiresBatteryNotLow: false,
requiresCharging: false,
requiresStorageNotLow: false,
requiresDeviceIdle: false,
requiredNetworkType: NetworkType.ANY,
startOnBoot: true,
), (String taskId) async {
log('Background fetch started with id $taskId');
await ScheduledTask.backgroundFetch();
BackgroundFetch.finish(taskId);
}, (String taskId) async {
log('Background fetch stopped because of an timeout with id $taskId');
BackgroundFetch.finish(taskId);
});
log('Background Fetch-API status: $status');
}
// called periodically, iOS and Android
static Future<void> backgroundFetch() async {
var sp = await SharedPreferences.getInstance();
var history = sp.getStringList(fetchApiLastRunTimestampKey) ?? List.empty(growable: true);
history.add(DateTime.now().toIso8601String());
try {
TimetableHomeWidget.update(App.appContext.currentContext!);
} on Exception catch(e) {
history.add('Got Error:');
history.add(e.toString());
history.add('--- EXCEPTION END ---');
}
sp.setStringList(fetchApiLastRunTimestampKey, history.take(100).toList());
}
// only Android, starts when app is terminated
@pragma('vm:entry-point')
static Future<void> headless(HeadlessTask task) async {
var taskId = task.taskId;
var isTimeout = task.timeout;
if (isTimeout) {
log('Background fetch headless task timed-out: $taskId');
BackgroundFetch.finish(taskId);
return;
}
log('Background fetch headless event received.');
await backgroundFetch();
BackgroundFetch.finish(taskId);
}
}

View File

@@ -0,0 +1,88 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:home_widget/home_widget.dart';
import 'package:screenshot/screenshot.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import '../../model/accountData.dart';
import '../../model/timetable/timetableProps.dart';
import '../../storage/base/settingsProvider.dart';
import '../../theming/darkAppTheme.dart';
import '../../theming/lightAppTheme.dart';
import '../../view/pages/timetable/calendar.dart';
class TimetableHomeWidget {
static Future<void> update(BuildContext context) async {
await AccountData().waitForPopulation();
var data = TimetableProps();
var settings = SettingsProvider();
settings.waitForPopulation();
var completer = Completer();
data.addListener(() async {
if(completer.isCompleted) return;
if(data.primaryLoading()) return;
await _generate(data, settings);
if(completer.isCompleted) return;
completer.complete();
});
data.run();
await completer.future;
}
static Future<void> _generate(TimetableProps data, SettingsProvider settings) async {
log('Generating widget screen...');
log('data: ${data.getTimetableResponse.toJson().toString().substring(0, 400)}...');
var screenshotController = ScreenshotController();
var calendarController = CalendarController();
calendarController.displayDate = DateTime.now().copyWith(hour: 07, minute: 00);
var imageData = await screenshotController.captureFromWidget(
SizedBox(
height: 700,
width: 300,
child: Directionality(
textDirection: TextDirection.ltr,
child: MediaQuery(
data: MediaQueryData(),
child: MaterialApp(
localizationsDelegates: const [
...GlobalMaterialLocalizations.delegates,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: const [
Locale('de'),
Locale('en'),
],
locale: const Locale('de'),
darkTheme: DarkAppTheme.theme,
theme: LightAppTheme.theme,
themeMode: settings.val().appTheme,
home: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Scaffold(
body: Calendar(
controller: calendarController,
timetableProps: data,
settings: settings,
isHomeWidget: true,
),
),
),
),
),
),
),
delay: Duration(seconds: 5),
);
HomeWidget.saveWidgetData<String>('screen', base64.encode(imageData));
HomeWidget.updateWidget(name: 'TimetableWidget');
log('Widget screen successfully updated! (${imageData.length})');
}
}

View File

@@ -2,21 +2,23 @@ import 'dart:async';
import 'dart:developer'; import 'dart:developer';
import 'dart:io'; import 'dart:io';
import 'package:background_fetch/background_fetch.dart';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart'; 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: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:path_provider/path_provider.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: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';
import 'background_tasks/scheduledTask.dart';
import 'firebase_options.dart'; import 'firebase_options.dart';
import 'model/accountData.dart'; import 'model/accountData.dart';
import 'model/accountModel.dart'; import 'model/accountModel.dart';
@@ -42,13 +44,15 @@ Future<void> main() async {
var initialisationTasks = [ var initialisationTasks = [
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform) Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
.then((value) async => log("Firebase token: ${await FirebaseMessaging.instance.getToken() ?? "Error: no Firebase token!"}")) .then((value) async => log("Firebase token: ${await FirebaseMessaging.instance.getToken() ?? "Error: no Firebase token!"}"))
.onError((error, stackTrace) => log('Error initializing Firebase: $error', stackTrace: stackTrace)), .onError((error, stackTrace) => log('Error initializing Firebase: $error')),
PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem').then(addCertificateAsTrusted), PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem').then(addCertificateAsTrusted),
PlatformAssetBundle().load('assets/ca/lets-encrypt-r10.pem').then(addCertificateAsTrusted), PlatformAssetBundle().load('assets/ca/lets-encrypt-r10.pem').then(addCertificateAsTrusted),
Future(() async { Future(() async {
await HydratedStorage.build(storageDirectory: await getTemporaryDirectory()).then((storage) => HydratedBloc.storage = storage); await HydratedStorage.build(
storageDirectory: HydratedStorageDirectory((await getTemporaryDirectory()).path)
).then((storage) => HydratedBloc.storage = storage);
}) })
]; ];
@@ -82,6 +86,8 @@ Future<void> main() async {
child: const Main(), child: const Main(),
) )
); );
BackgroundFetch.registerHeadlessTask(ScheduledTask.headless);
} }
class Main extends StatefulWidget { class Main extends StatefulWidget {
@@ -109,6 +115,7 @@ class _MainState extends State<Main> {
Provider.of<BreakerProps>(context, listen: false).run(); Provider.of<BreakerProps>(context, listen: false).run();
}); });
ScheduledTask.configure();
super.initState(); super.initState();
} }
@@ -123,7 +130,6 @@ class _MainState extends State<Main> {
checkerboardOffscreenLayers: devToolsSettings.checkerboardOffscreenLayers, checkerboardOffscreenLayers: devToolsSettings.checkerboardOffscreenLayers,
checkerboardRasterCacheImages: devToolsSettings.checkerboardRasterCacheImages, checkerboardRasterCacheImages: devToolsSettings.checkerboardRasterCacheImages,
debugShowCheckedModeBanner: false,
localizationsDelegates: const [ localizationsDelegates: const [
...GlobalMaterialLocalizations.delegates, ...GlobalMaterialLocalizations.delegates,
GlobalWidgetsLocalizations.delegate, GlobalWidgetsLocalizations.delegate,
@@ -145,7 +151,7 @@ class _MainState extends State<Main> {
child: Consumer<AccountModel>( child: Consumer<AccountModel>(
builder: (context, accountModel, child) { builder: (context, accountModel, child) {
switch(accountModel.state) { switch(accountModel.state) {
case AccountModelState.loggedIn: return const App(); case AccountModelState.loggedIn: return App(key: App.appContext);
case AccountModelState.loggedOut: return const Login(); case AccountModelState.loggedOut: return const Login();
case AccountModelState.undefined: return const PlaceholderView(icon: Icons.timer, text: 'Daten werden geladen'); case AccountModelState.undefined: return const PlaceholderView(icon: Icons.timer, text: 'Daten werden geladen');
} }

View File

@@ -23,7 +23,11 @@ class _BreakerState extends State<Breaker> {
builder: (context, value, child) { builder: (context, value, child) {
var 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;

View File

@@ -1,4 +1,5 @@
import 'package:package_info/package_info.dart'; import 'package:flutter/foundation.dart';
import 'package:package_info_plus/package_info_plus.dart';
import '../../api/apiResponse.dart'; import '../../api/apiResponse.dart';
import '../../api/mhsl/breaker/getBreakers/getBreakersCache.dart'; import '../../api/mhsl/breaker/getBreakers/getBreakersCache.dart';
@@ -12,6 +13,8 @@ class BreakerProps extends DataHolder {
PackageInfo? packageInfo; PackageInfo? packageInfo;
String? isBlocked(BreakerArea? type) { String? isBlocked(BreakerArea? type) {
if(kDebugMode) return null;
if(packageInfo == null) { if(packageInfo == null) {
PackageInfo.fromPlatform().then((value) => packageInfo = value); PackageInfo.fromPlatform().then((value) => packageInfo = value);
return null; return null;

View File

@@ -1,5 +1,5 @@
import 'package:flutter_app_badger/flutter_app_badger.dart'; import 'package:flutter_app_badge/flutter_app_badge.dart';
import '../../api/apiResponse.dart'; import '../../api/apiResponse.dart';
import '../../api/marianumcloud/talk/room/getRoomCache.dart'; import '../../api/marianumcloud/talk/room/getRoomCache.dart';
@@ -20,7 +20,7 @@ class ChatListProps extends DataHolder {
onUpdate: (GetRoomResponse data) => { onUpdate: (GetRoomResponse data) => {
_getRoomResponse = data, _getRoomResponse = data,
notifyListeners(), notifyListeners(),
FlutterAppBadger.updateBadgeCount(data.data.map((e) => e.unreadMessages).reduce((a, b) => a+b)) FlutterAppBadge.count(data.data.map((e) => e.unreadMessages).reduce((a, b) => a+b))
} }
); );
} }

View File

@@ -44,7 +44,7 @@ class NotificationController {
} }
static Future<void> onAppOpenedByNotification(RemoteMessage message, BuildContext context) async { static Future<void> onAppOpenedByNotification(RemoteMessage message, BuildContext context) async {
NotificationTasks.navigateToTalk(); NotificationTasks.navigateToTalk(context);
NotificationTasks.updateProviders(context); NotificationTasks.updateProviders(context);
DebugTile(context).run(() { DebugTile(context).run(() {

View File

@@ -15,9 +15,6 @@ class NotificationService {
); );
final iosSettings = DarwinInitializationSettings( final iosSettings = DarwinInitializationSettings(
onDidReceiveLocalNotification: (id, title, body, payload) {
// TODO Navigate to Talk section (This runs when an Notification is tapped)
},
); );

View File

@@ -1,15 +1,16 @@
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart'; import 'package:flutter_app_badge/flutter_app_badge.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../main.dart'; import '../main.dart';
import '../model/chatList/chatListProps.dart'; import '../model/chatList/chatListProps.dart';
import '../model/chatList/chatProps.dart'; import '../model/chatList/chatProps.dart';
import '../state/app/modules/app_modules.dart';
class NotificationTasks { class NotificationTasks {
static void updateBadgeCount(RemoteMessage notification) { static void updateBadgeCount(RemoteMessage notification) {
FlutterAppBadger.updateBadgeCount(int.parse(notification.data['unreadCount'] ?? 0)); FlutterAppBadge.count(int.parse(notification.data['unreadCount'] ?? 0));
} }
static void updateProviders(BuildContext context) { static void updateProviders(BuildContext context) {
@@ -17,7 +18,9 @@ class NotificationTasks {
Provider.of<ChatProps>(context, listen: false).run(); Provider.of<ChatProps>(context, listen: false).run();
} }
static void navigateToTalk() { static void navigateToTalk(BuildContext context) {
Main.bottomNavigator.jumpToTab(1); var talkTab = AppModule.getBottomBarModules(context).map((e) => e.module).toList().indexOf(Modules.talk);
if(talkTab == -1) return;
Main.bottomNavigator.jumpToTab(talkTab);
} }
} }

View File

@@ -1,8 +1,8 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import '../../infrastructure/dataLoader/http_data_loader.dart'; import '../../infrastructure/dataLoader/data_loader.dart';
abstract class HolidayDataLoader<TResult> extends HttpDataLoader<TResult> { abstract class HolidayDataLoader<TResult> extends DataLoader<TResult> {
HolidayDataLoader() : super(Dio(BaseOptions( HolidayDataLoader() : super(Dio(BaseOptions(
baseUrl: 'https://ferien-api.de/api/v1/', baseUrl: 'https://ferien-api.de/api/v1/',
))); )));

View File

@@ -1,8 +1,8 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import '../../infrastructure/dataLoader/http_data_loader.dart'; import '../../infrastructure/dataLoader/data_loader.dart';
abstract class MhslDataLoader<TResult> extends HttpDataLoader<TResult> { abstract class MhslDataLoader<TResult> extends DataLoader<TResult> {
MhslDataLoader() : super(Dio(BaseOptions( MhslDataLoader() : super(Dio(BaseOptions(
baseUrl: 'https://mhsl.eu/marianum/marianummobile/' baseUrl: 'https://mhsl.eu/marianum/marianummobile/'
))); )));

View File

@@ -2,21 +2,26 @@ import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
abstract class HttpDataLoader<TResult> { abstract class DataLoader<TResult> {
final Dio dio; final Dio dio;
HttpDataLoader(this.dio) { DataLoader(this.dio) {
dio.options.connectTimeout = const Duration(seconds: 10).inMilliseconds; dio.options.connectTimeout = const Duration(seconds: 10).inMilliseconds;
dio.options.sendTimeout = const Duration(seconds: 30).inMilliseconds; dio.options.sendTimeout = const Duration(seconds: 30).inMilliseconds;
dio.options.receiveTimeout = const Duration(seconds: 30).inMilliseconds; dio.options.receiveTimeout = const Duration(seconds: 30).inMilliseconds;
} }
Future<TResult> run() async { Future<TResult> run() async {
var response = await fetch(); var fetcher = fetch();
await Future.wait([
fetcher,
Future.delayed(const Duration(milliseconds: 500)) // TODO tune or remove
]);
var response = await fetcher;
try { try {
return assemble(DataLoaderResult( return assemble(DataLoaderResult(
json: await compute(jsonDecode, response.data!), json: jsonDecode(response.data!),
headers: response.headers.map.map((key, value) => MapEntry(key, value.join(';'))), headers: response.headers.map.map((key, value) => MapEntry(key, value.join(';'))),
)); ));
} catch(trace, e) { } catch(trace, e) {

View File

@@ -19,7 +19,9 @@ mixin _$LoadableStateState {
List<ConnectivityResult>? get connections => List<ConnectivityResult>? get connections =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@JsonKey(ignore: true) /// Create a copy of LoadableStateState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoadableStateStateCopyWith<LoadableStateState> get copyWith => $LoadableStateStateCopyWith<LoadableStateState> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -43,6 +45,8 @@ class _$LoadableStateStateCopyWithImpl<$Res, $Val extends LoadableStateState>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of LoadableStateState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -76,6 +80,8 @@ class __$$LoadableStateStateImplCopyWithImpl<$Res>
$Res Function(_$LoadableStateStateImpl) _then) $Res Function(_$LoadableStateStateImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of LoadableStateState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -125,7 +131,9 @@ class _$LoadableStateStateImpl implements _LoadableStateState {
int get hashCode => Object.hash( int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_connections)); runtimeType, const DeepCollectionEquality().hash(_connections));
@JsonKey(ignore: true) /// Create a copy of LoadableStateState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$LoadableStateStateImplCopyWith<_$LoadableStateStateImpl> get copyWith => _$$LoadableStateStateImplCopyWith<_$LoadableStateStateImpl> get copyWith =>
@@ -140,8 +148,11 @@ abstract class _LoadableStateState implements LoadableStateState {
@override @override
List<ConnectivityResult>? get connections; List<ConnectivityResult>? get connections;
/// Create a copy of LoadableStateState
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$LoadableStateStateImplCopyWith<_$LoadableStateStateImpl> get copyWith => _$$LoadableStateStateImplCopyWith<_$LoadableStateStateImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }

View File

@@ -22,7 +22,9 @@ mixin _$LoadableState<TState> {
void Function()? get reFetch => throw _privateConstructorUsedError; void Function()? get reFetch => throw _privateConstructorUsedError;
LoadingError? get error => throw _privateConstructorUsedError; LoadingError? get error => throw _privateConstructorUsedError;
@JsonKey(ignore: true) /// Create a copy of LoadableState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoadableStateCopyWith<TState, LoadableState<TState>> get copyWith => $LoadableStateCopyWith<TState, LoadableState<TState>> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -54,6 +56,8 @@ class _$LoadableStateCopyWithImpl<TState, $Res,
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of LoadableState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -87,6 +91,8 @@ class _$LoadableStateCopyWithImpl<TState, $Res,
) as $Val); ) as $Val);
} }
/// Create a copy of LoadableState
/// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$LoadingErrorCopyWith<$Res>? get error { $LoadingErrorCopyWith<$Res>? get error {
@@ -128,6 +134,8 @@ class __$$LoadableStateImplCopyWithImpl<TState, $Res>
$Res Function(_$LoadableStateImpl<TState>) _then) $Res Function(_$LoadableStateImpl<TState>) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of LoadableState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -207,7 +215,9 @@ class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
int get hashCode => Object.hash(runtimeType, isLoading, int get hashCode => Object.hash(runtimeType, isLoading,
const DeepCollectionEquality().hash(data), lastFetch, reFetch, error); const DeepCollectionEquality().hash(data), lastFetch, reFetch, error);
@JsonKey(ignore: true) /// Create a copy of LoadableState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$LoadableStateImplCopyWith<TState, _$LoadableStateImpl<TState>> _$$LoadableStateImplCopyWith<TState, _$LoadableStateImpl<TState>>
@@ -234,8 +244,11 @@ abstract class _LoadableState<TState> extends LoadableState<TState> {
void Function()? get reFetch; void Function()? get reFetch;
@override @override
LoadingError? get error; LoadingError? get error;
/// Create a copy of LoadableState
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$LoadableStateImplCopyWith<TState, _$LoadableStateImpl<TState>> _$$LoadableStateImplCopyWith<TState, _$LoadableStateImpl<TState>>
get copyWith => throw _privateConstructorUsedError; get copyWith => throw _privateConstructorUsedError;
} }

View File

@@ -19,7 +19,9 @@ mixin _$LoadingError {
String get message => throw _privateConstructorUsedError; String get message => throw _privateConstructorUsedError;
bool get allowRetry => throw _privateConstructorUsedError; bool get allowRetry => throw _privateConstructorUsedError;
@JsonKey(ignore: true) /// Create a copy of LoadingError
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoadingErrorCopyWith<LoadingError> get copyWith => $LoadingErrorCopyWith<LoadingError> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -43,6 +45,8 @@ class _$LoadingErrorCopyWithImpl<$Res, $Val extends LoadingError>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of LoadingError
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -81,6 +85,8 @@ class __$$LoadingErrorImplCopyWithImpl<$Res>
_$LoadingErrorImpl _value, $Res Function(_$LoadingErrorImpl) _then) _$LoadingErrorImpl _value, $Res Function(_$LoadingErrorImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of LoadingError
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -129,7 +135,9 @@ class _$LoadingErrorImpl implements _LoadingError {
@override @override
int get hashCode => Object.hash(runtimeType, message, allowRetry); int get hashCode => Object.hash(runtimeType, message, allowRetry);
@JsonKey(ignore: true) /// Create a copy of LoadingError
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$LoadingErrorImplCopyWith<_$LoadingErrorImpl> get copyWith => _$$LoadingErrorImplCopyWith<_$LoadingErrorImpl> get copyWith =>
@@ -145,8 +153,11 @@ abstract class _LoadingError implements LoadingError {
String get message; String get message;
@override @override
bool get allowRetry; bool get allowRetry;
/// Create a copy of LoadingError
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$LoadingErrorImplCopyWith<_$LoadingErrorImpl> get copyWith => _$$LoadingErrorImplCopyWith<_$LoadingErrorImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }

View File

@@ -17,16 +17,13 @@ class LoadableStateConsumer<TController extends Bloc<LoadableHydratedBlocEvent<T
final Widget Function(TState state, bool loading) child; final Widget Function(TState state, bool loading) child;
final void Function(TState state)? onLoad; final void Function(TState state)? onLoad;
final bool wrapWithScrollView; final bool wrapWithScrollView;
final TController? controllerByValue; const LoadableStateConsumer({required this.child, this.onLoad, this.wrapWithScrollView = false, super.key});
const LoadableStateConsumer({required this.child, this.onLoad, this.wrapWithScrollView = false, this.controllerByValue = null, super.key});
static Duration animationDuration = const Duration(milliseconds: 200); static Duration animationDuration = const Duration(milliseconds: 200);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var loadableState = controllerByValue != null var loadableState = context.watch<TController>().state;
? controllerByValue!.state
: context.watch<TController>().state;
if(!loadableState.isLoading && onLoad != null) { if(!loadableState.isLoading && onLoad != null) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) => onLoad!(loadableState.data)); WidgetsBinding.instance.addPostFrameCallback((timeStamp) => onLoad!(loadableState.data));

View File

@@ -30,17 +30,16 @@ abstract class LoadableHydratedBloc<
isLoading: state.isLoading, isLoading: state.isLoading,
data: event.state(innerState ?? fromNothing()), data: event.state(innerState ?? fromNothing()),
lastFetch: state.lastFetch, lastFetch: state.lastFetch,
reFetch: fetch, reFetch: retry,
error: state.error, error: state.error,
)); ));
if(event.fetch) fetch();
}); });
on<DataGathered<TState>>((event, emit) => emit(LoadableState( on<DataGathered<TState>>((event, emit) => emit(LoadableState(
isLoading: false, isLoading: false,
data: event.state(innerState ?? fromNothing()), data: event.state(innerState ?? fromNothing()),
lastFetch: DateTime.now().millisecondsSinceEpoch, lastFetch: DateTime.now().millisecondsSinceEpoch,
reFetch: fetch, reFetch: retry,
error: null, error: null,
))); )));
@@ -56,7 +55,7 @@ abstract class LoadableHydratedBloc<
isLoading: false, isLoading: false,
data: innerState, data: innerState,
lastFetch: state.lastFetch, lastFetch: state.lastFetch,
reFetch: fetch, reFetch: retry,
error: event.error error: event.error
))); )));
@@ -67,14 +66,19 @@ abstract class LoadableHydratedBloc<
TState? get innerState => state.data; TState? get innerState => state.data;
TRepository get repo => _repository; TRepository get repo => _repository;
void retry() {
log('Fetch retry triggered for ${TState.toString()}');
add(RefetchStarted<TState>());
fetch();
}
void fetch() { void fetch() {
log('Fetching data for ${TState.toString()}'); log('Fetching data for ${TState.toString()}');
add(RefetchStarted<TState>());
gatherData().catchError( gatherData().catchError(
(e) { (e) {
log('Error while fetching ${TState.toString()}: ${e.toString()}'); log('Error while fetching ${TState.toString()}: ${e.toString()}');
add(Error(LoadingError( add(Error(LoadingError(
message: e.toString(), message: e.message ?? e.toString(),
allowRetry: true, allowRetry: true,
))); )));
}, },
@@ -88,7 +92,7 @@ abstract class LoadableHydratedBloc<
var rawData = LoadableSaveContext.unwrap(json); var rawData = LoadableSaveContext.unwrap(json);
return LoadableState( return LoadableState(
isLoading: true, isLoading: true,
data: fromStorage(rawData.data), // TODO fromStorage in isolate data: fromStorage(rawData.data),
lastFetch: rawData.meta.timestamp, lastFetch: rawData.meta.timestamp,
reFetch: null, reFetch: null,
error: null, error: null,
@@ -99,7 +103,7 @@ abstract class LoadableHydratedBloc<
Map<String, dynamic>? toJson(LoadableState<TState> state) { Map<String, dynamic>? toJson(LoadableState<TState> state) {
Map<String, dynamic>? data; Map<String, dynamic>? data;
try { try {
data = state.data == null ? null : toStorage(state.data); // TODO toStorage in isolate data = state.data == null ? null : toStorage(state.data);
} catch(e) { } catch(e) {
log('Failed to save state ${TState.toString()}: ${e.toString()}'); log('Failed to save state ${TState.toString()}: ${e.toString()}');
} }

View File

@@ -3,8 +3,7 @@ import '../../loadableState/loading_error.dart';
class LoadableHydratedBlocEvent<TState> {} class LoadableHydratedBlocEvent<TState> {}
class Emit<TState> extends LoadableHydratedBlocEvent<TState> { class Emit<TState> extends LoadableHydratedBlocEvent<TState> {
final TState Function(TState state) state; final TState Function(TState state) state;
final bool fetch; Emit(this.state);
Emit(this.state, {this.fetch = false});
} }
class DataGathered<TState> extends LoadableHydratedBlocEvent<TState> { class DataGathered<TState> extends LoadableHydratedBlocEvent<TState> {
final TState Function(TState state) state; final TState Function(TState state) state;

View File

@@ -22,8 +22,12 @@ LoadableSaveContext _$LoadableSaveContextFromJson(Map<String, dynamic> json) {
mixin _$LoadableSaveContext { mixin _$LoadableSaveContext {
int get timestamp => throw _privateConstructorUsedError; int get timestamp => throw _privateConstructorUsedError;
/// Serializes this LoadableSaveContext to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of LoadableSaveContext
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoadableSaveContextCopyWith<LoadableSaveContext> get copyWith => $LoadableSaveContextCopyWith<LoadableSaveContext> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -47,6 +51,8 @@ class _$LoadableSaveContextCopyWithImpl<$Res, $Val extends LoadableSaveContext>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of LoadableSaveContext
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -80,6 +86,8 @@ class __$$LoadableSaveContextImplCopyWithImpl<$Res>
$Res Function(_$LoadableSaveContextImpl) _then) $Res Function(_$LoadableSaveContextImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of LoadableSaveContext
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -119,11 +127,13 @@ class _$LoadableSaveContextImpl extends _LoadableSaveContext {
other.timestamp == timestamp)); other.timestamp == timestamp));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, timestamp); int get hashCode => Object.hash(runtimeType, timestamp);
@JsonKey(ignore: true) /// Create a copy of LoadableSaveContext
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$LoadableSaveContextImplCopyWith<_$LoadableSaveContextImpl> get copyWith => _$$LoadableSaveContextImplCopyWith<_$LoadableSaveContextImpl> get copyWith =>
@@ -148,8 +158,11 @@ abstract class _LoadableSaveContext extends LoadableSaveContext {
@override @override
int get timestamp; int get timestamp;
/// Create a copy of LoadableSaveContext
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$LoadableSaveContextImplCopyWith<_$LoadableSaveContextImpl> get copyWith => _$$LoadableSaveContextImplCopyWith<_$LoadableSaveContextImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }

View File

@@ -1,48 +0,0 @@
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:flutter/material.dart';
import 'bloc_module.dart';
class SwappingBloc<TBloc> {
final TBloc initialBloc;
final StreamController<TBloc> updater = StreamController<TBloc>();
SwappingBloc(this.initialBloc);
void swap(TBloc bloc) {
updater.add(bloc);
}
}
class SwappingBlocModule<TBloc extends StateStreamableSource<TState>, TState> extends StatefulWidget {
final SwappingBloc<TBloc> bloc;
final Widget Function(BuildContext context, TBloc bloc, TState state) child;
const SwappingBlocModule({super.key, required this.bloc, required this.child});
@override
State<SwappingBlocModule<TBloc, TState>> createState() => _SwappingBlocModuleState<TBloc, TState>();
}
class _SwappingBlocModuleState<TBloc extends StateStreamableSource<TState>, TState> extends State<SwappingBlocModule<TBloc, TState>> {
late TBloc bloc;
@override
void initState() {
super.initState();
bloc = widget.bloc.initialBloc;
widget.bloc.updater.stream.listen((event) {
setState(() {
bloc = event;
});
});
}
@override
Widget build(BuildContext context) => BlocModule<TBloc, TState>(
autoRebuild: true,
create: (context) => bloc,
child: (context, bloc, state) => widget.child(context, bloc, state),
);
}

View File

@@ -1,51 +1,129 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.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 '../../../api/mhsl/breaker/getBreakers/getBreakersResponse.dart'; import '../../../api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
import '../../../model/breakers/Breaker.dart'; import '../../../model/breakers/Breaker.dart';
import '../../../model/chatList/chatListProps.dart';
import '../../../storage/base/settingsProvider.dart';
import '../../../view/pages/files/files.dart'; import '../../../view/pages/files/files.dart';
import '../../../view/pages/more/roomplan/roomplan.dart'; import '../../../view/pages/more/roomplan/roomplan.dart';
import '../../../view/pages/talk/chatList.dart'; import '../../../view/pages/talk/chatList.dart';
import '../../../view/pages/timetable/timetable.dart'; import '../../../view/pages/timetable/timetable.dart';
import '../../../widget/centeredLeading.dart'; import '../../../widget/centeredLeading.dart';
import 'files/view/files_view.dart';
import 'gradeAverages/view/grade_averages_view.dart'; import 'gradeAverages/view/grade_averages_view.dart';
import 'holidays/view/holidays_view.dart'; import 'holidays/view/holidays_view.dart';
import 'marianumMessage/view/marianum_message_list_view.dart'; import 'marianumMessage/view/marianum_message_list_view.dart';
import 'package:badges/badges.dart' as badges;
class AppModule { class AppModule {
Modules module;
String name; String name;
IconData icon; Widget Function() icon;
BreakerArea breakerArea;
Widget Function() create; Widget Function() create;
AppModule(this.name, this.icon, this.create); AppModule(this.module, {required this.name, required this.icon, this.breakerArea = BreakerArea.global, required this.create});
static Map<Modules, AppModule> modules() => { static Map<Modules, AppModule> modules(BuildContext context, { showFiltered = false }) {
Modules.timetable: AppModule('Vertretung', Icons.calendar_month, Timetable.new), var settings = Provider.of<SettingsProvider>(context, listen: false);
Modules.talk: AppModule('Talk', Icons.chat, ChatList.new), var available = {
Modules.files: AppModule('Files', Icons.folder, Files.new), Modules.timetable: AppModule(
Modules.blocFiles: AppModule('BlocFiles', Icons.folder, FilesView.new), Modules.timetable,
Modules.marianumMessage: AppModule('Marianum Message', Icons.newspaper, MarianumMessageListView.new), name: 'Stundenplan',
Modules.roomPlan: AppModule('Raumplan', Icons.location_pin, Roomplan.new), icon: () => Icon(Icons.calendar_month),
Modules.gradeAveragesCalculator: AppModule('Notendurschnittsrechner', Icons.calculate, GradeAveragesView.new), breakerArea: BreakerArea.timetable,
Modules.holidays: AppModule('Schulferien', Icons.flight, HolidaysView.new), create: Timetable.new,
),
Modules.talk: AppModule(
Modules.talk,
name: 'Talk',
icon: () => Consumer<ChatListProps>(
builder: (context, value, child) {
if(value.primaryLoading()) return Icon(Icons.chat);
var 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: Icon(Icons.chat),
);
},
),
breakerArea: BreakerArea.talk,
create: ChatList.new,
),
Modules.files: AppModule(
Modules.files,
name: 'Dateien',
icon: () => Icon(Icons.folder),
breakerArea: BreakerArea.files,
create: Files.new,
),
Modules.marianumMessage: AppModule(
Modules.marianumMessage,
name: 'Marianum Message',
icon: () => Icon(Icons.newspaper),
breakerArea: BreakerArea.more,
create: MarianumMessageListView.new,
),
Modules.roomPlan: AppModule(
Modules.roomPlan,
name: 'Raumplan',
icon: () => Icon(Icons.location_pin),
breakerArea: BreakerArea.more,
create: Roomplan.new,
),
Modules.gradeAveragesCalculator: AppModule(
Modules.gradeAveragesCalculator,
name: 'Notendurschnittsrechner',
icon: () => Icon(Icons.calculate),
breakerArea: BreakerArea.more,
create: GradeAveragesView.new,
),
Modules.holidays: AppModule(
Modules.holidays,
name: 'Schulferien',
icon: () => Icon(Icons.flight),
breakerArea: BreakerArea.more,
create: HolidaysView.new,
),
}; };
static AppModule getModule(Modules module) => modules()[module]!; if(!showFiltered) available.removeWhere((key, value) => settings.val().modulesSettings.hiddenModules.contains(key));
Widget toListTile(BuildContext context) => ListTile( return { for (var element in settings.val().modulesSettings.moduleOrder.where((element) => available.containsKey(element))) element : available[element]! };
leading: CenteredLeading(Icon(icon)), }
static List<AppModule> getBottomBarModules(BuildContext context) => modules(context).values.toList().getRange(0, 3).toList();
static List<AppModule> getOverhangModules(BuildContext context) => modules(context).values.skip(3).toList();
Widget toListTile(BuildContext context, {Key? key, bool isReorder = false, Function()? onVisibleChange, bool isVisible = true}) => ListTile(
key: key,
leading: CenteredLeading(icon()),
title: Text(name), title: Text(name),
onTap: () => pushScreen(context, withNavBar: false, screen: create()), onTap: isReorder ? null : () => pushScreen(context, withNavBar: false, screen: create()),
trailing: const Icon(Icons.arrow_right), trailing: isReorder
? Row(mainAxisSize: MainAxisSize.min, children: [
IconButton(onPressed: onVisibleChange, icon: Icon(isVisible ? Icons.visibility_outlined : Icons.visibility_off_outlined)),
Icon(Icons.drag_handle_outlined)
])
: const Icon(Icons.arrow_right),
); );
PersistentTabConfig toBottomTab(BuildContext context, {Widget Function(IconData icon)? itemBuilder}) => PersistentTabConfig( PersistentTabConfig toBottomTab(BuildContext context, {Widget Function(IconData icon)? iconBuilder}) => PersistentTabConfig(
screen: Breaker(breaker: BreakerArea.global, child: create()), screen: Breaker(breaker: breakerArea, child: create()),
item: ItemConfig( item: ItemConfig(
activeForegroundColor: Theme.of(context).primaryColor, activeForegroundColor: Theme.of(context).primaryColor,
inactiveForegroundColor: Theme.of(context).colorScheme.secondary, inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
icon: itemBuilder == null ? Icon(icon) : itemBuilder(icon), icon: icon(),
title: name title: name
), ),
); );
@@ -55,7 +133,6 @@ enum Modules {
timetable, timetable,
talk, talk,
files, files,
blocFiles,
marianumMessage, marianumMessage,
roomPlan, roomPlan,
gradeAveragesCalculator, gradeAveragesCalculator,

View File

@@ -1,71 +0,0 @@
import 'dart:developer';
import 'package:sorted/sorted.dart';
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc.dart';
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc_event.dart';
import '../repository/files_repository.dart';
import 'files_event.dart';
import 'files_state.dart';
class FilesBloc extends LoadableHydratedBloc<FilesEvent, FilesState, FilesRepository> {
static const String basePath = '/';
FilesBloc() {
add(Emit((state) => state.copyWith(currentFolder: basePath)));
on<EnterFolder>((event, emit) {
add(Emit((state) {
log('setFolder');
return state.copyWith(currentFolder: event.absolutePath);
}, fetch: true));
});
}
List<File>? getVisibleFiles() => innerState?.files[innerState?.currentFolder];
String getCurrentFolder() => innerState?.currentFolder ?? basePath;
String getCurrentFolderName() {
var folder = innerState?.currentFolder.split('/').reversed.elementAt(1);
return folder!.isEmpty ? 'Dateien' : folder;
}
bool canGoBack() => innerState?.currentFolder != basePath;
String goBackLocation() {
var pathSegments = innerState?.currentFolder.split(basePath) ?? [];
if (pathSegments.isNotEmpty) {
pathSegments.removeLast();
pathSegments.removeLast();
}
return pathSegments.join(basePath) + basePath;
}
List currentSortConfiguration() => [
SortedComparable<File, DateTime>((file) => file.updatedAt ?? DateTime.now()),
];
@override
FilesState fromNothing() => const FilesState(currentFolder: basePath, files: {});
@override
FilesState fromStorage(Map<String, dynamic> json) => FilesState.fromJson(json);
@override
Future<void> gatherData() async {
var fetchFolder = getCurrentFolder();
log(fetchFolder);
var files = await repo.getFileList(fetchFolder);
var newFileMap = Map.of(innerState?.files ?? <String, List<File>>{});
newFileMap[fetchFolder] = files;
if(fetchFolder != getCurrentFolder()) {
log('Fetch aborted due to folder change (expected "$fetchFolder" got "${getCurrentFolder()}")');
return;
}
add(DataGathered((state) => state.copyWith(files: newFileMap)));
}
@override
FilesRepository repository() => FilesRepository();
@override
Map<String, dynamic>? toStorage(FilesState state) => state.toJson();
}

View File

@@ -1,10 +0,0 @@
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc_event.dart';
import 'files_state.dart';
sealed class FilesEvent extends LoadableHydratedBlocEvent<FilesState> {}
class EnterFolder extends FilesEvent {
String absolutePath;
EnterFolder(this.absolutePath);
}

View File

@@ -1,29 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'files_state.freezed.dart';
part 'files_state.g.dart';
@freezed
class FilesState with _$FilesState {
const factory FilesState({
required String currentFolder,
required Map<String, List<File>> files,
}) = _FilesState;
factory FilesState.fromJson(Map<String, Object?> json) => _$FilesStateFromJson(json);
}
@freezed
class File with _$File {
const factory File({
required String path,
required bool isFolder,
required String name,
required DateTime? createdAt,
required DateTime? updatedAt,
required int? size,
required String? mimeType,
}) = _File;
factory File.fromJson(Map<String, Object?> json) => _$FileFromJson(json);
}

View File

@@ -1,439 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'files_state.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
FilesState _$FilesStateFromJson(Map<String, dynamic> json) {
return _FilesState.fromJson(json);
}
/// @nodoc
mixin _$FilesState {
String get currentFolder => throw _privateConstructorUsedError;
Map<String, List<File>> get files => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$FilesStateCopyWith<FilesState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $FilesStateCopyWith<$Res> {
factory $FilesStateCopyWith(
FilesState value, $Res Function(FilesState) then) =
_$FilesStateCopyWithImpl<$Res, FilesState>;
@useResult
$Res call({String currentFolder, Map<String, List<File>> files});
}
/// @nodoc
class _$FilesStateCopyWithImpl<$Res, $Val extends FilesState>
implements $FilesStateCopyWith<$Res> {
_$FilesStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? currentFolder = null,
Object? files = null,
}) {
return _then(_value.copyWith(
currentFolder: null == currentFolder
? _value.currentFolder
: currentFolder // ignore: cast_nullable_to_non_nullable
as String,
files: null == files
? _value.files
: files // ignore: cast_nullable_to_non_nullable
as Map<String, List<File>>,
) as $Val);
}
}
/// @nodoc
abstract class _$$FilesStateImplCopyWith<$Res>
implements $FilesStateCopyWith<$Res> {
factory _$$FilesStateImplCopyWith(
_$FilesStateImpl value, $Res Function(_$FilesStateImpl) then) =
__$$FilesStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String currentFolder, Map<String, List<File>> files});
}
/// @nodoc
class __$$FilesStateImplCopyWithImpl<$Res>
extends _$FilesStateCopyWithImpl<$Res, _$FilesStateImpl>
implements _$$FilesStateImplCopyWith<$Res> {
__$$FilesStateImplCopyWithImpl(
_$FilesStateImpl _value, $Res Function(_$FilesStateImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? currentFolder = null,
Object? files = null,
}) {
return _then(_$FilesStateImpl(
currentFolder: null == currentFolder
? _value.currentFolder
: currentFolder // ignore: cast_nullable_to_non_nullable
as String,
files: null == files
? _value._files
: files // ignore: cast_nullable_to_non_nullable
as Map<String, List<File>>,
));
}
}
/// @nodoc
@JsonSerializable()
class _$FilesStateImpl implements _FilesState {
const _$FilesStateImpl(
{required this.currentFolder,
required final Map<String, List<File>> files})
: _files = files;
factory _$FilesStateImpl.fromJson(Map<String, dynamic> json) =>
_$$FilesStateImplFromJson(json);
@override
final String currentFolder;
final Map<String, List<File>> _files;
@override
Map<String, List<File>> get files {
if (_files is EqualUnmodifiableMapView) return _files;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_files);
}
@override
String toString() {
return 'FilesState(currentFolder: $currentFolder, files: $files)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FilesStateImpl &&
(identical(other.currentFolder, currentFolder) ||
other.currentFolder == currentFolder) &&
const DeepCollectionEquality().equals(other._files, _files));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType, currentFolder, const DeepCollectionEquality().hash(_files));
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$FilesStateImplCopyWith<_$FilesStateImpl> get copyWith =>
__$$FilesStateImplCopyWithImpl<_$FilesStateImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$FilesStateImplToJson(
this,
);
}
}
abstract class _FilesState implements FilesState {
const factory _FilesState(
{required final String currentFolder,
required final Map<String, List<File>> files}) = _$FilesStateImpl;
factory _FilesState.fromJson(Map<String, dynamic> json) =
_$FilesStateImpl.fromJson;
@override
String get currentFolder;
@override
Map<String, List<File>> get files;
@override
@JsonKey(ignore: true)
_$$FilesStateImplCopyWith<_$FilesStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
File _$FileFromJson(Map<String, dynamic> json) {
return _File.fromJson(json);
}
/// @nodoc
mixin _$File {
String get path => throw _privateConstructorUsedError;
bool get isFolder => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
DateTime? get createdAt => throw _privateConstructorUsedError;
DateTime? get updatedAt => throw _privateConstructorUsedError;
int? get size => throw _privateConstructorUsedError;
String? get mimeType => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$FileCopyWith<File> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $FileCopyWith<$Res> {
factory $FileCopyWith(File value, $Res Function(File) then) =
_$FileCopyWithImpl<$Res, File>;
@useResult
$Res call(
{String path,
bool isFolder,
String name,
DateTime? createdAt,
DateTime? updatedAt,
int? size,
String? mimeType});
}
/// @nodoc
class _$FileCopyWithImpl<$Res, $Val extends File>
implements $FileCopyWith<$Res> {
_$FileCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? path = null,
Object? isFolder = null,
Object? name = null,
Object? createdAt = freezed,
Object? updatedAt = freezed,
Object? size = freezed,
Object? mimeType = freezed,
}) {
return _then(_value.copyWith(
path: null == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String,
isFolder: null == isFolder
? _value.isFolder
: isFolder // ignore: cast_nullable_to_non_nullable
as bool,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
size: freezed == size
? _value.size
: size // ignore: cast_nullable_to_non_nullable
as int?,
mimeType: freezed == mimeType
? _value.mimeType
: mimeType // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
/// @nodoc
abstract class _$$FileImplCopyWith<$Res> implements $FileCopyWith<$Res> {
factory _$$FileImplCopyWith(
_$FileImpl value, $Res Function(_$FileImpl) then) =
__$$FileImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String path,
bool isFolder,
String name,
DateTime? createdAt,
DateTime? updatedAt,
int? size,
String? mimeType});
}
/// @nodoc
class __$$FileImplCopyWithImpl<$Res>
extends _$FileCopyWithImpl<$Res, _$FileImpl>
implements _$$FileImplCopyWith<$Res> {
__$$FileImplCopyWithImpl(_$FileImpl _value, $Res Function(_$FileImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? path = null,
Object? isFolder = null,
Object? name = null,
Object? createdAt = freezed,
Object? updatedAt = freezed,
Object? size = freezed,
Object? mimeType = freezed,
}) {
return _then(_$FileImpl(
path: null == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String,
isFolder: null == isFolder
? _value.isFolder
: isFolder // ignore: cast_nullable_to_non_nullable
as bool,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
size: freezed == size
? _value.size
: size // ignore: cast_nullable_to_non_nullable
as int?,
mimeType: freezed == mimeType
? _value.mimeType
: mimeType // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
@JsonSerializable()
class _$FileImpl implements _File {
const _$FileImpl(
{required this.path,
required this.isFolder,
required this.name,
required this.createdAt,
required this.updatedAt,
required this.size,
required this.mimeType});
factory _$FileImpl.fromJson(Map<String, dynamic> json) =>
_$$FileImplFromJson(json);
@override
final String path;
@override
final bool isFolder;
@override
final String name;
@override
final DateTime? createdAt;
@override
final DateTime? updatedAt;
@override
final int? size;
@override
final String? mimeType;
@override
String toString() {
return 'File(path: $path, isFolder: $isFolder, name: $name, createdAt: $createdAt, updatedAt: $updatedAt, size: $size, mimeType: $mimeType)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FileImpl &&
(identical(other.path, path) || other.path == path) &&
(identical(other.isFolder, isFolder) ||
other.isFolder == isFolder) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.size, size) || other.size == size) &&
(identical(other.mimeType, mimeType) ||
other.mimeType == mimeType));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType, path, isFolder, name, createdAt, updatedAt, size, mimeType);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$FileImplCopyWith<_$FileImpl> get copyWith =>
__$$FileImplCopyWithImpl<_$FileImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$FileImplToJson(
this,
);
}
}
abstract class _File implements File {
const factory _File(
{required final String path,
required final bool isFolder,
required final String name,
required final DateTime? createdAt,
required final DateTime? updatedAt,
required final int? size,
required final String? mimeType}) = _$FileImpl;
factory _File.fromJson(Map<String, dynamic> json) = _$FileImpl.fromJson;
@override
String get path;
@override
bool get isFolder;
@override
String get name;
@override
DateTime? get createdAt;
@override
DateTime? get updatedAt;
@override
int? get size;
@override
String? get mimeType;
@override
@JsonKey(ignore: true)
_$$FileImplCopyWith<_$FileImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,50 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'files_state.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$FilesStateImpl _$$FilesStateImplFromJson(Map<String, dynamic> json) =>
_$FilesStateImpl(
currentFolder: json['currentFolder'] as String,
files: (json['files'] as Map<String, dynamic>).map(
(k, e) => MapEntry(
k,
(e as List<dynamic>)
.map((e) => File.fromJson(e as Map<String, dynamic>))
.toList()),
),
);
Map<String, dynamic> _$$FilesStateImplToJson(_$FilesStateImpl instance) =>
<String, dynamic>{
'currentFolder': instance.currentFolder,
'files': instance.files,
};
_$FileImpl _$$FileImplFromJson(Map<String, dynamic> json) => _$FileImpl(
path: json['path'] as String,
isFolder: json['isFolder'] as bool,
name: json['name'] as String,
createdAt: json['createdAt'] == null
? null
: DateTime.parse(json['createdAt'] as String),
updatedAt: json['updatedAt'] == null
? null
: DateTime.parse(json['updatedAt'] as String),
size: (json['size'] as num?)?.toInt(),
mimeType: json['mimeType'] as String?,
);
Map<String, dynamic> _$$FileImplToJson(_$FileImpl instance) =>
<String, dynamic>{
'path': instance.path,
'isFolder': instance.isFolder,
'name': instance.name,
'createdAt': instance.createdAt?.toIso8601String(),
'updatedAt': instance.updatedAt?.toIso8601String(),
'size': instance.size,
'mimeType': instance.mimeType,
};

View File

@@ -1,31 +0,0 @@
import 'package:nextcloud/nextcloud.dart';
import '../../../../../api/marianumcloud/webdav/webdavApi.dart';
import '../../../infrastructure/repository/repository.dart';
import '../bloc/files_state.dart';
class FilesRepository extends Repository<FilesState> {
Future<List<File>> getFileList(String path) async {
var webdav = await WebdavApi.webdav;
var response = await webdav.propfind(PathUri.parse(path)); // TODO move to custom data loader
var davFiles = response.toWebDavFiles();
davFiles.removeWhere((file) {
var filePath = file.path.path;
return filePath.isEmpty || filePath == path;
});
var files = davFiles.map((davFile) => File(
path: davFile.path.path,
isFolder: davFile.isDirectory,
name: davFile.name,
createdAt: davFile.createdDate,
updatedAt: davFile.lastModified,
size: davFile.size,
mimeType: davFile.mimeType
));
return files.toList();
}
}

View File

@@ -1,17 +0,0 @@
import 'package:flutter/material.dart';
import '../../../infrastructure/loadableState/loadable_state.dart';
import '../../../infrastructure/utilityWidgets/bloc_module.dart';
import '../bloc/files_bloc.dart';
import '../bloc/files_state.dart';
import 'folder_view.dart';
class FilesView extends StatelessWidget {
const FilesView({super.key});
@override
Widget build(BuildContext context) => BlocModule<FilesBloc, LoadableState<FilesState>>(
create: (context) => FilesBloc(),
autoRebuild: true,
child: (context, bloc, state) => FolderView(bloc),
);
}

View File

@@ -1,57 +0,0 @@
import 'dart:developer';
import 'package:filesize/filesize.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import '../../../../../widget/centeredLeading.dart';
import '../../../../../widget/list_view_util.dart';
import '../../../infrastructure/loadableState/view/loadable_state_consumer.dart';
import '../bloc/files_bloc.dart';
import '../bloc/files_event.dart';
import '../bloc/files_state.dart';
class FolderView extends StatelessWidget {
final FilesBloc bloc;
const FolderView(this.bloc, {super.key});
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
leading: !bloc.canGoBack() ? null : IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
bloc.add(EnterFolder(bloc.goBackLocation()));
Navigator.of(context).pop();
},
),
title: Text(bloc.getCurrentFolderName()),
actions: [
IconButton(onPressed: () {
log(bloc.innerState?.toJson().toString() ?? 'leer');
}, icon: const Icon(Icons.bug_report)),
IconButton(onPressed: () {
bloc.add(EnterFolder('/'));
}, icon: const Icon(Icons.home)),
],
),
body: LoadableStateConsumer<FilesBloc, FilesState>(
controllerByValue: bloc,
child: (state, loading) => ListViewUtil.fromList<File>(bloc.getVisibleFiles(), (file) => ListTile(
leading: CenteredLeading(Icon(file.isFolder ? Icons.folder : Icons.description_outlined)),
title: Text(file.name),
subtitle: file.isFolder
? Text('geändert ${Jiffy.parseFromDateTime(file.updatedAt ?? DateTime.now()).fromNow()}')
: Text('${filesize(file.size)}, ${Jiffy.parseFromDateTime(file.updatedAt ?? DateTime.now()).fromNow()}'),
trailing: Icon(file.isFolder ? Icons.arrow_right : null),
onTap: () {
log(file.path);
if(!file.isFolder) return;
Navigator.of(context).push(MaterialPageRoute(builder: (context) => FolderView(bloc)));
bloc.add(EnterFolder(file.path));
},
))
)
);
}

View File

@@ -24,8 +24,12 @@ mixin _$GradeAveragesState {
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
List<int> get grades => throw _privateConstructorUsedError; List<int> get grades => throw _privateConstructorUsedError;
/// Serializes this GradeAveragesState to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of GradeAveragesState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GradeAveragesStateCopyWith<GradeAveragesState> get copyWith => $GradeAveragesStateCopyWith<GradeAveragesState> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -49,6 +53,8 @@ class _$GradeAveragesStateCopyWithImpl<$Res, $Val extends GradeAveragesState>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of GradeAveragesState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -87,6 +93,8 @@ class __$$GradeAveragesStateImplCopyWithImpl<$Res>
$Res Function(_$GradeAveragesStateImpl) _then) $Res Function(_$GradeAveragesStateImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of GradeAveragesState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -141,12 +149,14 @@ class _$GradeAveragesStateImpl implements _GradeAveragesState {
const DeepCollectionEquality().equals(other._grades, _grades)); const DeepCollectionEquality().equals(other._grades, _grades));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash( int get hashCode => Object.hash(
runtimeType, gradingSystem, const DeepCollectionEquality().hash(_grades)); runtimeType, gradingSystem, const DeepCollectionEquality().hash(_grades));
@JsonKey(ignore: true) /// Create a copy of GradeAveragesState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$GradeAveragesStateImplCopyWith<_$GradeAveragesStateImpl> get copyWith => _$$GradeAveragesStateImplCopyWith<_$GradeAveragesStateImpl> get copyWith =>
@@ -173,8 +183,11 @@ abstract class _GradeAveragesState implements GradeAveragesState {
GradeAveragesGradingSystem get gradingSystem; GradeAveragesGradingSystem get gradingSystem;
@override @override
List<int> get grades; List<int> get grades;
/// Create a copy of GradeAveragesState
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$GradeAveragesStateImplCopyWith<_$GradeAveragesStateImpl> get copyWith => _$$GradeAveragesStateImplCopyWith<_$GradeAveragesStateImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }

View File

@@ -24,8 +24,12 @@ mixin _$HolidaysState {
bool get showDisclaimer => throw _privateConstructorUsedError; bool get showDisclaimer => throw _privateConstructorUsedError;
List<Holiday> get holidays => throw _privateConstructorUsedError; List<Holiday> get holidays => throw _privateConstructorUsedError;
/// Serializes this HolidaysState to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of HolidaysState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$HolidaysStateCopyWith<HolidaysState> get copyWith => $HolidaysStateCopyWith<HolidaysState> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -50,6 +54,8 @@ class _$HolidaysStateCopyWithImpl<$Res, $Val extends HolidaysState>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of HolidaysState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -94,6 +100,8 @@ class __$$HolidaysStateImplCopyWithImpl<$Res>
_$HolidaysStateImpl _value, $Res Function(_$HolidaysStateImpl) _then) _$HolidaysStateImpl _value, $Res Function(_$HolidaysStateImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of HolidaysState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -171,12 +179,14 @@ class _$HolidaysStateImpl
const DeepCollectionEquality().equals(other._holidays, _holidays)); const DeepCollectionEquality().equals(other._holidays, _holidays));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, showPastHolidays, showDisclaimer, int get hashCode => Object.hash(runtimeType, showPastHolidays, showDisclaimer,
const DeepCollectionEquality().hash(_holidays)); const DeepCollectionEquality().hash(_holidays));
@JsonKey(ignore: true) /// Create a copy of HolidaysState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$HolidaysStateImplCopyWith<_$HolidaysStateImpl> get copyWith => _$$HolidaysStateImplCopyWith<_$HolidaysStateImpl> get copyWith =>
@@ -205,8 +215,11 @@ abstract class _HolidaysState implements HolidaysState {
bool get showDisclaimer; bool get showDisclaimer;
@override @override
List<Holiday> get holidays; List<Holiday> get holidays;
/// Create a copy of HolidaysState
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$HolidaysStateImplCopyWith<_$HolidaysStateImpl> get copyWith => _$$HolidaysStateImplCopyWith<_$HolidaysStateImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -224,8 +237,12 @@ mixin _$Holiday {
String get name => throw _privateConstructorUsedError; String get name => throw _privateConstructorUsedError;
String get slug => throw _privateConstructorUsedError; String get slug => throw _privateConstructorUsedError;
/// Serializes this Holiday to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of Holiday
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$HolidayCopyWith<Holiday> get copyWith => throw _privateConstructorUsedError; $HolidayCopyWith<Holiday> get copyWith => throw _privateConstructorUsedError;
} }
@@ -253,6 +270,8 @@ class _$HolidayCopyWithImpl<$Res, $Val extends Holiday>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of Holiday
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -316,6 +335,8 @@ class __$$HolidayImplCopyWithImpl<$Res>
_$HolidayImpl _value, $Res Function(_$HolidayImpl) _then) _$HolidayImpl _value, $Res Function(_$HolidayImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of Holiday
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -414,12 +435,14 @@ class _$HolidayImpl with DiagnosticableTreeMixin implements _Holiday {
(identical(other.slug, slug) || other.slug == slug)); (identical(other.slug, slug) || other.slug == slug));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => int get hashCode =>
Object.hash(runtimeType, start, end, year, stateCode, name, slug); Object.hash(runtimeType, start, end, year, stateCode, name, slug);
@JsonKey(ignore: true) /// Create a copy of Holiday
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$HolidayImplCopyWith<_$HolidayImpl> get copyWith => _$$HolidayImplCopyWith<_$HolidayImpl> get copyWith =>
@@ -456,8 +479,11 @@ abstract class _Holiday implements Holiday {
String get name; String get name;
@override @override
String get slug; String get slug;
/// Create a copy of Holiday
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$HolidayImplCopyWith<_$HolidayImpl> get copyWith => _$$HolidayImplCopyWith<_$HolidayImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }

View File

@@ -1,7 +1,7 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import '../../../basis/dataloader/holiday_data_loader.dart'; import '../../../basis/dataloader/holiday_data_loader.dart';
import '../../../infrastructure/dataLoader/http_data_loader.dart'; import '../../../infrastructure/dataLoader/data_loader.dart';
import '../bloc/holidays_state.dart'; import '../bloc/holidays_state.dart';
class HolidaysGetHolidays extends HolidayDataLoader<List<Holiday>> { class HolidaysGetHolidays extends HolidayDataLoader<List<Holiday>> {

View File

@@ -22,8 +22,12 @@ MarianumMessageState _$MarianumMessageStateFromJson(Map<String, dynamic> json) {
mixin _$MarianumMessageState { mixin _$MarianumMessageState {
MarianumMessageList get messageList => throw _privateConstructorUsedError; MarianumMessageList get messageList => throw _privateConstructorUsedError;
/// Serializes this MarianumMessageState to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of MarianumMessageState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$MarianumMessageStateCopyWith<MarianumMessageState> get copyWith => $MarianumMessageStateCopyWith<MarianumMessageState> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -50,6 +54,8 @@ class _$MarianumMessageStateCopyWithImpl<$Res,
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of MarianumMessageState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -63,6 +69,8 @@ class _$MarianumMessageStateCopyWithImpl<$Res,
) as $Val); ) as $Val);
} }
/// Create a copy of MarianumMessageState
/// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$MarianumMessageListCopyWith<$Res> get messageList { $MarianumMessageListCopyWith<$Res> get messageList {
@@ -94,6 +102,8 @@ class __$$MarianumMessageStateImplCopyWithImpl<$Res>
$Res Function(_$MarianumMessageStateImpl) _then) $Res Function(_$MarianumMessageStateImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of MarianumMessageState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -133,11 +143,13 @@ class _$MarianumMessageStateImpl implements _MarianumMessageState {
other.messageList == messageList)); other.messageList == messageList));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, messageList); int get hashCode => Object.hash(runtimeType, messageList);
@JsonKey(ignore: true) /// Create a copy of MarianumMessageState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$MarianumMessageStateImplCopyWith<_$MarianumMessageStateImpl> _$$MarianumMessageStateImplCopyWith<_$MarianumMessageStateImpl>
@@ -163,8 +175,11 @@ abstract class _MarianumMessageState implements MarianumMessageState {
@override @override
MarianumMessageList get messageList; MarianumMessageList get messageList;
/// Create a copy of MarianumMessageState
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$MarianumMessageStateImplCopyWith<_$MarianumMessageStateImpl> _$$MarianumMessageStateImplCopyWith<_$MarianumMessageStateImpl>
get copyWith => throw _privateConstructorUsedError; get copyWith => throw _privateConstructorUsedError;
} }
@@ -178,8 +193,12 @@ mixin _$MarianumMessageList {
String get base => throw _privateConstructorUsedError; String get base => throw _privateConstructorUsedError;
List<MarianumMessage> get messages => throw _privateConstructorUsedError; List<MarianumMessage> get messages => throw _privateConstructorUsedError;
/// Serializes this MarianumMessageList to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of MarianumMessageList
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$MarianumMessageListCopyWith<MarianumMessageList> get copyWith => $MarianumMessageListCopyWith<MarianumMessageList> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -203,6 +222,8 @@ class _$MarianumMessageListCopyWithImpl<$Res, $Val extends MarianumMessageList>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of MarianumMessageList
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -241,6 +262,8 @@ class __$$MarianumMessageListImplCopyWithImpl<$Res>
$Res Function(_$MarianumMessageListImpl) _then) $Res Function(_$MarianumMessageListImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of MarianumMessageList
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -294,12 +317,14 @@ class _$MarianumMessageListImpl implements _MarianumMessageList {
const DeepCollectionEquality().equals(other._messages, _messages)); const DeepCollectionEquality().equals(other._messages, _messages));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash( int get hashCode => Object.hash(
runtimeType, base, const DeepCollectionEquality().hash(_messages)); runtimeType, base, const DeepCollectionEquality().hash(_messages));
@JsonKey(ignore: true) /// Create a copy of MarianumMessageList
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$MarianumMessageListImplCopyWith<_$MarianumMessageListImpl> get copyWith => _$$MarianumMessageListImplCopyWith<_$MarianumMessageListImpl> get copyWith =>
@@ -327,8 +352,11 @@ abstract class _MarianumMessageList implements MarianumMessageList {
String get base; String get base;
@override @override
List<MarianumMessage> get messages; List<MarianumMessage> get messages;
/// Create a copy of MarianumMessageList
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$MarianumMessageListImplCopyWith<_$MarianumMessageListImpl> get copyWith => _$$MarianumMessageListImplCopyWith<_$MarianumMessageListImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -343,8 +371,12 @@ mixin _$MarianumMessage {
String get date => throw _privateConstructorUsedError; String get date => throw _privateConstructorUsedError;
String get url => throw _privateConstructorUsedError; String get url => throw _privateConstructorUsedError;
/// Serializes this MarianumMessage to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
/// Create a copy of MarianumMessage
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$MarianumMessageCopyWith<MarianumMessage> get copyWith => $MarianumMessageCopyWith<MarianumMessage> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@@ -368,6 +400,8 @@ class _$MarianumMessageCopyWithImpl<$Res, $Val extends MarianumMessage>
// ignore: unused_field // ignore: unused_field
final $Res Function($Val) _then; final $Res Function($Val) _then;
/// Create a copy of MarianumMessage
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -411,6 +445,8 @@ class __$$MarianumMessageImplCopyWithImpl<$Res>
_$MarianumMessageImpl _value, $Res Function(_$MarianumMessageImpl) _then) _$MarianumMessageImpl _value, $Res Function(_$MarianumMessageImpl) _then)
: super(_value, _then); : super(_value, _then);
/// Create a copy of MarianumMessage
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({
@@ -466,11 +502,13 @@ class _$MarianumMessageImpl implements _MarianumMessage {
(identical(other.url, url) || other.url == url)); (identical(other.url, url) || other.url == url));
} }
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, name, date, url); int get hashCode => Object.hash(runtimeType, name, date, url);
@JsonKey(ignore: true) /// Create a copy of MarianumMessage
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$MarianumMessageImplCopyWith<_$MarianumMessageImpl> get copyWith => _$$MarianumMessageImplCopyWith<_$MarianumMessageImpl> get copyWith =>
@@ -500,8 +538,11 @@ abstract class _MarianumMessage implements MarianumMessage {
String get date; String get date;
@override @override
String get url; String get url;
/// Create a copy of MarianumMessage
/// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(ignore: true) @JsonKey(includeFromJson: false, includeToJson: false)
_$$MarianumMessageImplCopyWith<_$MarianumMessageImpl> get copyWith => _$$MarianumMessageImplCopyWith<_$MarianumMessageImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }

View File

@@ -1,6 +1,6 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import '../../../infrastructure/dataLoader/http_data_loader.dart'; import '../../../infrastructure/dataLoader/data_loader.dart';
import '../../../basis/dataloader/mhsl_data_loader.dart'; import '../../../basis/dataloader/mhsl_data_loader.dart';
import '../bloc/marianum_message_state.dart'; import '../bloc/marianum_message_state.dart';

View File

@@ -4,6 +4,7 @@ import 'package:json_annotation/json_annotation.dart';
import '../devTools/devToolsSettings.dart'; import '../devTools/devToolsSettings.dart';
import '../file/fileSettings.dart'; import '../file/fileSettings.dart';
import '../fileView/fileViewSettings.dart'; import '../fileView/fileViewSettings.dart';
import '../general/modulesSettings.dart';
import '../holidays/holidaysSettings.dart'; import '../holidays/holidaysSettings.dart';
import '../notification/notificationSettings.dart'; import '../notification/notificationSettings.dart';
import '../talk/talkSettings.dart'; import '../talk/talkSettings.dart';
@@ -20,6 +21,7 @@ class Settings {
ThemeMode appTheme; ThemeMode appTheme;
bool devToolsEnabled; bool devToolsEnabled;
ModulesSettings modulesSettings;
TimetableSettings timetableSettings; TimetableSettings timetableSettings;
TalkSettings talkSettings; TalkSettings talkSettings;
FileSettings fileSettings; FileSettings fileSettings;
@@ -31,6 +33,7 @@ class Settings {
Settings({ Settings({
required this.appTheme, required this.appTheme,
required this.devToolsEnabled, required this.devToolsEnabled,
required this.modulesSettings,
required this.timetableSettings, required this.timetableSettings,
required this.talkSettings, required this.talkSettings,
required this.fileSettings, required this.fileSettings,

View File

@@ -9,6 +9,8 @@ part of 'settings.dart';
Settings _$SettingsFromJson(Map<String, dynamic> json) => Settings( Settings _$SettingsFromJson(Map<String, dynamic> json) => Settings(
appTheme: Settings._themeFromJson(json['appTheme'] as String), appTheme: Settings._themeFromJson(json['appTheme'] as String),
devToolsEnabled: json['devToolsEnabled'] as bool, devToolsEnabled: json['devToolsEnabled'] as bool,
modulesSettings: ModulesSettings.fromJson(
json['modulesSettings'] as Map<String, dynamic>),
timetableSettings: TimetableSettings.fromJson( timetableSettings: TimetableSettings.fromJson(
json['timetableSettings'] as Map<String, dynamic>), json['timetableSettings'] as Map<String, dynamic>),
talkSettings: talkSettings:
@@ -28,6 +30,7 @@ Settings _$SettingsFromJson(Map<String, dynamic> json) => Settings(
Map<String, dynamic> _$SettingsToJson(Settings instance) => <String, dynamic>{ Map<String, dynamic> _$SettingsToJson(Settings instance) => <String, dynamic>{
'appTheme': Settings._themeToJson(instance.appTheme), 'appTheme': Settings._themeToJson(instance.appTheme),
'devToolsEnabled': instance.devToolsEnabled, 'devToolsEnabled': instance.devToolsEnabled,
'modulesSettings': instance.modulesSettings.toJson(),
'timetableSettings': instance.timetableSettings.toJson(), 'timetableSettings': instance.timetableSettings.toJson(),
'talkSettings': instance.talkSettings.toJson(), 'talkSettings': instance.talkSettings.toJson(),
'fileSettings': instance.fileSettings.toJson(), 'fileSettings': instance.fileSettings.toJson(),

View File

@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'package:easy_debounce/easy_debounce.dart'; import 'package:easy_debounce/easy_debounce.dart';
@@ -13,6 +14,8 @@ class SettingsProvider extends ChangeNotifier {
late SharedPreferences _storage; late SharedPreferences _storage;
late Settings _settings = DefaultSettings.get(); late Settings _settings = DefaultSettings.get();
final Completer<void> _populated = Completer();
Settings val({bool write = false}) { Settings val({bool write = false}) {
if(write) { if(write) {
notifyListeners(); notifyListeners();
@@ -56,6 +59,7 @@ class SettingsProvider extends ChangeNotifier {
} }
notifyListeners(); notifyListeners();
_populated.complete();
} }
Future<void> update() async { Future<void> update() async {
@@ -77,4 +81,8 @@ class SettingsProvider extends ChangeNotifier {
return mergedMap; return mergedMap;
} }
Future<void> waitForPopulation() async {
await _populated.future;
}
} }

View File

@@ -0,0 +1,19 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../state/app/modules/app_modules.dart';
part 'modulesSettings.g.dart';
@JsonSerializable()
class ModulesSettings {
List<Modules> moduleOrder;
List<Modules> hiddenModules;
ModulesSettings({
required this.moduleOrder,
required this.hiddenModules
});
factory ModulesSettings.fromJson(Map<String, dynamic> json) => _$ModulesSettingsFromJson(json);
Map<String, dynamic> toJson() => _$ModulesSettingsToJson(this);
}

View File

@@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'modulesSettings.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ModulesSettings _$ModulesSettingsFromJson(Map<String, dynamic> json) =>
ModulesSettings(
moduleOrder: (json['moduleOrder'] as List<dynamic>)
.map((e) => $enumDecode(_$ModulesEnumMap, e))
.toList(),
hiddenModules: (json['hiddenModules'] as List<dynamic>)
.map((e) => $enumDecode(_$ModulesEnumMap, e))
.toList(),
);
Map<String, dynamic> _$ModulesSettingsToJson(ModulesSettings instance) =>
<String, dynamic>{
'moduleOrder':
instance.moduleOrder.map((e) => _$ModulesEnumMap[e]!).toList(),
'hiddenModules':
instance.hiddenModules.map((e) => _$ModulesEnumMap[e]!).toList(),
};
const _$ModulesEnumMap = {
Modules.timetable: 'timetable',
Modules.talk: 'talk',
Modules.files: 'files',
Modules.marianumMessage: 'marianumMessage',
Modules.roomPlan: 'roomPlan',
Modules.gradeAveragesCalculator: 'gradeAveragesCalculator',
Modules.holidays: 'holidays',
};

View File

@@ -1,12 +1,18 @@
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import '../../view/pages/timetable/timetableNameMode.dart';
part 'timetableSettings.g.dart'; part 'timetableSettings.g.dart';
@JsonSerializable() @JsonSerializable()
class TimetableSettings { class TimetableSettings {
bool connectDoubleLessons; bool connectDoubleLessons;
TimetableNameMode timetableNameMode;
TimetableSettings({required this.connectDoubleLessons}); TimetableSettings({
required this.connectDoubleLessons,
required this.timetableNameMode
});
factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json); factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this); Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);

View File

@@ -9,9 +9,19 @@ part of 'timetableSettings.dart';
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) => TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
TimetableSettings( TimetableSettings(
connectDoubleLessons: json['connectDoubleLessons'] as bool, connectDoubleLessons: json['connectDoubleLessons'] as bool,
timetableNameMode:
$enumDecode(_$TimetableNameModeEnumMap, json['timetableNameMode']),
); );
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) => Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
<String, dynamic>{ <String, dynamic>{
'connectDoubleLessons': instance.connectDoubleLessons, 'connectDoubleLessons': instance.connectDoubleLessons,
'timetableNameMode':
_$TimetableNameModeEnumMap[instance.timetableNameMode]!,
};
const _$TimetableNameModeEnumMap = {
TimetableNameMode.name: 'name',
TimetableNameMode.longName: 'longName',
TimetableNameMode.alternateName: 'alternateName',
}; };

View File

@@ -1,26 +1,21 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../widget/dropdownDisplay.dart';
class AppTheme { class AppTheme {
static ThemeModeDisplay getDisplayOptions(ThemeMode theme) { static DropdownDisplay getDisplayOptions(ThemeMode theme) {
switch(theme) { switch(theme) {
case ThemeMode.system: case ThemeMode.system:
return ThemeModeDisplay(icon: Icons.auto_fix_high_outlined, displayName: 'Systemvorgabe'); return DropdownDisplay(icon: Icons.auto_fix_high_outlined, displayName: 'Systemvorgabe');
case ThemeMode.light: case ThemeMode.light:
return ThemeModeDisplay(icon: Icons.wb_sunny_outlined, displayName: 'Hell'); return DropdownDisplay(icon: Icons.wb_sunny_outlined, displayName: 'Hell');
case ThemeMode.dark: case ThemeMode.dark:
return ThemeModeDisplay(icon: Icons.dark_mode_outlined, displayName: 'Dunkel'); return DropdownDisplay(icon: Icons.dark_mode_outlined, displayName: 'Dunkel');
} }
} }
static bool isDarkMode(BuildContext context) => Theme.of(context).brightness == Brightness.dark; static bool isDarkMode(BuildContext context) => Theme.of(context).brightness == Brightness.dark;
} }
class ThemeModeDisplay {
final IconData icon;
final String displayName;
ThemeModeDisplay({required this.icon, required this.displayName});
}

View File

@@ -8,6 +8,6 @@ class LightAppTheme {
colorScheme: ColorScheme.fromSeed(seedColor: marianumRed), colorScheme: ColorScheme.fromSeed(seedColor: marianumRed),
floatingActionButtonTheme: const FloatingActionButtonThemeData( floatingActionButtonTheme: const FloatingActionButtonThemeData(
foregroundColor: Colors.white foregroundColor: Colors.white
), )
); );
} }

View File

@@ -1,11 +1,11 @@
import 'dart:io'; import 'dart:io';
import 'package:better_open_file/better_open_file.dart';
import 'package:filesize/filesize.dart'; import 'package:filesize/filesize.dart';
import 'package:flowder/flowder.dart'; import 'package:flowder/flowder.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart'; import 'package:jiffy/jiffy.dart';
import 'package:open_filex/open_filex.dart';
import '../../../widget/infoDialog.dart'; import '../../../widget/infoDialog.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';

View File

@@ -5,7 +5,7 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:loader_overlay/loader_overlay.dart'; import 'package:loader_overlay/loader_overlay.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:badges/badges.dart' as badges; import 'package:badges/badges.dart' as badges;
@@ -70,7 +70,7 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
decoration: InputDecoration( decoration: InputDecoration(
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
label: const Text('Feedback und Verbesserungen'), label: const Text('Feedback und Verbesserungen'),
errorText: _textFieldEmpty ? 'Bitte gib eine Beschreibung an???' : null, errorText: _textFieldEmpty ? 'Bitte gib eine Beschreibung an!' : null,
), ),
minLines: 4, minLines: 4,
maxLines: 7, maxLines: 7,

View File

@@ -3,33 +3,82 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:in_app_review/in_app_review.dart'; import 'package:in_app_review/in_app_review.dart';
import 'package:provider/provider.dart';
import '../../extensions/renderNotNull.dart'; import '../../extensions/renderNotNull.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 '../../state/app/modules/app_modules.dart'; import '../../state/app/modules/app_modules.dart';
import '../../storage/base/settingsProvider.dart';
import '../../widget/centeredLeading.dart'; import '../../widget/centeredLeading.dart';
import '../../widget/infoDialog.dart'; import '../../widget/infoDialog.dart';
import '../settings/defaultSettings.dart';
import '../settings/settings.dart'; import '../settings/settings.dart';
import 'more/feedback/feedbackDialog.dart'; import 'more/feedback/feedbackDialog.dart';
import 'more/share/selectShareTypeDialog.dart'; import 'more/share/selectShareTypeDialog.dart';
class Overhang extends StatelessWidget { class Overhang extends StatefulWidget {
const Overhang({super.key}); const Overhang({super.key});
@override @override
Widget build(BuildContext context) => Scaffold( State<Overhang> createState() => _OverhangState();
}
class _OverhangState extends State<Overhang> {
bool editMode = false;
@override
Widget build(BuildContext context) => Consumer<SettingsProvider>(builder: (context, settings, child) => Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Mehr'), title: const Text('Mehr'),
actions: [ actions: [
IconButton(onPressed: () => pushScreen(context, screen: const Settings(), withNavBar: false), icon: const Icon(Icons.settings)) if(editMode) IconButton(
onPressed: settings.val().modulesSettings.toJson().toString() != DefaultSettings.get().modulesSettings.toJson().toString()
? () => settings.val(write: true).modulesSettings = DefaultSettings.get().modulesSettings
: null,
icon: Icon(Icons.undo_outlined)
),
IconButton(onPressed: () => setState(() => editMode = !editMode), icon: Icon(Icons.edit_note_outlined), color: editMode ? Theme.of(context).primaryColor : null),
IconButton(onPressed: editMode ? null : () => pushScreen(context, screen: const Settings(), withNavBar: false), icon: const Icon(Icons.settings)),
], ],
), ),
body: ListView( body: editMode ? _sorting() : _overhang(),
));
Widget _sorting() => Consumer<SettingsProvider>(builder: (context, settings, child) {
void changeVisibility(Modules module) {
var hidden = settings.val(write: true).modulesSettings.hiddenModules;
hidden.contains(module) ? hidden.remove(module) : (hidden.length < 3 ? hidden.add(module) : null);
}
return ReorderableListView(
header: const Center(
heightFactor: 2,
child: Text('Halte und ziehe einen Eintrag, um ihn zu verschieben.\nEs können 3 Bereiche ausgeblendet werden.', textAlign: TextAlign.center)
),
children: AppModule.modules(context, showFiltered: true)
.map((key, value) => MapEntry(key, value.toListTile(
context,
key: Key(key.name),
isReorder: true,
onVisibleChange: () => changeVisibility(key),
isVisible: !settings.val().modulesSettings.hiddenModules.contains(key)
)))
.values
.toList(),
onReorder: (oldIndex, newIndex) {
if (newIndex > oldIndex) newIndex -= 1;
var order = settings.val().modulesSettings.moduleOrder.toList();
final movedModule = order.removeAt(oldIndex);
order.insert(newIndex, movedModule);
settings.val(write: true).modulesSettings.moduleOrder = order;
}
);
});
Widget _overhang() => ListView(
children: [ children: [
AppModule.getModule(Modules.marianumMessage).toListTile(context), ...AppModule.getOverhangModules(context).map((e) => e.toListTile(context)),
AppModule.getModule(Modules.roomPlan).toListTile(context),
AppModule.getModule(Modules.gradeAveragesCalculator).toListTile(context),
AppModule.getModule(Modules.holidays).toListTile(context),
const Divider(), const Divider(),
@@ -73,6 +122,5 @@ class Overhang extends StatelessWidget {
onTap: () => pushScreen(context, withNavBar: false, screen: const FeedbackDialog()), onTap: () => pushScreen(context, withNavBar: false, screen: const FeedbackDialog()),
), ),
], ],
),
); );
} }

View File

@@ -66,7 +66,7 @@ class _ChatInfoState extends State<ChatInfo> {
if(participants != null) ...[ if(participants != null) ...[
ListTile( ListTile(
leading: const Icon(Icons.supervised_user_circle), leading: const Icon(Icons.supervised_user_circle),
title: Text('${participants!.data.length} Teilnehmer'), title: Text('${participants!.data.length} Mitglieder'),
trailing: const Icon(Icons.arrow_right), trailing: const Icon(Icons.arrow_right),
onTap: () => TalkNavigator.pushSplitView(context, ParticipantsListView(participants!)), onTap: () => TalkNavigator.pushSplitView(context, ParticipantsListView(participants!)),
), ),

View File

@@ -1,28 +1,44 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart'; import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart';
import '../../../../../widget/userAvatar.dart'; import '../../../../../widget/userAvatar.dart';
class ParticipantsListView extends StatefulWidget { class ParticipantsListView extends StatelessWidget {
final GetParticipantsResponse participantsResponse; final GetParticipantsResponse participantsResponse;
const ParticipantsListView(this.participantsResponse, {super.key}); const ParticipantsListView(this.participantsResponse, {super.key});
@override @override
State<ParticipantsListView> createState() => _ParticipantsListViewState(); Widget build(BuildContext context) {
} lastname(participant) => participant.displayName.toString().split(' ').last;
class _ParticipantsListViewState extends State<ParticipantsListView> { final participants = participantsResponse.data
@override .sorted((a, b) => lastname(a).compareTo(lastname(b)))
Widget build(BuildContext context) => Scaffold( .sorted((a, b) => a.participantType.index.compareTo(b.participantType.index));
var groupedParticipants = participants.groupListsBy((participant) => participant.participantType);
return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Teilnehmende'), title: const Text('Mitglieder'),
), ),
body: ListView( body: ListView(
children: widget.participantsResponse.data.map((participant) => ListTile( children: [
...groupedParticipants.entries.map((entry) => Column(
children: [
ListTile(
title: Text(entry.key.prettyName),
titleTextStyle: TextStyle(fontWeight: FontWeight.bold),
),
...entry.value.map((participant) => ListTile(
leading: UserAvatar(id: participant.actorId), leading: UserAvatar(id: participant.actorId),
title: Text(participant.displayName), title: Text(participant.displayName),
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null, subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
)).toList(), )),
), Divider(),
],
))
],
)
); );
} }
}

View File

@@ -1,4 +1,3 @@
import 'package:better_open_file/better_open_file.dart';
import 'package:bubble/bubble.dart'; import 'package:bubble/bubble.dart';
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis; import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis;
import 'package:flowder/flowder.dart'; import 'package:flowder/flowder.dart';
@@ -6,6 +5,7 @@ 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:jiffy/jiffy.dart'; import 'package:jiffy/jiffy.dart';
import 'package:open_filex/open_filex.dart';
import '../../../../extensions/text.dart'; import '../../../../extensions/text.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -130,7 +130,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
emojis.EmojiPicker( emojis.EmojiPicker(
config: emojis.Config( config: emojis.Config(
height: 256, height: 256,
swapCategoryAndBottomBar: true, // swapCategoryAndBottomBar: true, // TODO this property is no longer supported, need to find an replacement
emojiViewConfig: emojis.EmojiViewConfig( emojiViewConfig: emojis.EmojiViewConfig(
backgroundColor: Theme.of(context).canvasColor, backgroundColor: Theme.of(context).canvasColor,
recentsLimit: 67, recentsLimit: 67,
@@ -148,7 +148,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
), ),
searchViewConfig: emojis.SearchViewConfig( searchViewConfig: emojis.SearchViewConfig(
backgroundColor: Theme.of(context).dividerColor, backgroundColor: Theme.of(context).dividerColor,
buttonColor: Theme.of(context).dividerColor, // buttonColor: Theme.of(context).dividerColor, // TODO property no longer supported
hintText: 'Suchen', hintText: 'Suchen',
buttonIconColor: Colors.white, buttonIconColor: Colors.white,
), ),
@@ -206,7 +206,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
), ),
), ),
Visibility( Visibility(
visible: !message.containsFile, visible: widget.bubbleData.message != '{file}',
child: ListTile( child: ListTile(
leading: const Icon(Icons.copy), leading: const Icon(Icons.copy),
title: const Text('Nachricht kopieren'), title: const Text('Nachricht kopieren'),
@@ -282,14 +282,15 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
if(!widget.bubbleData.isReplyable) return; if(!widget.bubbleData.isReplyable) return;
var dx = details.delta.dx - _dragStartPosition.dx; var dx = details.delta.dx - _dragStartPosition.dx;
setState(() { setState(() {
_position = (_position.dx + dx).abs() > 30 ? Offset(_position.dx, 0) : Offset(_position.dx + dx, 0); _position = (_position.dx + dx).abs() > 60 ? Offset(_position.dx, 0) : Offset(_position.dx + dx, 0);
}); });
}, },
onHorizontalDragEnd: (DragEndDetails details) { onHorizontalDragEnd: (DragEndDetails details) {
var isAction = _position.dx.abs() > 50;
setState(() { setState(() {
_position = const Offset(0, 0); _position = const Offset(0, 0);
}); });
if(widget.bubbleData.isReplyable) { if(widget.bubbleData.isReplyable && isAction) {
Provider.of<ChatProps>(context, listen: false).setReferenceMessageId(widget.bubbleData.id, context, widget.chatData.token); Provider.of<ChatProps>(context, listen: false).setReferenceMessageId(widget.bubbleData.id, context, widget.chatData.token);
} }
}, },
@@ -322,7 +323,9 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
return; return;
} }
setState(() {
downloadProgress = 1; downloadProgress = 1;
});
downloadCore = FileElement.download(context, message.file!.path!, message.file!.name, (progress) { downloadCore = FileElement.download(context, message.file!.path!, message.file!.name, (progress) {
if(progress > 1) { if(progress > 1) {
setState(() { setState(() {
@@ -407,7 +410,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
bottom: 0, bottom: 0,
right: 0, right: 0,
left: 0, left: 0,
child: LinearProgressIndicator(value: downloadProgress/100), child: LinearProgressIndicator(value: downloadProgress == 1 ? null : downloadProgress/100),
), ),
), ),
], ],

View File

@@ -21,23 +21,26 @@ class ChatMessage {
ChatMessage({required this.originalMessage, this.originalData}) { ChatMessage({required this.originalMessage, this.originalData}) {
if(originalData?.containsKey('file') ?? false) { if(originalData?.containsKey('file') ?? false) {
file = originalData?['file']; file = originalData?['file'];
content = file?.name ?? 'Datei';
} else {
content = RichObjectStringProcessor.parseToString(originalMessage, originalData);
} }
content = RichObjectStringProcessor.parseToString(originalMessage, originalData);
} }
Widget getWidget() { Widget getWidget() {
if(file == null) { var contentWidget = Linkify(
return Linkify(
text: content, text: content,
onOpen: onOpen, onOpen: onOpen,
); );
}
return CachedNetworkImage( if(file == null) return contentWidget;
errorWidget: (context, url, error) => Padding(padding: const EdgeInsets.only(top: 10), child: Row(
return Padding(
padding: const EdgeInsets.only(top: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CachedNetworkImage(
errorWidget: (context, url, error) => Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
@@ -46,13 +49,20 @@ class ChatMessage {
Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))),
const SizedBox(width: 10), const SizedBox(width: 10),
], ],
)), ),
alignment: Alignment.center, alignment: Alignment.center,
placeholder: (context, url) => const Padding(padding: EdgeInsets.all(10), child: CircularProgressIndicator()), placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())),
fadeInDuration: Duration.zero, fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero, fadeOutDuration: Duration.zero,
errorListener: (value) {}, errorListener: (value) {},
imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1', imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=130&y=-1&a=1',
),
if(originalMessage != '{file}') ...[
SizedBox(height: 5),
contentWidget
]
],
)
); );
} }

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