From 8bf5e5a06a404cd4e207de9a2d826ed942be2ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Tue, 2 Apr 2024 19:12:28 +0200 Subject: [PATCH 01/11] disabled gestureNavigation on bottomNavigation --- lib/app.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/app.dart b/lib/app.dart index 9bff71b..4b2a449 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -97,7 +97,6 @@ class _AppState extends State with WidgetsBindingObserver { Widget build(BuildContext context) { return PersistentTabView( controller: App.bottomNavigator, - gestureNavigationEnabled: true, navBarOverlap: const NavBarOverlap.none(), backgroundColor: Theme.of(context).colorScheme.primary, From 27618f44044cef639c4e001343425ad9b9388160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Tue, 2 Apr 2024 19:16:49 +0200 Subject: [PATCH 02/11] added min/ max-scale to fileViewer --- lib/widget/fileViewer.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/widget/fileViewer.dart b/lib/widget/fileViewer.dart index 72d0ea3..5907aa2 100644 --- a/lib/widget/fileViewer.dart +++ b/lib/widget/fileViewer.dart @@ -78,6 +78,8 @@ class _FileViewerState extends State { backgroundColor: Colors.white, body: PhotoView( controller: photoViewController, + maxScale: 3.0, + minScale: 0.1, imageProvider: Image.file(File(widget.path)).image, backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.surface), ) From 4c7f53e309dba1ef279a34f7a6cb82e5d9a7104b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Wed, 3 Apr 2024 19:18:17 +0200 Subject: [PATCH 03/11] updated project style guidelines --- analysis_options.yaml | 7 ++ lib/api/apiError.dart | 6 +- lib/api/apiParams.dart | 2 +- lib/api/apiRequest.dart | 2 +- lib/api/apiResponse.dart | 2 +- lib/api/holidays/getHolidays.dart | 4 +- lib/api/holidays/getHolidaysCache.dart | 6 +- lib/api/holidays/getHolidaysResponse.dart | 2 +- .../autocomplete/autocompleteApi.dart | 13 ++- .../autocomplete/autocompleteResponse.dart | 2 +- .../files-sharing/fileSharingApi.dart | 9 +- .../files-sharing/fileSharingApiParams.dart | 2 +- lib/api/marianumcloud/talk/chat/getChat.dart | 10 +-- .../marianumcloud/talk/chat/getChatCache.dart | 10 +-- .../talk/chat/getChatParams.dart | 2 +- .../talk/chat/getChatResponse.dart | 12 ++- .../talk/chat/richObjectStringProcessor.dart | 2 +- .../talk/createRoom/createRoom.dart | 6 +- .../talk/createRoom/createRoomParams.dart | 2 +- .../talk/deleteMessage/deleteMessage.dart | 10 +-- .../deleteReactMessage.dart | 6 +- .../deleteReactMessageParams.dart | 2 +- .../talk/getParticipants/getParticipants.dart | 10 +-- .../getParticipants/getParticipantsCache.dart | 10 +-- .../getParticipantsResponse.dart | 2 +- .../talk/getReactions/getReactions.dart | 10 +-- .../getReactions/getReactionsResponse.dart | 2 +- .../talk/leaveRoom/leaveRoom.dart | 10 +-- .../talk/reactMessage/reactMessage.dart | 6 +- .../talk/reactMessage/reactMessageParams.dart | 2 +- lib/api/marianumcloud/talk/room/getRoom.dart | 10 +-- .../marianumcloud/talk/room/getRoomCache.dart | 10 +-- .../talk/room/getRoomParams.dart | 2 +- .../talk/room/getRoomResponse.dart | 2 +- .../talk/sendMessage/sendMessage.dart | 6 +- .../talk/sendMessage/sendMessageParams.dart | 2 +- .../talk/sendMessage/sendMessageResponse.dart | 2 +- .../talk/setFavorite/setFavorite.dart | 6 +- .../talk/setReadMarker/setReadMarker.dart | 6 +- .../setReadMarker/setReadMarkerParams.dart | 2 +- lib/api/marianumcloud/talk/talkApi.dart | 4 +- lib/api/marianumcloud/talk/talkError.dart | 6 +- .../queries/downloadFile/downloadFile.dart | 2 +- .../downloadFile/downloadFileParams.dart | 2 +- .../downloadFile/downloadFileResponse.dart | 2 +- .../queries/listFiles/cacheableFile.dart | 2 +- .../webdav/queries/listFiles/listFiles.dart | 6 +- .../queries/listFiles/listFilesCache.dart | 10 +-- .../queries/listFiles/listFilesParams.dart | 2 +- .../queries/listFiles/listFilesResponse.dart | 2 +- lib/api/marianumcloud/webdav/webdavApi.dart | 10 +-- .../mhsl/breaker/getBreakers/getBreakers.dart | 10 +-- .../breaker/getBreakers/getBreakersCache.dart | 10 +-- .../getBreakers/getBreakersResponse.dart | 2 +- .../add/addCustomTimetableEvent.dart | 4 +- .../add/addCustomTimetableEventParams.dart | 2 +- .../customTimetableEvent.dart | 2 +- .../get/getCustomTimetableEvent.dart | 10 +-- .../get/getCustomTimetableEventCache.dart | 10 +-- .../get/getCustomTimetableEventParams.dart | 2 +- .../get/getCustomTimetableEventResponse.dart | 2 +- .../remove/removeCustomTimetableEvent.dart | 6 +- .../removeCustomTimetableEventParams.dart | 2 +- .../update/updateCustomTimetableEvent.dart | 6 +- .../updateCustomTimetableEventParams.dart | 2 +- .../mhsl/message/getMessages/getMessages.dart | 10 +-- .../message/getMessages/getMessagesCache.dart | 10 +-- lib/api/mhsl/mhslApi.dart | 7 +- .../mhsl/notify/register/notifyRegister.dart | 4 +- .../notify/register/notifyRegisterParams.dart | 2 +- lib/api/mhsl/server/feedback/addFeedback.dart | 6 +- .../server/feedback/addFeedbackParams.dart | 2 +- .../update/updateUserIndexParams.dart | 2 +- .../userIndex/update/updateUserindex.dart | 6 +- lib/api/requestCache.dart | 8 +- .../queries/authenticate/authenticate.dart | 4 +- .../authenticate/authenticateParams.dart | 2 +- .../authenticate/authenticateResponse.dart | 2 +- .../queries/getHolidays/getHolidays.dart | 8 +- .../queries/getHolidays/getHolidaysCache.dart | 10 +-- .../getHolidays/getHolidaysResponse.dart | 2 +- .../webuntis/queries/getRooms/getRooms.dart | 4 +- .../queries/getRooms/getRoomsCache.dart | 10 +-- .../queries/getRooms/getRoomsResponse.dart | 2 +- .../queries/getSubjects/getSubjects.dart | 4 +- .../queries/getSubjects/getSubjectsCache.dart | 10 +-- .../getSubjects/getSubjectsResponse.dart | 2 +- .../queries/getTimetable/getTimetable.dart | 4 +- .../getTimetable/getTimetableCache.dart | 10 +-- .../getTimetable/getTimetableParams.dart | 2 +- .../getTimetable/getTimetableResponse.dart | 2 +- lib/api/webuntis/webuntisApi.dart | 16 ++-- lib/api/webuntis/webuntisError.dart | 6 +- lib/app.dart | 8 +- lib/extensions/dateTime.dart | 26 ++---- lib/extensions/renderNotNull.dart | 6 +- lib/extensions/text.dart | 4 +- lib/extensions/timeOfDay.dart | 14 +-- lib/main.dart | 10 +-- lib/model/accountData.dart | 24 ++--- lib/model/accountModel.dart | 2 +- lib/model/breakers/Breaker.dart | 6 +- lib/model/breakers/BreakerProps.dart | 12 ++- lib/model/chatList/chatListProps.dart | 6 +- lib/model/chatList/chatProps.dart | 12 +-- lib/model/dataCleaner.dart | 6 +- lib/model/dataHolder.dart | 8 +- lib/model/endpointData.dart | 18 ++-- lib/model/files/filesProps.dart | 6 +- lib/model/holidays/holidaysProps.dart | 6 +- lib/model/message/messageProps.dart | 6 +- lib/model/timetable/timetableProps.dart | 12 +-- lib/notification/notificationController.dart | 2 +- lib/notification/notificationService.dart | 18 ++-- lib/notification/notificationTasks.dart | 2 +- lib/notification/notifyUpdater.dart | 10 +-- lib/storage/base/settings.dart | 2 +- lib/storage/base/settingsProvider.dart | 8 +- lib/storage/devTools/devToolsSettings.dart | 2 +- lib/storage/file/fileSettings.dart | 2 +- lib/storage/fileView/fileViewSettings.dart | 2 +- .../gradeAverages/gradeAveragesSettings.dart | 2 +- lib/storage/holidays/holidaysSettings.dart | 2 +- .../notification/notificationSettings.dart | 2 +- lib/storage/talk/talkSettings.dart | 2 +- lib/storage/timetable/timetableSettings.dart | 2 +- lib/theming/appTheme.dart | 6 +- lib/theming/darkAppTheme.dart | 2 +- lib/theming/lightAppTheme.dart | 2 +- lib/view/login/login.dart | 14 +-- lib/view/pages/files/fileElement.dart | 28 +++--- lib/view/pages/files/fileUploadDialog.dart | 10 +-- lib/view/pages/files/files.dart | 28 +++--- .../pages/more/feedback/feedbackDialog.dart | 7 +- lib/view/pages/more/holidays/holidays.dart | 31 +++---- lib/view/pages/more/message/message.dart | 7 +- lib/view/pages/more/message/messageView.dart | 10 +-- lib/view/pages/more/roomplan/roomplan.dart | 4 +- .../more/share/appSharePlatformView.dart | 2 +- lib/view/pages/more/share/qrShareView.dart | 4 +- .../more/share/selectShareTypeDialog.dart | 4 +- lib/view/pages/overhang.dart | 5 +- lib/view/pages/talk/chatDetails/chatInfo.dart | 2 +- .../participants/participantsListView.dart | 10 +-- lib/view/pages/talk/chatList.dart | 6 +- lib/view/pages/talk/chatView.dart | 12 ++- .../pages/talk/components/chatBubble.dart | 36 +++----- .../pages/talk/components/chatMessage.dart | 14 ++- .../pages/talk/components/chatTextfield.dart | 12 ++- lib/view/pages/talk/components/chatTile.dart | 13 +-- .../talk/components/splitViewPlaceholder.dart | 4 +- lib/view/pages/talk/joinChat.dart | 18 ++-- lib/view/pages/talk/messageReactions.dart | 12 +-- lib/view/pages/talk/searchChat.dart | 14 +-- lib/view/pages/talk/talkNavigator.dart | 4 +- lib/view/pages/timetable/CrossPainter.dart | 2 +- .../pages/timetable/appointmentDetails.dart | 34 +++----- .../pages/timetable/arbitraryAppointment.dart | 10 +-- .../timetable/customTimetableColors.dart | 6 +- .../customTimetableEventEditDialog.dart | 8 +- .../pages/timetable/timeRegionComponent.dart | 4 +- lib/view/pages/timetable/timetable.dart | 87 ++++++++----------- lib/view/pages/timetable/timetableEvents.dart | 2 +- .../timetable/viewCustomTimetableEvents.dart | 10 +-- lib/view/settings/defaultSettings.dart | 6 +- lib/view/settings/devToolsSettingsDialog.dart | 12 +-- lib/view/settings/privacyInfo.dart | 8 +- lib/view/settings/settings.dart | 15 +--- lib/widget/about/about.dart | 4 +- lib/widget/animatedTime.dart | 8 +- lib/widget/centeredLeading.dart | 4 +- lib/widget/clickableAppBar.dart | 4 +- lib/widget/confirmDialog.dart | 4 +- lib/widget/debug/cacheView.dart | 16 ++-- lib/widget/debug/debugTile.dart | 14 +-- lib/widget/debug/jsonViewer.dart | 15 +--- lib/widget/filePick.dart | 6 +- lib/widget/fileViewer.dart | 10 +-- lib/widget/focusBehaviour.dart | 2 +- lib/widget/infoDialog.dart | 2 +- lib/widget/largeProfilePictureView.dart | 4 +- lib/widget/loadingSpinner.dart | 4 +- lib/widget/placeholderView.dart | 4 +- lib/widget/sharePositionOrigin.dart | 6 +- lib/widget/unimplementedDialog.dart | 2 +- 185 files changed, 505 insertions(+), 873 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 5e39472..ebc4a78 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -28,6 +28,13 @@ linter: prefer_relative_imports: true unnecessary_lambdas: true prefer_single_quotes: true + prefer_if_elements_to_conditional_expressions: true + prefer_expression_function_bodies: true + omit_local_variable_types: true + eol_at_end_of_file: true + cast_nullable_to_non_nullable: true + avoid_void_async: true + avoid_multiple_declarations_per_line: true # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/lib/api/apiError.dart b/lib/api/apiError.dart index 039774e..42fe5c2 100644 --- a/lib/api/apiError.dart +++ b/lib/api/apiError.dart @@ -4,7 +4,5 @@ class ApiError { ApiError(this.message); @override - String toString() { - return 'ApiError: $message'; - } -} \ No newline at end of file + String toString() => 'ApiError: $message'; +} diff --git a/lib/api/apiParams.dart b/lib/api/apiParams.dart index d59ae83..b679813 100644 --- a/lib/api/apiParams.dart +++ b/lib/api/apiParams.dart @@ -1,3 +1,3 @@ class ApiParams { -} \ No newline at end of file +} diff --git a/lib/api/apiRequest.dart b/lib/api/apiRequest.dart index f4f9c66..705ccbc 100644 --- a/lib/api/apiRequest.dart +++ b/lib/api/apiRequest.dart @@ -2,4 +2,4 @@ class ApiRequest { -} \ No newline at end of file +} diff --git a/lib/api/apiResponse.dart b/lib/api/apiResponse.dart index 547e286..4eacb01 100644 --- a/lib/api/apiResponse.dart +++ b/lib/api/apiResponse.dart @@ -6,4 +6,4 @@ abstract class ApiResponse { @JsonKey(includeIfNull: false) late Map? headers; -} \ No newline at end of file +} diff --git a/lib/api/holidays/getHolidays.dart b/lib/api/holidays/getHolidays.dart index 641884e..1d7be0b 100644 --- a/lib/api/holidays/getHolidays.dart +++ b/lib/api/holidays/getHolidays.dart @@ -6,7 +6,7 @@ import 'getHolidaysResponse.dart'; class GetHolidays { Future query() async { - String response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body; + var response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body; return GetHolidaysResponse( List.from( jsonDecode(response).map( @@ -15,4 +15,4 @@ class GetHolidays { ) ); } -} \ No newline at end of file +} diff --git a/lib/api/holidays/getHolidaysCache.dart b/lib/api/holidays/getHolidaysCache.dart index 1803bd7..1e8f7e6 100644 --- a/lib/api/holidays/getHolidaysCache.dart +++ b/lib/api/holidays/getHolidaysCache.dart @@ -23,7 +23,5 @@ class GetHolidaysCache extends RequestCache { } @override - Future onLoad() { - return GetHolidays().query(); - } -} \ No newline at end of file + Future onLoad() => GetHolidays().query(); +} diff --git a/lib/api/holidays/getHolidaysResponse.dart b/lib/api/holidays/getHolidaysResponse.dart index 2ce1a95..6ba00bb 100644 --- a/lib/api/holidays/getHolidaysResponse.dart +++ b/lib/api/holidays/getHolidaysResponse.dart @@ -35,4 +35,4 @@ class GetHolidaysResponseObject { factory GetHolidaysResponseObject.fromJson(Map json) => _$GetHolidaysResponseObjectFromJson(json); Map toJson() => _$GetHolidaysResponseObjectToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/autocomplete/autocompleteApi.dart b/lib/api/marianumcloud/autocomplete/autocompleteApi.dart index 194fe24..f11b91c 100644 --- a/lib/api/marianumcloud/autocomplete/autocompleteApi.dart +++ b/lib/api/marianumcloud/autocomplete/autocompleteApi.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; -import 'package:http/http.dart'; import '../../../model/accountData.dart'; import '../../../model/endpointData.dart'; @@ -10,7 +9,7 @@ import 'autocompleteResponse.dart'; class AutocompleteApi { Future find(String query) async { - Map getParameters = { + var getParameters = { 'search': query, 'itemType': ' ', 'itemId': ' ', @@ -18,16 +17,16 @@ class AutocompleteApi { 'limit': '10', }; - Map headers = {}; + var headers = {}; headers.putIfAbsent('Accept', () => 'application/json'); headers.putIfAbsent('OCS-APIRequest', () => 'true'); - Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters); + var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters); - Response response = await http.get(endpoint, headers: headers); + var response = await http.get(endpoint, headers: headers); if(response.statusCode != HttpStatus.ok) throw Exception('Api call failed with ${response.statusCode}: ${response.body}'); - String result = response.body; + var result = response.body; return AutocompleteResponse.fromJson(jsonDecode(result)['ocs']); } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/autocomplete/autocompleteResponse.dart b/lib/api/marianumcloud/autocomplete/autocompleteResponse.dart index 8677726..15e1ffc 100644 --- a/lib/api/marianumcloud/autocomplete/autocompleteResponse.dart +++ b/lib/api/marianumcloud/autocomplete/autocompleteResponse.dart @@ -27,4 +27,4 @@ class AutocompleteResponseObject { factory AutocompleteResponseObject.fromJson(Map json) => _$AutocompleteResponseObjectFromJson(json); Map toJson() => _$AutocompleteResponseObjectToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/files-sharing/fileSharingApi.dart b/lib/api/marianumcloud/files-sharing/fileSharingApi.dart index 978b7a0..42d5dd8 100644 --- a/lib/api/marianumcloud/files-sharing/fileSharingApi.dart +++ b/lib/api/marianumcloud/files-sharing/fileSharingApi.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:http/http.dart' as http; -import 'package:http/http.dart'; import '../../../model/accountData.dart'; import '../../../model/endpointData.dart'; @@ -9,15 +8,15 @@ import 'fileSharingApiParams.dart'; class FileSharingApi { Future share(FileSharingApiParams query) async { - Map headers = {}; + var headers = {}; headers.putIfAbsent('Accept', () => 'application/json'); headers.putIfAbsent('OCS-APIRequest', () => 'true'); - Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString()))); - Response response = await http.post(endpoint, headers: headers); + var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString()))); + var response = await http.post(endpoint, headers: headers); if(response.statusCode != HttpStatus.ok) { throw Exception('Api call failed with ${response.statusCode}: ${response.body}'); } } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/files-sharing/fileSharingApiParams.dart b/lib/api/marianumcloud/files-sharing/fileSharingApiParams.dart index 3dac0dd..edcc6a5 100644 --- a/lib/api/marianumcloud/files-sharing/fileSharingApiParams.dart +++ b/lib/api/marianumcloud/files-sharing/fileSharingApiParams.dart @@ -20,4 +20,4 @@ class FileSharingApiParams { factory FileSharingApiParams.fromJson(Map json) => _$FileSharingApiParamsFromJson(json); Map toJson() => _$FileSharingApiParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/chat/getChat.dart b/lib/api/marianumcloud/talk/chat/getChat.dart index 2af2c54..fb64466 100644 --- a/lib/api/marianumcloud/talk/chat/getChat.dart +++ b/lib/api/marianumcloud/talk/chat/getChat.dart @@ -14,13 +14,9 @@ class GetChat extends TalkApi { GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson()); @override - assemble(String raw) { - return GetChatResponse.fromJson(jsonDecode(raw)['ocs']); - } + assemble(String raw) => GetChatResponse.fromJson(jsonDecode(raw)['ocs']); @override - Future request(Uri uri, Object? body, Map? headers) { - return http.get(uri, headers: headers); - } + Future request(Uri uri, Object? body, Map? headers) => http.get(uri, headers: headers); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/chat/getChatCache.dart b/lib/api/marianumcloud/talk/chat/getChatCache.dart index cb60032..1a6cfd0 100644 --- a/lib/api/marianumcloud/talk/chat/getChatCache.dart +++ b/lib/api/marianumcloud/talk/chat/getChatCache.dart @@ -13,8 +13,7 @@ class GetChatCache extends RequestCache { } @override - Future onLoad() { - return GetChat( + Future onLoad() => GetChat( chatToken, GetChatParams( lookIntoFuture: GetChatParamsSwitch.off, @@ -22,11 +21,8 @@ class GetChatCache extends RequestCache { limit: 200, ) ).run(); - } @override - GetChatResponse onLocalData(String json) { - return GetChatResponse.fromJson(jsonDecode(json)); - } + GetChatResponse onLocalData(String json) => GetChatResponse.fromJson(jsonDecode(json)); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/chat/getChatParams.dart b/lib/api/marianumcloud/talk/chat/getChatParams.dart index 02ea362..08197b2 100644 --- a/lib/api/marianumcloud/talk/chat/getChatParams.dart +++ b/lib/api/marianumcloud/talk/chat/getChatParams.dart @@ -31,4 +31,4 @@ class GetChatParams extends ApiParams { enum GetChatParamsSwitch { @JsonValue(1) on, @JsonValue(0) off, -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/chat/getChatResponse.dart b/lib/api/marianumcloud/talk/chat/getChatResponse.dart index fbec9d0..b62b897 100644 --- a/lib/api/marianumcloud/talk/chat/getChatResponse.dart +++ b/lib/api/marianumcloud/talk/chat/getChatResponse.dart @@ -16,7 +16,7 @@ class GetChatResponse extends ApiResponse { Map toJson() => _$GetChatResponseToJson(this); List sortByTimestamp() { - List sorted = data.toList(); + var sorted = data.toList(); sorted.sort((a, b) => a.timestamp.compareTo(b.timestamp)); return sorted; } @@ -60,12 +60,11 @@ class GetChatResponseObject { Map toJson() => _$GetChatResponseObjectToJson(this); static GetChatResponseObject getDateDummy(int timestamp) { - DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); + var elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy')); } - static GetChatResponseObject getTextDummy(String text) { - return GetChatResponseObject( + static GetChatResponseObject getTextDummy(String text) => GetChatResponseObject( 0, '', GetRoomResponseObjectMessageActorType.user, @@ -81,13 +80,12 @@ class GetChatResponseObject { null, null ); - } } Map? _fromJson(json) { if(json is Map) { - Map data = {}; + var data = {}; for (var element in json.keys) { data.putIfAbsent(element, () => RichObjectString.fromJson(json[element])); } @@ -119,4 +117,4 @@ enum RichObjectStringObjectType { @JsonValue('guest') guest, @JsonValue('highlight') highlight, @JsonValue('talk-poll') talkPoll, -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/chat/richObjectStringProcessor.dart b/lib/api/marianumcloud/talk/chat/richObjectStringProcessor.dart index 9e7ea83..b61d064 100644 --- a/lib/api/marianumcloud/talk/chat/richObjectStringProcessor.dart +++ b/lib/api/marianumcloud/talk/chat/richObjectStringProcessor.dart @@ -11,4 +11,4 @@ class RichObjectStringProcessor { return message; } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/createRoom/createRoom.dart b/lib/api/marianumcloud/talk/createRoom/createRoom.dart index 9407932..27d274d 100644 --- a/lib/api/marianumcloud/talk/createRoom/createRoom.dart +++ b/lib/api/marianumcloud/talk/createRoom/createRoom.dart @@ -10,9 +10,7 @@ class CreateRoom extends TalkApi { CreateRoom(this.params) : super('v4/room', params); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override Future? request(Uri uri, Object? body, Map? headers) { @@ -22,4 +20,4 @@ class CreateRoom extends TalkApi { return null; } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/createRoom/createRoomParams.dart b/lib/api/marianumcloud/talk/createRoom/createRoomParams.dart index 66534fa..cb1d1b5 100644 --- a/lib/api/marianumcloud/talk/createRoom/createRoomParams.dart +++ b/lib/api/marianumcloud/talk/createRoom/createRoomParams.dart @@ -24,4 +24,4 @@ class CreateRoomParams extends ApiParams { factory CreateRoomParams.fromJson(Map json) => _$CreateRoomParamsFromJson(json); Map toJson() => _$CreateRoomParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/deleteMessage/deleteMessage.dart b/lib/api/marianumcloud/talk/deleteMessage/deleteMessage.dart index c60d0ee..580f899 100644 --- a/lib/api/marianumcloud/talk/deleteMessage/deleteMessage.dart +++ b/lib/api/marianumcloud/talk/deleteMessage/deleteMessage.dart @@ -10,13 +10,9 @@ class DeleteMessage extends TalkApi { DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override - Future? request(Uri uri, ApiParams? body, Map? headers) { - return http.delete(uri, headers: headers); - } + Future? request(Uri uri, ApiParams? body, Map? headers) => http.delete(uri, headers: headers); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessage.dart b/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessage.dart index e24ff26..d586d5b 100644 --- a/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessage.dart +++ b/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessage.dart @@ -11,9 +11,7 @@ class DeleteReactMessage extends TalkApi { DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override Future? request(Uri uri, ApiParams? body, Map? headers) { @@ -23,4 +21,4 @@ class DeleteReactMessage extends TalkApi { return null; } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessageParams.dart b/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessageParams.dart index 93f13cb..c40c317 100644 --- a/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessageParams.dart +++ b/lib/api/marianumcloud/talk/deleteReactMessage/deleteReactMessageParams.dart @@ -12,4 +12,4 @@ class DeleteReactMessageParams extends ApiParams { factory DeleteReactMessageParams.fromJson(Map json) => _$DeleteReactMessageParamsFromJson(json); Map toJson() => _$DeleteReactMessageParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/getParticipants/getParticipants.dart b/lib/api/marianumcloud/talk/getParticipants/getParticipants.dart index 38a8266..ec88234 100644 --- a/lib/api/marianumcloud/talk/getParticipants/getParticipants.dart +++ b/lib/api/marianumcloud/talk/getParticipants/getParticipants.dart @@ -10,13 +10,9 @@ class GetParticipants extends TalkApi { GetParticipants(this.token) : super('v4/room/$token/participants', null); @override - GetParticipantsResponse assemble(String raw) { - return GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']); - } + GetParticipantsResponse assemble(String raw) => GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']); @override - Future request(Uri uri, Object? body, Map? headers) { - return http.get(uri, headers: headers); - } + Future request(Uri uri, Object? body, Map? headers) => http.get(uri, headers: headers); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/getParticipants/getParticipantsCache.dart b/lib/api/marianumcloud/talk/getParticipants/getParticipantsCache.dart index e457059..4adfd5c 100644 --- a/lib/api/marianumcloud/talk/getParticipants/getParticipantsCache.dart +++ b/lib/api/marianumcloud/talk/getParticipants/getParticipantsCache.dart @@ -12,15 +12,11 @@ class GetParticipantsCache extends RequestCache { } @override - Future onLoad() { - return GetParticipants( + Future onLoad() => GetParticipants( chatToken, ).run(); - } @override - GetParticipantsResponse onLocalData(String json) { - return GetParticipantsResponse.fromJson(jsonDecode(json)); - } + GetParticipantsResponse onLocalData(String json) => GetParticipantsResponse.fromJson(jsonDecode(json)); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart b/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart index 85b99fb..1be47ce 100644 --- a/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart +++ b/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart @@ -69,4 +69,4 @@ enum GetParticipantsResponseObjectParticipantsInCallFlags { @JsonValue(2) providesAudio, @JsonValue(3) providesVideo, @JsonValue(4) usesSipDialIn -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/getReactions/getReactions.dart b/lib/api/marianumcloud/talk/getReactions/getReactions.dart index e946751..5b9a8e3 100644 --- a/lib/api/marianumcloud/talk/getReactions/getReactions.dart +++ b/lib/api/marianumcloud/talk/getReactions/getReactions.dart @@ -13,13 +13,9 @@ class GetReactions extends TalkApi { GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null); @override - assemble(String raw) { - return GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']); - } + assemble(String raw) => GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']); @override - Future? request(Uri uri, ApiParams? body, Map? headers) { - return http.get(uri, headers: headers); - } + Future? request(Uri uri, ApiParams? body, Map? headers) => http.get(uri, headers: headers); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/getReactions/getReactionsResponse.dart b/lib/api/marianumcloud/talk/getReactions/getReactionsResponse.dart index 5c0fd14..5a6c9f0 100644 --- a/lib/api/marianumcloud/talk/getReactions/getReactionsResponse.dart +++ b/lib/api/marianumcloud/talk/getReactions/getReactionsResponse.dart @@ -30,4 +30,4 @@ class GetReactionsResponseObject { enum GetReactionsResponseObjectActorType { @JsonValue('guests') guests, @JsonValue('users') users, -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/leaveRoom/leaveRoom.dart b/lib/api/marianumcloud/talk/leaveRoom/leaveRoom.dart index 4d13fe0..ee1f090 100644 --- a/lib/api/marianumcloud/talk/leaveRoom/leaveRoom.dart +++ b/lib/api/marianumcloud/talk/leaveRoom/leaveRoom.dart @@ -9,12 +9,8 @@ class LeaveRoom extends TalkApi { LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override - Future request(Uri uri, Object? body, Map? headers) { - return http.delete(uri, headers: headers); - } -} \ No newline at end of file + Future request(Uri uri, Object? body, Map? headers) => http.delete(uri, headers: headers); +} diff --git a/lib/api/marianumcloud/talk/reactMessage/reactMessage.dart b/lib/api/marianumcloud/talk/reactMessage/reactMessage.dart index 4ce840f..ac76bd2 100644 --- a/lib/api/marianumcloud/talk/reactMessage/reactMessage.dart +++ b/lib/api/marianumcloud/talk/reactMessage/reactMessage.dart @@ -11,9 +11,7 @@ class ReactMessage extends TalkApi { ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override Future? request(Uri uri, ApiParams? body, Map? headers) { @@ -23,4 +21,4 @@ class ReactMessage extends TalkApi { return null; } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/reactMessage/reactMessageParams.dart b/lib/api/marianumcloud/talk/reactMessage/reactMessageParams.dart index 05ef0ac..0fb6cc1 100644 --- a/lib/api/marianumcloud/talk/reactMessage/reactMessageParams.dart +++ b/lib/api/marianumcloud/talk/reactMessage/reactMessageParams.dart @@ -12,4 +12,4 @@ class ReactMessageParams extends ApiParams { factory ReactMessageParams.fromJson(Map json) => _$ReactMessageParamsFromJson(json); Map toJson() => _$ReactMessageParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/room/getRoom.dart b/lib/api/marianumcloud/talk/room/getRoom.dart index 5e0c092..dd7cc52 100644 --- a/lib/api/marianumcloud/talk/room/getRoom.dart +++ b/lib/api/marianumcloud/talk/room/getRoom.dart @@ -14,13 +14,9 @@ class GetRoom extends TalkApi { @override - GetRoomResponse assemble(String raw) { - return GetRoomResponse.fromJson(jsonDecode(raw)['ocs']); - } + GetRoomResponse assemble(String raw) => GetRoomResponse.fromJson(jsonDecode(raw)['ocs']); @override - Future request(Uri uri, Object? body, Map? headers) { - return http.get(uri, headers: headers); - } + Future request(Uri uri, Object? body, Map? headers) => http.get(uri, headers: headers); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/room/getRoomCache.dart b/lib/api/marianumcloud/talk/room/getRoomCache.dart index 091bd65..295856c 100644 --- a/lib/api/marianumcloud/talk/room/getRoomCache.dart +++ b/lib/api/marianumcloud/talk/room/getRoomCache.dart @@ -12,16 +12,12 @@ class GetRoomCache extends RequestCache { } @override - GetRoomResponse onLocalData(String json) { - return GetRoomResponse.fromJson(jsonDecode(json)); - } + GetRoomResponse onLocalData(String json) => GetRoomResponse.fromJson(jsonDecode(json)); @override - Future onLoad() { - return GetRoom( + Future onLoad() => GetRoom( GetRoomParams( includeStatus: true, ) ).run(); - } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/room/getRoomParams.dart b/lib/api/marianumcloud/talk/room/getRoomParams.dart index f90e914..70d371d 100644 --- a/lib/api/marianumcloud/talk/room/getRoomParams.dart +++ b/lib/api/marianumcloud/talk/room/getRoomParams.dart @@ -22,4 +22,4 @@ class GetRoomParams extends ApiParams { enum GetRoomParamsStatusUpdate { @JsonValue(0) defaults, @JsonValue(1) keepAlive, -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/room/getRoomResponse.dart b/lib/api/marianumcloud/talk/room/getRoomResponse.dart index 3899887..e8b9e27 100644 --- a/lib/api/marianumcloud/talk/room/getRoomResponse.dart +++ b/lib/api/marianumcloud/talk/room/getRoomResponse.dart @@ -164,4 +164,4 @@ enum GetRoomResponseObjectMessageType { @JsonValue('comment_deleted') deletedComment, @JsonValue('system') system, @JsonValue('command') command, -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/sendMessage/sendMessage.dart b/lib/api/marianumcloud/talk/sendMessage/sendMessage.dart index 79f6845..61af457 100644 --- a/lib/api/marianumcloud/talk/sendMessage/sendMessage.dart +++ b/lib/api/marianumcloud/talk/sendMessage/sendMessage.dart @@ -10,9 +10,7 @@ class SendMessage extends TalkApi { SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override Future? request(Uri uri, ApiParams? body, Map? headers) { @@ -22,4 +20,4 @@ class SendMessage extends TalkApi { return null; } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/sendMessage/sendMessageParams.dart b/lib/api/marianumcloud/talk/sendMessage/sendMessageParams.dart index 9cbeff6..e9150c4 100644 --- a/lib/api/marianumcloud/talk/sendMessage/sendMessageParams.dart +++ b/lib/api/marianumcloud/talk/sendMessage/sendMessageParams.dart @@ -13,4 +13,4 @@ class SendMessageParams extends ApiParams { factory SendMessageParams.fromJson(Map json) => _$SendMessageParamsFromJson(json); Map toJson() => _$SendMessageParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/sendMessage/sendMessageResponse.dart b/lib/api/marianumcloud/talk/sendMessage/sendMessageResponse.dart index 52fe5c4..5c9500b 100644 --- a/lib/api/marianumcloud/talk/sendMessage/sendMessageResponse.dart +++ b/lib/api/marianumcloud/talk/sendMessage/sendMessageResponse.dart @@ -2,4 +2,4 @@ import '../../../apiResponse.dart'; class SendMessageResponse extends ApiResponse { -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/setFavorite/setFavorite.dart b/lib/api/marianumcloud/talk/setFavorite/setFavorite.dart index f5ab5df..5f06d51 100644 --- a/lib/api/marianumcloud/talk/setFavorite/setFavorite.dart +++ b/lib/api/marianumcloud/talk/setFavorite/setFavorite.dart @@ -11,9 +11,7 @@ class SetFavorite extends TalkApi { SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null); @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override Future request(Uri uri, Object? body, Map? headers) { @@ -24,4 +22,4 @@ class SetFavorite extends TalkApi { } } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/setReadMarker/setReadMarker.dart b/lib/api/marianumcloud/talk/setReadMarker/setReadMarker.dart index fbdd5a4..c3ae029 100644 --- a/lib/api/marianumcloud/talk/setReadMarker/setReadMarker.dart +++ b/lib/api/marianumcloud/talk/setReadMarker/setReadMarker.dart @@ -15,9 +15,7 @@ class SetReadMarker extends TalkApi { } @override - assemble(String raw) { - return null; - } + assemble(String raw) => null; @override Future request(Uri uri, Object? body, Map? headers) { @@ -29,4 +27,4 @@ class SetReadMarker extends TalkApi { } } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart b/lib/api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart index 58ac2a8..5f037c2 100644 --- a/lib/api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart +++ b/lib/api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart @@ -14,4 +14,4 @@ class SetReadMarkerParams extends ApiParams { factory SetReadMarkerParams.fromJson(Map json) => _$SetReadMarkerParamsFromJson(json); Map toJson() => _$SetReadMarkerParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/talkApi.dart b/lib/api/marianumcloud/talk/talkApi.dart index 7da0e91..b90af22 100644 --- a/lib/api/marianumcloud/talk/talkApi.dart +++ b/lib/api/marianumcloud/talk/talkApi.dart @@ -34,7 +34,7 @@ abstract class TalkApi extends ApiRequest { getParameters?.update(key, (value) => value.toString()); }); - Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters); + var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters); headers ??= {}; headers?.putIfAbsent('Accept', () => 'application/json'); @@ -65,4 +65,4 @@ abstract class TalkApi extends ApiRequest { throw Exception('Error assembling Talk API response'); } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/talk/talkError.dart b/lib/api/marianumcloud/talk/talkError.dart index 8f2884e..186994d 100644 --- a/lib/api/marianumcloud/talk/talkError.dart +++ b/lib/api/marianumcloud/talk/talkError.dart @@ -6,7 +6,5 @@ class TalkError { TalkError(this.status, this.code, this.message); @override - String toString() { - return 'Talk - $status - ($code): $message'; - } -} \ No newline at end of file + String toString() => 'Talk - $status - ($code): $message'; +} diff --git a/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFile.dart b/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFile.dart index 3bfd5ba..30269c6 100644 --- a/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFile.dart +++ b/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFile.dart @@ -19,4 +19,4 @@ class DownloadFile extends WebdavApi { // OpenFile.open(localPath); throw UnimplementedError(); } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileParams.dart b/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileParams.dart index 48317d3..11b6231 100644 --- a/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileParams.dart +++ b/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileParams.dart @@ -14,4 +14,4 @@ class DownloadFileParams extends ApiParams { factory DownloadFileParams.fromJson(Map json) => _$DownloadFileParamsFromJson(json); Map toJson() => _$DownloadFileParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileResponse.dart b/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileResponse.dart index 5dfc741..3368cdd 100644 --- a/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileResponse.dart +++ b/lib/api/marianumcloud/webdav/queries/downloadFile/downloadFileResponse.dart @@ -11,4 +11,4 @@ class DownloadFileResponse { factory DownloadFileResponse.fromJson(Map json) => _$DownloadFileResponseFromJson(json); Map toJson() => _$DownloadFileResponseToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart index 90df17c..b8a9918 100644 --- a/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart +++ b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart @@ -34,4 +34,4 @@ class CacheableFile { factory CacheableFile.fromJson(Map json) => _$CacheableFileFromJson(json); Map toJson() => _$CacheableFileToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart index 96fd558..438204d 100644 --- a/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart +++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart @@ -13,8 +13,8 @@ class ListFiles extends WebdavApi { @override Future run() async { - List davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles(); - Set files = davFiles.map(CacheableFile.fromDavFile).toSet(); + var davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles(); + var files = davFiles.map(CacheableFile.fromDavFile).toSet(); // webdav handles subdirectories wrong, this is a fix // currently this fix is not needed anymore @@ -30,4 +30,4 @@ class ListFiles extends WebdavApi { return ListFilesResponse(files); } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart index ef1aefa..fab0e2d 100644 --- a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart +++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart @@ -11,19 +11,17 @@ class ListFilesCache extends RequestCache { ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) { var bytes = utf8.encode('MarianumMobile-$path'); - String cacheName = md5.convert(bytes).toString(); + var cacheName = md5.convert(bytes).toString(); start('MarianumMobile', 'wd-folder-$cacheName'); } @override Future onLoad() async { - ListFilesResponse data = await ListFiles(ListFilesParams(path)).run(); + var data = await ListFiles(ListFilesParams(path)).run(); return data; } @override - ListFilesResponse onLocalData(String json) { - return ListFilesResponse.fromJson(jsonDecode(json)); - } + ListFilesResponse onLocalData(String json) => ListFilesResponse.fromJson(jsonDecode(json)); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart index 8f839f9..f0adf21 100644 --- a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart +++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart @@ -12,4 +12,4 @@ class ListFilesParams extends ApiParams { factory ListFilesParams.fromJson(Map json) => _$ListFilesParamsFromJson(json); Map toJson() => _$ListFilesParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart index cc8b5d2..59f8d0e 100644 --- a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart +++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart @@ -54,4 +54,4 @@ class ListFilesResponse extends ApiResponse { var list = files.toList()..sort((a, b) => b.sort!.compareTo(a.sort!)); return reversed ? list.reversed.toList() : list; } -} \ No newline at end of file +} diff --git a/lib/api/marianumcloud/webdav/webdavApi.dart b/lib/api/marianumcloud/webdav/webdavApi.dart index 27ad784..cfa7159 100644 --- a/lib/api/marianumcloud/webdav/webdavApi.dart +++ b/lib/api/marianumcloud/webdav/webdavApi.dart @@ -17,11 +17,7 @@ abstract class WebdavApi extends ApiRequest { static Future webdav = establishWebdavConnection(); static Future webdavConnectString = buildWebdavConnectString(); - static Future establishWebdavConnection() async { - return NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav; - } + static Future establishWebdavConnection() async => NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav; - static Future buildWebdavConnectString() async { - return 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/'; - } -} \ No newline at end of file + static Future buildWebdavConnectString() async => 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/'; +} diff --git a/lib/api/mhsl/breaker/getBreakers/getBreakers.dart b/lib/api/mhsl/breaker/getBreakers/getBreakers.dart index 6395df5..63d2fe0 100644 --- a/lib/api/mhsl/breaker/getBreakers/getBreakers.dart +++ b/lib/api/mhsl/breaker/getBreakers/getBreakers.dart @@ -9,13 +9,9 @@ class GetBreakers extends MhslApi { GetBreakers() : super('breaker/'); @override - GetBreakersResponse assemble(String raw) { - return GetBreakersResponse.fromJson(jsonDecode(raw)); - } + GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw)); @override - Future? request(Uri uri) { - return http.get(uri); - } + Future? request(Uri uri) => http.get(uri); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/breaker/getBreakers/getBreakersCache.dart b/lib/api/mhsl/breaker/getBreakers/getBreakersCache.dart index 3b98444..50dcb9b 100644 --- a/lib/api/mhsl/breaker/getBreakers/getBreakersCache.dart +++ b/lib/api/mhsl/breaker/getBreakers/getBreakersCache.dart @@ -10,12 +10,8 @@ class GetBreakersCache extends RequestCache { } @override - GetBreakersResponse onLocalData(String json) { - return GetBreakersResponse.fromJson(jsonDecode(json)); - } + GetBreakersResponse onLocalData(String json) => GetBreakersResponse.fromJson(jsonDecode(json)); @override - Future onLoad() { - return GetBreakers().run(); - } -} \ No newline at end of file + Future onLoad() => GetBreakers().run(); +} diff --git a/lib/api/mhsl/breaker/getBreakers/getBreakersResponse.dart b/lib/api/mhsl/breaker/getBreakers/getBreakersResponse.dart index 0b7e6c4..6e0cb73 100644 --- a/lib/api/mhsl/breaker/getBreakers/getBreakersResponse.dart +++ b/lib/api/mhsl/breaker/getBreakers/getBreakersResponse.dart @@ -33,4 +33,4 @@ enum BreakerArea { @JsonValue('TALK') talk, @JsonValue('FILES') files, @JsonValue('MORE') more, -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEvent.dart b/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEvent.dart index 25bb7db..15f237f 100644 --- a/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEvent.dart +++ b/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEvent.dart @@ -16,7 +16,7 @@ class AddCustomTimetableEvent extends MhslApi { @override Future? request(Uri uri) { - String body = jsonEncode(params.toJson()); + var body = jsonEncode(params.toJson()); return http.post(uri, body: body); } -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEventParams.dart b/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEventParams.dart index 1ae908f..125d3ea 100644 --- a/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEventParams.dart +++ b/lib/api/mhsl/customTimetableEvent/add/addCustomTimetableEventParams.dart @@ -13,4 +13,4 @@ class AddCustomTimetableEventParams { factory AddCustomTimetableEventParams.fromJson(Map json) => _$AddCustomTimetableEventParamsFromJson(json); Map toJson() => _$AddCustomTimetableEventParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/customTimetableEvent.dart b/lib/api/mhsl/customTimetableEvent/customTimetableEvent.dart index 1a8efe5..d34489b 100644 --- a/lib/api/mhsl/customTimetableEvent/customTimetableEvent.dart +++ b/lib/api/mhsl/customTimetableEvent/customTimetableEvent.dart @@ -25,4 +25,4 @@ class CustomTimetableEvent { factory CustomTimetableEvent.fromJson(Map json) => _$CustomTimetableEventFromJson(json); Map toJson() => _$CustomTimetableEventToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEvent.dart b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEvent.dart index 50b10b7..bca7fd0 100644 --- a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEvent.dart +++ b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEvent.dart @@ -12,12 +12,8 @@ class GetCustomTimetableEvent extends MhslApi { GetCustomTimetableEvent(this.params) : super('server/timetable/customEvents?user=${params.user}'); @override - GetCustomTimetableEventResponse assemble(String raw) { - return GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)}); - } + GetCustomTimetableEventResponse assemble(String raw) => GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)}); @override - Future? request(Uri uri) { - return http.get(uri); - } -} \ No newline at end of file + Future? request(Uri uri) => http.get(uri); +} diff --git a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventCache.dart b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventCache.dart index 8c8762f..ba47a31 100644 --- a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventCache.dart +++ b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventCache.dart @@ -13,12 +13,8 @@ class GetCustomTimetableEventCache extends RequestCache onLoad() { - return GetCustomTimetableEvent(params).run(); - } + Future onLoad() => GetCustomTimetableEvent(params).run(); @override - GetCustomTimetableEventResponse onLocalData(String json) { - return GetCustomTimetableEventResponse.fromJson(jsonDecode(json)); - } -} \ No newline at end of file + GetCustomTimetableEventResponse onLocalData(String json) => GetCustomTimetableEventResponse.fromJson(jsonDecode(json)); +} diff --git a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventParams.dart b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventParams.dart index bf00f78..c4d6c79 100644 --- a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventParams.dart +++ b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventParams.dart @@ -10,4 +10,4 @@ class GetCustomTimetableEventParams { factory GetCustomTimetableEventParams.fromJson(Map json) => _$GetCustomTimetableEventParamsFromJson(json); Map toJson() => _$GetCustomTimetableEventParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventResponse.dart b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventResponse.dart index c923e19..c086b73 100644 --- a/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventResponse.dart +++ b/lib/api/mhsl/customTimetableEvent/get/getCustomTimetableEventResponse.dart @@ -13,4 +13,4 @@ class GetCustomTimetableEventResponse extends ApiResponse { factory GetCustomTimetableEventResponse.fromJson(Map json) => _$GetCustomTimetableEventResponseFromJson(json); Map toJson() => _$GetCustomTimetableEventResponseToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEvent.dart b/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEvent.dart index 7bfc00c..add1c55 100644 --- a/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEvent.dart +++ b/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEvent.dart @@ -15,7 +15,5 @@ class RemoveCustomTimetableEvent extends MhslApi { void assemble(String raw) {} @override - Future? request(Uri uri) { - return http.delete(uri, body: jsonEncode(params.toJson())); - } -} \ No newline at end of file + Future? request(Uri uri) => http.delete(uri, body: jsonEncode(params.toJson())); +} diff --git a/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEventParams.dart b/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEventParams.dart index 1be141a..3b1d989 100644 --- a/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEventParams.dart +++ b/lib/api/mhsl/customTimetableEvent/remove/removeCustomTimetableEventParams.dart @@ -10,4 +10,4 @@ class RemoveCustomTimetableEventParams { factory RemoveCustomTimetableEventParams.fromJson(Map json) => _$RemoveCustomTimetableEventParamsFromJson(json); Map toJson() => _$RemoveCustomTimetableEventParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEvent.dart b/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEvent.dart index 0dd8d94..9b1a754 100644 --- a/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEvent.dart +++ b/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEvent.dart @@ -15,7 +15,5 @@ class UpdateCustomTimetableEvent extends MhslApi { void assemble(String raw) {} @override - Future? request(Uri uri) { - return http.patch(uri, body: jsonEncode(params.toJson())); - } -} \ No newline at end of file + Future? request(Uri uri) => http.patch(uri, body: jsonEncode(params.toJson())); +} diff --git a/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEventParams.dart b/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEventParams.dart index 806d572..4a09c83 100644 --- a/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEventParams.dart +++ b/lib/api/mhsl/customTimetableEvent/update/updateCustomTimetableEventParams.dart @@ -14,4 +14,4 @@ class UpdateCustomTimetableEventParams { factory UpdateCustomTimetableEventParams.fromJson(Map json) => _$UpdateCustomTimetableEventParamsFromJson(json); Map toJson() => _$UpdateCustomTimetableEventParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/message/getMessages/getMessages.dart b/lib/api/mhsl/message/getMessages/getMessages.dart index d62be9e..32a5734 100644 --- a/lib/api/mhsl/message/getMessages/getMessages.dart +++ b/lib/api/mhsl/message/getMessages/getMessages.dart @@ -10,12 +10,8 @@ class GetMessages extends MhslApi { @override - GetMessagesResponse assemble(String raw) { - return GetMessagesResponse.fromJson(jsonDecode(raw)); - } + GetMessagesResponse assemble(String raw) => GetMessagesResponse.fromJson(jsonDecode(raw)); @override - Future request(Uri uri) { - return http.get(uri); - } -} \ No newline at end of file + Future request(Uri uri) => http.get(uri); +} diff --git a/lib/api/mhsl/message/getMessages/getMessagesCache.dart b/lib/api/mhsl/message/getMessages/getMessagesCache.dart index 96d736a..416ff45 100644 --- a/lib/api/mhsl/message/getMessages/getMessagesCache.dart +++ b/lib/api/mhsl/message/getMessages/getMessagesCache.dart @@ -10,12 +10,8 @@ class GetMessagesCache extends RequestCache { } @override - GetMessagesResponse onLocalData(String json) { - return GetMessagesResponse.fromJson(jsonDecode(json)); - } + GetMessagesResponse onLocalData(String json) => GetMessagesResponse.fromJson(jsonDecode(json)); @override - Future onLoad() { - return GetMessages().run(); - } -} \ No newline at end of file + Future onLoad() => GetMessages().run(); +} diff --git a/lib/api/mhsl/mhslApi.dart b/lib/api/mhsl/mhslApi.dart index df76c09..eb4910a 100644 --- a/lib/api/mhsl/mhslApi.dart +++ b/lib/api/mhsl/mhslApi.dart @@ -15,9 +15,9 @@ abstract class MhslApi extends ApiRequest { T assemble(String raw); Future run() async { - Uri endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath'); + var endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath'); - http.Response? data = await request(endpoint); + var data = await request(endpoint); if(data == null) { throw ApiError('Request could not be dispatched!'); } @@ -31,5 +31,4 @@ abstract class MhslApi extends ApiRequest { static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss'); static DateTime dateTimeFromJson(String time) => DateTime.parse(time); - -} \ No newline at end of file +} diff --git a/lib/api/mhsl/notify/register/notifyRegister.dart b/lib/api/mhsl/notify/register/notifyRegister.dart index 178b0c9..94ffde7 100644 --- a/lib/api/mhsl/notify/register/notifyRegister.dart +++ b/lib/api/mhsl/notify/register/notifyRegister.dart @@ -19,8 +19,8 @@ class NotifyRegister extends MhslApi { @override Future request(Uri uri) { - String requestString = jsonEncode(params.toJson()); + var requestString = jsonEncode(params.toJson()); log(requestString); return http.post(uri, body: requestString); } -} \ No newline at end of file +} diff --git a/lib/api/mhsl/notify/register/notifyRegisterParams.dart b/lib/api/mhsl/notify/register/notifyRegisterParams.dart index 75c7a95..3f18319 100644 --- a/lib/api/mhsl/notify/register/notifyRegisterParams.dart +++ b/lib/api/mhsl/notify/register/notifyRegisterParams.dart @@ -16,4 +16,4 @@ class NotifyRegisterParams { factory NotifyRegisterParams.fromJson(Map json) => _$NotifyRegisterParamsFromJson(json); Map toJson() => _$NotifyRegisterParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/server/feedback/addFeedback.dart b/lib/api/mhsl/server/feedback/addFeedback.dart index ad1f34a..54c3ce0 100644 --- a/lib/api/mhsl/server/feedback/addFeedback.dart +++ b/lib/api/mhsl/server/feedback/addFeedback.dart @@ -15,7 +15,5 @@ class AddFeedback extends MhslApi { void assemble(String raw) {} @override - Future? request(Uri uri) { - return http.post(uri, body: jsonEncode(params.toJson())); - } -} \ No newline at end of file + Future? request(Uri uri) => http.post(uri, body: jsonEncode(params.toJson())); +} diff --git a/lib/api/mhsl/server/feedback/addFeedbackParams.dart b/lib/api/mhsl/server/feedback/addFeedbackParams.dart index 3ed0c55..945b00c 100644 --- a/lib/api/mhsl/server/feedback/addFeedbackParams.dart +++ b/lib/api/mhsl/server/feedback/addFeedbackParams.dart @@ -19,4 +19,4 @@ class AddFeedbackParams { factory AddFeedbackParams.fromJson(Map json) => _$AddFeedbackParamsFromJson(json); Map toJson() => _$AddFeedbackParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/server/userIndex/update/updateUserIndexParams.dart b/lib/api/mhsl/server/userIndex/update/updateUserIndexParams.dart index 8a200fa..680edda 100644 --- a/lib/api/mhsl/server/userIndex/update/updateUserIndexParams.dart +++ b/lib/api/mhsl/server/userIndex/update/updateUserIndexParams.dart @@ -21,4 +21,4 @@ class UpdateUserIndexParams { factory UpdateUserIndexParams.fromJson(Map json) => _$UpdateUserIndexParamsFromJson(json); Map toJson() => _$UpdateUserIndexParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/mhsl/server/userIndex/update/updateUserindex.dart b/lib/api/mhsl/server/userIndex/update/updateUserindex.dart index 119906d..1f83c06 100644 --- a/lib/api/mhsl/server/userIndex/update/updateUserindex.dart +++ b/lib/api/mhsl/server/userIndex/update/updateUserindex.dart @@ -19,12 +19,12 @@ class UpdateUserIndex extends MhslApi { @override Future request(Uri uri) { - String data = jsonEncode(params.toJson()); + var data = jsonEncode(params.toJson()); log('Updating userindex:\n $data'); return http.post(uri, body: data); } - static void index() async { + static Future index() async { UpdateUserIndex( UpdateUserIndexParams( username: AccountData().getUsername(), @@ -35,4 +35,4 @@ class UpdateUserIndex extends MhslApi { ), ).run(); } -} \ No newline at end of file +} diff --git a/lib/api/requestCache.dart b/lib/api/requestCache.dart index 620df08..8040f2c 100644 --- a/lib/api/requestCache.dart +++ b/lib/api/requestCache.dart @@ -20,8 +20,8 @@ abstract class RequestCache { static void ignore(Exception e) {} - void start(String file, String document) async { - Map? tableData = await Localstore.instance.collection(file).doc(document).get(); + Future start(String file, String document) async { + var tableData = await Localstore.instance.collection(file).doc(document).get(); if(tableData != null) { onUpdate(onLocalData(tableData['json'])); } @@ -31,7 +31,7 @@ abstract class RequestCache { } try { - T newValue = await onLoad(); + var newValue = await onLoad(); onUpdate(newValue); Localstore.instance.collection(file).doc(document).set({ @@ -46,4 +46,4 @@ abstract class RequestCache { T onLocalData(String json); Future onLoad(); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/authenticate/authenticate.dart b/lib/api/webuntis/queries/authenticate/authenticate.dart index f237aa2..c42f62c 100644 --- a/lib/api/webuntis/queries/authenticate/authenticate.dart +++ b/lib/api/webuntis/queries/authenticate/authenticate.dart @@ -14,7 +14,7 @@ class Authenticate extends WebuntisApi { @override Future run() async { awaitingResponse = true; - String rawAnswer = await query(this); + var rawAnswer = await query(this); AuthenticateResponse response = finalize(AuthenticateResponse.fromJson(jsonDecode(rawAnswer)['result'])); _lastResponse = response; if(!awaitedResponse.isCompleted) awaitedResponse.complete(); @@ -46,4 +46,4 @@ class Authenticate extends WebuntisApi { return _lastResponse!; } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/authenticate/authenticateParams.dart b/lib/api/webuntis/queries/authenticate/authenticateParams.dart index 5e6fb48..bfa65e6 100644 --- a/lib/api/webuntis/queries/authenticate/authenticateParams.dart +++ b/lib/api/webuntis/queries/authenticate/authenticateParams.dart @@ -14,4 +14,4 @@ class AuthenticateParams extends ApiParams { factory AuthenticateParams.fromJson(Map json) => _$AuthenticateParamsFromJson(json); Map toJson() => _$AuthenticateParamsToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/authenticate/authenticateResponse.dart b/lib/api/webuntis/queries/authenticate/authenticateResponse.dart index f76ddad..509b1dc 100644 --- a/lib/api/webuntis/queries/authenticate/authenticateResponse.dart +++ b/lib/api/webuntis/queries/authenticate/authenticateResponse.dart @@ -16,4 +16,4 @@ class AuthenticateResponse extends ApiResponse { factory AuthenticateResponse.fromJson(Map json) => _$AuthenticateResponseFromJson(json); Map toJson() => _$AuthenticateResponseToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getHolidays/getHolidays.dart b/lib/api/webuntis/queries/getHolidays/getHolidays.dart index 699657d..145cb6e 100644 --- a/lib/api/webuntis/queries/getHolidays/getHolidays.dart +++ b/lib/api/webuntis/queries/getHolidays/getHolidays.dart @@ -8,7 +8,7 @@ class GetHolidays extends WebuntisApi { @override Future run() async { - String rawAnswer = await query(this); + var rawAnswer = await query(this); return finalize(GetHolidaysResponse.fromJson(jsonDecode(rawAnswer))); } @@ -17,12 +17,12 @@ class GetHolidays extends WebuntisApi { time = DateTime(time.year, time.month, time.day, 0, 0, 0, 0, 0); for (var element in holidaysResponse.result) { - DateTime start = DateTime.parse(element.startDate.toString()); - DateTime end = DateTime.parse(element.endDate.toString()); + var start = DateTime.parse(element.startDate.toString()); + var end = DateTime.parse(element.endDate.toString()); if(!start.isAfter(time) && !end.isBefore(time)) return element; } return null; } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getHolidays/getHolidaysCache.dart b/lib/api/webuntis/queries/getHolidays/getHolidaysCache.dart index 9f7924c..da89d46 100644 --- a/lib/api/webuntis/queries/getHolidays/getHolidaysCache.dart +++ b/lib/api/webuntis/queries/getHolidays/getHolidaysCache.dart @@ -10,12 +10,8 @@ class GetHolidaysCache extends RequestCache { } @override - Future onLoad() { - return GetHolidays().run(); - } + Future onLoad() => GetHolidays().run(); @override - GetHolidaysResponse onLocalData(String json) { - return GetHolidaysResponse.fromJson(jsonDecode(json)); - } -} \ No newline at end of file + GetHolidaysResponse onLocalData(String json) => GetHolidaysResponse.fromJson(jsonDecode(json)); +} diff --git a/lib/api/webuntis/queries/getHolidays/getHolidaysResponse.dart b/lib/api/webuntis/queries/getHolidays/getHolidaysResponse.dart index 7e93fab..f087c4a 100644 --- a/lib/api/webuntis/queries/getHolidays/getHolidaysResponse.dart +++ b/lib/api/webuntis/queries/getHolidays/getHolidaysResponse.dart @@ -26,4 +26,4 @@ class GetHolidaysResponseObject { factory GetHolidaysResponseObject.fromJson(Map json) => _$GetHolidaysResponseObjectFromJson(json); Map toJson() => _$GetHolidaysResponseObjectToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getRooms/getRooms.dart b/lib/api/webuntis/queries/getRooms/getRooms.dart index d28f040..45c53c5 100644 --- a/lib/api/webuntis/queries/getRooms/getRooms.dart +++ b/lib/api/webuntis/queries/getRooms/getRooms.dart @@ -9,7 +9,7 @@ class GetRooms extends WebuntisApi { @override Future run() async { - String rawAnswer = await query(this); + var rawAnswer = await query(this); try { return finalize(GetRoomsResponse.fromJson(jsonDecode(rawAnswer))); } catch(e, trace) { @@ -20,4 +20,4 @@ class GetRooms extends WebuntisApi { throw Exception('Failed to parse getRoom server response: $rawAnswer'); } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getRooms/getRoomsCache.dart b/lib/api/webuntis/queries/getRooms/getRoomsCache.dart index 777de09..d126cd0 100644 --- a/lib/api/webuntis/queries/getRooms/getRoomsCache.dart +++ b/lib/api/webuntis/queries/getRooms/getRoomsCache.dart @@ -10,13 +10,9 @@ class GetRoomsCache extends RequestCache { } @override - Future onLoad() { - return GetRooms().run(); - } + Future onLoad() => GetRooms().run(); @override - GetRoomsResponse onLocalData(String json) { - return GetRoomsResponse.fromJson(jsonDecode(json)); - } + GetRoomsResponse onLocalData(String json) => GetRoomsResponse.fromJson(jsonDecode(json)); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getRooms/getRoomsResponse.dart b/lib/api/webuntis/queries/getRooms/getRoomsResponse.dart index 91db146..fe4dc84 100644 --- a/lib/api/webuntis/queries/getRooms/getRoomsResponse.dart +++ b/lib/api/webuntis/queries/getRooms/getRoomsResponse.dart @@ -26,4 +26,4 @@ class GetRoomsResponseObject { factory GetRoomsResponseObject.fromJson(Map json) => _$GetRoomsResponseObjectFromJson(json); Map toJson() => _$GetRoomsResponseObjectToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getSubjects/getSubjects.dart b/lib/api/webuntis/queries/getSubjects/getSubjects.dart index 27ff750..8505381 100644 --- a/lib/api/webuntis/queries/getSubjects/getSubjects.dart +++ b/lib/api/webuntis/queries/getSubjects/getSubjects.dart @@ -8,7 +8,7 @@ class GetSubjects extends WebuntisApi { @override Future run() async { - String rawAnswer = await query(this); + var rawAnswer = await query(this); return finalize(GetSubjectsResponse.fromJson(jsonDecode(rawAnswer))); } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getSubjects/getSubjectsCache.dart b/lib/api/webuntis/queries/getSubjects/getSubjectsCache.dart index aea6387..a1670d0 100644 --- a/lib/api/webuntis/queries/getSubjects/getSubjectsCache.dart +++ b/lib/api/webuntis/queries/getSubjects/getSubjectsCache.dart @@ -10,13 +10,9 @@ class GetSubjectsCache extends RequestCache { } @override - Future onLoad() { - return GetSubjects().run(); - } + Future onLoad() => GetSubjects().run(); @override - onLocalData(String json) { - return GetSubjectsResponse.fromJson(jsonDecode(json)); - } + onLocalData(String json) => GetSubjectsResponse.fromJson(jsonDecode(json)); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getSubjects/getSubjectsResponse.dart b/lib/api/webuntis/queries/getSubjects/getSubjectsResponse.dart index 2db8261..cfd2cf1 100644 --- a/lib/api/webuntis/queries/getSubjects/getSubjectsResponse.dart +++ b/lib/api/webuntis/queries/getSubjects/getSubjectsResponse.dart @@ -26,4 +26,4 @@ class GetSubjectsResponseObject { factory GetSubjectsResponseObject.fromJson(Map json) => _$GetSubjectsResponseObjectFromJson(json); Map toJson() => _$GetSubjectsResponseObjectToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getTimetable/getTimetable.dart b/lib/api/webuntis/queries/getTimetable/getTimetable.dart index 369f012..e9da26d 100644 --- a/lib/api/webuntis/queries/getTimetable/getTimetable.dart +++ b/lib/api/webuntis/queries/getTimetable/getTimetable.dart @@ -11,8 +11,8 @@ class GetTimetable extends WebuntisApi { @override Future run() async { - String rawAnswer = await query(this); + var rawAnswer = await query(this); return finalize(GetTimetableResponse.fromJson(jsonDecode(rawAnswer))); } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getTimetable/getTimetableCache.dart b/lib/api/webuntis/queries/getTimetable/getTimetableCache.dart index 9e4adb8..54a1b86 100644 --- a/lib/api/webuntis/queries/getTimetable/getTimetableCache.dart +++ b/lib/api/webuntis/queries/getTimetable/getTimetableCache.dart @@ -15,13 +15,10 @@ class GetTimetableCache extends RequestCache { } @override - GetTimetableResponse onLocalData(String json) { - return GetTimetableResponse.fromJson(jsonDecode(json)); - } + GetTimetableResponse onLocalData(String json) => GetTimetableResponse.fromJson(jsonDecode(json)); @override - Future onLoad() async { - return GetTimetable( + Future onLoad() async => GetTimetable( GetTimetableParams( options: GetTimetableParamsOptions( element: GetTimetableParamsOptionsElement( @@ -38,5 +35,4 @@ class GetTimetableCache extends RequestCache { ) ) ).run(); - } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getTimetable/getTimetableParams.dart b/lib/api/webuntis/queries/getTimetable/getTimetableParams.dart index 1dec8c7..48ba379 100644 --- a/lib/api/webuntis/queries/getTimetable/getTimetableParams.dart +++ b/lib/api/webuntis/queries/getTimetable/getTimetableParams.dart @@ -91,4 +91,4 @@ enum GetTimetableParamsOptionsElementKeyType { @JsonValue('id') id, @JsonValue('name') name, @JsonValue('externalkey') externalkey -} \ No newline at end of file +} diff --git a/lib/api/webuntis/queries/getTimetable/getTimetableResponse.dart b/lib/api/webuntis/queries/getTimetable/getTimetableResponse.dart index e9752f2..fc6663c 100644 --- a/lib/api/webuntis/queries/getTimetable/getTimetableResponse.dart +++ b/lib/api/webuntis/queries/getTimetable/getTimetableResponse.dart @@ -136,4 +136,4 @@ class GetTimetableResponseObjectRoom { factory GetTimetableResponseObjectRoom.fromJson(Map json) => _$GetTimetableResponseObjectRoomFromJson(json); Map toJson() => _$GetTimetableResponseObjectRoomToJson(this); -} \ No newline at end of file +} diff --git a/lib/api/webuntis/webuntisApi.dart b/lib/api/webuntis/webuntisApi.dart index 90a7cf4..bf3e2e1 100644 --- a/lib/api/webuntis/webuntisApi.dart +++ b/lib/api/webuntis/webuntisApi.dart @@ -20,13 +20,13 @@ abstract class WebuntisApi extends ApiRequest { Future query(WebuntisApi untis) async { - String query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}'; + var query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}'; - String sessionId = '0'; + var sessionId = '0'; if(authenticatedResponse) { sessionId = (await Authenticate.getSession()).sessionId; } - http.Response data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'}); + var data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'}); response = data; dynamic jsonData = jsonDecode(data.body); @@ -48,16 +48,12 @@ abstract class WebuntisApi extends ApiRequest { Future run(); - String _body() { - return genericParam == null ? '{}' : jsonEncode(genericParam); - } + String _body() => genericParam == null ? '{}' : jsonEncode(genericParam); - Future post(String data, Map? headers) async { - return await http + Future post(String data, Map? headers) async => await http .post(endpoint, body: data, headers: headers) .timeout( const Duration(seconds: 10), onTimeout: () => throw WebuntisError('Timeout', 1) ); - } -} \ No newline at end of file +} diff --git a/lib/api/webuntis/webuntisError.dart b/lib/api/webuntis/webuntisError.dart index b79b727..fadcc2e 100644 --- a/lib/api/webuntis/webuntisError.dart +++ b/lib/api/webuntis/webuntisError.dart @@ -5,7 +5,5 @@ class WebuntisError implements Exception { WebuntisError(this.message, this.code); @override - String toString() { - return 'WebUntis ($code): $message'; - } -} \ No newline at end of file + String toString() => 'WebUntis ($code): $message'; +} diff --git a/lib/app.dart b/lib/app.dart index 4b2a449..11ea0ac 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -94,8 +94,7 @@ class _AppState extends State with WidgetsBindingObserver { } @override - Widget build(BuildContext context) { - return PersistentTabView( + Widget build(BuildContext context) => PersistentTabView( controller: App.bottomNavigator, navBarOverlap: const NavBarOverlap.none(), backgroundColor: Theme.of(context).colorScheme.primary, @@ -119,7 +118,7 @@ class _AppState extends State with WidgetsBindingObserver { icon: Consumer( builder: (context, value, child) { if(value.primaryLoading()) return const Icon(Icons.chat); - int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b); + 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), @@ -164,7 +163,6 @@ class _AppState extends State with WidgetsBindingObserver { ), ), ); - } @override void dispose() { @@ -173,4 +171,4 @@ class _AppState extends State with WidgetsBindingObserver { WidgetsBinding.instance.removeObserver(this); super.dispose(); } -} \ No newline at end of file +} diff --git a/lib/extensions/dateTime.dart b/lib/extensions/dateTime.dart index ebfda66..7852873 100644 --- a/lib/extensions/dateTime.dart +++ b/lib/extensions/dateTime.dart @@ -1,30 +1,20 @@ import 'package:flutter/material.dart'; extension IsSameDay on DateTime { - bool isSameDay(DateTime other) { - return year == other.year && month == other.month && day == other.day; - } + bool isSameDay(DateTime other) => year == other.year && month == other.month && day == other.day; - DateTime nextWeekday(int day) { - return add(Duration(days: (day - weekday) % DateTime.daysPerWeek)); - } + DateTime nextWeekday(int day) => add(Duration(days: (day - weekday) % DateTime.daysPerWeek)); - DateTime withTime(TimeOfDay time) { - return copyWith(hour: time.hour, minute: time.minute); - } + DateTime withTime(TimeOfDay time) => copyWith(hour: time.hour, minute: time.minute); - TimeOfDay toTimeOfDay() { - return TimeOfDay(hour: hour, minute: minute); - } + TimeOfDay toTimeOfDay() => TimeOfDay(hour: hour, minute: minute); bool isSameDateTime(DateTime other) { - bool isSameDay = this.isSameDay(other); - bool isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay()); + var isSameDay = this.isSameDay(other); + var isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay()); return isSameDay && isSameTimeOfDay; } - bool isSameOrAfter(DateTime other) { - return isSameDateTime(other) || isAfter(other); - } -} \ No newline at end of file + bool isSameOrAfter(DateTime other) => isSameDateTime(other) || isAfter(other); +} diff --git a/lib/extensions/renderNotNull.dart b/lib/extensions/renderNotNull.dart index 86d9207..3d267a0 100644 --- a/lib/extensions/renderNotNull.dart +++ b/lib/extensions/renderNotNull.dart @@ -1,5 +1,3 @@ extension RenderNotNullExt on T? { - R? wrapNullable(R Function(T data) defaultValueCallback) { - return this != null ? defaultValueCallback(this as T) : null; - } -} \ No newline at end of file + R? wrapNullable(R Function(T data) defaultValueCallback) => this != null ? defaultValueCallback(this as T) : null; +} diff --git a/lib/extensions/text.dart b/lib/extensions/text.dart index caaabe1..0cf90a2 100644 --- a/lib/extensions/text.dart +++ b/lib/extensions/text.dart @@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; extension TextExt on Text { Size get size { - final TextPainter textPainter = TextPainter( + final textPainter = TextPainter( text: TextSpan(text: data, style: style), maxLines: 1, textDirection: TextDirection.ltr )..layout(minWidth: 0, maxWidth: double.infinity); return textPainter.size; } -} \ No newline at end of file +} diff --git a/lib/extensions/timeOfDay.dart b/lib/extensions/timeOfDay.dart index cb4d60b..c99a47e 100644 --- a/lib/extensions/timeOfDay.dart +++ b/lib/extensions/timeOfDay.dart @@ -1,15 +1,9 @@ import 'package:flutter/material.dart'; extension TimeOfDayExt on TimeOfDay { - bool isBefore(TimeOfDay other) { - return hour < other.hour && minute < other.minute; - } + bool isBefore(TimeOfDay other) => hour < other.hour && minute < other.minute; - bool isAfter(TimeOfDay other) { - return hour > other.hour && minute > other.minute; - } + bool isAfter(TimeOfDay other) => hour > other.hour && minute > other.minute; - TimeOfDay add({int hours = 0, int minutes = 0}) { - return replacing(hour: hour + hours, minute: minute + minutes); - } -} \ No newline at end of file + TimeOfDay add({int hours = 0, int minutes = 0}) => replacing(hour: hour + hours, minute: minute + minutes); +} diff --git a/lib/main.dart b/lib/main.dart index b4f7e59..10b741b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -41,16 +41,14 @@ Future main() async { log('Error initializing Firebase app!'); } - ByteData data = await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem'); + var data = await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem'); SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List()); if(kReleaseMode) { - ErrorWidget.builder = (error) { - return PlaceholderView( + ErrorWidget.builder = (error) => PlaceholderView( icon: Icons.phonelink_erase_rounded, text: error.toStringShort(), ); - }; } runApp( @@ -101,8 +99,7 @@ class _MainState extends State
{ } @override - Widget build(BuildContext context) { - return Directionality( + Widget build(BuildContext context) => Directionality( textDirection: TextDirection.ltr, child: Consumer( builder: (context, settings, child) { @@ -146,7 +143,6 @@ class _MainState extends State
{ }, ), ); - } @override void dispose() { diff --git a/lib/model/accountData.dart b/lib/model/accountData.dart index 7648511..419146a 100644 --- a/lib/model/accountData.dart +++ b/lib/model/accountData.dart @@ -17,9 +17,7 @@ class AccountData { final Future _storage = SharedPreferences.getInstance(); Completer _populated = Completer(); - factory AccountData() { - return _instance; - } + factory AccountData() => _instance; AccountData._construct() { _updateFromStorage(); @@ -38,16 +36,12 @@ class AccountData { return _password!; } - String getUserSecret() { - return sha512.convert(utf8.encode('${AccountData().getUsername()}:${AccountData().getPassword()}')).toString(); - } + String getUserSecret() => sha512.convert(utf8.encode('${AccountData().getUsername()}:${AccountData().getPassword()}')).toString(); - Future getDeviceId() async { - return sha512.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}')).toString(); - } + Future getDeviceId() async => sha512.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}')).toString(); Future setData(String username, String password) async { - SharedPreferences storage = await _storage; + var storage = await _storage; storage.setString(_usernameField, username); storage.setString(_passwordField, password); @@ -59,13 +53,13 @@ class AccountData { if(context != null) Provider.of(context, listen: false).setState(AccountModelState.loggedOut); - SharedPreferences storage = await _storage; + var storage = await _storage; await storage.remove(_usernameField); await storage.remove(_passwordField); } Future _updateFromStorage() async { - SharedPreferences storage = await _storage; + var storage = await _storage; //await storage.reload(); // This line was the cause of the first rejected google play upload :( if(storage.containsKey(_usernameField) && storage.containsKey(_passwordField)) { _username = storage.getString(_usernameField); @@ -79,12 +73,10 @@ class AccountData { return isPopulated(); } - bool isPopulated() { - return _username != null && _password != null; - } + bool isPopulated() => _username != null && _password != null; String buildHttpAuthString() { if(!isPopulated()) throw Exception('AccountData (e.g. username or password) is not initialized!'); return '$_username:$_password'; } -} \ No newline at end of file +} diff --git a/lib/model/accountModel.dart b/lib/model/accountModel.dart index 39df3f4..26abcfd 100644 --- a/lib/model/accountModel.dart +++ b/lib/model/accountModel.dart @@ -14,4 +14,4 @@ enum AccountModelState { undefined, loggedIn, loggedOut, -} \ No newline at end of file +} diff --git a/lib/model/breakers/Breaker.dart b/lib/model/breakers/Breaker.dart index 7fb4b24..1545296 100644 --- a/lib/model/breakers/Breaker.dart +++ b/lib/model/breakers/Breaker.dart @@ -19,10 +19,9 @@ class Breaker extends StatefulWidget { class _BreakerState extends State { @override - Widget build(BuildContext context) { - return Consumer( + Widget build(BuildContext context) => Consumer( builder: (context, value, child) { - String? blocked = value.isBlocked(widget.breaker); + var blocked = value.isBlocked(widget.breaker); 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}"); } @@ -30,5 +29,4 @@ class _BreakerState extends State { return widget.child; }, ); - } } diff --git a/lib/model/breakers/BreakerProps.dart b/lib/model/breakers/BreakerProps.dart index 54bf2a4..1c5fed5 100644 --- a/lib/model/breakers/BreakerProps.dart +++ b/lib/model/breakers/BreakerProps.dart @@ -18,13 +18,13 @@ class BreakerProps extends DataHolder { } if(primaryLoading()) return null; - GetBreakersResponse breakers = _getBreakersResponse!; + var breakers = _getBreakersResponse!; if(breakers.global.areas.contains(type)) return breakers.global.message; - int selfVersion = int.parse(packageInfo!.buildNumber); + var selfVersion = int.parse(packageInfo!.buildNumber); for(var key in breakers.regional.keys) { - GetBreakersReponseObject value = breakers.regional[key]!; + var value = breakers.regional[key]!; if(int.parse(key.split('b')[1]) >= selfVersion) { if(value.areas.contains(type)) return value.message; @@ -35,9 +35,7 @@ class BreakerProps extends DataHolder { } @override - List properties() { - return [_getBreakersResponse]; - } + List properties() => [_getBreakersResponse]; @override void run() { @@ -48,4 +46,4 @@ class BreakerProps extends DataHolder { } ); } -} \ No newline at end of file +} diff --git a/lib/model/chatList/chatListProps.dart b/lib/model/chatList/chatListProps.dart index 5ba1793..2c4e2b7 100644 --- a/lib/model/chatList/chatListProps.dart +++ b/lib/model/chatList/chatListProps.dart @@ -11,9 +11,7 @@ class ChatListProps extends DataHolder { GetRoomResponse get getRoomsResponse => _getRoomResponse!; @override - List properties() { - return [_getRoomResponse]; - } + List properties() => [_getRoomResponse]; @override void run({renew}) { @@ -27,4 +25,4 @@ class ChatListProps extends DataHolder { ); } -} \ No newline at end of file +} diff --git a/lib/model/chatList/chatProps.dart b/lib/model/chatList/chatProps.dart index c96ed6c..bd0a749 100644 --- a/lib/model/chatList/chatProps.dart +++ b/lib/model/chatList/chatProps.dart @@ -11,15 +11,13 @@ class ChatProps extends DataHolder { GetChatResponse get getChatResponse => _getChatResponse!; @override - List properties() { - return [_getChatResponse]; - } + List properties() => [_getChatResponse]; @override void run() { notifyListeners(); if(_queryToken.isEmpty) return; - DateTime requestStart = DateTime.now(); + var requestStart = DateTime.now(); GetChatCache( chatToken: _queryToken, @@ -39,7 +37,5 @@ class ChatProps extends DataHolder { run(); } - String currentToken() { - return _queryToken; - } -} \ No newline at end of file + String currentToken() => _queryToken; +} diff --git a/lib/model/dataCleaner.dart b/lib/model/dataCleaner.dart index 5e6a3ce..a2706a9 100644 --- a/lib/model/dataCleaner.dart +++ b/lib/model/dataCleaner.dart @@ -3,13 +3,13 @@ import 'package:localstore/localstore.dart'; import '../widget/debug/cacheView.dart'; class DataCleaner { - static void cleanOldCache() async { + static Future cleanOldCache() async { var cacheData = await Localstore.instance.collection(CacheView.collection).get(); cacheData?.forEach((key, value) async { - DateTime lastUpdate = DateTime.fromMillisecondsSinceEpoch(value['lastupdate']); + var lastUpdate = DateTime.fromMillisecondsSinceEpoch(value['lastupdate']); if(DateTime.now().subtract(const Duration(days: 200)).isAfter(lastUpdate)) { await Localstore.instance.collection(CacheView.collection).doc(key.split('/').last).delete(); } }); } -} \ No newline at end of file +} diff --git a/lib/model/dataHolder.dart b/lib/model/dataHolder.dart index 5169eb8..84b3dbd 100644 --- a/lib/model/dataHolder.dart +++ b/lib/model/dataHolder.dart @@ -6,19 +6,17 @@ import '../api/apiResponse.dart'; abstract class DataHolder extends ChangeNotifier { - CollectionRef storage(String path) { - return Localstore.instance.collection(path); - } + CollectionRef storage(String path) => Localstore.instance.collection(path); void run(); List properties(); bool primaryLoading() { // log("${toString()} ${properties().map((e) => e != null ? "1" : "0").join(", ")}"); - for(ApiResponse? element in properties()) { + for(var element in properties()) { if(element == null) return true; } return false; //return properties().where((element) => element != null).isEmpty; } -} \ No newline at end of file +} diff --git a/lib/model/endpointData.dart b/lib/model/endpointData.dart index d151435..18e8699 100644 --- a/lib/model/endpointData.dart +++ b/lib/model/endpointData.dart @@ -23,17 +23,13 @@ class Endpoint { Endpoint({required this.domain, this.path = ''}); - String full() { - return domain + path; - } + String full() => domain + path; } class EndpointData { static final EndpointData _instance = EndpointData._construct(); - factory EndpointData() { - return _instance; - } + factory EndpointData() => _instance; EndpointData._construct(); @@ -43,8 +39,7 @@ class EndpointData { return existingName.startsWith('google') ? EndpointMode.stage : EndpointMode.live; } - Endpoint webuntis() { - return EndpointOptions( + Endpoint webuntis() => EndpointOptions( live: Endpoint( domain: 'peleus.webuntis.com', ), @@ -53,10 +48,8 @@ class EndpointData { path: '/marianum/marianummobile/webuntis/public/index.php/api' ), ).get(getEndpointMode()); - } - Endpoint nextcloud() { - return EndpointOptions( + Endpoint nextcloud() => EndpointOptions( live: Endpoint( domain: 'cloud.marianum-fulda.de', ), @@ -65,6 +58,5 @@ class EndpointData { path: '/marianum/marianummobile/cloud', ) ).get(getEndpointMode()); - } -} \ No newline at end of file +} diff --git a/lib/model/files/filesProps.dart b/lib/model/files/filesProps.dart index a7160c2..979c708 100644 --- a/lib/model/files/filesProps.dart +++ b/lib/model/files/filesProps.dart @@ -23,9 +23,7 @@ class FilesProps extends DataHolder { } @override - List properties() { - return [_listFilesResponse]; - } + List properties() => [_listFilesResponse]; @override void run() { @@ -51,4 +49,4 @@ class FilesProps extends DataHolder { if(folderPath.isEmpty) currentFolderName = 'Home'; run(); } -} \ No newline at end of file +} diff --git a/lib/model/holidays/holidaysProps.dart b/lib/model/holidays/holidaysProps.dart index c46820f..a3e153f 100644 --- a/lib/model/holidays/holidaysProps.dart +++ b/lib/model/holidays/holidaysProps.dart @@ -10,9 +10,7 @@ class HolidaysProps extends DataHolder { GetHolidaysResponse get getHolidaysResponse => _getHolidaysResponse!; @override - List properties() { - return [_getHolidaysResponse]; - } + List properties() => [_getHolidaysResponse]; @override void run() { @@ -23,4 +21,4 @@ class HolidaysProps extends DataHolder { }, ); } -} \ No newline at end of file +} diff --git a/lib/model/message/messageProps.dart b/lib/model/message/messageProps.dart index 80644b8..c2e2a37 100644 --- a/lib/model/message/messageProps.dart +++ b/lib/model/message/messageProps.dart @@ -9,9 +9,7 @@ class MessageProps extends DataHolder { GetMessagesResponse get getMessagesResponse => _getMessagesResponse!; @override - List properties() { - return [_getMessagesResponse]; - } + List properties() => [_getMessagesResponse]; @override void run({renew}) { @@ -24,4 +22,4 @@ class MessageProps extends DataHolder { ); } -} \ No newline at end of file +} diff --git a/lib/model/timetable/timetableProps.dart b/lib/model/timetable/timetableProps.dart index d12282f..2d7be91 100644 --- a/lib/model/timetable/timetableProps.dart +++ b/lib/model/timetable/timetableProps.dart @@ -42,9 +42,7 @@ class TimetableProps extends DataHolder { bool get hasError => error != null; @override - List properties() { - return [_getTimetableResponse, _getRoomsResponse, _getSubjectsResponse, _getHolidaysResponse, _getCustomTimetableEventResponse]; - } + List properties() => [_getTimetableResponse, _getRoomsResponse, _getSubjectsResponse, _getHolidaysResponse, _getCustomTimetableEventResponse]; @override void run({renew}) { @@ -101,9 +99,7 @@ class TimetableProps extends DataHolder { DateTime getDate(DateTime d) => DateTime(d.year, d.month, d.day); - bool isWeekend(DateTime queryDate) { - return queryDate.weekday == DateTime.saturday || queryDate.weekday == DateTime.sunday; - } + bool isWeekend(DateTime queryDate) => queryDate.weekday == DateTime.saturday || queryDate.weekday == DateTime.sunday; void updateWeek(DateTime start, DateTime end) { properties().forEach((element) => element = null); @@ -123,7 +119,7 @@ class TimetableProps extends DataHolder { error = null; notifyListeners(); - DateTime queryWeek = DateTime.now().add(const Duration(days: 2)); + var queryWeek = DateTime.now().add(const Duration(days: 2)); startDate = getDate(queryWeek.subtract(Duration(days: queryWeek.weekday - 1))); endDate = getDate(queryWeek.add(Duration(days: DateTime.daysPerWeek - queryWeek.weekday))); @@ -131,4 +127,4 @@ class TimetableProps extends DataHolder { run(); notifyListeners(); } -} \ No newline at end of file +} diff --git a/lib/notification/notificationController.dart b/lib/notification/notificationController.dart index f5babc9..af35c22 100644 --- a/lib/notification/notificationController.dart +++ b/lib/notification/notificationController.dart @@ -60,4 +60,4 @@ class NotificationController { )); }); } -} \ No newline at end of file +} diff --git a/lib/notification/notificationService.dart b/lib/notification/notificationService.dart index cbb5758..c855db6 100644 --- a/lib/notification/notificationService.dart +++ b/lib/notification/notificationService.dart @@ -3,27 +3,25 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; class NotificationService { static final NotificationService _instance = NotificationService._internal(); - factory NotificationService() { - return _instance; - } + factory NotificationService() => _instance; NotificationService._internal(); FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); Future initializeNotifications() async { - const AndroidInitializationSettings androidSettings = AndroidInitializationSettings( + const androidSettings = AndroidInitializationSettings( '@mipmap/ic_launcher' ); - final DarwinInitializationSettings iosSettings = DarwinInitializationSettings( + final iosSettings = DarwinInitializationSettings( onDidReceiveLocalNotification: (id, title, body, payload) { // TODO Navigate to Talk section (This runs when an Notification is tapped) }, ); - final InitializationSettings initializationSettings = InitializationSettings( + final initializationSettings = InitializationSettings( android: androidSettings, iOS: iosSettings, ); @@ -34,7 +32,7 @@ class NotificationService { } Future showNotification({required String title, required String body, required int badgeCount}) async { - const AndroidNotificationDetails androidPlatformChannelSpecifics = + const androidPlatformChannelSpecifics = AndroidNotificationDetails( 'marmobile', 'Marianum Fulda', @@ -43,9 +41,9 @@ class NotificationService { ticker: 'Marianum Fulda', ); - const DarwinNotificationDetails iosPlatformChannelSpecifics = DarwinNotificationDetails(); + const iosPlatformChannelSpecifics = DarwinNotificationDetails(); - const NotificationDetails platformChannelSpecifics = NotificationDetails( + const platformChannelSpecifics = NotificationDetails( android: androidPlatformChannelSpecifics, iOS: iosPlatformChannelSpecifics ); @@ -57,4 +55,4 @@ class NotificationService { platformChannelSpecifics, ); } -} \ No newline at end of file +} diff --git a/lib/notification/notificationTasks.dart b/lib/notification/notificationTasks.dart index dd9f860..9719b67 100644 --- a/lib/notification/notificationTasks.dart +++ b/lib/notification/notificationTasks.dart @@ -20,4 +20,4 @@ class NotificationTasks { static void navigateToTalk() { App.bottomNavigator.jumpToTab(1); } -} \ No newline at end of file +} diff --git a/lib/notification/notifyUpdater.dart b/lib/notification/notifyUpdater.dart index b22d221..271e820 100644 --- a/lib/notification/notifyUpdater.dart +++ b/lib/notification/notifyUpdater.dart @@ -8,8 +8,7 @@ import '../storage/base/settingsProvider.dart'; import '../widget/confirmDialog.dart'; class NotifyUpdater { - static ConfirmDialog enableAfterDisclaimer(SettingsProvider settings) { - return ConfirmDialog( + static ConfirmDialog enableAfterDisclaimer(SettingsProvider settings) => ConfirmDialog( title: 'Warnung', icon: Icons.warning_amber, content: '' @@ -25,9 +24,8 @@ class NotifyUpdater { NotifyUpdater.registerToServer(); }, ); - } - static void registerToServer() async { - String? fcmToken = await FirebaseMessaging.instance.getToken(); + static Future registerToServer() async { + var fcmToken = await FirebaseMessaging.instance.getToken(); if(fcmToken == null) throw Exception('Failed to register push notification because there is no FBC token!'); @@ -39,4 +37,4 @@ class NotifyUpdater { ), ).run(); } -} \ No newline at end of file +} diff --git a/lib/storage/base/settings.dart b/lib/storage/base/settings.dart index 46cd3b8..4759059 100644 --- a/lib/storage/base/settings.dart +++ b/lib/storage/base/settings.dart @@ -48,4 +48,4 @@ class Settings { factory Settings.fromJson(Map json) => _$SettingsFromJson(json); Map toJson() => _$SettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/base/settingsProvider.dart b/lib/storage/base/settingsProvider.dart index 1853c30..b1fb43f 100644 --- a/lib/storage/base/settingsProvider.dart +++ b/lib/storage/base/settingsProvider.dart @@ -29,7 +29,7 @@ class SettingsProvider extends ChangeNotifier { _readFromStorage(); } - void reset() async { + Future reset() async { _storage = await SharedPreferences.getInstance(); _storage.remove(_fieldName); _settings = DefaultSettings.get(); @@ -38,7 +38,7 @@ class SettingsProvider extends ChangeNotifier { notifyListeners(); } - void _readFromStorage() async { + Future _readFromStorage() async { _storage = await SharedPreferences.getInstance(); try { @@ -63,7 +63,7 @@ class SettingsProvider extends ChangeNotifier { } Map _mergeSettings(Map oldMap, Map newMap) { - Map mergedMap = Map.from(newMap); + var mergedMap = Map.from(newMap); oldMap.forEach((key, value) { if (mergedMap.containsKey(key)) { @@ -77,4 +77,4 @@ class SettingsProvider extends ChangeNotifier { return mergedMap; } -} \ No newline at end of file +} diff --git a/lib/storage/devTools/devToolsSettings.dart b/lib/storage/devTools/devToolsSettings.dart index 39dfaa5..4a882ed 100644 --- a/lib/storage/devTools/devToolsSettings.dart +++ b/lib/storage/devTools/devToolsSettings.dart @@ -12,4 +12,4 @@ class DevToolsSettings { factory DevToolsSettings.fromJson(Map json) => _$DevToolsSettingsFromJson(json); Map toJson() => _$DevToolsSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/file/fileSettings.dart b/lib/storage/file/fileSettings.dart index 054f9c0..9dec6ca 100644 --- a/lib/storage/file/fileSettings.dart +++ b/lib/storage/file/fileSettings.dart @@ -15,4 +15,4 @@ class FileSettings { factory FileSettings.fromJson(Map json) => _$FileSettingsFromJson(json); Map toJson() => _$FileSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/fileView/fileViewSettings.dart b/lib/storage/fileView/fileViewSettings.dart index 5ebc15d..1f0f1b3 100644 --- a/lib/storage/fileView/fileViewSettings.dart +++ b/lib/storage/fileView/fileViewSettings.dart @@ -10,4 +10,4 @@ class FileViewSettings { factory FileViewSettings.fromJson(Map json) => _$FileViewSettingsFromJson(json); Map toJson() => _$FileViewSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/gradeAverages/gradeAveragesSettings.dart b/lib/storage/gradeAverages/gradeAveragesSettings.dart index 8c3645a..721f239 100644 --- a/lib/storage/gradeAverages/gradeAveragesSettings.dart +++ b/lib/storage/gradeAverages/gradeAveragesSettings.dart @@ -13,4 +13,4 @@ class GradeAveragesSettings { factory GradeAveragesSettings.fromJson(Map json) => _$GradeAveragesSettingsFromJson(json); Map toJson() => _$GradeAveragesSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/holidays/holidaysSettings.dart b/lib/storage/holidays/holidaysSettings.dart index af6912b..6a25292 100644 --- a/lib/storage/holidays/holidaysSettings.dart +++ b/lib/storage/holidays/holidaysSettings.dart @@ -11,4 +11,4 @@ class HolidaysSettings { factory HolidaysSettings.fromJson(Map json) => _$HolidaysSettingsFromJson(json); Map toJson() => _$HolidaysSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/notification/notificationSettings.dart b/lib/storage/notification/notificationSettings.dart index 81607ba..ce02847 100644 --- a/lib/storage/notification/notificationSettings.dart +++ b/lib/storage/notification/notificationSettings.dart @@ -11,4 +11,4 @@ class NotificationSettings { factory NotificationSettings.fromJson(Map json) => _$NotificationSettingsFromJson(json); Map toJson() => _$NotificationSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/talk/talkSettings.dart b/lib/storage/talk/talkSettings.dart index 7f63d1b..a0df6a2 100644 --- a/lib/storage/talk/talkSettings.dart +++ b/lib/storage/talk/talkSettings.dart @@ -12,4 +12,4 @@ class TalkSettings { factory TalkSettings.fromJson(Map json) => _$TalkSettingsFromJson(json); Map toJson() => _$TalkSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/storage/timetable/timetableSettings.dart b/lib/storage/timetable/timetableSettings.dart index cd1098d..5242556 100644 --- a/lib/storage/timetable/timetableSettings.dart +++ b/lib/storage/timetable/timetableSettings.dart @@ -10,4 +10,4 @@ class TimetableSettings { factory TimetableSettings.fromJson(Map json) => _$TimetableSettingsFromJson(json); Map toJson() => _$TimetableSettingsToJson(this); -} \ No newline at end of file +} diff --git a/lib/theming/appTheme.dart b/lib/theming/appTheme.dart index 717bb74..bcf44f7 100644 --- a/lib/theming/appTheme.dart +++ b/lib/theming/appTheme.dart @@ -15,9 +15,7 @@ class AppTheme { } } - static bool isDarkMode(BuildContext context) { - return Theme.of(context).brightness == Brightness.dark; - } + static bool isDarkMode(BuildContext context) => Theme.of(context).brightness == Brightness.dark; } class ThemeModeDisplay { @@ -25,4 +23,4 @@ class ThemeModeDisplay { final String displayName; ThemeModeDisplay({required this.icon, required this.displayName}); -} \ No newline at end of file +} diff --git a/lib/theming/darkAppTheme.dart b/lib/theming/darkAppTheme.dart index a8d33e5..97e6a81 100644 --- a/lib/theming/darkAppTheme.dart +++ b/lib/theming/darkAppTheme.dart @@ -10,4 +10,4 @@ class DarkAppTheme { ), primaryColor: marianumRed, ); -} \ No newline at end of file +} diff --git a/lib/theming/lightAppTheme.dart b/lib/theming/lightAppTheme.dart index 09a707a..97e9130 100644 --- a/lib/theming/lightAppTheme.dart +++ b/lib/theming/lightAppTheme.dart @@ -10,4 +10,4 @@ class LightAppTheme { foregroundColor: Colors.white ) ); -} \ No newline at end of file +} diff --git a/lib/view/login/login.dart b/lib/view/login/login.dart index a99e8be..6f7d0a5 100644 --- a/lib/view/login/login.dart +++ b/lib/view/login/login.dart @@ -20,9 +20,7 @@ class Login extends StatefulWidget { class _LoginState extends State { bool displayDisclaimerText = true; - String? _checkInput(value){ - return (value ?? '').length == 0 ? 'Eingabe erforderlich' : null; - } + String? _checkInput(value)=> (value ?? '').length == 0 ? 'Eingabe erforderlich' : null; Future _login(LoginData data) async { await AccountData().removeData(); @@ -49,15 +47,10 @@ class _LoginState extends State { return null; } - Future _resetPassword(String name) { - return Future.delayed(Duration.zero).then((_) { - return 'Diese Funktion steht nicht zur Verfügung!'; - }); - } + Future _resetPassword(String name) => Future.delayed(Duration.zero).then((_) => 'Diese Funktion steht nicht zur Verfügung!'); @override - Widget build(BuildContext context) { - return FlutterLogin( + Widget build(BuildContext context) => FlutterLogin( logo: Image.asset('assets/logo/icon.png').image, userValidator: _checkInput, @@ -109,5 +102,4 @@ class _LoginState extends State { userType: LoginUserType.name, ); - } } diff --git a/lib/view/pages/files/fileElement.dart b/lib/view/pages/files/fileElement.dart index 02c1e09..478da24 100644 --- a/lib/view/pages/files/fileElement.dart +++ b/lib/view/pages/files/fileElement.dart @@ -26,14 +26,14 @@ class FileElement extends StatefulWidget { const FileElement(this.file, this.path, this.refetch, {super.key}); static Future download(BuildContext context, String remotePath, String name, Function(double) onProgress, Function(OpenResult) onDone) async { - Directory paths = await getTemporaryDirectory(); + var paths = await getTemporaryDirectory(); var encodedPath = Uri.encodeComponent(remotePath); encodedPath = encodedPath.replaceAll('%2F', '/'); - String local = paths.path + Platform.pathSeparator + name; + var local = paths.path + Platform.pathSeparator + name; - DownloaderUtils options = DownloaderUtils( + var options = DownloaderUtils( progressCallback: (current, total) { final progress = (current / total) * 100; onProgress(progress); @@ -52,7 +52,7 @@ class FileElement extends StatefulWidget { ); return await Flowder.download( - "${await WebdavApi.webdavConnectString}$encodedPath", + '${await WebdavApi.webdavConnectString}$encodedPath', options, ); } @@ -89,8 +89,7 @@ class _FileElementState extends State { } @override - Widget build(BuildContext context) { - return ListTile( + Widget build(BuildContext context) => ListTile( leading: CenteredLeading( Icon(widget.file.isDirectory ? Icons.folder : Icons.description_outlined) ), @@ -100,9 +99,7 @@ class _FileElementState extends State { onTap: () { if(widget.file.isDirectory) { Navigator.of(context).push(MaterialPageRoute( - builder: (context) { - return Files(widget.path.toList()..add(widget.file.name)); - }, + builder: (context) => Files(widget.path.toList()..add(widget.file.name)), )); } else { if(EndpointData().getEndpointMode() == EndpointMode.stage) { @@ -141,12 +138,10 @@ class _FileElementState extends State { setState(() => percent = progress); }, (result) { if(result.type != ResultType.done) { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( title: const Text('Download'), content: Text(result.message), - ); - }); + )); } setState(() { @@ -158,8 +153,7 @@ class _FileElementState extends State { } }, onLongPress: () { - showDialog(context: context, builder: (context) { - return SimpleDialog( + showDialog(context: context, builder: (context) => SimpleDialog( children: [ ListTile( leading: const Icon(Icons.delete_outline), @@ -189,9 +183,7 @@ class _FileElementState extends State { ), ), ], - ); - }); + )); }, ); - } } diff --git a/lib/view/pages/files/fileUploadDialog.dart b/lib/view/pages/files/fileUploadDialog.dart index 6322ee5..0708cdf 100644 --- a/lib/view/pages/files/fileUploadDialog.dart +++ b/lib/view/pages/files/fileUploadDialog.dart @@ -32,18 +32,18 @@ class _FileUploadDialogState extends State { TextEditingController fileNameController = TextEditingController(); - void upload({bool override = false}) async { + Future upload({bool override = false}) async { setState(() { state = FileUploadState.upload; }); - WebDavClient webdavClient = await WebdavApi.webdav; + var webdavClient = await WebdavApi.webdav; if(!override) { setState(() { state = FileUploadState.checkConflict; }); - List result = (await webdavClient.propfind(PathUri.parse(widget.remotePath.join('/')))).responses; + var result = (await webdavClient.propfind(PathUri.parse(widget.remotePath.join('/')))).responses; if(result.any((element) => element.href!.endsWith('/$targetFileName'))) { setState(() { state = FileUploadState.conflict; @@ -56,7 +56,7 @@ class _FileUploadDialogState extends State { } } - Future uploadTask = webdavClient.putFile(File(widget.localPath), FileStat.statSync(widget.localPath), PathUri.parse(fullRemotePath)); // TODO use onProgress from putFile + var uploadTask = webdavClient.putFile(File(widget.localPath), FileStat.statSync(widget.localPath), PathUri.parse(fullRemotePath)); // TODO use onProgress from putFile uploadTask.then(Future.value).catchError((e) { setState(() { state = FileUploadState.error; @@ -230,4 +230,4 @@ enum FileUploadState { upload, done, error -} \ No newline at end of file +} diff --git a/lib/view/pages/files/files.dart b/lib/view/pages/files/files.dart index b377cbf..28f991f 100644 --- a/lib/view/pages/files/files.dart +++ b/lib/view/pages/files/files.dart @@ -64,9 +64,7 @@ class SortOptions { ) }; - static BetterSortOption getOption(SortOption option) { - return options[option]!; - } + static BetterSortOption getOption(SortOption option) => options[option]!; } class _FilesState extends State { @@ -101,7 +99,7 @@ class _FilesState extends State { @override Widget build(BuildContext context) { - List files = data?.sortBy( + var files = data?.sortBy( sortOption: currentSort, foldersToTop: Provider.of(context).val().fileSettings.sortFoldersToTop, reversed: currentSortDirection @@ -119,8 +117,7 @@ class _FilesState extends State { // ), PopupMenuButton( icon: Icon(currentSortDirection ? Icons.text_rotate_up : Icons.text_rotation_down), - itemBuilder: (context) { - return [true, false].map((e) => PopupMenuItem( + itemBuilder: (context) => [true, false].map((e) => PopupMenuItem( value: e, enabled: e != currentSortDirection, child: Row( @@ -130,8 +127,7 @@ class _FilesState extends State { Text(e ? 'Aufsteigend' : 'Absteigend') ], ) - )).toList(); - }, + )).toList(), onSelected: (e) { setState(() { currentSortDirection = e; @@ -141,8 +137,7 @@ class _FilesState extends State { ), PopupMenuButton( icon: const Icon(Icons.sort), - itemBuilder: (context) { - return SortOptions.options.keys.map((key) => PopupMenuItem( + itemBuilder: (context) => SortOptions.options.keys.map((key) => PopupMenuItem( value: key, enabled: key != currentSort, child: Row( @@ -152,8 +147,7 @@ class _FilesState extends State { Text(SortOptions.getOption(key).displayName) ], ) - )).toList(); - }, + )).toList(), onSelected: (e) { setState(() { currentSort = e; @@ -167,8 +161,7 @@ class _FilesState extends State { heroTag: 'uploadFile', backgroundColor: Theme.of(context).primaryColor, onPressed: () { - showDialog(context: context, builder: (context) { - return SimpleDialog( + showDialog(context: context, builder: (context) => SimpleDialog( children: [ ListTile( leading: const Icon(Icons.create_new_folder_outlined), @@ -224,8 +217,7 @@ class _FilesState extends State { ), ), ], - ); - }); + )); }, child: const Icon(Icons.add), ), @@ -239,7 +231,7 @@ class _FilesState extends State { padding: EdgeInsets.zero, itemCount: files.length, itemBuilder: (context, index) { - CacheableFile file = files.toList()[index]; + var file = files.toList()[index]; return FileElement(file, widget.path, _query); }, ), @@ -248,7 +240,7 @@ class _FilesState extends State { ); } - void mediaUpload(String? path) async { + Future mediaUpload(String? path) async { context.loaderOverlay.hide(); if(path == null) { diff --git a/lib/view/pages/more/feedback/feedbackDialog.dart b/lib/view/pages/more/feedback/feedbackDialog.dart index 2e0a3e7..b155fa8 100644 --- a/lib/view/pages/more/feedback/feedbackDialog.dart +++ b/lib/view/pages/more/feedback/feedbackDialog.dart @@ -44,8 +44,7 @@ class _FeedbackDialogState extends State { } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Feedback'), ), @@ -125,7 +124,7 @@ class _FeedbackDialogState extends State { onPressed: () async { context.loaderOverlay.show(); var imageData = await (await FilePick.galleryPick())?.readAsBytes(); - context.loaderOverlay.hide(); + if(context.mounted) context.loaderOverlay.hide(); setState(() { _image = imageData; }); @@ -170,6 +169,4 @@ class _FeedbackDialogState extends State { ], ), ); - - } } diff --git a/lib/view/pages/more/holidays/holidays.dart b/lib/view/pages/more/holidays/holidays.dart index 477915a..6d5df2a 100644 --- a/lib/view/pages/more/holidays/holidays.dart +++ b/lib/view/pages/more/holidays/holidays.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; import 'package:provider/provider.dart'; -import '../../../../api/holidays/getHolidaysResponse.dart'; import '../../../../model/holidays/holidaysProps.dart'; import '../../../../storage/base/settingsProvider.dart'; import '../../../../widget/centeredLeading.dart'; @@ -22,9 +21,7 @@ class Holidays extends StatefulWidget { } extension StringExtension on String { - String capitalize() { - return "${this[0].toUpperCase()}${substring(1).toLowerCase()}"; - } + String capitalize() => '${this[0].toUpperCase()}${substring(1).toLowerCase()}'; } class _HolidaysState extends State { @@ -41,13 +38,10 @@ class _HolidaysState extends State { super.initState(); } - String parseString(String enDate) { - return Jiffy.parse(enDate).format(pattern: 'dd.MM.yyyy'); - } + String parseString(String enDate) => Jiffy.parse(enDate).format(pattern: 'dd.MM.yyyy'); void showDisclaimer() { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( title: const Text('Richtigkeit und Bereitstellung der Daten'), content: Column( mainAxisSize: MainAxisSize.min, @@ -70,13 +64,11 @@ class _HolidaysState extends State { TextButton(child: const Text('ferien-api.de besuchen'), onPressed: () => ConfirmDialog.openBrowser(context, 'https://ferien-api.de/')), TextButton(child: const Text('Okay'), onPressed: () => Navigator.of(context).pop()), ], - ); - }); + )); } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Schulferien in Hessen'), actions: [ @@ -87,8 +79,7 @@ class _HolidaysState extends State { PopupMenuButton( initialValue: settings.val().holidaysSettings.showPastEvents, icon: const Icon(Icons.manage_history_outlined), - itemBuilder: (context) { - return [true, false].map((e) => PopupMenuItem( + itemBuilder: (context) => [true, false].map((e) => PopupMenuItem( value: e, enabled: e != showPastEvents, child: Row( @@ -98,8 +89,7 @@ class _HolidaysState extends State { Text(e ? 'Alle anzeigen' : 'Nur zukünftige anzeigen') ], ) - )).toList(); - }, + )).toList(), onSelected: (e) { setState(() { showPastEvents = e; @@ -112,7 +102,7 @@ class _HolidaysState extends State { body: Consumer(builder: (context, value, child) { if(value.primaryLoading()) return const LoadingSpinner(); - List holidays = value.getHolidaysResponse.data; + var holidays = value.getHolidaysResponse.data; if(!showPastEvents) holidays = holidays.where((element) => DateTime.parse(element.end).isAfter(DateTime.now())).toList(); if(holidays.isEmpty) return const PlaceholderView(icon: Icons.search_off, text: 'Es wurden keine Ferieneinträge gefunden!'); @@ -120,8 +110,8 @@ class _HolidaysState extends State { return ListView.builder( itemCount: holidays.length, itemBuilder: (context, index) { - GetHolidaysResponseObject holiday = holidays[index]; - String holidayType = holiday.name.split(' ').first.capitalize(); + var holiday = holidays[index]; + var holidayType = holiday.name.split(' ').first.capitalize(); return ListTile( leading: const CenteredLeading(Icon(Icons.calendar_month)), title: Text('$holidayType ab ${parseString(holiday.start)}'), @@ -164,5 +154,4 @@ class _HolidaysState extends State { }, ) ); - } } diff --git a/lib/view/pages/more/message/message.dart b/lib/view/pages/more/message/message.dart index 3d12f3f..d9be17f 100644 --- a/lib/view/pages/more/message/message.dart +++ b/lib/view/pages/more/message/message.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../../../../api/mhsl/message/getMessages/getMessagesResponse.dart'; import '../../../../model/message/messageProps.dart'; import '../../../../widget/loadingSpinner.dart'; import 'messageView.dart'; @@ -24,8 +23,7 @@ class _MessageState extends State { } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Marianum Message'), ), @@ -36,7 +34,7 @@ class _MessageState extends State { child: ListView.builder( itemCount: value.getMessagesResponse.messages.length, itemBuilder: (context, index) { - GetMessagesResponseObject message = value.getMessagesResponse.messages.toList()[index]; + var message = value.getMessagesResponse.messages.toList()[index]; return ListTile( leading: const Column( mainAxisAlignment: MainAxisAlignment.center, @@ -58,5 +56,4 @@ class _MessageState extends State { ); }), ); - } } diff --git a/lib/view/pages/more/message/messageView.dart b/lib/view/pages/more/message/messageView.dart index 63b25fc..791a2ed 100644 --- a/lib/view/pages/more/message/messageView.dart +++ b/lib/view/pages/more/message/messageView.dart @@ -17,8 +17,7 @@ class MessageView extends StatefulWidget { class _MessageViewState extends State { @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: Text(widget.message.name), ), @@ -27,8 +26,7 @@ class _MessageViewState extends State { enableHyperlinkNavigation: true, onDocumentLoadFailed: (PdfDocumentLoadFailedDetails e) { Navigator.of(context).pop(); - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( title: const Text('Fehler beim öffnen'), content: Text("Dokument '${widget.message.name}' konnte nicht geladen werden:\n${e.description}"), actions: [ @@ -36,8 +34,7 @@ class _MessageViewState extends State { Navigator.of(context).pop(); }, child: const Text('Ok')) ], - ); - }); + )); }, onHyperlinkClicked: (PdfHyperlinkClickedDetails e) { showDialog( @@ -52,5 +49,4 @@ class _MessageViewState extends State { }, ), ); - } } diff --git a/lib/view/pages/more/roomplan/roomplan.dart b/lib/view/pages/more/roomplan/roomplan.dart index 09f365f..edabc5e 100644 --- a/lib/view/pages/more/roomplan/roomplan.dart +++ b/lib/view/pages/more/roomplan/roomplan.dart @@ -5,8 +5,7 @@ class Roomplan extends StatelessWidget { const Roomplan({super.key}); @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Raumplan'), ), @@ -17,5 +16,4 @@ class Roomplan extends StatelessWidget { backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.background), ), ); - } } diff --git a/lib/view/pages/more/share/appSharePlatformView.dart b/lib/view/pages/more/share/appSharePlatformView.dart index 1789312..b25d7c1 100644 --- a/lib/view/pages/more/share/appSharePlatformView.dart +++ b/lib/view/pages/more/share/appSharePlatformView.dart @@ -8,7 +8,7 @@ class AppSharePlatformView extends StatelessWidget { @override Widget build(BuildContext context) { - Color foregroundColor = Theme.of(context).colorScheme.onBackground; + var foregroundColor = Theme.of(context).colorScheme.onBackground; return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/view/pages/more/share/qrShareView.dart b/lib/view/pages/more/share/qrShareView.dart index 6e52b54..b945224 100644 --- a/lib/view/pages/more/share/qrShareView.dart +++ b/lib/view/pages/more/share/qrShareView.dart @@ -11,8 +11,7 @@ class QrShareView extends StatefulWidget { class _QrShareViewState extends State { @override - Widget build(BuildContext context) { - return DefaultTabController( + Widget build(BuildContext context) => DefaultTabController( length: 2, child: Scaffold( appBar: AppBar( @@ -32,5 +31,4 @@ class _QrShareViewState extends State { ), ), ); - } } diff --git a/lib/view/pages/more/share/selectShareTypeDialog.dart b/lib/view/pages/more/share/selectShareTypeDialog.dart index a10097d..0b768bc 100644 --- a/lib/view/pages/more/share/selectShareTypeDialog.dart +++ b/lib/view/pages/more/share/selectShareTypeDialog.dart @@ -8,8 +8,7 @@ class SelectShareTypeDialog extends StatelessWidget { const SelectShareTypeDialog({super.key}); @override - Widget build(BuildContext context) { - return SimpleDialog( + Widget build(BuildContext context) => SimpleDialog( children: [ ListTile( leading: const Icon(Icons.qr_code_2_outlined), @@ -36,5 +35,4 @@ class SelectShareTypeDialog extends StatelessWidget { ) ], ); - } } diff --git a/lib/view/pages/overhang.dart b/lib/view/pages/overhang.dart index 4ed82c0..0fbe65a 100644 --- a/lib/view/pages/overhang.dart +++ b/lib/view/pages/overhang.dart @@ -21,9 +21,7 @@ class Overhang extends StatelessWidget { const Overhang({super.key}); @override - Widget build(BuildContext context) { - - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Mehr'), actions: [ @@ -79,5 +77,4 @@ class Overhang extends StatelessWidget { ], ), ); - } } diff --git a/lib/view/pages/talk/chatDetails/chatInfo.dart b/lib/view/pages/talk/chatDetails/chatInfo.dart index 35ebb7a..2460704 100644 --- a/lib/view/pages/talk/chatDetails/chatInfo.dart +++ b/lib/view/pages/talk/chatDetails/chatInfo.dart @@ -35,7 +35,7 @@ class _ChatInfoState extends State { @override Widget build(BuildContext context) { - bool isGroup = widget.room.type != GetRoomResponseObjectConversationType.oneToOne; + var isGroup = widget.room.type != GetRoomResponseObjectConversationType.oneToOne; return Scaffold( appBar: AppBar( title: Text(widget.room.displayName), diff --git a/lib/view/pages/talk/chatDetails/participants/participantsListView.dart b/lib/view/pages/talk/chatDetails/participants/participantsListView.dart index a96d023..2bc863b 100644 --- a/lib/view/pages/talk/chatDetails/participants/participantsListView.dart +++ b/lib/view/pages/talk/chatDetails/participants/participantsListView.dart @@ -13,20 +13,16 @@ class ParticipantsListView extends StatefulWidget { class _ParticipantsListViewState extends State { @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Teilnehmende'), ), body: ListView( - children: widget.participantsResponse.data.map((participant) { - return ListTile( + children: widget.participantsResponse.data.map((participant) => ListTile( leading: UserAvatar(id: participant.actorId), title: Text(participant.displayName), subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null, - ); - }).toList(), + )).toList(), ), ); - } } diff --git a/lib/view/pages/talk/chatList.dart b/lib/view/pages/talk/chatList.dart index bf1cd9d..905a11d 100644 --- a/lib/view/pages/talk/chatList.dart +++ b/lib/view/pages/talk/chatList.dart @@ -119,14 +119,14 @@ class _ChatListState extends State { if(data.primaryLoading()) return const LoadingSpinner(); latestData = data; - List chats = []; + var chats = []; for (var chatRoom in data.getRoomsResponse.sortBy( lastActivity: true, favoritesToTop: Provider.of(context).val().talkSettings.sortFavoritesToTop, unreadToTop: Provider.of(context).val().talkSettings.sortUnreadToTop, ) ) { - bool hasDraft = settings.val().talkSettings.drafts.containsKey(chatRoom.token); + var hasDraft = settings.val().talkSettings.drafts.containsKey(chatRoom.token); chats.add(ChatTile(data: chatRoom, query: _query, hasDraft: hasDraft)); } @@ -146,4 +146,4 @@ class _ChatListState extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index 92fe293..c66725f 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -40,19 +40,18 @@ class _ChatViewState extends State { } @override - Widget build(BuildContext context) { - return Consumer( + Widget build(BuildContext context) => Consumer( builder: (context, data, child) { - List messages = List.empty(growable: true); + var messages = List.empty(growable: true); if(!data.primaryLoading()) { - DateTime lastDate = DateTime.now(); + var lastDate = DateTime.now(); data.getChatResponse.sortByTimestamp().forEach((element) { - DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(element.timestamp * 1000); + var elementDate = DateTime.fromMillisecondsSinceEpoch(element.timestamp * 1000); if(element.systemMessage.contains('reaction')) return; - int commonRead = int.parse(data.getChatResponse.headers?['x-chat-last-common-read'] ?? '0'); + var commonRead = int.parse(data.getChatResponse.headers?['x-chat-last-common-read'] ?? '0'); if(!elementDate.isSameDay(lastDate)) { lastDate = elementDate; @@ -140,5 +139,4 @@ class _ChatViewState extends State { ); }, ); - } } diff --git a/lib/view/pages/talk/components/chatBubble.dart b/lib/view/pages/talk/components/chatBubble.dart index 0323117..6e56dc7 100644 --- a/lib/view/pages/talk/components/chatBubble.dart +++ b/lib/view/pages/talk/components/chatBubble.dart @@ -51,15 +51,13 @@ class ChatBubble extends StatefulWidget { class _ChatBubbleState extends State { - BubbleStyle getSystemStyle() { - return BubbleStyle( + BubbleStyle getSystemStyle() => BubbleStyle( color: AppTheme.isDarkMode(context) ? const Color(0xff182229) : Colors.white, borderWidth: 1, elevation: 2, margin: const BubbleEdges.only(bottom: 20, top: 10), alignment: Alignment.center, ); - } BubbleStyle getRemoteStyle(bool seamless) { var color = AppTheme.isDarkMode(context) ? const Color(0xff202c33) : Colors.white; @@ -105,17 +103,17 @@ class _ChatBubbleState extends State { @override Widget build(BuildContext context) { message = ChatMessage(originalMessage: widget.bubbleData.message, originalData: widget.bubbleData.messageParameters); - bool showActorDisplayName = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment && widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne; - bool showBubbleTime = widget.bubbleData.messageType != GetRoomResponseObjectMessageType.system; + var showActorDisplayName = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment && widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne; + var showBubbleTime = widget.bubbleData.messageType != GetRoomResponseObjectMessageType.system; - Text actorText = Text( + var actorText = Text( widget.bubbleData.actorDisplayName, textAlign: TextAlign.start, overflow: TextOverflow.ellipsis, style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold), ); - Text timeText = Text( + var timeText = Text( Jiffy.parseFromMillisecondsSinceEpoch(widget.bubbleData.timestamp * 1000).format(pattern: 'HH:mm'), textAlign: TextAlign.end, style: TextStyle(color: widget.timeIconColor, fontSize: widget.timeIconSize), @@ -186,8 +184,8 @@ class _ChatBubbleState extends State { ), onLongPress: () { showDialog(context: context, builder: (context) { - List commonReactions = ['👍', '👎', '😆', '❤️', '👀']; - bool canReact = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment; + var commonReactions = ['👍', '👎', '😆', '❤️', '👀']; + var canReact = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment; return SimpleDialog( children: [ Visibility( @@ -217,8 +215,7 @@ class _ChatBubbleState extends State { ), IconButton( onPressed: () { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( contentPadding: const EdgeInsets.all(15), titlePadding: const EdgeInsets.only(left: 6, top: 15), title: Row( @@ -278,8 +275,7 @@ class _ChatBubbleState extends State { ], ), ), - ); - }); + )); }, style: IconButton.styleFrom( padding: EdgeInsets.zero, @@ -350,8 +346,7 @@ class _ChatBubbleState extends State { if(message.file == null) return; if(downloadProgress > 0) { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( title: const Text('Download abbrechen?'), content: const Text('Möchtest du den Download abbrechen?'), actions: [ @@ -369,8 +364,7 @@ class _ChatBubbleState extends State { }); }, child: const Text('Ja, Abbrechen')) ], - ); - }); + )); return; } @@ -388,11 +382,9 @@ class _ChatBubbleState extends State { }); if(result.type != ResultType.done) { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( content: Text(result.message), - ); - }); + )); } }); }, @@ -408,7 +400,7 @@ class _ChatBubbleState extends State { alignment: widget.isSender ? WrapAlignment.end : WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, children: widget.bubbleData.reactions?.entries.map((e) { - bool hasSelfReacted = widget.bubbleData.reactionsSelf?.contains(e.key) ?? false; + var hasSelfReacted = widget.bubbleData.reactionsSelf?.contains(e.key) ?? false; return Container( margin: const EdgeInsets.only(right: 2.5, left: 2.5), child: ActionChip( diff --git a/lib/view/pages/talk/components/chatMessage.dart b/lib/view/pages/talk/components/chatMessage.dart index 4b72500..48bcaf9 100644 --- a/lib/view/pages/talk/components/chatMessage.dart +++ b/lib/view/pages/talk/components/chatMessage.dart @@ -37,8 +37,7 @@ class ChatMessage { } return CachedNetworkImage( - errorWidget: (context, url, error) { - return Padding(padding: const EdgeInsets.only(top: 10), child: Row( + errorWidget: (context, url, error) => Padding(padding: const EdgeInsets.only(top: 10), child: Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -47,12 +46,9 @@ class ChatMessage { Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), const SizedBox(width: 10), ], - )); - }, + )), alignment: Alignment.center, - placeholder: (context, url) { - return const Padding(padding: EdgeInsets.all(10), child: CircularProgressIndicator()); - }, + placeholder: (context, url) => const Padding(padding: EdgeInsets.all(10), child: CircularProgressIndicator()), fadeInDuration: Duration.zero, fadeOutDuration: Duration.zero, errorListener: (value) {}, @@ -60,9 +56,9 @@ class ChatMessage { ); } - void onOpen(LinkableElement link) async { + Future onOpen(LinkableElement link) async { if(await canLaunchUrlString(link.url)) { await launchUrlString(link.url); } } -} \ No newline at end of file +} diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index 5513d8a..b77928d 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -34,15 +34,15 @@ class _ChatTextfieldState extends State { Provider.of(context, listen: false).run(); } - void mediaUpload(String? path) async { + Future mediaUpload(String? path) async { context.loaderOverlay.hide(); if(path == null) { return; } - String filename = "${path.split("/").last.split(".").first}-${const Uuid().v4()}.${path.split(".").last}"; - String shareFolder = 'MarianumMobile'; + var filename = "${path.split("/").last.split(".").first}-${const Uuid().v4()}.${path.split(".").last}"; + var shareFolder = 'MarianumMobile'; WebdavApi.webdav.then((webdav) { webdav.mkcol(PathUri.parse('/$shareFolder')); }); @@ -91,8 +91,7 @@ class _ChatTextfieldState extends State { children: [ GestureDetector( onTap: (){ - showDialog(context: context, builder: (context) { - return SimpleDialog( + showDialog(context: context, builder: (context) => SimpleDialog( children: [ ListTile( leading: const Icon(Icons.file_open), @@ -118,8 +117,7 @@ class _ChatTextfieldState extends State { ), ), ], - ); - }); + )); }, child: Material( elevation: 5, diff --git a/lib/view/pages/talk/components/chatTile.dart b/lib/view/pages/talk/components/chatTile.dart index e1e4dba..0eee6d8 100644 --- a/lib/view/pages/talk/components/chatTile.dart +++ b/lib/view/pages/talk/components/chatTile.dart @@ -40,7 +40,7 @@ class _ChatTileState extends State { username = value.getString('username')! }); - bool isGroup = widget.data.type != GetRoomResponseObjectConversationType.oneToOne; + var isGroup = widget.data.type != GetRoomResponseObjectConversationType.oneToOne; circleAvatar = UserAvatar(id: isGroup ? widget.data.token : widget.data.name, isGroup: isGroup); } @@ -56,10 +56,7 @@ class _ChatTileState extends State { @override - Widget build(BuildContext context) { - - return Consumer(builder: (context, chatData, child) { - return ListTile( + Widget build(BuildContext context) => Consumer(builder: (context, chatData, child) => ListTile( style: ListTileStyle.list, tileColor: chatData.currentToken() == widget.data.token && TalkNavigator.isSecondaryVisible(context) ? Theme.of(context).primaryColor.withAlpha(100) @@ -120,7 +117,7 @@ class _ChatTileState extends State { ), onTap: () async { setCurrentAsRead(); - ChatView view = ChatView(room: widget.data, selfId: username, avatar: circleAvatar); + var view = ChatView(room: widget.data, selfId: username, avatar: circleAvatar); TalkNavigator.pushSplitView(context, view, overrideToSingleSubScreen: true); Provider.of(context, listen: false).setQueryToken(widget.data.token); }, @@ -185,7 +182,5 @@ class _ChatTileState extends State { ], )); }, - ); - }); - } + )); } diff --git a/lib/view/pages/talk/components/splitViewPlaceholder.dart b/lib/view/pages/talk/components/splitViewPlaceholder.dart index 29d8473..d5c4030 100644 --- a/lib/view/pages/talk/components/splitViewPlaceholder.dart +++ b/lib/view/pages/talk/components/splitViewPlaceholder.dart @@ -6,8 +6,7 @@ class SplitViewPlaceholder extends StatelessWidget { const SplitViewPlaceholder({super.key}); @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar(), body: Center( child: Column( @@ -25,5 +24,4 @@ class SplitViewPlaceholder extends StatelessWidget { ), ) ); - } } diff --git a/lib/view/pages/talk/joinChat.dart b/lib/view/pages/talk/joinChat.dart index f629ff9..e51815a 100644 --- a/lib/view/pages/talk/joinChat.dart +++ b/lib/view/pages/talk/joinChat.dart @@ -11,8 +11,7 @@ class JoinChat extends SearchDelegate { CancelableOperation? future; @override - List? buildActions(BuildContext context) { - return [ + List? buildActions(BuildContext context) => [ if(future != null && query.isNotEmpty) FutureBuilder( future: future!.value, builder: (context, snapshot) { @@ -35,12 +34,9 @@ class JoinChat extends SearchDelegate { ), if(query.isNotEmpty) IconButton(onPressed: () => query = '', icon: const Icon(Icons.delete)), ]; - } @override - Widget? buildLeading(BuildContext context) { - return null; - } + Widget? buildLeading(BuildContext context) => null; @override Widget buildResults(BuildContext context) { @@ -61,8 +57,8 @@ class JoinChat extends SearchDelegate { return ListView.builder( itemCount: snapshot.data!.data.length, itemBuilder: (context, index) { - AutocompleteResponseObject object = snapshot.data!.data[index]; - CircleAvatar circleAvatar = CircleAvatar( + var object = snapshot.data!.data[index]; + var circleAvatar = CircleAvatar( foregroundImage: Image.network('https://${EndpointData().nextcloud().full()}/avatar/${object.id}/128').image, backgroundColor: Theme.of(context).primaryColor, foregroundColor: Colors.white, @@ -89,8 +85,6 @@ class JoinChat extends SearchDelegate { } @override - Widget buildSuggestions(BuildContext context) { - return buildResults(context); - } + Widget buildSuggestions(BuildContext context) => buildResults(context); -} \ No newline at end of file +} diff --git a/lib/view/pages/talk/messageReactions.dart b/lib/view/pages/talk/messageReactions.dart index 592ef29..1ab77ca 100644 --- a/lib/view/pages/talk/messageReactions.dart +++ b/lib/view/pages/talk/messageReactions.dart @@ -30,8 +30,7 @@ class _MessageReactionsState extends State { } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Reaktionen'), ), @@ -42,8 +41,7 @@ class _MessageReactionsState extends State { if(snapshot.data == null) return const PlaceholderView(icon: Icons.search_off_outlined, text: 'Keine Reaktionen gefunden!'); return ListView( children: [ - ...snapshot.data!.data.entries.map((entry) { - return ExpansionTile( + ...snapshot.data!.data.entries.map((entry) => ExpansionTile( textColor: Theme.of(context).colorScheme.onSurface, collapsedTextColor: Theme.of(context).colorScheme.onSurface, iconColor: Theme.of(context).colorScheme.onSurface, @@ -53,7 +51,7 @@ class _MessageReactionsState extends State { leading: CenteredLeading(Text(entry.key)), title: Text('${entry.value.length} mal reagiert'), children: entry.value.map((e) { - bool isSelf = AccountData().getUsername() == e.actorId; + var isSelf = AccountData().getUsername() == e.actorId; return ListTile( leading: UserAvatar(id: e.actorId, isGroup: false), title: Text(e.actorDisplayName), @@ -71,12 +69,10 @@ class _MessageReactionsState extends State { ), ); }).toList(), - ); - }) + )) ], ); }, ), ); - } } diff --git a/lib/view/pages/talk/searchChat.dart b/lib/view/pages/talk/searchChat.dart index 39bdd56..3f39738 100644 --- a/lib/view/pages/talk/searchChat.dart +++ b/lib/view/pages/talk/searchChat.dart @@ -9,16 +9,12 @@ class SearchChat extends SearchDelegate { SearchChat(this.chats); @override - List? buildActions(BuildContext context) { - return [ + List? buildActions(BuildContext context) => [ if(query.isNotEmpty) IconButton(onPressed: () => query = '', icon: const Icon(Icons.delete)), ]; - } @override - Widget? buildLeading(BuildContext context) { - return null; - } + Widget? buildLeading(BuildContext context) => null; @override Widget buildResults(BuildContext context) { @@ -35,7 +31,5 @@ class SearchChat extends SearchDelegate { } @override - Widget buildSuggestions(BuildContext context) { - return buildResults(context); - } -} \ No newline at end of file + Widget buildSuggestions(BuildContext context) => buildResults(context); +} diff --git a/lib/view/pages/talk/talkNavigator.dart b/lib/view/pages/talk/talkNavigator.dart index e882c98..18c33ab 100644 --- a/lib/view/pages/talk/talkNavigator.dart +++ b/lib/view/pages/talk/talkNavigator.dart @@ -9,10 +9,10 @@ class TalkNavigator { static void pushSplitView(BuildContext context, Widget view, {bool overrideToSingleSubScreen = false}) { if(isSecondaryVisible(context)) { - SplitViewState splitView = SplitView.of(context); + var splitView = SplitView.of(context); overrideToSingleSubScreen ? splitView.setSecondary(view) : splitView.push(view); } else { pushScreen(context, screen: view, withNavBar: false); } } -} \ No newline at end of file +} diff --git a/lib/view/pages/timetable/CrossPainter.dart b/lib/view/pages/timetable/CrossPainter.dart index 49c2418..99e4431 100644 --- a/lib/view/pages/timetable/CrossPainter.dart +++ b/lib/view/pages/timetable/CrossPainter.dart @@ -13,4 +13,4 @@ class CrossPainter extends CustomPainter { @override bool shouldRepaint(CrossPainter oldDelegate) => false; -} \ No newline at end of file +} diff --git a/lib/view/pages/timetable/appointmentDetails.dart b/lib/view/pages/timetable/appointmentDetails.dart index 43f9663..9adb671 100644 --- a/lib/view/pages/timetable/appointmentDetails.dart +++ b/lib/view/pages/timetable/appointmentDetails.dart @@ -33,7 +33,7 @@ class AppointmentDetails { } static void show(BuildContext context, TimetableProps webuntisData, Appointment appointment) { - (appointment.id as ArbitraryAppointment).handlers( + (appointment.id! as ArbitraryAppointment).handlers( (webuntis) => _webuntis(context, webuntisData, appointment, webuntis), (customData) => _custom(context, webuntisData, customData) ); @@ -76,21 +76,18 @@ class AppointmentDetails { _bottomSheet( context, - (context) { - return Center( + (context) => Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text("${_getEventPrefix(timetableData.code)}${subject.alternateName}", textAlign: TextAlign.center, style: const TextStyle(fontSize: 25), overflow: TextOverflow.ellipsis), + Text('${_getEventPrefix(timetableData.code)}${subject.alternateName}', textAlign: TextAlign.center, style: const TextStyle(fontSize: 25), overflow: TextOverflow.ellipsis), Text(subject.longName), Text("${Jiffy.parseFromDateTime(appointment.startTime).format(pattern: "HH:mm")} - ${Jiffy.parseFromDateTime(appointment.endTime).format(pattern: "HH:mm")}", style: const TextStyle(fontSize: 15)), ], ), - ); - }, + ), - (context) { - return SliverChildListDelegate( + (context) => SliverChildListDelegate( [ const Divider(), ListTile( @@ -132,13 +129,12 @@ class AppointmentDetails { ), DebugTile(context).jsonData(timetableData.toJson()), ], - ); - } + ) ); } static Completer deleteCustomEvent(BuildContext context, CustomTimetableEvent appointment) { - Completer future = Completer(); + var future = Completer(); ConfirmDialog( title: 'Termin löschen', content: "Der ${appointment.rrule.isEmpty ? "Termin" : "Serientermin"} wird unwiederruflich gelöscht.", @@ -160,8 +156,7 @@ class AppointmentDetails { static void _custom(BuildContext context, TimetableProps webuntisData, CustomTimetableEvent appointment) { _bottomSheet( context, - (context) { - return Center( + (context) => Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -169,10 +164,8 @@ class AppointmentDetails { Text("${Jiffy.parseFromDateTime(appointment.startDate).format(pattern: "HH:mm")} - ${Jiffy.parseFromDateTime(appointment.endDate).format(pattern: "HH:mm")}", style: const TextStyle(fontSize: 15)), ], ), - ); - }, - (context) { - return SliverChildListDelegate( + ), + (context) => SliverChildListDelegate( [ const Divider(), Center( @@ -212,7 +205,7 @@ class AppointmentDetails { builder: (context, snapshot) { if(appointment.rrule.isEmpty) return const Text('Keine weiteren vorkomnisse'); if(snapshot.data == null) return const Text('...'); - RecurrenceRule rrule = RecurrenceRule.fromString(appointment.rrule); + var rrule = RecurrenceRule.fromString(appointment.rrule); if(!rrule.canFullyConvertToText) return const Text('Keine genauere Angabe möglich.'); return Text(rrule.toText(l10n: snapshot.data!)); }, @@ -227,8 +220,7 @@ class AppointmentDetails { ), DebugTile(context).jsonData(appointment.toJson()), ] - ); - } + ) ); } -} \ No newline at end of file +} diff --git a/lib/view/pages/timetable/arbitraryAppointment.dart b/lib/view/pages/timetable/arbitraryAppointment.dart index 2dd081b..46c9b1b 100644 --- a/lib/view/pages/timetable/arbitraryAppointment.dart +++ b/lib/view/pages/timetable/arbitraryAppointment.dart @@ -8,16 +8,12 @@ class ArbitraryAppointment { ArbitraryAppointment({this.webuntis, this.custom}); - bool hasWebuntis() { - return webuntis != null; - } + bool hasWebuntis() => webuntis != null; - bool hasCustom() { - return custom != null; - } + bool hasCustom() => custom != null; void handlers(void Function(GetTimetableResponseObject webuntisData) webuntis, void Function(CustomTimetableEvent customData) custom) { if(hasWebuntis()) webuntis(this.webuntis!); if(hasCustom()) custom(this.custom!); } -} \ No newline at end of file +} diff --git a/lib/view/pages/timetable/customTimetableColors.dart b/lib/view/pages/timetable/customTimetableColors.dart index 15d5231..1b65838 100644 --- a/lib/view/pages/timetable/customTimetableColors.dart +++ b/lib/view/pages/timetable/customTimetableColors.dart @@ -29,9 +29,7 @@ class TimetableColors { } } - static Color getColorFromString(String color) { - return getDisplayOptions(CustomTimetableColors.values.firstWhere((element) => element.name == color, orElse: () => TimetableColors.defaultColor)).color; - } + static Color getColorFromString(String color) => getDisplayOptions(CustomTimetableColors.values.firstWhere((element) => element.name == color, orElse: () => TimetableColors.defaultColor)).color; } class ColorModeDisplay { @@ -39,4 +37,4 @@ class ColorModeDisplay { final String displayName; ColorModeDisplay({required this.color, required this.displayName}); -} \ No newline at end of file +} diff --git a/lib/view/pages/timetable/customTimetableEventEditDialog.dart b/lib/view/pages/timetable/customTimetableEventEditDialog.dart index f08aafd..ba21525 100644 --- a/lib/view/pages/timetable/customTimetableEventEditDialog.dart +++ b/lib/view/pages/timetable/customTimetableEventEditDialog.dart @@ -51,8 +51,7 @@ class _AddCustomTimetableEventDialogState extends State AlertDialog( insetPadding: const EdgeInsets.all(20), contentPadding: const EdgeInsets.all(10), title: const Text('Termin hinzufügen'), @@ -89,7 +88,7 @@ class _AddCustomTimetableEventDialogState extends State { @override Widget build(BuildContext context) { - String text = widget.details.region.text!; - Color? color = widget.details.region.color; + var text = widget.details.region.text!; + var color = widget.details.region.color; if (text == 'centerIcon') { return Container( diff --git a/lib/view/pages/timetable/timetable.dart b/lib/view/pages/timetable/timetable.dart index 0475af6..dc5ffe1 100644 --- a/lib/view/pages/timetable/timetable.dart +++ b/lib/view/pages/timetable/timetable.dart @@ -7,8 +7,6 @@ import 'package:provider/provider.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; import '../../../api/webuntis/queries/getHolidays/getHolidaysResponse.dart'; -import '../../../api/webuntis/queries/getRooms/getRoomsResponse.dart'; -import '../../../api/webuntis/queries/getSubjects/getSubjectsResponse.dart'; import '../../../api/webuntis/queries/getTimetable/getTimetableResponse.dart'; import '../../../model/timetable/timetableProps.dart'; import '../../../storage/base/settingsProvider.dart'; @@ -53,9 +51,7 @@ class _TimetableState extends State { } @override - Widget build(BuildContext context) { - - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Stunden & Vertretungsplan'), actions: [ @@ -67,8 +63,7 @@ class _TimetableState extends State { ), PopupMenuButton( icon: const Icon(Icons.edit_calendar_outlined), - itemBuilder: (context) { - return CalendarActions.values.map( + itemBuilder: (context) => CalendarActions.values.map( (e) { String title; Icon icon; @@ -89,8 +84,7 @@ class _TimetableState extends State { ) ); } - ).toList(); - }, + ).toList(), onSelected: (value) { switch(value) { case CalendarActions.addEvent: @@ -125,7 +119,7 @@ class _TimetableState extends State { if(value.primaryLoading()) return const LoadingSpinner(); - GetHolidaysResponse holidays = value.getHolidaysResponse; + var holidays = value.getHolidaysResponse; return RefreshIndicator( child: SfCalendar( @@ -181,7 +175,6 @@ class _TimetableState extends State { }, ), ); - } @override void dispose() { @@ -190,19 +183,18 @@ class _TimetableState extends State { } List _buildSpecialTimeRegions(GetHolidaysResponse holidays) { - DateTime lastMonday = DateTime.now().subtract(const Duration(days: 14)).nextWeekday(DateTime.monday); - DateTime firstBreak = lastMonday.copyWith(hour: 10, minute: 15); - DateTime secondBreak = lastMonday.copyWith(hour: 13, minute: 50); + var lastMonday = DateTime.now().subtract(const Duration(days: 14)).nextWeekday(DateTime.monday); + var firstBreak = lastMonday.copyWith(hour: 10, minute: 15); + var secondBreak = lastMonday.copyWith(hour: 13, minute: 50); - Iterable holidayList = holidays.result.map((holiday) { - DateTime startDay = _parseWebuntisTimestamp(holiday.startDate, 0); - int dayCount = _parseWebuntisTimestamp(holiday.endDate, 0) + var holidayList = holidays.result.map((holiday) { + var startDay = _parseWebuntisTimestamp(holiday.startDate, 0); + var dayCount = _parseWebuntisTimestamp(holiday.endDate, 0) .difference(startDay) .inDays; - List days = List.generate(dayCount, (index) => startDay.add(Duration(days: index))); + var days = List.generate(dayCount, (index) => startDay.add(Duration(days: index))); - return days.map((holidayDay) { - return TimeRegion( + return days.map((holidayDay) => TimeRegion( startTime: holidayDay.copyWith(hour: 07, minute: 55), endTime: holidayDay.copyWith(hour: 16, minute: 30), text: 'holiday:${holiday.name}', @@ -211,13 +203,10 @@ class _TimetableState extends State { .disabledColor .withAlpha(50), iconData: Icons.holiday_village_outlined - ); - }); + )); }).expand((e) => e); - bool isInHoliday(DateTime time) { - return holidayList.any((element) => element.startTime.isSameDay(time)); - } + bool isInHoliday(DateTime time) => holidayList.any((element) => element.startTime.isSameDay(time)); return [ ...holidayList, @@ -246,34 +235,34 @@ class _TimetableState extends State { List _removeDuplicates(TimetableProps data, Duration maxTimeBetweenDouble) { - List timetableList = data.getTimetableResponse.result.toList(); + var timetableList = data.getTimetableResponse.result.toList(); if(timetableList.isEmpty) return timetableList; timetableList.sort((a, b) => _parseWebuntisTimestamp(a.date, a.startTime).compareTo(_parseWebuntisTimestamp(b.date, b.startTime))); - GetTimetableResponseObject previousElement = timetableList.first; + var previousElement = timetableList.first; for(var i = 1; i < timetableList.length; i++) { - GetTimetableResponseObject currentElement = timetableList.elementAt(i); + var currentElement = timetableList.elementAt(i); bool isSameLesson() { - int? currentSubjectId = currentElement.su.firstOrNull?.id; - int? previousSubjectId = previousElement.su.firstOrNull?.id; + var currentSubjectId = currentElement.su.firstOrNull?.id; + var previousSubjectId = previousElement.su.firstOrNull?.id; if(currentSubjectId == null || previousSubjectId == null || currentSubjectId != previousSubjectId) return false; - int? currentRoomId = currentElement.ro.firstOrNull?.id; - int? previousRoomId = previousElement.ro.firstOrNull?.id; + var currentRoomId = currentElement.ro.firstOrNull?.id; + var previousRoomId = previousElement.ro.firstOrNull?.id; if(currentRoomId != previousRoomId) return false; - int? currentTeacherId = currentElement.te.firstOrNull?.id; - int? previousTeacherId = previousElement.te.firstOrNull?.id; + var currentTeacherId = currentElement.te.firstOrNull?.id; + var previousTeacherId = previousElement.te.firstOrNull?.id; if(currentTeacherId != previousTeacherId) return false; - String? currentStatusCode = currentElement.code; - String? previousStatusCode = previousElement.code; + var currentStatusCode = currentElement.code; + var previousStatusCode = previousElement.code; if(currentStatusCode != previousStatusCode) return false; @@ -297,20 +286,20 @@ class _TimetableState extends State { TimetableEvents _buildTableEvents(TimetableProps data) { - List timetableList = data.getTimetableResponse.result.toList(); + var timetableList = data.getTimetableResponse.result.toList(); if(settings.val().timetableSettings.connectDoubleLessons) { timetableList = _removeDuplicates(data, const Duration(minutes: 5)); } - List appointments = timetableList.map((element) { + var appointments = timetableList.map((element) { - GetRoomsResponse rooms = data.getRoomsResponse; - GetSubjectsResponse subjects = data.getSubjectsResponse; + var rooms = data.getRoomsResponse; + var subjects = data.getSubjectsResponse; try { - DateTime startTime = _parseWebuntisTimestamp(element.date, element.startTime); - DateTime endTime = _parseWebuntisTimestamp(element.date, element.endTime); + var startTime = _parseWebuntisTimestamp(element.date, element.startTime); + var endTime = _parseWebuntisTimestamp(element.date, element.endTime); return Appointment( id: ArbitraryAppointment(webuntis: element), startTime: startTime, @@ -324,7 +313,7 @@ class _TimetableState extends State { color: _getEventColor(element, startTime, endTime), ); } catch(e) { - DateTime endTime = _parseWebuntisTimestamp(element.date, element.endTime); + var endTime = _parseWebuntisTimestamp(element.date, element.endTime); return Appointment( id: ArbitraryAppointment(webuntis: element), startTime: _parseWebuntisTimestamp(element.date, element.startTime), @@ -339,8 +328,7 @@ class _TimetableState extends State { } }).toList(); - appointments.addAll(data.getCustomTimetableEventResponse.events.map((customEvent) { - return Appointment( + appointments.addAll(data.getCustomTimetableEventResponse.events.map((customEvent) => Appointment( id: ArbitraryAppointment(custom: customEvent), startTime: customEvent.startDate, endTime: customEvent.endDate, @@ -350,20 +338,19 @@ class _TimetableState extends State { color: TimetableColors.getColorFromString(customEvent.color ?? TimetableColors.defaultColor.name), startTimeZone: '', endTimeZone: '', - ); - })); + ))); return TimetableEvents(appointments); } DateTime _parseWebuntisTimestamp(int date, int time) { - String timeString = time.toString().padLeft(4, '0'); + var timeString = time.toString().padLeft(4, '0'); return DateTime.parse('$date ${timeString.substring(0, 2)}:${timeString.substring(2, 4)}'); } Color _getEventColor(GetTimetableResponseObject webuntisElement, DateTime startTime, DateTime endTime) { // Make element darker, when it already took place - int alpha = endTime.isBefore(DateTime.now()) ? 100 : 255; + var alpha = endTime.isBefore(DateTime.now()) ? 100 : 255; // Cancelled if(webuntisElement.code == 'cancelled') return const Color(0xff000000).withAlpha(alpha); @@ -382,7 +369,7 @@ class _TimetableState extends State { } bool _isCrossedOut(CalendarAppointmentDetails calendarEntry) { - ArbitraryAppointment appointment = calendarEntry.appointments.first.id as ArbitraryAppointment; + var appointment = calendarEntry.appointments.first.id as ArbitraryAppointment; if(appointment.hasWebuntis()) { return appointment.webuntis!.code == 'cancelled'; } diff --git a/lib/view/pages/timetable/timetableEvents.dart b/lib/view/pages/timetable/timetableEvents.dart index 03510fa..8450df7 100644 --- a/lib/view/pages/timetable/timetableEvents.dart +++ b/lib/view/pages/timetable/timetableEvents.dart @@ -5,4 +5,4 @@ class TimetableEvents extends CalendarDataSource { TimetableEvents(List source) { appointments = source; } -} \ No newline at end of file +} diff --git a/lib/view/pages/timetable/viewCustomTimetableEvents.dart b/lib/view/pages/timetable/viewCustomTimetableEvents.dart index 144738b..f089184 100644 --- a/lib/view/pages/timetable/viewCustomTimetableEvents.dart +++ b/lib/view/pages/timetable/viewCustomTimetableEvents.dart @@ -34,8 +34,7 @@ class _ViewCustomTimetableEventsState extends State { } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Eigene Termine'), actions: [ @@ -49,8 +48,7 @@ class _ViewCustomTimetableEventsState extends State { if(value.primaryLoading()) return const LoadingSpinner(); var listView = ListView( - children: value.getCustomTimetableEventResponse.events.map((e) { - return ListTile( + children: value.getCustomTimetableEventResponse.events.map((e) => ListTile( title: Text(e.title), subtitle: Text("${e.rrule.isNotEmpty ? "wiederholdend, " : ""}beginnend ${Jiffy.parseFromDateTime(e.startDate).fromNow()}"), leading: CenteredLeading(Icon(e.rrule.isEmpty ? Icons.event_outlined : Icons.event_repeat_outlined)), @@ -71,8 +69,7 @@ class _ViewCustomTimetableEventsState extends State { ) ], ), - ); - }).toList(), + )).toList(), ); var placeholder = PlaceholderView( @@ -95,5 +92,4 @@ class _ViewCustomTimetableEventsState extends State { ); }), ); - } } diff --git a/lib/view/settings/defaultSettings.dart b/lib/view/settings/defaultSettings.dart index 311da12..20ce747 100644 --- a/lib/view/settings/defaultSettings.dart +++ b/lib/view/settings/defaultSettings.dart @@ -14,8 +14,7 @@ import '../../storage/timetable/timetableSettings.dart'; import '../pages/files/files.dart'; class DefaultSettings { - static Settings get() { - return Settings( + static Settings get() => Settings( appTheme: ThemeMode.system, devToolsEnabled: false, gradeAveragesSettings: GradeAveragesSettings( @@ -53,5 +52,4 @@ class DefaultSettings { showPerformanceOverlay: false, ), ); - } -} \ No newline at end of file +} diff --git a/lib/view/settings/devToolsSettingsDialog.dart b/lib/view/settings/devToolsSettingsDialog.dart index f96d797..c62cdde 100644 --- a/lib/view/settings/devToolsSettingsDialog.dart +++ b/lib/view/settings/devToolsSettingsDialog.dart @@ -19,8 +19,7 @@ class DevToolsSettingsDialog extends StatefulWidget { class _DevToolsSettingsDialogState extends State { @override - Widget build(BuildContext context) { - return Column( + Widget build(BuildContext context) => Column( children: [ ListTile( leading: const CenteredLeading(Icon(Icons.speed_outlined)), @@ -95,14 +94,10 @@ class _DevToolsSettingsDialogState extends State { title: const Text('Cache-storage JSON dump'), subtitle: FutureBuilder( future: const CacheView().totalSize(), - builder: (context, snapshot) { - return Text("etwa ${snapshot.hasError ? "?" : snapshot.hasData ? filesize(snapshot.data) : "..."}\nLange tippen um zu löschen"); - }, + builder: (context, snapshot) => Text("etwa ${snapshot.hasError ? "?" : snapshot.hasData ? filesize(snapshot.data) : "..."}\nLange tippen um zu löschen"), ), onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (context) { - return const CacheView(); - })); + Navigator.push(context, MaterialPageRoute(builder: (context) => const CacheView())); }, onLongPress: () { ConfirmDialog( @@ -116,5 +111,4 @@ class _DevToolsSettingsDialogState extends State { ), ], ); - } } diff --git a/lib/view/settings/privacyInfo.dart b/lib/view/settings/privacyInfo.dart index 65d2286..ceb9ea5 100644 --- a/lib/view/settings/privacyInfo.dart +++ b/lib/view/settings/privacyInfo.dart @@ -11,8 +11,7 @@ class PrivacyInfo { PrivacyInfo({required this.providerText, required this.imprintUrl, required this.privacyUrl}); void showPopup(BuildContext context) { - showDialog(context: context, builder: (context) { - return SimpleDialog( + showDialog(context: context, builder: (context) => SimpleDialog( title: Text('Betreiberinformation | $providerText'), children: [ ListTile( @@ -28,7 +27,6 @@ class PrivacyInfo { onTap: () => ConfirmDialog.openBrowser(context, privacyUrl), ), ], - ); - }); + )); } -} \ No newline at end of file +} diff --git a/lib/view/settings/settings.dart b/lib/view/settings/settings.dart index fc3473a..2d7fcc5 100644 --- a/lib/view/settings/settings.dart +++ b/lib/view/settings/settings.dart @@ -36,10 +36,7 @@ class _SettingsState extends State { bool developerMode = false; @override - Widget build(BuildContext context) { - - return Consumer(builder: (context, settings, child) { - return Scaffold( + Widget build(BuildContext context) => Consumer(builder: (context, settings, child) => Scaffold( appBar: AppBar( title: const Text('Einstellungen'), ), @@ -218,8 +215,7 @@ class _SettingsState extends State { leading: const Icon(Icons.policy_outlined), title: const Text('Impressum & Datenschutz'), onTap: () { - showDialog(context: context, builder: (context) { - return SimpleDialog( + showDialog(context: context, builder: (context) => SimpleDialog( children: [ ListTile( leading: const CenteredLeading(Icon(Icons.school_outlined)), @@ -243,8 +239,7 @@ class _SettingsState extends State { onTap: () => PrivacyInfo(providerText: 'mhsl', imprintUrl: 'https://mhsl.eu/id.html', privacyUrl: 'https://mhsl.eu/datenschutz.html').showPopup(context), ), ], - ); - }); + )); }, trailing: const Icon(Icons.arrow_right), ), @@ -297,7 +292,5 @@ class _SettingsState extends State { ), ], ), - ); - }); - } + )); } diff --git a/lib/widget/about/about.dart b/lib/widget/about/about.dart index ff5b7fb..17003f2 100644 --- a/lib/widget/about/about.dart +++ b/lib/widget/about/about.dart @@ -5,8 +5,7 @@ class About extends StatelessWidget { const About({super.key}); @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Über diese App'), ), @@ -16,5 +15,4 @@ class About extends StatelessWidget { child: Text('Marianum Fulda'), ), ); - } } diff --git a/lib/widget/animatedTime.dart b/lib/widget/animatedTime.dart index 11edc25..ea9991e 100644 --- a/lib/widget/animatedTime.dart +++ b/lib/widget/animatedTime.dart @@ -29,8 +29,7 @@ class _AnimatedTimeState extends State { } @override - Widget build(BuildContext context) { - return Row( + Widget build(BuildContext context) => Row( children: [ const Text('Noch '), buildWidget(current.inDays), @@ -42,10 +41,8 @@ class _AnimatedTimeState extends State { buildWidget(current.inSeconds > 60 ? current.inSeconds - current.inMinutes * 60 : current.inSeconds), ], ); - } - AnimatedDigitWidget buildWidget(int value) { - return AnimatedDigitWidget( + AnimatedDigitWidget buildWidget(int value) => AnimatedDigitWidget( value: value, duration: const Duration(milliseconds: 100), textStyle: TextStyle( @@ -53,7 +50,6 @@ class _AnimatedTimeState extends State { color: Theme.of(context).colorScheme.onSurface, ), ); - } @override void dispose() { diff --git a/lib/widget/centeredLeading.dart b/lib/widget/centeredLeading.dart index e83596b..2993e3f 100644 --- a/lib/widget/centeredLeading.dart +++ b/lib/widget/centeredLeading.dart @@ -5,11 +5,9 @@ class CenteredLeading extends StatelessWidget { const CenteredLeading(this.child, {super.key}); @override - Widget build(BuildContext context) { - return Column( + Widget build(BuildContext context) => Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [child], ); - } } diff --git a/lib/widget/clickableAppBar.dart b/lib/widget/clickableAppBar.dart index b83cb10..a928113 100644 --- a/lib/widget/clickableAppBar.dart +++ b/lib/widget/clickableAppBar.dart @@ -6,9 +6,7 @@ class ClickableAppBar extends StatelessWidget implements PreferredSizeWidget { const ClickableAppBar({required this.onTap, required this.appBar, super.key}); @override - Widget build(BuildContext context) { - return GestureDetector(onTap: onTap, child: appBar); - } + Widget build(BuildContext context) => GestureDetector(onTap: onTap, child: appBar); @override Size get preferredSize => appBar.preferredSize; diff --git a/lib/widget/confirmDialog.dart b/lib/widget/confirmDialog.dart index 75fc153..8e2f01f 100644 --- a/lib/widget/confirmDialog.dart +++ b/lib/widget/confirmDialog.dart @@ -15,8 +15,7 @@ class ConfirmDialog extends StatelessWidget { } @override - Widget build(BuildContext context) { - return AlertDialog( + Widget build(BuildContext context) => AlertDialog( icon: icon != null ? Icon(icon) : null, title: Text(title), content: Text(content), @@ -30,7 +29,6 @@ class ConfirmDialog extends StatelessWidget { }, child: Text(confirmButton)), ], ); - } static void openBrowser(BuildContext context, String url) { showDialog( diff --git a/lib/widget/debug/cacheView.dart b/lib/widget/debug/cacheView.dart index caa34aa..ce4e9ad 100644 --- a/lib/widget/debug/cacheView.dart +++ b/lib/widget/debug/cacheView.dart @@ -39,8 +39,7 @@ class _CacheViewState extends State { } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Lokaler cache'), ), @@ -52,7 +51,7 @@ class _CacheViewState extends State { itemCount: snapshot.data!.length, itemBuilder: (context, index) { Map element = snapshot.data![snapshot.data!.keys.elementAt(index)]; - String filename = snapshot.data!.keys.elementAt(index).split('/').last; + var filename = snapshot.data!.keys.elementAt(index).split('/').last; return ListTile( leading: const Icon(Icons.text_snippet_outlined), @@ -60,13 +59,10 @@ class _CacheViewState extends State { subtitle: Text("${filesize(jsonEncode(element).length * 8)}, ${Jiffy.parseFromMillisecondsSinceEpoch(element['lastupdate']).fromNow()}"), trailing: const Icon(Icons.arrow_right), onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (context) { - return JsonViewer(title: filename, data: jsonDecode(element['json'])); - },)); + Navigator.push(context, MaterialPageRoute(builder: (context) => JsonViewer(title: filename, data: jsonDecode(element['json'])),)); }, onLongPress: () { - showDialog(context: context, builder: (context) { - return SimpleDialog( + showDialog(context: context, builder: (context) => SimpleDialog( children: [ const ListTile( leading: Icon(Icons.delete_forever), @@ -81,8 +77,7 @@ class _CacheViewState extends State { }, ) ], - ); - }); + )); }, ); }, @@ -99,7 +94,6 @@ class _CacheViewState extends State { }, ), ); - } } extension FutureExtension on Future { diff --git a/lib/widget/debug/debugTile.dart b/lib/widget/debug/debugTile.dart index 0bf879f..bc5a8c4 100644 --- a/lib/widget/debug/debugTile.dart +++ b/lib/widget/debug/debugTile.dart @@ -13,15 +13,12 @@ class DebugTile { bool devConditionFulfilled() => Provider.of(context, listen: false).val().devToolsEnabled && (onlyInDebug ? kDebugMode : true); - Widget jsonData(Map data, {bool ignoreConfig = false}) { - return callback( + Widget jsonData(Map data, {bool ignoreConfig = false}) => callback( title: 'JSON daten anzeigen', onTab: () => JsonViewer.asDialog(context, data) ); - } - Widget callback({String title = 'Debugaktion', required void Function() onTab}) { - return child( + Widget callback({String title = 'Debugaktion', required void Function() onTab}) => child( ListTile( leading: const CenteredLeading(Icon(Icons.developer_mode_outlined)), title: Text(title), @@ -29,17 +26,14 @@ class DebugTile { onTap: onTab, ) ); - } - Widget child(Widget child) { - return Visibility( + Widget child(Widget child) => Visibility( visible: devConditionFulfilled(), child: child, ); - } void run(void Function() callback) { if(!devConditionFulfilled()) return; callback(); } -} \ No newline at end of file +} diff --git a/lib/widget/debug/jsonViewer.dart b/lib/widget/debug/jsonViewer.dart index f89ec89..465a98b 100644 --- a/lib/widget/debug/jsonViewer.dart +++ b/lib/widget/debug/jsonViewer.dart @@ -9,8 +9,7 @@ class JsonViewer extends StatelessWidget { const JsonViewer({super.key, required this.title, required this.data}); @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: Text(title), ), @@ -19,16 +18,11 @@ class JsonViewer extends StatelessWidget { child: Text(format(data)), ), ); - } - static String format(Map jsonInput) { - return prettyJson(jsonInput, indent: 2); - //return jsonInput.replaceAllMapped(RegExp(r'[{,}]'), (match) => "${match.group(0)}\n "); - } + static String format(Map jsonInput) => prettyJson(jsonInput, indent: 2); static void asDialog(BuildContext context, Map dataMap) { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( scrollable: true, title: const Row(children: [Icon(Icons.bug_report_outlined), Text('Rohdaten')]), content: Text(JsonViewer.format(dataMap)), @@ -45,7 +39,6 @@ class JsonViewer extends StatelessWidget { }, child: const Text('Inline Kopieren')), TextButton(onPressed: () => Navigator.of(context).pop(), child: const Text('Schließen')) ], - ); - }); + )); } } diff --git a/lib/widget/filePick.dart b/lib/widget/filePick.dart index b37fef4..e5bbd94 100644 --- a/lib/widget/filePick.dart +++ b/lib/widget/filePick.dart @@ -6,7 +6,7 @@ class FilePick { static final _picker = ImagePicker(); static Future galleryPick() async { - final XFile? pickedImage = await _picker.pickImage(source: ImageSource.gallery); + final pickedImage = await _picker.pickImage(source: ImageSource.gallery); if (pickedImage != null) { return pickedImage; } @@ -14,7 +14,7 @@ class FilePick { } static Future documentPick() async { - FilePickerResult? result = await FilePicker.platform.pickFiles(); + var result = await FilePicker.platform.pickFiles(); return result?.files.single.path; } -} \ No newline at end of file +} diff --git a/lib/widget/fileViewer.dart b/lib/widget/fileViewer.dart index 5907aa2..8eb01e1 100644 --- a/lib/widget/fileViewer.dart +++ b/lib/widget/fileViewer.dart @@ -35,8 +35,7 @@ class _FileViewerState extends State { @override Widget build(BuildContext context) { - AppBar appbar({List actions = const []}) { - return AppBar( + AppBar appbar({List actions = const []}) => AppBar( title: Text(widget.path.split('/').last), actions: [ IconButton( @@ -57,7 +56,6 @@ class _FileViewerState extends State { ...actions ], ); - } switch(openExternal ? '' : widget.path.split('.').last.toLowerCase()) { case 'png': @@ -98,11 +96,9 @@ class _FileViewerState extends State { OpenFile.open(widget.path).then((result) { Navigator.of(context).pop(); if(result.type != ResultType.done) { - showDialog(context: context, builder: (context) { - return AlertDialog( + showDialog(context: context, builder: (context) => AlertDialog( content: Text(result.message), - ); - }); + )); } }); diff --git a/lib/widget/focusBehaviour.dart b/lib/widget/focusBehaviour.dart index fe5a52b..da83d3d 100644 --- a/lib/widget/focusBehaviour.dart +++ b/lib/widget/focusBehaviour.dart @@ -4,4 +4,4 @@ class FocusBehaviour { static void textFieldTapOutside(BuildContext context) { FocusScope.of(context).requestFocus(FocusNode()); } -} \ No newline at end of file +} diff --git a/lib/widget/infoDialog.dart b/lib/widget/infoDialog.dart index d066e45..e30a61e 100644 --- a/lib/widget/infoDialog.dart +++ b/lib/widget/infoDialog.dart @@ -7,4 +7,4 @@ class InfoDialog { contentPadding: const EdgeInsets.all(20), )); } -} \ No newline at end of file +} diff --git a/lib/widget/largeProfilePictureView.dart b/lib/widget/largeProfilePictureView.dart index 4de08c5..65a9a4f 100644 --- a/lib/widget/largeProfilePictureView.dart +++ b/lib/widget/largeProfilePictureView.dart @@ -8,8 +8,7 @@ class LargeProfilePictureView extends StatelessWidget { const LargeProfilePictureView(this.username, {super.key}); @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Profilbild'), ), @@ -18,5 +17,4 @@ class LargeProfilePictureView extends StatelessWidget { backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.surface), ), ); - } } diff --git a/lib/widget/loadingSpinner.dart b/lib/widget/loadingSpinner.dart index 5419b1d..4cf9ab0 100644 --- a/lib/widget/loadingSpinner.dart +++ b/lib/widget/loadingSpinner.dart @@ -26,8 +26,7 @@ class _LoadingSpinnerState extends State { } @override - Widget build(BuildContext context) { - return Center( + Widget build(BuildContext context) => Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -47,7 +46,6 @@ class _LoadingSpinnerState extends State { ], ), ); - } @override void dispose() { diff --git a/lib/widget/placeholderView.dart b/lib/widget/placeholderView.dart index c06d27d..8896b94 100644 --- a/lib/widget/placeholderView.dart +++ b/lib/widget/placeholderView.dart @@ -7,8 +7,7 @@ class PlaceholderView extends StatelessWidget { const PlaceholderView({super.key, required this.icon, required this.text, this.button}); @override - Widget build(BuildContext context) { - return DefaultTextStyle( + Widget build(BuildContext context) => DefaultTextStyle( style: const TextStyle(), child: Center( child: Container( @@ -33,5 +32,4 @@ class PlaceholderView extends StatelessWidget { ), ), ); - } } diff --git a/lib/widget/sharePositionOrigin.dart b/lib/widget/sharePositionOrigin.dart index af07c71..f110beb 100644 --- a/lib/widget/sharePositionOrigin.dart +++ b/lib/widget/sharePositionOrigin.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; class SharePositionOrigin { - static Rect get(BuildContext context) { - return Rect.fromLTWH(0, 0, MediaQuery.of(context).size.width, MediaQuery.of(context).size.height / 2); - } -} \ No newline at end of file + static Rect get(BuildContext context) => Rect.fromLTWH(0, 0, MediaQuery.of(context).size.width, MediaQuery.of(context).size.height / 2); +} diff --git a/lib/widget/unimplementedDialog.dart b/lib/widget/unimplementedDialog.dart index c829c17..c02472d 100644 --- a/lib/widget/unimplementedDialog.dart +++ b/lib/widget/unimplementedDialog.dart @@ -4,4 +4,4 @@ class UnimplementedDialog { static void show(BuildContext context) { showDialog(context: context, builder: (context) => const AlertDialog(content: Text('Not implemented yet'))); } -} \ No newline at end of file +} From b4defb9eda87c5358a85e520e1ce5ba147476216 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Fri, 5 Apr 2024 18:16:12 +0200 Subject: [PATCH 04/11] added upload with multiple files --- lib/view/pages/files/files.dart | 36 +- lib/view/pages/files/filesUploadDialog.dart | 318 ++++++++++++++++++ .../pages/talk/components/chatTextfield.dart | 53 +-- lib/widget/filePick.dart | 7 +- 4 files changed, 369 insertions(+), 45 deletions(-) create mode 100644 lib/view/pages/files/filesUploadDialog.dart diff --git a/lib/view/pages/files/files.dart b/lib/view/pages/files/files.dart index b377cbf..f0c9add 100644 --- a/lib/view/pages/files/files.dart +++ b/lib/view/pages/files/files.dart @@ -1,9 +1,11 @@ +import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:loader_overlay/loader_overlay.dart'; import 'package:nextcloud/nextcloud.dart'; +import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart'; import 'package:provider/provider.dart'; import '../../../api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart'; @@ -15,8 +17,8 @@ import '../../../storage/base/settingsProvider.dart'; import '../../../widget/loadingSpinner.dart'; import '../../../widget/placeholderView.dart'; import '../../../widget/filePick.dart'; -import 'fileUploadDialog.dart'; import 'fileElement.dart'; +import 'filesUploadDialog.dart'; class Files extends StatefulWidget { final List path; @@ -90,7 +92,8 @@ class _FilesState extends State { ListFilesCache( path: widget.path.isEmpty ? '/' : widget.path.join('/'), onUpdate: (ListFilesResponse d) { - if(!context.mounted) return; // prevent setState when widget is possibly already disposed + log('_query'); + if(!context.mounted) return; // prevent setState when widget is possibly already disposed d.files.removeWhere((element) => element.name.isEmpty || element.name == widget.path.lastOrNull()); setState(() { data = d; @@ -99,6 +102,18 @@ class _FilesState extends State { ); } + void mediaUpload(List? paths) async { + if(paths == null) return; + + pushScreen( + context, + withNavBar: false, + screen: FilesUploadDialog(filePaths: paths, remotePath: widget.path.join('/'), onUploadFinished: (uploadedFilePaths) => _query), + ); + + return; + } + @override Widget build(BuildContext context) { List files = data?.sortBy( @@ -149,7 +164,7 @@ class _FilesState extends State { children: [ Icon(SortOptions.getOption(key).icon, color: Theme.of(context).colorScheme.onSurface), const SizedBox(width: 15), - Text(SortOptions.getOption(key).displayName) + Text(SortOptions.getOption(key).displayName), ], ) )).toList(); @@ -204,7 +219,6 @@ class _FilesState extends State { leading: const Icon(Icons.upload_file), title: const Text('Aus Dateien hochladen'), onTap: () { - context.loaderOverlay.show(); FilePick.documentPick().then(mediaUpload); Navigator.of(context).pop(); }, @@ -215,9 +229,8 @@ class _FilesState extends State { leading: const Icon(Icons.add_a_photo_outlined), title: const Text('Aus Gallerie hochladen'), onTap: () { - context.loaderOverlay.show(); FilePick.galleryPick().then((value) { - mediaUpload(value?.path); + if(value != null) mediaUpload([value.path]); }); Navigator.of(context).pop(); }, @@ -247,15 +260,4 @@ class _FilesState extends State { ) ); } - - void mediaUpload(String? path) async { - context.loaderOverlay.hide(); - - if(path == null) { - return; - } - - var fileName = path.split(Platform.pathSeparator).last; - showDialog(context: context, builder: (context) => FileUploadDialog(localPath: path, remotePath: widget.path, fileName: fileName, onUploadFinished: _query), barrierDismissible: false); - } } diff --git a/lib/view/pages/files/filesUploadDialog.dart b/lib/view/pages/files/filesUploadDialog.dart new file mode 100644 index 0000000..9f9ce02 --- /dev/null +++ b/lib/view/pages/files/filesUploadDialog.dart @@ -0,0 +1,318 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:loader_overlay/loader_overlay.dart'; +import 'package:nextcloud/nextcloud.dart'; +import 'package:uuid/uuid.dart'; + +import '../../../api/marianumcloud/webdav/webdavApi.dart'; +import '../../../widget/focusBehaviour.dart'; + +class FilesUploadDialog extends StatefulWidget { + final List filePaths; + final String remotePath; + final void Function(List uploadedFilePaths) onUploadFinished; + final bool uniqueNames; + + const FilesUploadDialog({super.key, required this.filePaths, required this.remotePath, required this.onUploadFinished, this.uniqueNames = false}); + + @override + State createState() => _FilesUploadDialogState(); +} + +class UploadableFile { + TextEditingController fileNameController = TextEditingController(); + String filePath; + String fileName; + double? _uploadProgress; + bool isConflicting = false; + + UploadableFile(this.filePath, this.fileName); +} + + +class _FilesUploadDialogState extends State { + final List _uploadableFiles = []; + bool _isUploading = false; + double _progressValue = 0.0; + String _infoText = ''; + + @override + void initState() { + super.initState(); + + _uploadableFiles.addAll(widget.filePaths.map((filePath) { + String fileName = filePath.split(Platform.pathSeparator).last; + return UploadableFile(filePath, fileName); + })); + } + + void showErrorMessage(int errorCode){ + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Ein Fehler ist aufgetreten'), + contentPadding: const EdgeInsets.all(10), + content: Text('Error code: $errorCode'), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text('Schließen', textAlign: TextAlign.center), + ), + ], + ); + } + ); + } + + void uploadSelectedFiles({bool override = false}) async { + setState(() { + _isUploading = true; + _infoText = 'Vorbereiten'; + }); + + for (var element in _uploadableFiles) { + setState(() { + element.isConflicting = false; + }); + } + + WebDavClient webdavClient = await WebdavApi.webdav; + + if (!override) { + List result = (await webdavClient.propfind(PathUri.parse(widget.remotePath))).responses; + List conflictingFiles = []; + + for (var file in _uploadableFiles) { + String fileName = file.fileName; + if (result.any((element) => Uri.decodeComponent(element.href!).endsWith('/$fileName'))) { + // konflikt + conflictingFiles.add(file); + } + } + + if(conflictingFiles.isNotEmpty) { + bool replaceFiles = await showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return AlertDialog( + contentPadding: const EdgeInsets.all(10), + title: const Text('Konflikt', textAlign: TextAlign.center), + content: conflictingFiles.length == 1 ? + Text( + 'Eine Datei mit dem Namen "${conflictingFiles.map((e) => e.fileName).first}" existiert bereits.\n' + '(Datei ${_uploadableFiles.indexOf(conflictingFiles.first)+1})', + textAlign: TextAlign.left, + ) : + Text( + '${conflictingFiles.length} Dateien mit den Namen ${conflictingFiles.map((e) => e.fileName).toList()} existieren bereits.\n' + '(Dateien ${conflictingFiles.map((e) => _uploadableFiles.indexOf(e)+1).toList()})', + textAlign: TextAlign.left, + ), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context, false); + }, + child: const Text('Bearbeiten', textAlign: TextAlign.center), + ), + TextButton( + onPressed: () { + Navigator.pop(context, true); + }, + child: const Text('Ersetzen', textAlign: TextAlign.center), + ), + ], + ); + } + ); + + if(!replaceFiles) { + for (var element in conflictingFiles) { + element.isConflicting = true; + } + setState(() { + _isUploading = false; + _progressValue = 0.0; + _infoText = ''; + }); + return; + } + } + } + + List uploadetFilePaths = []; + for (var file in _uploadableFiles) { + String fileName = file.fileName; + String filePath = file.filePath; + + if(widget.uniqueNames) fileName = '${fileName.split('.').first}-${const Uuid().v4()}.${fileName.split('.').last}'; + + String fullRemotePath = '${widget.remotePath}/$fileName'; + + setState(() { + _infoText = '${_uploadableFiles.indexOf(file) + 1}/${_uploadableFiles.length}'; + }); + + HttpClientResponse uploadTask = await webdavClient.putFile( + File(filePath), + FileStat.statSync(filePath), + PathUri.parse(fullRemotePath), + onProgress: (progress) { + setState(() { + file._uploadProgress = progress; + _progressValue = ((progress + _uploadableFiles.indexOf(file)) / _uploadableFiles.length).toDouble(); + }); + }, + ); + + if(uploadTask.statusCode < 200 || uploadTask.statusCode > 299) { + // error code + setState(() { + _isUploading = false; + _progressValue = 0.0; + _infoText = ''; + }); + Navigator.of(context).pop(); + showErrorMessage(uploadTask.statusCode); + } else { + uploadetFilePaths.add(fullRemotePath); + } + } + + setState(() { + _isUploading = false; + _progressValue = 0.0; + _infoText = ''; + }); + Navigator.of(context).pop(); + widget.onUploadFinished(uploadetFilePaths); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Dateien hochladen'), + automaticallyImplyLeading: false, + ), + body: LoaderOverlay( + overlayWholeScreen: true, + child: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: _uploadableFiles.length, + itemBuilder: (context, index) { + final currentFile = _uploadableFiles[index]; + currentFile.fileNameController.text = currentFile.fileName; + return ListTile( + title: TextField( + readOnly: _isUploading, + controller: currentFile.fileNameController, + decoration: InputDecoration( + border: const UnderlineInputBorder(), + label: Text('Datei ${index+1}'), + errorText: currentFile.isConflicting ? 'existiert bereits' : null, + errorStyle: const TextStyle(color: Colors.red), + ), + onChanged: (input) { + currentFile.fileName = input; + }, + onTapOutside: (PointerDownEvent event) { + FocusBehaviour.textFieldTapOutside(context); + if(currentFile.isConflicting){ + setState(() { + currentFile.isConflicting = false; + }); + } + }, + onEditingComplete: () { + if(currentFile.isConflicting){ + setState(() { + currentFile.isConflicting = false; + }); + } + }, + ), + subtitle: _isUploading && (currentFile._uploadProgress ?? 0) < 1 ? LinearProgressIndicator( + value: currentFile._uploadProgress, + borderRadius: const BorderRadius.all(Radius.circular(2)), + ) : null, + leading: Container( + width: 24, + height: 24, + padding: EdgeInsets.zero, + child: IconButton( + tooltip: 'Datei entfernen', + padding: EdgeInsets.zero, + onPressed: () { + if(!_isUploading) { + if(_uploadableFiles.length-1 <= 0) Navigator.of(context).pop(); + setState(() { + _uploadableFiles.removeAt(index); + }); + } + }, + icon: const Icon(Icons.close_outlined), + ), + ), + trailing: Container( + width: 24, + height: 24, + padding: EdgeInsets.zero, + child: IconButton( + tooltip: 'Namen löschen', + padding: EdgeInsets.zero, + onPressed: () { + if(!_isUploading) { + setState(() { + currentFile.fileName = ''; + }); + } + }, + icon: const Icon(Icons.delete_outlined), + ), + ), + ); + }, + ), + ), + Padding( + padding: const EdgeInsets.only(left: 15, right: 15, bottom: 15, top: 5), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Visibility( + visible: !_isUploading, + child: TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text('Abbrechen'), + ), + ), + const Expanded(child: SizedBox.shrink()), + Visibility( + visible: _isUploading, + replacement: TextButton( + onPressed: () => uploadSelectedFiles(override: widget.uniqueNames), + child: const Text('Hochladen'), + ), + child: Stack( + alignment: Alignment.center, + children: [ + CircularProgressIndicator(value: _progressValue), + Center(child: Text(_infoText)), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index 5513d8a..09c81d7 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -1,10 +1,9 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:loader_overlay/loader_overlay.dart'; import 'package:nextcloud/nextcloud.dart'; +import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart'; import 'package:provider/provider.dart'; -import 'package:uuid/uuid.dart'; import '../../../../api/marianumcloud/files-sharing/fileSharingApi.dart'; import '../../../../api/marianumcloud/files-sharing/fileSharingApiParams.dart'; @@ -15,7 +14,7 @@ import '../../../../model/chatList/chatProps.dart'; import '../../../../storage/base/settingsProvider.dart'; import '../../../../widget/filePick.dart'; import '../../../../widget/focusBehaviour.dart'; -import '../../files/fileUploadDialog.dart'; +import '../../files/filesUploadDialog.dart'; class ChatTextfield extends StatefulWidget { final String sendToToken; @@ -34,34 +33,40 @@ class _ChatTextfieldState extends State { Provider.of(context, listen: false).run(); } - void mediaUpload(String? path) async { - context.loaderOverlay.hide(); - - if(path == null) { - return; + void share(String shareFolder, List filePaths) { + for (var element in filePaths) { + String fileName = element.split(Platform.pathSeparator).last; + FileSharingApi().share(FileSharingApiParams( + shareType: 10, + shareWith: widget.sendToToken, + path: '$shareFolder/$fileName', + )).then((value) => _query()); } + } + + void mediaUpload(List? paths) async { + if (paths == null) return; - String filename = "${path.split("/").last.split(".").first}-${const Uuid().v4()}.${path.split(".").last}"; String shareFolder = 'MarianumMobile'; WebdavApi.webdav.then((webdav) { webdav.mkcol(PathUri.parse('/$shareFolder')); }); - showDialog(context: context, builder: (context) => FileUploadDialog( - doShowFinish: false, - fileName: filename, - localPath: path, - remotePath: [shareFolder], - onUploadFinished: () { - FileSharingApi().share(FileSharingApiParams( - shareType: 10, - shareWith: widget.sendToToken, - path: '$shareFolder/$filename', - )).then((value) => _query()); - }, - ), barrierDismissible: false); + pushScreen( + context, + withNavBar: false, + screen: FilesUploadDialog( + filePaths: paths, + remotePath: shareFolder, + onUploadFinished: (uploadedFilePaths) { + share(shareFolder, uploadedFilePaths); + }, + uniqueNames: true, + ), + ); } + void setDraft(String text) { if(text.isNotEmpty) { settings.val(write: true).talkSettings.drafts[widget.sendToToken] = text; @@ -98,7 +103,6 @@ class _ChatTextfieldState extends State { leading: const Icon(Icons.file_open), title: const Text('Aus Dateien auswählen'), onTap: () { - context.loaderOverlay.show(); FilePick.documentPick().then(mediaUpload); Navigator.of(context).pop(); }, @@ -109,9 +113,8 @@ class _ChatTextfieldState extends State { leading: const Icon(Icons.image), title: const Text('Aus Gallerie auswählen'), onTap: () { - context.loaderOverlay.show(); FilePick.galleryPick().then((value) { - mediaUpload(value?.path); + if(value != null) mediaUpload([value.path]); }); Navigator.of(context).pop(); }, diff --git a/lib/widget/filePick.dart b/lib/widget/filePick.dart index b37fef4..0d7c0e5 100644 --- a/lib/widget/filePick.dart +++ b/lib/widget/filePick.dart @@ -13,8 +13,9 @@ class FilePick { return null; } - static Future documentPick() async { - FilePickerResult? result = await FilePicker.platform.pickFiles(); - return result?.files.single.path; + static Future?> documentPick() async { + FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); + List? paths = result?.files.nonNulls.map((e) => e.path).toList(); + return paths?.nonNulls.toList(); } } \ No newline at end of file From 277b3366f9d0ea308fbde23e8519c8fbbfdac514 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Fri, 5 Apr 2024 18:19:49 +0200 Subject: [PATCH 05/11] added upload with multiple files --- lib/view/pages/files/fileUploadDialog.dart | 233 --------------------- 1 file changed, 233 deletions(-) delete mode 100644 lib/view/pages/files/fileUploadDialog.dart diff --git a/lib/view/pages/files/fileUploadDialog.dart b/lib/view/pages/files/fileUploadDialog.dart deleted file mode 100644 index 6322ee5..0000000 --- a/lib/view/pages/files/fileUploadDialog.dart +++ /dev/null @@ -1,233 +0,0 @@ -import 'dart:developer'; -import 'dart:io'; - -import 'package:async/async.dart'; -import 'package:flutter/material.dart'; -import 'package:nextcloud/nextcloud.dart'; - -import '../../../api/marianumcloud/webdav/webdavApi.dart'; - -class FileUploadDialog extends StatefulWidget { - final String localPath; - final List remotePath; - final String fileName; - final void Function() onUploadFinished; - - final bool doShowFinish; - - const FileUploadDialog({super.key, required this.localPath, required this.remotePath, required this.fileName, required this.onUploadFinished, this.doShowFinish = true}); - - @override - State createState() => _FileUploadDialogState(); -} - -class _FileUploadDialogState extends State { - FileUploadState state = FileUploadState.naming; - CancelableOperation? cancelableOperation; - late String targetFileName; - late String remoteFolderName; - late String fullRemotePath = "${widget.remotePath.join("/")}/$targetFileName"; - String? lastError; - - TextEditingController fileNameController = TextEditingController(); - - - void upload({bool override = false}) async { - setState(() { - state = FileUploadState.upload; - }); - - WebDavClient webdavClient = await WebdavApi.webdav; - - if(!override) { - setState(() { - state = FileUploadState.checkConflict; - }); - List result = (await webdavClient.propfind(PathUri.parse(widget.remotePath.join('/')))).responses; - if(result.any((element) => element.href!.endsWith('/$targetFileName'))) { - setState(() { - state = FileUploadState.conflict; - }); - return; - } else { - setState(() { - state = FileUploadState.upload; - }); - } - } - - Future uploadTask = webdavClient.putFile(File(widget.localPath), FileStat.statSync(widget.localPath), PathUri.parse(fullRemotePath)); // TODO use onProgress from putFile - uploadTask.then(Future.value).catchError((e) { - setState(() { - state = FileUploadState.error; - }); - return null; - }); - - - cancelableOperation = CancelableOperation.fromFuture( - uploadTask, - onCancel: () => log('Upload cancelled'), - ); - - cancelableOperation!.then((value) { - setState(() { - state = FileUploadState.done; - }); - }); - } - - void cancel() { - cancelableOperation?.cancel(); - setState(() { - state = FileUploadState.naming; - }); - } - - @override - void initState() { - super.initState(); - targetFileName = widget.fileName; - remoteFolderName = widget.remotePath.isNotEmpty ? widget.remotePath.last : '/'; - fileNameController.text = widget.fileName; - } - - @override - Widget build(BuildContext context) { - if(state == FileUploadState.naming) { - return AlertDialog( - title: const Text('Datei hochladen'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TextField( - controller: fileNameController, - onChanged: (input) { - targetFileName = input; - }, - autocorrect: false, - decoration: const InputDecoration( - labelText: 'Dateiname', - ), - ), - ], - ), - actions: [ - TextButton(onPressed: () { - Navigator.of(context).pop(); - }, child: const Text('Abbrechen')), - TextButton(onPressed: () async { - upload(); - }, child: const Text('Hochladen')), - ], - - ); - } - - if(state == FileUploadState.conflict) { - return AlertDialog( - icon: const Icon(Icons.error_outline), - title: const Text('Datei konflikt'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text("Es gibt bereits eine Datei mit dem Namen $targetFileName in dem ausgewählten Ordner '$remoteFolderName'", textAlign: TextAlign.center), - ], - ), - actions: [ - TextButton(onPressed: () { - setState(() { - state = FileUploadState.naming; - }); - }, child: const Text('Datei umbenennen')), - TextButton(onPressed: () { - upload(override: true); - }, child: const Text('Datei überschreiben')), - ], - - ); - } - - if(state == FileUploadState.upload || state == FileUploadState.checkConflict) { - return AlertDialog( - icon: const Icon(Icons.upload), - title: const Text('Hochladen'), - content: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Visibility( - visible: state == FileUploadState.upload, - replacement: const Text('Prüfe auf dateikonflikte...'), - child: const Text('Upload läuft!\nDies kann je nach Dateigröße einige Zeit dauern...', textAlign: TextAlign.center), - ), - const SizedBox(height: 30), - const CircularProgressIndicator() - ], - ), - actions: const [ - // TODO implement working upload cancelling - // TextButton(onPressed: () { - // cancel(); - // }, child: const Text("Abbrechen")), - ], - - ); - } - - if(state == FileUploadState.done) { - widget.onUploadFinished(); - if(!widget.doShowFinish) { - Navigator.of(context).pop(); - return const SizedBox.shrink(); - } - return AlertDialog( - icon: const Icon(Icons.done), - title: const Text('Upload fertig'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text("Die Datei wurde erfolgreich nach '$remoteFolderName' hochgeladen!", textAlign: TextAlign.center), - ], - ), - actions: [ - TextButton(onPressed: () { - Navigator.of(context).pop(); - }, child: const Text('Fertig')), - ], - - ); - } - - if(state == FileUploadState.error) { - return AlertDialog( - icon: const Icon(Icons.error_outline), - title: const Text('Fehler'), - content: const Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text('Es ist ein Fehler aufgetreten!', textAlign: TextAlign.center), - ], - ), - actions: [ - TextButton(onPressed: () { - Navigator.of(context).pop(); - }, child: const Text('Schlißen')), - ], - - ); - } - - throw UnimplementedError('Invalid state'); - - } -} - -enum FileUploadState { - naming, - checkConflict, - conflict, - upload, - done, - error -} \ No newline at end of file From 02dd659d1df3ab2f2b10d7160c86cc8d89f7cfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Sat, 6 Apr 2024 11:40:48 +0200 Subject: [PATCH 06/11] fixed typos --- lib/view/settings/settings.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/view/settings/settings.dart b/lib/view/settings/settings.dart index 2d7fcc5..1827588 100644 --- a/lib/view/settings/settings.dart +++ b/lib/view/settings/settings.dart @@ -177,11 +177,11 @@ class _SettingsState extends State { onLongPress: () => showDialog(context: context, builder: (context) => AlertDialog( title: const Text('Info über Push'), content: const SingleChildScrollView(child: Text('' - "Aufgrund technischer Limitationen müssen Push-nachrichten über einen externen Server - hier 'mhsl.eu' (Author dieser App) - erfolgen.\n\n" + "Aufgrund technischer Limitationen müssen Push-Nachrichten über einen externen Server - hier 'mhsl.eu' (Author dieser App) - erfolgen.\n\n" 'Wenn Push aktiviert wird, werden deine Zugangsdaten und ein Token verschlüsselt an den Betreiber gesendet und von ihm unverschlüsselt gespeichert.\n\n' 'Der extene Server verwendet die Zugangsdaten um sich maschinell in Nextcloud Talk anzumelden und via Websockets auf neue Nachrichten zu warten.\n\n' 'Wenn eine neue Nachricht eintrifft wird dein Telefon via FBC-Messaging (Google Firebase Push) vom externen Server benachrichtigt.\n\n' - 'Behalte im Hinterkopf, dass deine Zugangsdaten auf einem externen Server gespeichert werden und dies trots bester Absichten ein Sicherheitsrisiko sein kann!' + 'Behalte im Hinterkopf, dass deine Zugangsdaten auf einem externen Server gespeichert werden und dies trotz bester Absichten ein Sicherheitsrisiko sein kann!' )), actions: [ TextButton(onPressed: () => Navigator.of(context).pop(), child: const Text('Zurück')) From e901f139d60902f0134d9d7eb58eb39e4c21adbf Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Sat, 6 Apr 2024 13:34:52 +0200 Subject: [PATCH 07/11] solved some pr comments --- lib/view/pages/files/files.dart | 3 - lib/view/pages/files/filesUploadDialog.dart | 70 +++++++++++++-------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/lib/view/pages/files/files.dart b/lib/view/pages/files/files.dart index f0c9add..3402bba 100644 --- a/lib/view/pages/files/files.dart +++ b/lib/view/pages/files/files.dart @@ -1,5 +1,4 @@ -import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; @@ -92,8 +91,6 @@ class _FilesState extends State { ListFilesCache( path: widget.path.isEmpty ? '/' : widget.path.join('/'), onUpdate: (ListFilesResponse d) { - log('_query'); - if(!context.mounted) return; // prevent setState when widget is possibly already disposed d.files.removeWhere((element) => element.name.isEmpty || element.name == widget.path.lastOrNull()); setState(() { data = d; diff --git a/lib/view/pages/files/filesUploadDialog.dart b/lib/view/pages/files/filesUploadDialog.dart index 9f9ce02..8e19d8a 100644 --- a/lib/view/pages/files/filesUploadDialog.dart +++ b/lib/view/pages/files/filesUploadDialog.dart @@ -6,6 +6,7 @@ import 'package:nextcloud/nextcloud.dart'; import 'package:uuid/uuid.dart'; import '../../../api/marianumcloud/webdav/webdavApi.dart'; +import '../../../widget/confirmDialog.dart'; import '../../../widget/focusBehaviour.dart'; class FilesUploadDialog extends StatefulWidget { @@ -32,29 +33,34 @@ class UploadableFile { class _FilesUploadDialogState extends State { - final List _uploadableFiles = []; + late List _uploadableFiles; bool _isUploading = false; - double _progressValue = 0.0; + double _overallProgressValue = 0.0; String _infoText = ''; @override void initState() { super.initState(); - _uploadableFiles.addAll(widget.filePaths.map((filePath) { + _uploadableFiles = widget.filePaths.map((filePath) { String fileName = filePath.split(Platform.pathSeparator).last; return UploadableFile(filePath, fileName); - })); + }).toList(); + + /*_uploadableFiles.addAll(widget.filePaths.map((filePath) { + String fileName = filePath.split(Platform.pathSeparator).last; + return UploadableFile(filePath, fileName); + }));*/ } - void showErrorMessage(int errorCode){ + void showHttpErrorCode(int httpErrorCode){ showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Ein Fehler ist aufgetreten'), contentPadding: const EdgeInsets.all(10), - content: Text('Error code: $errorCode'), + content: Text('Error code: $httpErrorCode'), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), @@ -66,31 +72,27 @@ class _FilesUploadDialogState extends State { ); } - void uploadSelectedFiles({bool override = false}) async { + void uploadFiles({bool override = false}) async { setState(() { _isUploading = true; _infoText = 'Vorbereiten'; + for (var file in _uploadableFiles) { + file.isConflicting = false; + } }); - for (var element in _uploadableFiles) { - setState(() { - element.isConflicting = false; - }); - } - WebDavClient webdavClient = await WebdavApi.webdav; if (!override) { List result = (await webdavClient.propfind(PathUri.parse(widget.remotePath))).responses; - List conflictingFiles = []; - - for (var file in _uploadableFiles) { + List conflictingFiles = _uploadableFiles.where((file) { String fileName = file.fileName; if (result.any((element) => Uri.decodeComponent(element.href!).endsWith('/$fileName'))) { // konflikt - conflictingFiles.add(file); + return true; } - } + return false; + }).toList(); if(conflictingFiles.isNotEmpty) { bool replaceFiles = await showDialog( @@ -120,9 +122,23 @@ class _FilesUploadDialogState extends State { ), TextButton( onPressed: () { - Navigator.pop(context, true); + showDialog( + context: context, + builder: (context) { + return ConfirmDialog( + title: 'Bist du sicher?', + content: '', + onConfirm: () { + Navigator.pop(context, true); + }, + confirmButton: 'Ja', + cancelButton: 'Nein', + ); + } + ); + }, - child: const Text('Ersetzen', textAlign: TextAlign.center), + child: const Text('Überschreiben', textAlign: TextAlign.center), ), ], ); @@ -135,7 +151,7 @@ class _FilesUploadDialogState extends State { } setState(() { _isUploading = false; - _progressValue = 0.0; + _overallProgressValue = 0.0; _infoText = ''; }); return; @@ -163,7 +179,7 @@ class _FilesUploadDialogState extends State { onProgress: (progress) { setState(() { file._uploadProgress = progress; - _progressValue = ((progress + _uploadableFiles.indexOf(file)) / _uploadableFiles.length).toDouble(); + _overallProgressValue = ((progress + _uploadableFiles.indexOf(file)) / _uploadableFiles.length).toDouble(); }); }, ); @@ -172,11 +188,11 @@ class _FilesUploadDialogState extends State { // error code setState(() { _isUploading = false; - _progressValue = 0.0; + _overallProgressValue = 0.0; _infoText = ''; }); Navigator.of(context).pop(); - showErrorMessage(uploadTask.statusCode); + showHttpErrorCode(uploadTask.statusCode); } else { uploadetFilePaths.add(fullRemotePath); } @@ -184,7 +200,7 @@ class _FilesUploadDialogState extends State { setState(() { _isUploading = false; - _progressValue = 0.0; + _overallProgressValue = 0.0; _infoText = ''; }); Navigator.of(context).pop(); @@ -296,13 +312,13 @@ class _FilesUploadDialogState extends State { Visibility( visible: _isUploading, replacement: TextButton( - onPressed: () => uploadSelectedFiles(override: widget.uniqueNames), + onPressed: () => uploadFiles(override: widget.uniqueNames), child: const Text('Hochladen'), ), child: Stack( alignment: Alignment.center, children: [ - CircularProgressIndicator(value: _progressValue), + CircularProgressIndicator(value: _overallProgressValue), Center(child: Text(_infoText)), ], ), From 8131ccae1e77dfaf11455004880cf6bc353f8dff Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Sun, 7 Apr 2024 15:49:43 +0200 Subject: [PATCH 08/11] solved some pr comments --- lib/view/pages/files/files.dart | 2 +- lib/view/pages/files/filesUploadDialog.dart | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/view/pages/files/files.dart b/lib/view/pages/files/files.dart index 3402bba..00b6719 100644 --- a/lib/view/pages/files/files.dart +++ b/lib/view/pages/files/files.dart @@ -105,7 +105,7 @@ class _FilesState extends State { pushScreen( context, withNavBar: false, - screen: FilesUploadDialog(filePaths: paths, remotePath: widget.path.join('/'), onUploadFinished: (uploadedFilePaths) => _query), + screen: FilesUploadDialog(filePaths: paths, remotePath: widget.path.join('/'), onUploadFinished: (uploadedFilePaths) => _query()), ); return; diff --git a/lib/view/pages/files/filesUploadDialog.dart b/lib/view/pages/files/filesUploadDialog.dart index 8e19d8a..c90b5b0 100644 --- a/lib/view/pages/files/filesUploadDialog.dart +++ b/lib/view/pages/files/filesUploadDialog.dart @@ -108,11 +108,14 @@ class _FilesUploadDialogState extends State { '(Datei ${_uploadableFiles.indexOf(conflictingFiles.first)+1})', textAlign: TextAlign.left, ) : - Text( - '${conflictingFiles.length} Dateien mit den Namen ${conflictingFiles.map((e) => e.fileName).toList()} existieren bereits.\n' - '(Dateien ${conflictingFiles.map((e) => _uploadableFiles.indexOf(e)+1).toList()})', - textAlign: TextAlign.left, + SingleChildScrollView( + child: Text( + '${conflictingFiles.length} Dateien mit den Namen: ${conflictingFiles.map((e) => '\n${e.fileName}').join(', ')}\n existieren bereits.\n' + '(Dateien ${conflictingFiles.map((e) => _uploadableFiles.indexOf(e)+1).join(', ')})', + textAlign: TextAlign.left, + ), ), + actions: [ TextButton( onPressed: () { @@ -126,8 +129,8 @@ class _FilesUploadDialogState extends State { context: context, builder: (context) { return ConfirmDialog( - title: 'Bist du sicher?', - content: '', + title: 'Bestätigen', + content: 'Bist du sicher, dass du ${conflictingFiles.map((e) => e.fileName).toList()} überschreiben möchtest?', onConfirm: () { Navigator.pop(context, true); }, From d8c72a5d2865249e15c9613d28e7300ebab27f07 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Sun, 7 Apr 2024 16:48:38 +0200 Subject: [PATCH 09/11] solved most pr comments and a bug --- lib/view/pages/files/files.dart | 6 +- lib/view/pages/files/filesUploadDialog.dart | 108 ++++++++---------- .../pages/talk/components/chatTextfield.dart | 6 +- 3 files changed, 55 insertions(+), 65 deletions(-) diff --git a/lib/view/pages/files/files.dart b/lib/view/pages/files/files.dart index 2b1a6f9..a39bdbe 100644 --- a/lib/view/pages/files/files.dart +++ b/lib/view/pages/files/files.dart @@ -65,9 +65,7 @@ class SortOptions { ) }; - static BetterSortOption getOption(SortOption option) { - return options[option]!; - } + static BetterSortOption getOption(SortOption option) => options[option]!; } class _FilesState extends State { @@ -99,7 +97,7 @@ class _FilesState extends State { ); } - void mediaUpload(List? paths) async { + Future mediaUpload(List? paths) async { if(paths == null) return; pushScreen( diff --git a/lib/view/pages/files/filesUploadDialog.dart b/lib/view/pages/files/filesUploadDialog.dart index c90b5b0..794d9a7 100644 --- a/lib/view/pages/files/filesUploadDialog.dart +++ b/lib/view/pages/files/filesUploadDialog.dart @@ -43,21 +43,15 @@ class _FilesUploadDialogState extends State { super.initState(); _uploadableFiles = widget.filePaths.map((filePath) { - String fileName = filePath.split(Platform.pathSeparator).last; + var fileName = filePath.split(Platform.pathSeparator).last; return UploadableFile(filePath, fileName); }).toList(); - - /*_uploadableFiles.addAll(widget.filePaths.map((filePath) { - String fileName = filePath.split(Platform.pathSeparator).last; - return UploadableFile(filePath, fileName); - }));*/ } void showHttpErrorCode(int httpErrorCode){ showDialog( context: context, - builder: (BuildContext context) { - return AlertDialog( + builder: (BuildContext context) => AlertDialog( title: const Text('Ein Fehler ist aufgetreten'), contentPadding: const EdgeInsets.all(10), content: Text('Error code: $httpErrorCode'), @@ -67,12 +61,11 @@ class _FilesUploadDialogState extends State { child: const Text('Schließen', textAlign: TextAlign.center), ), ], - ); - } + ) ); } - void uploadFiles({bool override = false}) async { + Future uploadFiles({bool override = false}) async { setState(() { _isUploading = true; _infoText = 'Vorbereiten'; @@ -81,41 +74,33 @@ class _FilesUploadDialogState extends State { } }); - WebDavClient webdavClient = await WebdavApi.webdav; + var webdavClient = await WebdavApi.webdav; if (!override) { - List result = (await webdavClient.propfind(PathUri.parse(widget.remotePath))).responses; - List conflictingFiles = _uploadableFiles.where((file) { - String fileName = file.fileName; - if (result.any((element) => Uri.decodeComponent(element.href!).endsWith('/$fileName'))) { - // konflikt - return true; - } - return false; + var result = (await webdavClient.propfind(PathUri.parse(widget.remotePath))).responses; + var conflictingFiles = _uploadableFiles.where((file) { + var fileName = file.fileName; + return result.any((element) => Uri.decodeComponent(element.href!).endsWith('/$fileName')); }).toList(); if(conflictingFiles.isNotEmpty) { bool replaceFiles = await showDialog( context: context, barrierDismissible: false, - builder: (context) { - return AlertDialog( + builder: (context) => AlertDialog( contentPadding: const EdgeInsets.all(10), title: const Text('Konflikt', textAlign: TextAlign.center), content: conflictingFiles.length == 1 ? Text( - 'Eine Datei mit dem Namen "${conflictingFiles.map((e) => e.fileName).first}" existiert bereits.\n' - '(Datei ${_uploadableFiles.indexOf(conflictingFiles.first)+1})', + 'Eine Datei mit dem Namen "${conflictingFiles.map((e) => e.fileName).first}" existiert bereits.', textAlign: TextAlign.left, ) : SingleChildScrollView( child: Text( - '${conflictingFiles.length} Dateien mit den Namen: ${conflictingFiles.map((e) => '\n${e.fileName}').join(', ')}\n existieren bereits.\n' - '(Dateien ${conflictingFiles.map((e) => _uploadableFiles.indexOf(e)+1).join(', ')})', + '${conflictingFiles.length} Dateien mit folgenden Namen existieren bereits: \n${conflictingFiles.map((e) => '\n - ${e.fileName}').join('')}', textAlign: TextAlign.left, ), ), - actions: [ TextButton( onPressed: () { @@ -127,55 +112,52 @@ class _FilesUploadDialogState extends State { onPressed: () { showDialog( context: context, - builder: (context) { - return ConfirmDialog( - title: 'Bestätigen', - content: 'Bist du sicher, dass du ${conflictingFiles.map((e) => e.fileName).toList()} überschreiben möchtest?', - onConfirm: () { - Navigator.pop(context, true); - }, - confirmButton: 'Ja', - cancelButton: 'Nein', - ); - } + builder: (context) => ConfirmDialog( + title: 'Bestätigen?', + content: 'Bist du sicher, dass du ${conflictingFiles.length} Dateien überschreiben möchtest?', + onConfirm: () { + Navigator.pop(context, true); + }, + confirmButton: 'Ja', + cancelButton: 'Nein', + ), ); }, child: const Text('Überschreiben', textAlign: TextAlign.center), ), ], - ); - } + ) ); if(!replaceFiles) { - for (var element in conflictingFiles) { - element.isConflicting = true; - } setState(() { _isUploading = false; _overallProgressValue = 0.0; _infoText = ''; + for (var element in conflictingFiles) { + element.isConflicting = true; + } }); return; } } } - List uploadetFilePaths = []; + var uploadetFilePaths = []; for (var file in _uploadableFiles) { - String fileName = file.fileName; - String filePath = file.filePath; + var fileName = file.fileName; + var filePath = file.filePath; if(widget.uniqueNames) fileName = '${fileName.split('.').first}-${const Uuid().v4()}.${fileName.split('.').last}'; - String fullRemotePath = '${widget.remotePath}/$fileName'; + var fullRemotePath = '${widget.remotePath}/$fileName'; setState(() { _infoText = '${_uploadableFiles.indexOf(file) + 1}/${_uploadableFiles.length}'; }); - HttpClientResponse uploadTask = await webdavClient.putFile( + var uploadTask = await webdavClient.putFile( File(filePath), FileStat.statSync(filePath), PathUri.parse(fullRemotePath), @@ -211,8 +193,7 @@ class _FilesUploadDialogState extends State { } @override - Widget build(BuildContext context) { - return Scaffold( + Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: const Text('Dateien hochladen'), automaticallyImplyLeading: false, @@ -318,13 +299,25 @@ class _FilesUploadDialogState extends State { onPressed: () => uploadFiles(override: widget.uniqueNames), child: const Text('Hochladen'), ), - child: Stack( - alignment: Alignment.center, - children: [ - CircularProgressIndicator(value: _overallProgressValue), - Center(child: Text(_infoText)), - ], + child: Visibility( + visible: _infoText.length < 5, + replacement: Row( + children: [ + Text(_infoText), + const SizedBox(width: 15), + CircularProgressIndicator(value: _overallProgressValue), + ], + ), + child: Stack( + alignment: Alignment.center, + children: [ + CircularProgressIndicator(value: _overallProgressValue), + Center(child: Text(_infoText)), + ], + ), ), + + ), ], ), @@ -333,5 +326,4 @@ class _FilesUploadDialogState extends State { ), ), ); - } -} \ No newline at end of file +} diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index 791db03..a39be26 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -35,7 +35,7 @@ class _ChatTextfieldState extends State { void share(String shareFolder, List filePaths) { for (var element in filePaths) { - String fileName = element.split(Platform.pathSeparator).last; + var fileName = element.split(Platform.pathSeparator).last; FileSharingApi().share(FileSharingApiParams( shareType: 10, shareWith: widget.sendToToken, @@ -44,10 +44,10 @@ class _ChatTextfieldState extends State { } } - void mediaUpload(List? paths) async { + Future mediaUpload(List? paths) async { if (paths == null) return; - String shareFolder = 'MarianumMobile'; + var shareFolder = 'MarianumMobile'; WebdavApi.webdav.then((webdav) { webdav.mkcol(PathUri.parse('/$shareFolder')); }); From cf4dea566e125656d31f279daa38c056c37f2d11 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Mon, 8 Apr 2024 22:39:28 +0200 Subject: [PATCH 10/11] solved pr comments; picking multiple Images from Gallery is now possible --- lib/view/pages/files/files.dart | 4 ++-- lib/view/pages/files/filesUploadDialog.dart | 20 +------------------ .../pages/talk/components/chatTextfield.dart | 4 ++-- lib/widget/filePick.dart | 8 ++++++++ 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/lib/view/pages/files/files.dart b/lib/view/pages/files/files.dart index a39bdbe..8068408 100644 --- a/lib/view/pages/files/files.dart +++ b/lib/view/pages/files/files.dart @@ -219,8 +219,8 @@ class _FilesState extends State { leading: const Icon(Icons.add_a_photo_outlined), title: const Text('Aus Gallerie hochladen'), onTap: () { - FilePick.galleryPick().then((value) { - if(value != null) mediaUpload([value.path]); + FilePick.multipleGalleryPick().then((value) { + if(value != null) mediaUpload(value.map((e) => e.path).toList()); }); Navigator.of(context).pop(); }, diff --git a/lib/view/pages/files/filesUploadDialog.dart b/lib/view/pages/files/filesUploadDialog.dart index 794d9a7..72803c2 100644 --- a/lib/view/pages/files/filesUploadDialog.dart +++ b/lib/view/pages/files/filesUploadDialog.dart @@ -170,7 +170,6 @@ class _FilesUploadDialogState extends State { ); if(uploadTask.statusCode < 200 || uploadTask.statusCode > 299) { - // error code setState(() { _isUploading = false; _overallProgressValue = 0.0; @@ -241,7 +240,7 @@ class _FilesUploadDialogState extends State { value: currentFile._uploadProgress, borderRadius: const BorderRadius.all(Radius.circular(2)), ) : null, - leading: Container( + trailing: Container( width: 24, height: 24, padding: EdgeInsets.zero, @@ -256,23 +255,6 @@ class _FilesUploadDialogState extends State { }); } }, - icon: const Icon(Icons.close_outlined), - ), - ), - trailing: Container( - width: 24, - height: 24, - padding: EdgeInsets.zero, - child: IconButton( - tooltip: 'Namen löschen', - padding: EdgeInsets.zero, - onPressed: () { - if(!_isUploading) { - setState(() { - currentFile.fileName = ''; - }); - } - }, icon: const Icon(Icons.delete_outlined), ), ), diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index a39be26..3628006 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -111,8 +111,8 @@ class _ChatTextfieldState extends State { leading: const Icon(Icons.image), title: const Text('Aus Gallerie auswählen'), onTap: () { - FilePick.galleryPick().then((value) { - if(value != null) mediaUpload([value.path]); + FilePick.multipleGalleryPick().then((value) { + if(value != null) mediaUpload(value.map((e) => e.path).toList()); }); Navigator.of(context).pop(); }, diff --git a/lib/widget/filePick.dart b/lib/widget/filePick.dart index a4d490d..b9d7dbb 100644 --- a/lib/widget/filePick.dart +++ b/lib/widget/filePick.dart @@ -13,6 +13,14 @@ class FilePick { return null; } + static Future?> multipleGalleryPick() async { + final pickedImages = await _picker.pickMultiImage(); + if(pickedImages.isNotEmpty) { + return pickedImages; + } + return null; + } + static Future?> documentPick() async { var result = await FilePicker.platform.pickFiles(allowMultiple: true); var paths = result?.files.nonNulls.map((e) => e.path).toList(); From 0302c10fcd2e229185112ee74a81a1638ccc72ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Tue, 9 Apr 2024 18:53:56 +0200 Subject: [PATCH 11/11] #53 fixed misplaced profile pictures --- lib/view/pages/talk/components/chatTile.dart | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/view/pages/talk/components/chatTile.dart b/lib/view/pages/talk/components/chatTile.dart index 0eee6d8..7c313dc 100644 --- a/lib/view/pages/talk/components/chatTile.dart +++ b/lib/view/pages/talk/components/chatTile.dart @@ -30,18 +30,14 @@ class ChatTile extends StatefulWidget { } class _ChatTileState extends State { - late String username; - late UserAvatar circleAvatar; + late String selfUsername; @override void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { - username = value.getString('username')! + selfUsername = value.getString('username')! }); - - var isGroup = widget.data.type != GetRoomResponseObjectConversationType.oneToOne; - circleAvatar = UserAvatar(id: isGroup ? widget.data.token : widget.data.name, isGroup: isGroup); } void setCurrentAsRead() { @@ -54,9 +50,11 @@ class _ChatTileState extends State { ).run().then((value) => widget.query(renew: true)); } - @override - Widget build(BuildContext context) => Consumer(builder: (context, chatData, child) => ListTile( + Widget build(BuildContext context) => Consumer(builder: (context, chatData, child) { + var isGroup = widget.data.type != GetRoomResponseObjectConversationType.oneToOne; + var circleAvatar = UserAvatar(id: isGroup ? widget.data.token : widget.data.name, isGroup: isGroup); + return ListTile( style: ListTileStyle.list, tileColor: chatData.currentToken() == widget.data.token && TalkNavigator.isSecondaryVisible(context) ? Theme.of(context).primaryColor.withAlpha(100) @@ -117,7 +115,7 @@ class _ChatTileState extends State { ), onTap: () async { setCurrentAsRead(); - var view = ChatView(room: widget.data, selfId: username, avatar: circleAvatar); + var view = ChatView(room: widget.data, selfId: selfUsername, avatar: circleAvatar); TalkNavigator.pushSplitView(context, view, overrideToSingleSubScreen: true); Provider.of(context, listen: false).setQueryToken(widget.data.token); }, @@ -182,5 +180,6 @@ class _ChatTileState extends State { ], )); }, - )); + ); + }); }