Compare commits
9 Commits
999e30ab3a
...
develop-bl
Author | SHA1 | Date | |
---|---|---|---|
5bdfb9f766 | |||
54b777237f | |||
ddeeaeaeac | |||
c8e31b896b | |||
c443a1d567 | |||
08ef784f57 | |||
fe93a94fc6 | |||
a33c4ddac5 | |||
634fe41e78 |
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import 'getHolidaysResponse.dart';
|
import 'getHolidaysResponse.dart';
|
||||||
@@ -7,11 +6,10 @@ import 'getHolidaysResponse.dart';
|
|||||||
class GetHolidays {
|
class GetHolidays {
|
||||||
Future<GetHolidaysResponse> query() async {
|
Future<GetHolidaysResponse> query() async {
|
||||||
var response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
|
var response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
|
||||||
|
var data = jsonDecode(response) as List<dynamic>;
|
||||||
return GetHolidaysResponse(
|
return GetHolidaysResponse(
|
||||||
List<GetHolidaysResponseObject>.from(
|
List<GetHolidaysResponseObject>.from(
|
||||||
jsonDecode(response).map<GetHolidaysResponseObject>(
|
data.map<GetHolidaysResponseObject>((e) => GetHolidaysResponseObject.fromJson(e as Map<String, dynamic>))
|
||||||
GetHolidaysResponseObject.fromJson
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -13,12 +13,11 @@ class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
|
|||||||
GetHolidaysResponse onLocalData(String json) {
|
GetHolidaysResponse onLocalData(String json) {
|
||||||
List<dynamic> parsedListJson = jsonDecode(json)['data'];
|
List<dynamic> parsedListJson = jsonDecode(json)['data'];
|
||||||
return GetHolidaysResponse(
|
return GetHolidaysResponse(
|
||||||
List<GetHolidaysResponseObject>.from(
|
List<GetHolidaysResponseObject>.from(
|
||||||
parsedListJson.map<GetHolidaysResponseObject>(
|
parsedListJson.map<GetHolidaysResponseObject>(
|
||||||
// ignore: unnecessary_lambdas
|
(i) => GetHolidaysResponseObject.fromJson(i as Map<String, dynamic>)
|
||||||
(dynamic i) => GetHolidaysResponseObject.fromJson(i)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ GetHolidaysResponseObject _$GetHolidaysResponseObjectFromJson(
|
|||||||
GetHolidaysResponseObject(
|
GetHolidaysResponseObject(
|
||||||
start: json['start'] as String,
|
start: json['start'] as String,
|
||||||
end: json['end'] as String,
|
end: json['end'] as String,
|
||||||
year: json['year'] as int,
|
year: (json['year'] as num).toInt(),
|
||||||
stateCode: json['stateCode'] as String,
|
stateCode: json['stateCode'] as String,
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
slug: json['slug'] as String,
|
slug: json['slug'] as String,
|
||||||
|
@@ -9,7 +9,7 @@ part of 'fileSharingApiParams.dart';
|
|||||||
FileSharingApiParams _$FileSharingApiParamsFromJson(
|
FileSharingApiParams _$FileSharingApiParamsFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
FileSharingApiParams(
|
FileSharingApiParams(
|
||||||
shareType: json['shareType'] as int,
|
shareType: (json['shareType'] as num).toInt(),
|
||||||
shareWith: json['shareWith'] as String,
|
shareWith: json['shareWith'] as String,
|
||||||
path: json['path'] as String,
|
path: json['path'] as String,
|
||||||
referenceId: json['referenceId'] as String?,
|
referenceId: json['referenceId'] as String?,
|
||||||
|
@@ -10,10 +10,10 @@ GetChatParams _$GetChatParamsFromJson(Map<String, dynamic> json) =>
|
|||||||
GetChatParams(
|
GetChatParams(
|
||||||
lookIntoFuture:
|
lookIntoFuture:
|
||||||
$enumDecode(_$GetChatParamsSwitchEnumMap, json['lookIntoFuture']),
|
$enumDecode(_$GetChatParamsSwitchEnumMap, json['lookIntoFuture']),
|
||||||
limit: json['limit'] as int?,
|
limit: (json['limit'] as num?)?.toInt(),
|
||||||
lastKnownMessageId: json['lastKnownMessageId'] as int?,
|
lastKnownMessageId: (json['lastKnownMessageId'] as num?)?.toInt(),
|
||||||
lastCommonReadId: json['lastCommonReadId'] as int?,
|
lastCommonReadId: (json['lastCommonReadId'] as num?)?.toInt(),
|
||||||
timeout: json['timeout'] as int?,
|
timeout: (json['timeout'] as num?)?.toInt(),
|
||||||
setReadMarker: $enumDecodeNullable(
|
setReadMarker: $enumDecodeNullable(
|
||||||
_$GetChatParamsSwitchEnumMap, json['setReadMarker']),
|
_$GetChatParamsSwitchEnumMap, json['setReadMarker']),
|
||||||
includeLastKnown: $enumDecodeNullable(
|
includeLastKnown: $enumDecodeNullable(
|
||||||
|
@@ -32,13 +32,13 @@ Map<String, dynamic> _$GetChatResponseToJson(GetChatResponse instance) {
|
|||||||
GetChatResponseObject _$GetChatResponseObjectFromJson(
|
GetChatResponseObject _$GetChatResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetChatResponseObject(
|
GetChatResponseObject(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['token'] as String,
|
json['token'] as String,
|
||||||
$enumDecode(
|
$enumDecode(
|
||||||
_$GetRoomResponseObjectMessageActorTypeEnumMap, json['actorType']),
|
_$GetRoomResponseObjectMessageActorTypeEnumMap, json['actorType']),
|
||||||
json['actorId'] as String,
|
json['actorId'] as String,
|
||||||
json['actorDisplayName'] as String,
|
json['actorDisplayName'] as String,
|
||||||
json['timestamp'] as int,
|
(json['timestamp'] as num).toInt(),
|
||||||
json['systemMessage'] as String,
|
json['systemMessage'] as String,
|
||||||
$enumDecode(
|
$enumDecode(
|
||||||
_$GetRoomResponseObjectMessageTypeEnumMap, json['messageType']),
|
_$GetRoomResponseObjectMessageTypeEnumMap, json['messageType']),
|
||||||
@@ -47,7 +47,7 @@ GetChatResponseObject _$GetChatResponseObjectFromJson(
|
|||||||
json['message'] as String,
|
json['message'] as String,
|
||||||
_fromJson(json['messageParameters']),
|
_fromJson(json['messageParameters']),
|
||||||
(json['reactions'] as Map<String, dynamic>?)?.map(
|
(json['reactions'] as Map<String, dynamic>?)?.map(
|
||||||
(k, e) => MapEntry(k, e as int),
|
(k, e) => MapEntry(k, (e as num).toInt()),
|
||||||
),
|
),
|
||||||
(json['reactionsSelf'] as List<dynamic>?)
|
(json['reactionsSelf'] as List<dynamic>?)
|
||||||
?.map((e) => e as String)
|
?.map((e) => e as String)
|
||||||
|
@@ -8,7 +8,7 @@ part of 'createRoomParams.dart';
|
|||||||
|
|
||||||
CreateRoomParams _$CreateRoomParamsFromJson(Map<String, dynamic> json) =>
|
CreateRoomParams _$CreateRoomParamsFromJson(Map<String, dynamic> json) =>
|
||||||
CreateRoomParams(
|
CreateRoomParams(
|
||||||
roomType: json['roomType'] as int,
|
roomType: (json['roomType'] as num).toInt(),
|
||||||
invite: json['invite'] as String,
|
invite: json['invite'] as String,
|
||||||
source: json['source'] as String?,
|
source: json['source'] as String?,
|
||||||
roomName: json['roomName'] as String?,
|
roomName: json['roomName'] as String?,
|
||||||
|
@@ -35,17 +35,17 @@ Map<String, dynamic> _$GetParticipantsResponseToJson(
|
|||||||
GetParticipantsResponseObject _$GetParticipantsResponseObjectFromJson(
|
GetParticipantsResponseObject _$GetParticipantsResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetParticipantsResponseObject(
|
GetParticipantsResponseObject(
|
||||||
json['attendeeId'] as int,
|
(json['attendeeId'] as num).toInt(),
|
||||||
json['actorType'] as String,
|
json['actorType'] as String,
|
||||||
json['actorId'] as String,
|
json['actorId'] as String,
|
||||||
json['displayName'] as String,
|
json['displayName'] as String,
|
||||||
$enumDecode(_$GetParticipantsResponseObjectParticipantTypeEnumMap,
|
$enumDecode(_$GetParticipantsResponseObjectParticipantTypeEnumMap,
|
||||||
json['participantType']),
|
json['participantType']),
|
||||||
json['lastPing'] as int,
|
(json['lastPing'] as num).toInt(),
|
||||||
$enumDecode(_$GetParticipantsResponseObjectParticipantsInCallFlagsEnumMap,
|
$enumDecode(_$GetParticipantsResponseObjectParticipantsInCallFlagsEnumMap,
|
||||||
json['inCall']),
|
json['inCall']),
|
||||||
json['permissions'] as int,
|
(json['permissions'] as num).toInt(),
|
||||||
json['attendeePermissions'] as int,
|
(json['attendeePermissions'] as num).toInt(),
|
||||||
json['sessionId'] as String?,
|
json['sessionId'] as String?,
|
||||||
(json['sessionIds'] as List<dynamic>).map((e) => e as String).toList(),
|
(json['sessionIds'] as List<dynamic>).map((e) => e as String).toList(),
|
||||||
json['status'] as String?,
|
json['status'] as String?,
|
||||||
|
@@ -44,7 +44,7 @@ GetReactionsResponseObject _$GetReactionsResponseObjectFromJson(
|
|||||||
_$GetReactionsResponseObjectActorTypeEnumMap, json['actorType']),
|
_$GetReactionsResponseObjectActorTypeEnumMap, json['actorType']),
|
||||||
json['actorId'] as String,
|
json['actorId'] as String,
|
||||||
json['actorDisplayName'] as String,
|
json['actorDisplayName'] as String,
|
||||||
json['timestamp'] as int,
|
(json['timestamp'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$GetReactionsResponseObjectToJson(
|
Map<String, dynamic> _$GetReactionsResponseObjectToJson(
|
||||||
|
@@ -11,7 +11,7 @@ GetRoomParams _$GetRoomParamsFromJson(Map<String, dynamic> json) =>
|
|||||||
noStatusUpdate: $enumDecodeNullable(
|
noStatusUpdate: $enumDecodeNullable(
|
||||||
_$GetRoomParamsStatusUpdateEnumMap, json['noStatusUpdate']),
|
_$GetRoomParamsStatusUpdateEnumMap, json['noStatusUpdate']),
|
||||||
includeStatus: json['includeStatus'] as bool?,
|
includeStatus: json['includeStatus'] as bool?,
|
||||||
modifiedSince: json['modifiedSince'] as int?,
|
modifiedSince: (json['modifiedSince'] as num?)?.toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$GetRoomParamsToJson(GetRoomParams instance) =>
|
Map<String, dynamic> _$GetRoomParamsToJson(GetRoomParams instance) =>
|
||||||
|
@@ -32,33 +32,33 @@ Map<String, dynamic> _$GetRoomResponseToJson(GetRoomResponse instance) {
|
|||||||
GetRoomResponseObject _$GetRoomResponseObjectFromJson(
|
GetRoomResponseObject _$GetRoomResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetRoomResponseObject(
|
GetRoomResponseObject(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['token'] as String,
|
json['token'] as String,
|
||||||
$enumDecode(_$GetRoomResponseObjectConversationTypeEnumMap, json['type']),
|
$enumDecode(_$GetRoomResponseObjectConversationTypeEnumMap, json['type']),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['displayName'] as String,
|
json['displayName'] as String,
|
||||||
json['description'] as String,
|
json['description'] as String,
|
||||||
json['participantType'] as int,
|
(json['participantType'] as num).toInt(),
|
||||||
json['participantFlags'] as int,
|
(json['participantFlags'] as num).toInt(),
|
||||||
json['readOnly'] as int,
|
(json['readOnly'] as num).toInt(),
|
||||||
json['listable'] as int,
|
(json['listable'] as num).toInt(),
|
||||||
json['lastPing'] as int,
|
(json['lastPing'] as num).toInt(),
|
||||||
json['sessionId'] as String,
|
json['sessionId'] as String,
|
||||||
json['hasPassword'] as bool,
|
json['hasPassword'] as bool,
|
||||||
json['hasCall'] as bool,
|
json['hasCall'] as bool,
|
||||||
json['callFlag'] as int,
|
(json['callFlag'] as num).toInt(),
|
||||||
json['canStartCall'] as bool,
|
json['canStartCall'] as bool,
|
||||||
json['canDeleteConversation'] as bool,
|
json['canDeleteConversation'] as bool,
|
||||||
json['canLeaveConversation'] as bool,
|
json['canLeaveConversation'] as bool,
|
||||||
json['lastActivity'] as int,
|
(json['lastActivity'] as num).toInt(),
|
||||||
json['isFavorite'] as bool,
|
json['isFavorite'] as bool,
|
||||||
$enumDecode(_$GetRoomResponseObjectParticipantNotificationLevelEnumMap,
|
$enumDecode(_$GetRoomResponseObjectParticipantNotificationLevelEnumMap,
|
||||||
json['notificationLevel']),
|
json['notificationLevel']),
|
||||||
json['unreadMessages'] as int,
|
(json['unreadMessages'] as num).toInt(),
|
||||||
json['unreadMention'] as bool,
|
json['unreadMention'] as bool,
|
||||||
json['unreadMentionDirect'] as bool,
|
json['unreadMentionDirect'] as bool,
|
||||||
json['lastReadMessage'] as int,
|
(json['lastReadMessage'] as num).toInt(),
|
||||||
json['lastCommonReadMessage'] as int,
|
(json['lastCommonReadMessage'] as num).toInt(),
|
||||||
GetChatResponseObject.fromJson(
|
GetChatResponseObject.fromJson(
|
||||||
json['lastMessage'] as Map<String, dynamic>),
|
json['lastMessage'] as Map<String, dynamic>),
|
||||||
json['status'] as String?,
|
json['status'] as String?,
|
||||||
|
@@ -8,7 +8,7 @@ part of 'setReadMarkerParams.dart';
|
|||||||
|
|
||||||
SetReadMarkerParams _$SetReadMarkerParamsFromJson(Map<String, dynamic> json) =>
|
SetReadMarkerParams _$SetReadMarkerParamsFromJson(Map<String, dynamic> json) =>
|
||||||
SetReadMarkerParams(
|
SetReadMarkerParams(
|
||||||
lastReadMessage: json['lastReadMessage'] as int?,
|
lastReadMessage: (json['lastReadMessage'] as num?)?.toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$SetReadMarkerParamsToJson(
|
Map<String, dynamic> _$SetReadMarkerParamsToJson(
|
||||||
|
@@ -12,7 +12,7 @@ CacheableFile _$CacheableFileFromJson(Map<String, dynamic> json) =>
|
|||||||
isDirectory: json['isDirectory'] as bool,
|
isDirectory: json['isDirectory'] as bool,
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
mimeType: json['mimeType'] as String?,
|
mimeType: json['mimeType'] as String?,
|
||||||
size: json['size'] as int?,
|
size: (json['size'] as num?)?.toInt(),
|
||||||
eTag: json['eTag'] as String?,
|
eTag: json['eTag'] as String?,
|
||||||
createdAt: json['createdAt'] == null
|
createdAt: json['createdAt'] == null
|
||||||
? null
|
? null
|
||||||
|
@@ -11,7 +11,7 @@ AddFeedbackParams _$AddFeedbackParamsFromJson(Map<String, dynamic> json) =>
|
|||||||
user: json['user'] as String,
|
user: json['user'] as String,
|
||||||
feedback: json['feedback'] as String,
|
feedback: json['feedback'] as String,
|
||||||
screenshot: json['screenshot'] as String?,
|
screenshot: json['screenshot'] as String?,
|
||||||
appVersion: json['appVersion'] as int,
|
appVersion: (json['appVersion'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$AddFeedbackParamsToJson(AddFeedbackParams instance) =>
|
Map<String, dynamic> _$AddFeedbackParamsToJson(AddFeedbackParams instance) =>
|
||||||
|
@@ -12,7 +12,7 @@ UpdateUserIndexParams _$UpdateUserIndexParamsFromJson(
|
|||||||
user: json['user'] as String,
|
user: json['user'] as String,
|
||||||
username: json['username'] as String,
|
username: json['username'] as String,
|
||||||
device: json['device'] as String,
|
device: json['device'] as String,
|
||||||
appVersion: json['appVersion'] as int,
|
appVersion: (json['appVersion'] as num).toInt(),
|
||||||
deviceInfo: json['deviceInfo'] as String,
|
deviceInfo: json['deviceInfo'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -10,9 +10,9 @@ AuthenticateResponse _$AuthenticateResponseFromJson(
|
|||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
AuthenticateResponse(
|
AuthenticateResponse(
|
||||||
json['sessionId'] as String,
|
json['sessionId'] as String,
|
||||||
json['personType'] as int,
|
(json['personType'] as num).toInt(),
|
||||||
json['personId'] as int,
|
(json['personId'] as num).toInt(),
|
||||||
json['klasseId'] as int,
|
(json['klasseId'] as num).toInt(),
|
||||||
)..headers = (json['headers'] as Map<String, dynamic>?)?.map(
|
)..headers = (json['headers'] as Map<String, dynamic>?)?.map(
|
||||||
(k, e) => MapEntry(k, e as String),
|
(k, e) => MapEntry(k, e as String),
|
||||||
);
|
);
|
||||||
|
@@ -33,11 +33,11 @@ Map<String, dynamic> _$GetHolidaysResponseToJson(GetHolidaysResponse instance) {
|
|||||||
GetHolidaysResponseObject _$GetHolidaysResponseObjectFromJson(
|
GetHolidaysResponseObject _$GetHolidaysResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetHolidaysResponseObject(
|
GetHolidaysResponseObject(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longName'] as String,
|
json['longName'] as String,
|
||||||
json['startDate'] as int,
|
(json['startDate'] as num).toInt(),
|
||||||
json['endDate'] as int,
|
(json['endDate'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$GetHolidaysResponseObjectToJson(
|
Map<String, dynamic> _$GetHolidaysResponseObjectToJson(
|
||||||
|
@@ -33,7 +33,7 @@ Map<String, dynamic> _$GetRoomsResponseToJson(GetRoomsResponse instance) {
|
|||||||
GetRoomsResponseObject _$GetRoomsResponseObjectFromJson(
|
GetRoomsResponseObject _$GetRoomsResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetRoomsResponseObject(
|
GetRoomsResponseObject(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longName'] as String,
|
json['longName'] as String,
|
||||||
json['active'] as bool,
|
json['active'] as bool,
|
||||||
|
@@ -33,7 +33,7 @@ Map<String, dynamic> _$GetSubjectsResponseToJson(GetSubjectsResponse instance) {
|
|||||||
GetSubjectsResponseObject _$GetSubjectsResponseObjectFromJson(
|
GetSubjectsResponseObject _$GetSubjectsResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetSubjectsResponseObject(
|
GetSubjectsResponseObject(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longName'] as String,
|
json['longName'] as String,
|
||||||
json['alternateName'] as String,
|
json['alternateName'] as String,
|
||||||
|
@@ -22,8 +22,8 @@ GetTimetableParamsOptions _$GetTimetableParamsOptionsFromJson(
|
|||||||
GetTimetableParamsOptions(
|
GetTimetableParamsOptions(
|
||||||
element: GetTimetableParamsOptionsElement.fromJson(
|
element: GetTimetableParamsOptionsElement.fromJson(
|
||||||
json['element'] as Map<String, dynamic>),
|
json['element'] as Map<String, dynamic>),
|
||||||
startDate: json['startDate'] as int?,
|
startDate: (json['startDate'] as num?)?.toInt(),
|
||||||
endDate: json['endDate'] as int?,
|
endDate: (json['endDate'] as num?)?.toInt(),
|
||||||
onlyBaseTimetable: json['onlyBaseTimetable'] as bool?,
|
onlyBaseTimetable: json['onlyBaseTimetable'] as bool?,
|
||||||
showBooking: json['showBooking'] as bool?,
|
showBooking: json['showBooking'] as bool?,
|
||||||
showInfo: json['showInfo'] as bool?,
|
showInfo: json['showInfo'] as bool?,
|
||||||
@@ -99,8 +99,8 @@ const _$GetTimetableParamsOptionsFieldsEnumMap = {
|
|||||||
GetTimetableParamsOptionsElement _$GetTimetableParamsOptionsElementFromJson(
|
GetTimetableParamsOptionsElement _$GetTimetableParamsOptionsElementFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableParamsOptionsElement(
|
GetTimetableParamsOptionsElement(
|
||||||
id: json['id'] as int,
|
id: (json['id'] as num).toInt(),
|
||||||
type: json['type'] as int,
|
type: (json['type'] as num).toInt(),
|
||||||
keyType: $enumDecodeNullable(
|
keyType: $enumDecodeNullable(
|
||||||
_$GetTimetableParamsOptionsElementKeyTypeEnumMap, json['keyType']),
|
_$GetTimetableParamsOptionsElementKeyTypeEnumMap, json['keyType']),
|
||||||
);
|
);
|
||||||
|
@@ -35,16 +35,16 @@ Map<String, dynamic> _$GetTimetableResponseToJson(
|
|||||||
GetTimetableResponseObject _$GetTimetableResponseObjectFromJson(
|
GetTimetableResponseObject _$GetTimetableResponseObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableResponseObject(
|
GetTimetableResponseObject(
|
||||||
id: json['id'] as int,
|
id: (json['id'] as num).toInt(),
|
||||||
date: json['date'] as int,
|
date: (json['date'] as num).toInt(),
|
||||||
startTime: json['startTime'] as int,
|
startTime: (json['startTime'] as num).toInt(),
|
||||||
endTime: json['endTime'] as int,
|
endTime: (json['endTime'] as num).toInt(),
|
||||||
lstype: json['lstype'] as String?,
|
lstype: json['lstype'] as String?,
|
||||||
code: json['code'] as String?,
|
code: json['code'] as String?,
|
||||||
info: json['info'] as String?,
|
info: json['info'] as String?,
|
||||||
substText: json['substText'] as String?,
|
substText: json['substText'] as String?,
|
||||||
lstext: json['lstext'] as String?,
|
lstext: json['lstext'] as String?,
|
||||||
lsnumber: json['lsnumber'] as int?,
|
lsnumber: (json['lsnumber'] as num?)?.toInt(),
|
||||||
statflags: json['statflags'] as String?,
|
statflags: json['statflags'] as String?,
|
||||||
activityType: json['activityType'] as String?,
|
activityType: json['activityType'] as String?,
|
||||||
sg: json['sg'] as String?,
|
sg: json['sg'] as String?,
|
||||||
@@ -110,7 +110,7 @@ GetTimetableResponseObjectFieldsObject
|
|||||||
_$GetTimetableResponseObjectFieldsObjectFromJson(
|
_$GetTimetableResponseObjectFieldsObjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableResponseObjectFieldsObject(
|
GetTimetableResponseObjectFieldsObject(
|
||||||
id: json['id'] as int?,
|
id: (json['id'] as num?)?.toInt(),
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
longname: json['longname'] as String?,
|
longname: json['longname'] as String?,
|
||||||
externalkey: json['externalkey'] as String?,
|
externalkey: json['externalkey'] as String?,
|
||||||
@@ -128,7 +128,7 @@ Map<String, dynamic> _$GetTimetableResponseObjectFieldsObjectToJson(
|
|||||||
GetTimetableResponseObjectClass _$GetTimetableResponseObjectClassFromJson(
|
GetTimetableResponseObjectClass _$GetTimetableResponseObjectClassFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableResponseObjectClass(
|
GetTimetableResponseObjectClass(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longname'] as String,
|
json['longname'] as String,
|
||||||
json['externalkey'] as String?,
|
json['externalkey'] as String?,
|
||||||
@@ -146,10 +146,10 @@ Map<String, dynamic> _$GetTimetableResponseObjectClassToJson(
|
|||||||
GetTimetableResponseObjectTeacher _$GetTimetableResponseObjectTeacherFromJson(
|
GetTimetableResponseObjectTeacher _$GetTimetableResponseObjectTeacherFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableResponseObjectTeacher(
|
GetTimetableResponseObjectTeacher(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longname'] as String,
|
json['longname'] as String,
|
||||||
json['orgid'] as int?,
|
(json['orgid'] as num?)?.toInt(),
|
||||||
json['orgname'] as String?,
|
json['orgname'] as String?,
|
||||||
json['externalkey'] as String?,
|
json['externalkey'] as String?,
|
||||||
);
|
);
|
||||||
@@ -168,7 +168,7 @@ Map<String, dynamic> _$GetTimetableResponseObjectTeacherToJson(
|
|||||||
GetTimetableResponseObjectSubject _$GetTimetableResponseObjectSubjectFromJson(
|
GetTimetableResponseObjectSubject _$GetTimetableResponseObjectSubjectFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableResponseObjectSubject(
|
GetTimetableResponseObjectSubject(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longname'] as String,
|
json['longname'] as String,
|
||||||
);
|
);
|
||||||
@@ -184,7 +184,7 @@ Map<String, dynamic> _$GetTimetableResponseObjectSubjectToJson(
|
|||||||
GetTimetableResponseObjectRoom _$GetTimetableResponseObjectRoomFromJson(
|
GetTimetableResponseObjectRoom _$GetTimetableResponseObjectRoomFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
GetTimetableResponseObjectRoom(
|
GetTimetableResponseObjectRoom(
|
||||||
json['id'] as int,
|
(json['id'] as num).toInt(),
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['longname'] as String,
|
json['longname'] as String,
|
||||||
);
|
);
|
||||||
|
93
lib/app.dart
93
lib/app.dart
@@ -94,55 +94,56 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => PersistentTabView(
|
Widget build(BuildContext context) => PersistentTabView(
|
||||||
controller: Main.bottomNavigator,
|
controller: Main.bottomNavigator,
|
||||||
navBarOverlap: const NavBarOverlap.none(),
|
navBarOverlap: const NavBarOverlap.none(),
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
handleAndroidBackButtonPress: false,
|
handleAndroidBackButtonPress: true,
|
||||||
|
|
||||||
screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)),
|
screenTransitionAnimation: const ScreenTransitionAnimation(curve: Curves.easeOutQuad, duration: Duration(milliseconds: 200)),
|
||||||
tabs: [
|
tabs: [
|
||||||
AppModule.getModule(Modules.timetable).toBottomTab(context),
|
AppModule.getModule(Modules.timetable).toBottomTab(context),
|
||||||
AppModule.getModule(Modules.talk).toBottomTab(
|
AppModule.getModule(Modules.talk).toBottomTab(
|
||||||
context,
|
context,
|
||||||
itemBuilder: (icon) => Consumer<ChatListProps>(
|
itemBuilder: (icon) => Consumer<ChatListProps>(
|
||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
if(value.primaryLoading()) return Icon(icon);
|
if(value.primaryLoading()) return Icon(icon);
|
||||||
var 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(
|
return badges.Badge(
|
||||||
showBadge: messages > 0,
|
showBadge: messages > 0,
|
||||||
position: badges.BadgePosition.topEnd(top: -3, end: -3),
|
position: badges.BadgePosition.topEnd(top: -3, end: -3),
|
||||||
stackFit: StackFit.loose,
|
stackFit: StackFit.loose,
|
||||||
badgeStyle: badges.BadgeStyle(
|
badgeStyle: badges.BadgeStyle(
|
||||||
padding: const EdgeInsets.all(3),
|
padding: const EdgeInsets.all(3),
|
||||||
badgeColor: Theme.of(context).primaryColor,
|
badgeColor: Theme.of(context).primaryColor,
|
||||||
elevation: 1,
|
elevation: 1,
|
||||||
),
|
),
|
||||||
badgeContent: Text('$messages', style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold)),
|
badgeContent: Text('$messages', style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold)),
|
||||||
child: Icon(icon),
|
child: Icon(icon),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
|
||||||
AppModule.getModule(Modules.files).toBottomTab(context),
|
|
||||||
|
|
||||||
PersistentTabConfig(
|
|
||||||
screen: const Breaker(breaker: BreakerArea.more, child: Overhang()),
|
|
||||||
item: ItemConfig(
|
|
||||||
activeForegroundColor: Theme.of(context).primaryColor,
|
|
||||||
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
|
|
||||||
icon: const Icon(Icons.apps),
|
|
||||||
title: 'Mehr'
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
navBarBuilder: (config) => Style6BottomNavBar(
|
|
||||||
navBarConfig: config,
|
|
||||||
navBarDecoration: NavBarDecoration(
|
|
||||||
border: const Border(top: BorderSide(width: 1, color: Colors.grey)),
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
AppModule.getModule(Modules.blocFiles).toBottomTab(context),
|
||||||
|
AppModule.getModule(Modules.files).toBottomTab(context),
|
||||||
|
|
||||||
|
PersistentTabConfig(
|
||||||
|
screen: const Breaker(breaker: BreakerArea.more, child: Overhang()),
|
||||||
|
item: ItemConfig(
|
||||||
|
activeForegroundColor: Theme.of(context).primaryColor,
|
||||||
|
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
|
||||||
|
icon: const Icon(Icons.apps),
|
||||||
|
title: 'Mehr'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
navBarBuilder: (config) => Style6BottomNavBar(
|
||||||
|
navBarConfig: config,
|
||||||
|
navBarDecoration: NavBarDecoration(
|
||||||
|
border: const Border(top: BorderSide(width: 1, color: Colors.grey)),
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
@@ -42,7 +42,7 @@ Future<void> main() async {
|
|||||||
var initialisationTasks = [
|
var initialisationTasks = [
|
||||||
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
|
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
|
||||||
.then((value) async => log("Firebase token: ${await FirebaseMessaging.instance.getToken() ?? "Error: no Firebase token!"}"))
|
.then((value) async => log("Firebase token: ${await FirebaseMessaging.instance.getToken() ?? "Error: no Firebase token!"}"))
|
||||||
.onError((error, stackTrace) => log('Error initializing Firebase: $error')),
|
.onError((error, stackTrace) => log('Error initializing Firebase: $error', stackTrace: stackTrace)),
|
||||||
|
|
||||||
PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem').then(addCertificateAsTrusted),
|
PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem').then(addCertificateAsTrusted),
|
||||||
PlatformAssetBundle().load('assets/ca/lets-encrypt-r10.pem').then(addCertificateAsTrusted),
|
PlatformAssetBundle().load('assets/ca/lets-encrypt-r10.pem').then(addCertificateAsTrusted),
|
||||||
|
9
lib/state/app/basis/dataloader/holiday_data_loader.dart
Normal file
9
lib/state/app/basis/dataloader/holiday_data_loader.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
import '../../infrastructure/dataLoader/http_data_loader.dart';
|
||||||
|
|
||||||
|
abstract class HolidayDataLoader<TResult> extends HttpDataLoader<TResult> {
|
||||||
|
HolidayDataLoader() : super(Dio(BaseOptions(
|
||||||
|
baseUrl: 'https://ferien-api.de/api/v1/',
|
||||||
|
)));
|
||||||
|
}
|
@@ -1,8 +1,8 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
import 'data_loader.dart';
|
import '../../infrastructure/dataLoader/http_data_loader.dart';
|
||||||
|
|
||||||
abstract class MhslDataLoader<TResult> extends DataLoader<TResult> {
|
abstract class MhslDataLoader<TResult> extends HttpDataLoader<TResult> {
|
||||||
MhslDataLoader() : super(Dio(BaseOptions(
|
MhslDataLoader() : super(Dio(BaseOptions(
|
||||||
baseUrl: 'https://mhsl.eu/marianum/marianummobile/'
|
baseUrl: 'https://mhsl.eu/marianum/marianummobile/'
|
||||||
)));
|
)));
|
@@ -2,26 +2,21 @@ import 'dart:convert';
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
abstract class DataLoader<TResult> {
|
abstract class HttpDataLoader<TResult> {
|
||||||
final Dio dio;
|
final Dio dio;
|
||||||
DataLoader(this.dio) {
|
HttpDataLoader(this.dio) {
|
||||||
dio.options.connectTimeout = const Duration(seconds: 10).inMilliseconds;
|
dio.options.connectTimeout = const Duration(seconds: 10).inMilliseconds;
|
||||||
dio.options.sendTimeout = const Duration(seconds: 30).inMilliseconds;
|
dio.options.sendTimeout = const Duration(seconds: 30).inMilliseconds;
|
||||||
dio.options.receiveTimeout = const Duration(seconds: 30).inMilliseconds;
|
dio.options.receiveTimeout = const Duration(seconds: 30).inMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<TResult> run() async {
|
Future<TResult> run() async {
|
||||||
var fetcher = fetch();
|
var response = await fetch();
|
||||||
await Future.wait([
|
|
||||||
fetcher,
|
|
||||||
Future.delayed(const Duration(milliseconds: 500)) // TODO tune or remove
|
|
||||||
]);
|
|
||||||
|
|
||||||
var response = await fetcher;
|
|
||||||
try {
|
try {
|
||||||
return assemble(DataLoaderResult(
|
return assemble(DataLoaderResult(
|
||||||
json: jsonDecode(response.data!),
|
json: await compute(jsonDecode, response.data!),
|
||||||
headers: response.headers.map.map((key, value) => MapEntry(key, value.join(';'))),
|
headers: response.headers.map.map((key, value) => MapEntry(key, value.join(';'))),
|
||||||
));
|
));
|
||||||
} catch(trace, e) {
|
} catch(trace, e) {
|
||||||
@@ -35,8 +30,12 @@ abstract class DataLoader<TResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DataLoaderResult {
|
class DataLoaderResult {
|
||||||
final Map<String, dynamic> json;
|
final dynamic json;
|
||||||
final Map<String, String> headers;
|
final Map<String, String> headers;
|
||||||
|
|
||||||
|
Map<String, dynamic> asMap() => json as Map<String, dynamic>;
|
||||||
|
List<dynamic> asList() => json as List<dynamic>;
|
||||||
|
List<Map<String, dynamic>> asListOfMaps() => asList().map((e) => e as Map<String, dynamic>).toList();
|
||||||
|
|
||||||
DataLoaderResult({required this.json, required this.headers});
|
DataLoaderResult({required this.json, required this.headers});
|
||||||
}
|
}
|
@@ -9,11 +9,11 @@ class LoadableState<TState> with _$LoadableState {
|
|||||||
const LoadableState._();
|
const LoadableState._();
|
||||||
|
|
||||||
const factory LoadableState({
|
const factory LoadableState({
|
||||||
@Default(true) bool isLoading,
|
required bool isLoading,
|
||||||
@Default(null) TState? data,
|
required TState? data,
|
||||||
@Default(null) int? lastFetch,
|
required int? lastFetch,
|
||||||
@Default(null) void Function()? reFetch,
|
required void Function()? reFetch,
|
||||||
@Default(null) LoadingError? error,
|
required LoadingError? error,
|
||||||
}) = _LoadableState;
|
}) = _LoadableState;
|
||||||
|
|
||||||
bool _hasError() => error != null;
|
bool _hasError() => error != null;
|
||||||
|
@@ -166,27 +166,22 @@ class __$$LoadableStateImplCopyWithImpl<TState, $Res>
|
|||||||
|
|
||||||
class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
|
class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
|
||||||
const _$LoadableStateImpl(
|
const _$LoadableStateImpl(
|
||||||
{this.isLoading = true,
|
{required this.isLoading,
|
||||||
this.data = null,
|
required this.data,
|
||||||
this.lastFetch = null,
|
required this.lastFetch,
|
||||||
this.reFetch = null,
|
required this.reFetch,
|
||||||
this.error = null})
|
required this.error})
|
||||||
: super._();
|
: super._();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
|
||||||
final TState? data;
|
final TState? data;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
|
||||||
final int? lastFetch;
|
final int? lastFetch;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
|
||||||
final void Function()? reFetch;
|
final void Function()? reFetch;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
|
||||||
final LoadingError? error;
|
final LoadingError? error;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -222,11 +217,11 @@ class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
|
|||||||
|
|
||||||
abstract class _LoadableState<TState> extends LoadableState<TState> {
|
abstract class _LoadableState<TState> extends LoadableState<TState> {
|
||||||
const factory _LoadableState(
|
const factory _LoadableState(
|
||||||
{final bool isLoading,
|
{required final bool isLoading,
|
||||||
final TState? data,
|
required final TState? data,
|
||||||
final int? lastFetch,
|
required final int? lastFetch,
|
||||||
final void Function()? reFetch,
|
required final void Function()? reFetch,
|
||||||
final LoadingError? error}) = _$LoadableStateImpl<TState>;
|
required final LoadingError? error}) = _$LoadableStateImpl<TState>;
|
||||||
const _LoadableState._() : super._();
|
const _LoadableState._() : super._();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -15,14 +15,23 @@ import 'loadable_state_primary_loading.dart';
|
|||||||
|
|
||||||
class LoadableStateConsumer<TController extends Bloc<LoadableHydratedBlocEvent<TState>, LoadableState<TState>>, TState> extends StatelessWidget {
|
class LoadableStateConsumer<TController extends Bloc<LoadableHydratedBlocEvent<TState>, LoadableState<TState>>, TState> extends StatelessWidget {
|
||||||
final Widget Function(TState state, bool loading) child;
|
final Widget Function(TState state, bool loading) child;
|
||||||
|
final void Function(TState state)? onLoad;
|
||||||
final bool wrapWithScrollView;
|
final bool wrapWithScrollView;
|
||||||
const LoadableStateConsumer({required this.child, this.wrapWithScrollView = false, super.key});
|
final TController? controllerByValue;
|
||||||
|
const LoadableStateConsumer({required this.child, this.onLoad, this.wrapWithScrollView = false, this.controllerByValue = null, super.key});
|
||||||
|
|
||||||
static Duration animationDuration = const Duration(milliseconds: 200);
|
static Duration animationDuration = const Duration(milliseconds: 200);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var loadableState = context.watch<TController>().state;
|
var loadableState = controllerByValue != null
|
||||||
|
? controllerByValue!.state
|
||||||
|
: context.watch<TController>().state;
|
||||||
|
|
||||||
|
if(!loadableState.isLoading && onLoad != null) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) => onLoad!(loadableState.data));
|
||||||
|
}
|
||||||
|
|
||||||
var childWidget = ConditionalWrapper(
|
var childWidget = ConditionalWrapper(
|
||||||
condition: loadableState.reFetch != null,
|
condition: loadableState.reFetch != null,
|
||||||
wrapper: (child) => RefreshIndicator(
|
wrapper: (child) => RefreshIndicator(
|
||||||
|
@@ -89,4 +89,3 @@ class _LoadableStateErrorBarTextState extends State<LoadableStateErrorBarText> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,14 +5,19 @@ class BlocModule<TBloc extends StateStreamableSource<TState>, TState> extends St
|
|||||||
final TBloc Function(BuildContext context) create;
|
final TBloc Function(BuildContext context) create;
|
||||||
final Widget Function(BuildContext context, TBloc bloc, TState state) child;
|
final Widget Function(BuildContext context, TBloc bloc, TState state) child;
|
||||||
final bool autoRebuild;
|
final bool autoRebuild;
|
||||||
const BlocModule({required this.create, required this.child, this.autoRebuild = false, super.key});
|
final void Function(BuildContext context, TBloc bloc)? onInitialisation;
|
||||||
|
const BlocModule({required this.create, required this.child, this.autoRebuild = false, this.onInitialisation, super.key});
|
||||||
|
|
||||||
Widget rebuildChild(BuildContext context) => child(context, context.watch<TBloc>(), context.watch<TBloc>().state);
|
Widget rebuildChild(BuildContext context) => child(context, context.watch<TBloc>(), context.watch<TBloc>().state);
|
||||||
Widget staticChild(BuildContext context) => child(context, context.read<TBloc>(), context.read<TBloc>().state);
|
Widget staticChild(BuildContext context) => child(context, context.read<TBloc>(), context.read<TBloc>().state);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => BlocProvider<TBloc>(
|
Widget build(BuildContext context) => BlocProvider<TBloc>(
|
||||||
create: create,
|
create: (context) {
|
||||||
|
var bloc = create(context);
|
||||||
|
this.onInitialisation != null ? this.onInitialisation!(context, bloc) : null;
|
||||||
|
return bloc;
|
||||||
|
},
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) => autoRebuild
|
builder: (context) => autoRebuild
|
||||||
? rebuildChild(context)
|
? rebuildChild(context)
|
||||||
|
@@ -17,28 +17,46 @@ abstract class LoadableHydratedBloc<
|
|||||||
LoadableState<TState>
|
LoadableState<TState>
|
||||||
> {
|
> {
|
||||||
late TRepository _repository;
|
late TRepository _repository;
|
||||||
LoadableHydratedBloc() : super(const LoadableState()) {
|
LoadableHydratedBloc() : super(const LoadableState(
|
||||||
|
error: null,
|
||||||
|
data: null,
|
||||||
|
isLoading: true,
|
||||||
|
lastFetch: null,
|
||||||
|
reFetch: null,
|
||||||
|
)) {
|
||||||
|
|
||||||
on<Emit<TState>>((event, emit) => emit(LoadableState(
|
on<Emit<TState>>((event, emit) {
|
||||||
isLoading: event.loading,
|
emit(LoadableState(
|
||||||
|
isLoading: state.isLoading,
|
||||||
data: event.state(innerState ?? fromNothing()),
|
data: event.state(innerState ?? fromNothing()),
|
||||||
lastFetch: DateTime.now().millisecondsSinceEpoch,
|
lastFetch: state.lastFetch,
|
||||||
reFetch: retry
|
reFetch: fetch,
|
||||||
|
error: state.error,
|
||||||
|
));
|
||||||
|
if(event.fetch) fetch();
|
||||||
|
});
|
||||||
|
|
||||||
|
on<DataGathered<TState>>((event, emit) => emit(LoadableState(
|
||||||
|
isLoading: false,
|
||||||
|
data: event.state(innerState ?? fromNothing()),
|
||||||
|
lastFetch: DateTime.now().millisecondsSinceEpoch,
|
||||||
|
reFetch: fetch,
|
||||||
|
error: null,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
on<RefetchStarted<TState>>((event, emit) => emit(LoadableState(
|
on<RefetchStarted<TState>>((event, emit) => emit(LoadableState(
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
data: innerState,
|
data: innerState,
|
||||||
lastFetch: state.lastFetch
|
lastFetch: state.lastFetch,
|
||||||
|
reFetch: null,
|
||||||
|
error: null,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
on<ClearState<TState>>((event, emit) => emit(const LoadableState()));
|
|
||||||
|
|
||||||
on<Error<TState>>((event, emit) => emit(LoadableState(
|
on<Error<TState>>((event, emit) => emit(LoadableState(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
data: innerState,
|
data: innerState,
|
||||||
lastFetch: state.lastFetch,
|
lastFetch: state.lastFetch,
|
||||||
reFetch: retry,
|
reFetch: fetch,
|
||||||
error: event.error
|
error: event.error
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@@ -49,19 +67,14 @@ abstract class LoadableHydratedBloc<
|
|||||||
TState? get innerState => state.data;
|
TState? get innerState => state.data;
|
||||||
TRepository get repo => _repository;
|
TRepository get repo => _repository;
|
||||||
|
|
||||||
void retry() {
|
|
||||||
log('Fetch retry triggered for ${TState.toString()}');
|
|
||||||
add(RefetchStarted<TState>());
|
|
||||||
fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fetch() {
|
void fetch() {
|
||||||
log('Fetching data for ${TState.toString()}');
|
log('Fetching data for ${TState.toString()}');
|
||||||
|
add(RefetchStarted<TState>());
|
||||||
gatherData().catchError(
|
gatherData().catchError(
|
||||||
(e) {
|
(e) {
|
||||||
log('Error while fetching ${TState.toString()}: ${e.toString()}');
|
log('Error while fetching ${TState.toString()}: ${e.toString()}');
|
||||||
add(Error(LoadingError(
|
add(Error(LoadingError(
|
||||||
message: e.message,
|
message: e.toString(),
|
||||||
allowRetry: true,
|
allowRetry: true,
|
||||||
)));
|
)));
|
||||||
},
|
},
|
||||||
@@ -73,14 +86,29 @@ abstract class LoadableHydratedBloc<
|
|||||||
@override
|
@override
|
||||||
fromJson(Map<String, dynamic> json) {
|
fromJson(Map<String, dynamic> json) {
|
||||||
var rawData = LoadableSaveContext.unwrap(json);
|
var rawData = LoadableSaveContext.unwrap(json);
|
||||||
return LoadableState(isLoading: true, lastFetch: rawData.meta.timestamp, data: fromStorage(rawData.data));
|
return LoadableState(
|
||||||
|
isLoading: true,
|
||||||
|
data: fromStorage(rawData.data), // TODO fromStorage in isolate
|
||||||
|
lastFetch: rawData.meta.timestamp,
|
||||||
|
reFetch: null,
|
||||||
|
error: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic>? toJson(LoadableState<TState> state) => LoadableSaveContext.wrap(
|
Map<String, dynamic>? toJson(LoadableState<TState> state) {
|
||||||
toStorage(state.data),
|
Map<String, dynamic>? data;
|
||||||
|
try {
|
||||||
|
data = state.data == null ? null : toStorage(state.data); // TODO toStorage in isolate
|
||||||
|
} catch(e) {
|
||||||
|
log('Failed to save state ${TState.toString()}: ${e.toString()}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadableSaveContext.wrap(
|
||||||
|
data,
|
||||||
state.lastFetch ?? DateTime.now().millisecondsSinceEpoch
|
state.lastFetch ?? DateTime.now().millisecondsSinceEpoch
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> gatherData();
|
Future<void> gatherData();
|
||||||
TRepository repository();
|
TRepository repository();
|
||||||
|
@@ -3,10 +3,13 @@ import '../../loadableState/loading_error.dart';
|
|||||||
class LoadableHydratedBlocEvent<TState> {}
|
class LoadableHydratedBlocEvent<TState> {}
|
||||||
class Emit<TState> extends LoadableHydratedBlocEvent<TState> {
|
class Emit<TState> extends LoadableHydratedBlocEvent<TState> {
|
||||||
final TState Function(TState state) state;
|
final TState Function(TState state) state;
|
||||||
final bool loading;
|
final bool fetch;
|
||||||
Emit(this.state, {this.loading = false});
|
Emit(this.state, {this.fetch = false});
|
||||||
|
}
|
||||||
|
class DataGathered<TState> extends LoadableHydratedBlocEvent<TState> {
|
||||||
|
final TState Function(TState state) state;
|
||||||
|
DataGathered(this.state);
|
||||||
}
|
}
|
||||||
class ClearState<TState> extends LoadableHydratedBlocEvent<TState> {}
|
|
||||||
class Error<TState> extends LoadableHydratedBlocEvent<TState> {
|
class Error<TState> extends LoadableHydratedBlocEvent<TState> {
|
||||||
final LoadingError error;
|
final LoadingError error;
|
||||||
Error(this.error);
|
Error(this.error);
|
||||||
|
@@ -21,4 +21,3 @@ class LoadableSaveContext with _$LoadableSaveContext {
|
|||||||
static ({Map<String, dynamic> data, LoadableSaveContext meta}) unwrap(Map<String, dynamic> data) =>
|
static ({Map<String, dynamic> data, LoadableSaveContext meta}) unwrap(Map<String, dynamic> data) =>
|
||||||
(data: data[dataKey] as Map<String, dynamic>, meta: LoadableSaveContext.fromJson(data[metaKey]));
|
(data: data[dataKey] as Map<String, dynamic>, meta: LoadableSaveContext.fromJson(data[metaKey]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ part of 'loadable_save_context.dart';
|
|||||||
_$LoadableSaveContextImpl _$$LoadableSaveContextImplFromJson(
|
_$LoadableSaveContextImpl _$$LoadableSaveContextImplFromJson(
|
||||||
Map<String, dynamic> json) =>
|
Map<String, dynamic> json) =>
|
||||||
_$LoadableSaveContextImpl(
|
_$LoadableSaveContextImpl(
|
||||||
timestamp: json['timestamp'] as int,
|
timestamp: (json['timestamp'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$LoadableSaveContextImplToJson(
|
Map<String, dynamic> _$$LoadableSaveContextImplToJson(
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'bloc_module.dart';
|
||||||
|
|
||||||
|
class SwappingBloc<TBloc> {
|
||||||
|
final TBloc initialBloc;
|
||||||
|
final StreamController<TBloc> updater = StreamController<TBloc>();
|
||||||
|
|
||||||
|
SwappingBloc(this.initialBloc);
|
||||||
|
|
||||||
|
void swap(TBloc bloc) {
|
||||||
|
updater.add(bloc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SwappingBlocModule<TBloc extends StateStreamableSource<TState>, TState> extends StatefulWidget {
|
||||||
|
final SwappingBloc<TBloc> bloc;
|
||||||
|
final Widget Function(BuildContext context, TBloc bloc, TState state) child;
|
||||||
|
const SwappingBlocModule({super.key, required this.bloc, required this.child});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SwappingBlocModule<TBloc, TState>> createState() => _SwappingBlocModuleState<TBloc, TState>();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SwappingBlocModuleState<TBloc extends StateStreamableSource<TState>, TState> extends State<SwappingBlocModule<TBloc, TState>> {
|
||||||
|
late TBloc bloc;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
bloc = widget.bloc.initialBloc;
|
||||||
|
widget.bloc.updater.stream.listen((event) {
|
||||||
|
setState(() {
|
||||||
|
bloc = event;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => BlocModule<TBloc, TState>(
|
||||||
|
autoRebuild: true,
|
||||||
|
create: (context) => bloc,
|
||||||
|
child: (context, bloc, state) => widget.child(context, bloc, state),
|
||||||
|
);
|
||||||
|
}
|
@@ -4,12 +4,13 @@ import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
|
|||||||
import '../../../api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
|
import '../../../api/mhsl/breaker/getBreakers/getBreakersResponse.dart';
|
||||||
import '../../../model/breakers/Breaker.dart';
|
import '../../../model/breakers/Breaker.dart';
|
||||||
import '../../../view/pages/files/files.dart';
|
import '../../../view/pages/files/files.dart';
|
||||||
import '../../../view/pages/more/holidays/holidays.dart';
|
|
||||||
import '../../../view/pages/more/roomplan/roomplan.dart';
|
import '../../../view/pages/more/roomplan/roomplan.dart';
|
||||||
import '../../../view/pages/talk/chatList.dart';
|
import '../../../view/pages/talk/chatList.dart';
|
||||||
import '../../../view/pages/timetable/timetable.dart';
|
import '../../../view/pages/timetable/timetable.dart';
|
||||||
import '../../../widget/centeredLeading.dart';
|
import '../../../widget/centeredLeading.dart';
|
||||||
|
import 'files/view/files_view.dart';
|
||||||
import 'gradeAverages/view/grade_averages_view.dart';
|
import 'gradeAverages/view/grade_averages_view.dart';
|
||||||
|
import 'holidays/view/holidays_view.dart';
|
||||||
import 'marianumMessage/view/marianum_message_list_view.dart';
|
import 'marianumMessage/view/marianum_message_list_view.dart';
|
||||||
|
|
||||||
class AppModule {
|
class AppModule {
|
||||||
@@ -23,10 +24,11 @@ class AppModule {
|
|||||||
Modules.timetable: AppModule('Vertretung', Icons.calendar_month, Timetable.new),
|
Modules.timetable: AppModule('Vertretung', Icons.calendar_month, Timetable.new),
|
||||||
Modules.talk: AppModule('Talk', Icons.chat, ChatList.new),
|
Modules.talk: AppModule('Talk', Icons.chat, ChatList.new),
|
||||||
Modules.files: AppModule('Files', Icons.folder, Files.new),
|
Modules.files: AppModule('Files', Icons.folder, Files.new),
|
||||||
|
Modules.blocFiles: AppModule('BlocFiles', Icons.folder, FilesView.new),
|
||||||
Modules.marianumMessage: AppModule('Marianum Message', Icons.newspaper, MarianumMessageListView.new),
|
Modules.marianumMessage: AppModule('Marianum Message', Icons.newspaper, MarianumMessageListView.new),
|
||||||
Modules.roomPlan: AppModule('Raumplan', Icons.location_pin, Roomplan.new),
|
Modules.roomPlan: AppModule('Raumplan', Icons.location_pin, Roomplan.new),
|
||||||
Modules.gradeAveragesCalculator: AppModule('Notendurschnittsrechner', Icons.calculate, GradeAveragesView.new),
|
Modules.gradeAveragesCalculator: AppModule('Notendurschnittsrechner', Icons.calculate, GradeAveragesView.new),
|
||||||
Modules.holidays: AppModule('Schulferien', Icons.holiday_village, Holidays.new),
|
Modules.holidays: AppModule('Schulferien', Icons.flight, HolidaysView.new),
|
||||||
};
|
};
|
||||||
|
|
||||||
static AppModule getModule(Modules module) => modules()[module]!;
|
static AppModule getModule(Modules module) => modules()[module]!;
|
||||||
@@ -53,6 +55,7 @@ enum Modules {
|
|||||||
timetable,
|
timetable,
|
||||||
talk,
|
talk,
|
||||||
files,
|
files,
|
||||||
|
blocFiles,
|
||||||
marianumMessage,
|
marianumMessage,
|
||||||
roomPlan,
|
roomPlan,
|
||||||
gradeAveragesCalculator,
|
gradeAveragesCalculator,
|
||||||
|
71
lib/state/app/modules/files/bloc/files_bloc.dart
Normal file
71
lib/state/app/modules/files/bloc/files_bloc.dart
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:sorted/sorted.dart';
|
||||||
|
|
||||||
|
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc.dart';
|
||||||
|
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc_event.dart';
|
||||||
|
import '../repository/files_repository.dart';
|
||||||
|
import 'files_event.dart';
|
||||||
|
import 'files_state.dart';
|
||||||
|
|
||||||
|
class FilesBloc extends LoadableHydratedBloc<FilesEvent, FilesState, FilesRepository> {
|
||||||
|
static const String basePath = '/';
|
||||||
|
|
||||||
|
FilesBloc() {
|
||||||
|
add(Emit((state) => state.copyWith(currentFolder: basePath)));
|
||||||
|
on<EnterFolder>((event, emit) {
|
||||||
|
add(Emit((state) {
|
||||||
|
log('setFolder');
|
||||||
|
return state.copyWith(currentFolder: event.absolutePath);
|
||||||
|
}, fetch: true));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<File>? getVisibleFiles() => innerState?.files[innerState?.currentFolder];
|
||||||
|
String getCurrentFolder() => innerState?.currentFolder ?? basePath;
|
||||||
|
String getCurrentFolderName() {
|
||||||
|
var folder = innerState?.currentFolder.split('/').reversed.elementAt(1);
|
||||||
|
return folder!.isEmpty ? 'Dateien' : folder;
|
||||||
|
}
|
||||||
|
bool canGoBack() => innerState?.currentFolder != basePath;
|
||||||
|
String goBackLocation() {
|
||||||
|
var pathSegments = innerState?.currentFolder.split(basePath) ?? [];
|
||||||
|
if (pathSegments.isNotEmpty) {
|
||||||
|
pathSegments.removeLast();
|
||||||
|
pathSegments.removeLast();
|
||||||
|
}
|
||||||
|
return pathSegments.join(basePath) + basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
List currentSortConfiguration() => [
|
||||||
|
SortedComparable<File, DateTime>((file) => file.updatedAt ?? DateTime.now()),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
FilesState fromNothing() => const FilesState(currentFolder: basePath, files: {});
|
||||||
|
|
||||||
|
@override
|
||||||
|
FilesState fromStorage(Map<String, dynamic> json) => FilesState.fromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> gatherData() async {
|
||||||
|
var fetchFolder = getCurrentFolder();
|
||||||
|
log(fetchFolder);
|
||||||
|
var files = await repo.getFileList(fetchFolder);
|
||||||
|
var newFileMap = Map.of(innerState?.files ?? <String, List<File>>{});
|
||||||
|
newFileMap[fetchFolder] = files;
|
||||||
|
if(fetchFolder != getCurrentFolder()) {
|
||||||
|
log('Fetch aborted due to folder change (expected "$fetchFolder" got "${getCurrentFolder()}")');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
add(DataGathered((state) => state.copyWith(files: newFileMap)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
FilesRepository repository() => FilesRepository();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic>? toStorage(FilesState state) => state.toJson();
|
||||||
|
|
||||||
|
}
|
10
lib/state/app/modules/files/bloc/files_event.dart
Normal file
10
lib/state/app/modules/files/bloc/files_event.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc_event.dart';
|
||||||
|
import 'files_state.dart';
|
||||||
|
|
||||||
|
sealed class FilesEvent extends LoadableHydratedBlocEvent<FilesState> {}
|
||||||
|
class EnterFolder extends FilesEvent {
|
||||||
|
String absolutePath;
|
||||||
|
EnterFolder(this.absolutePath);
|
||||||
|
}
|
||||||
|
|
29
lib/state/app/modules/files/bloc/files_state.dart
Normal file
29
lib/state/app/modules/files/bloc/files_state.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'files_state.freezed.dart';
|
||||||
|
part 'files_state.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class FilesState with _$FilesState {
|
||||||
|
const factory FilesState({
|
||||||
|
required String currentFolder,
|
||||||
|
required Map<String, List<File>> files,
|
||||||
|
}) = _FilesState;
|
||||||
|
|
||||||
|
factory FilesState.fromJson(Map<String, Object?> json) => _$FilesStateFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class File with _$File {
|
||||||
|
const factory File({
|
||||||
|
required String path,
|
||||||
|
required bool isFolder,
|
||||||
|
required String name,
|
||||||
|
required DateTime? createdAt,
|
||||||
|
required DateTime? updatedAt,
|
||||||
|
required int? size,
|
||||||
|
required String? mimeType,
|
||||||
|
}) = _File;
|
||||||
|
|
||||||
|
factory File.fromJson(Map<String, Object?> json) => _$FileFromJson(json);
|
||||||
|
}
|
439
lib/state/app/modules/files/bloc/files_state.freezed.dart
Normal file
439
lib/state/app/modules/files/bloc/files_state.freezed.dart
Normal file
@@ -0,0 +1,439 @@
|
|||||||
|
// coverage:ignore-file
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
|
part of 'files_state.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||||
|
|
||||||
|
FilesState _$FilesStateFromJson(Map<String, dynamic> json) {
|
||||||
|
return _FilesState.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$FilesState {
|
||||||
|
String get currentFolder => throw _privateConstructorUsedError;
|
||||||
|
Map<String, List<File>> get files => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$FilesStateCopyWith<FilesState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $FilesStateCopyWith<$Res> {
|
||||||
|
factory $FilesStateCopyWith(
|
||||||
|
FilesState value, $Res Function(FilesState) then) =
|
||||||
|
_$FilesStateCopyWithImpl<$Res, FilesState>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String currentFolder, Map<String, List<File>> files});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$FilesStateCopyWithImpl<$Res, $Val extends FilesState>
|
||||||
|
implements $FilesStateCopyWith<$Res> {
|
||||||
|
_$FilesStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? currentFolder = null,
|
||||||
|
Object? files = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
currentFolder: null == currentFolder
|
||||||
|
? _value.currentFolder
|
||||||
|
: currentFolder // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
files: null == files
|
||||||
|
? _value.files
|
||||||
|
: files // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, List<File>>,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$FilesStateImplCopyWith<$Res>
|
||||||
|
implements $FilesStateCopyWith<$Res> {
|
||||||
|
factory _$$FilesStateImplCopyWith(
|
||||||
|
_$FilesStateImpl value, $Res Function(_$FilesStateImpl) then) =
|
||||||
|
__$$FilesStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({String currentFolder, Map<String, List<File>> files});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$FilesStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$FilesStateCopyWithImpl<$Res, _$FilesStateImpl>
|
||||||
|
implements _$$FilesStateImplCopyWith<$Res> {
|
||||||
|
__$$FilesStateImplCopyWithImpl(
|
||||||
|
_$FilesStateImpl _value, $Res Function(_$FilesStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? currentFolder = null,
|
||||||
|
Object? files = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$FilesStateImpl(
|
||||||
|
currentFolder: null == currentFolder
|
||||||
|
? _value.currentFolder
|
||||||
|
: currentFolder // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
files: null == files
|
||||||
|
? _value._files
|
||||||
|
: files // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, List<File>>,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$FilesStateImpl implements _FilesState {
|
||||||
|
const _$FilesStateImpl(
|
||||||
|
{required this.currentFolder,
|
||||||
|
required final Map<String, List<File>> files})
|
||||||
|
: _files = files;
|
||||||
|
|
||||||
|
factory _$FilesStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$FilesStateImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String currentFolder;
|
||||||
|
final Map<String, List<File>> _files;
|
||||||
|
@override
|
||||||
|
Map<String, List<File>> get files {
|
||||||
|
if (_files is EqualUnmodifiableMapView) return _files;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableMapView(_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'FilesState(currentFolder: $currentFolder, files: $files)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$FilesStateImpl &&
|
||||||
|
(identical(other.currentFolder, currentFolder) ||
|
||||||
|
other.currentFolder == currentFolder) &&
|
||||||
|
const DeepCollectionEquality().equals(other._files, _files));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType, currentFolder, const DeepCollectionEquality().hash(_files));
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$FilesStateImplCopyWith<_$FilesStateImpl> get copyWith =>
|
||||||
|
__$$FilesStateImplCopyWithImpl<_$FilesStateImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$FilesStateImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _FilesState implements FilesState {
|
||||||
|
const factory _FilesState(
|
||||||
|
{required final String currentFolder,
|
||||||
|
required final Map<String, List<File>> files}) = _$FilesStateImpl;
|
||||||
|
|
||||||
|
factory _FilesState.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$FilesStateImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get currentFolder;
|
||||||
|
@override
|
||||||
|
Map<String, List<File>> get files;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$FilesStateImplCopyWith<_$FilesStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
File _$FileFromJson(Map<String, dynamic> json) {
|
||||||
|
return _File.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$File {
|
||||||
|
String get path => throw _privateConstructorUsedError;
|
||||||
|
bool get isFolder => throw _privateConstructorUsedError;
|
||||||
|
String get name => throw _privateConstructorUsedError;
|
||||||
|
DateTime? get createdAt => throw _privateConstructorUsedError;
|
||||||
|
DateTime? get updatedAt => throw _privateConstructorUsedError;
|
||||||
|
int? get size => throw _privateConstructorUsedError;
|
||||||
|
String? get mimeType => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$FileCopyWith<File> get copyWith => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $FileCopyWith<$Res> {
|
||||||
|
factory $FileCopyWith(File value, $Res Function(File) then) =
|
||||||
|
_$FileCopyWithImpl<$Res, File>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{String path,
|
||||||
|
bool isFolder,
|
||||||
|
String name,
|
||||||
|
DateTime? createdAt,
|
||||||
|
DateTime? updatedAt,
|
||||||
|
int? size,
|
||||||
|
String? mimeType});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$FileCopyWithImpl<$Res, $Val extends File>
|
||||||
|
implements $FileCopyWith<$Res> {
|
||||||
|
_$FileCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? path = null,
|
||||||
|
Object? isFolder = null,
|
||||||
|
Object? name = null,
|
||||||
|
Object? createdAt = freezed,
|
||||||
|
Object? updatedAt = freezed,
|
||||||
|
Object? size = freezed,
|
||||||
|
Object? mimeType = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
path: null == path
|
||||||
|
? _value.path
|
||||||
|
: path // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
isFolder: null == isFolder
|
||||||
|
? _value.isFolder
|
||||||
|
: isFolder // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
name: null == name
|
||||||
|
? _value.name
|
||||||
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
createdAt: freezed == createdAt
|
||||||
|
? _value.createdAt
|
||||||
|
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
|
as DateTime?,
|
||||||
|
updatedAt: freezed == updatedAt
|
||||||
|
? _value.updatedAt
|
||||||
|
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
|
as DateTime?,
|
||||||
|
size: freezed == size
|
||||||
|
? _value.size
|
||||||
|
: size // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int?,
|
||||||
|
mimeType: freezed == mimeType
|
||||||
|
? _value.mimeType
|
||||||
|
: mimeType // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$FileImplCopyWith<$Res> implements $FileCopyWith<$Res> {
|
||||||
|
factory _$$FileImplCopyWith(
|
||||||
|
_$FileImpl value, $Res Function(_$FileImpl) then) =
|
||||||
|
__$$FileImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{String path,
|
||||||
|
bool isFolder,
|
||||||
|
String name,
|
||||||
|
DateTime? createdAt,
|
||||||
|
DateTime? updatedAt,
|
||||||
|
int? size,
|
||||||
|
String? mimeType});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$FileImplCopyWithImpl<$Res>
|
||||||
|
extends _$FileCopyWithImpl<$Res, _$FileImpl>
|
||||||
|
implements _$$FileImplCopyWith<$Res> {
|
||||||
|
__$$FileImplCopyWithImpl(_$FileImpl _value, $Res Function(_$FileImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? path = null,
|
||||||
|
Object? isFolder = null,
|
||||||
|
Object? name = null,
|
||||||
|
Object? createdAt = freezed,
|
||||||
|
Object? updatedAt = freezed,
|
||||||
|
Object? size = freezed,
|
||||||
|
Object? mimeType = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_$FileImpl(
|
||||||
|
path: null == path
|
||||||
|
? _value.path
|
||||||
|
: path // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
isFolder: null == isFolder
|
||||||
|
? _value.isFolder
|
||||||
|
: isFolder // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
name: null == name
|
||||||
|
? _value.name
|
||||||
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
createdAt: freezed == createdAt
|
||||||
|
? _value.createdAt
|
||||||
|
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
|
as DateTime?,
|
||||||
|
updatedAt: freezed == updatedAt
|
||||||
|
? _value.updatedAt
|
||||||
|
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
|
as DateTime?,
|
||||||
|
size: freezed == size
|
||||||
|
? _value.size
|
||||||
|
: size // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int?,
|
||||||
|
mimeType: freezed == mimeType
|
||||||
|
? _value.mimeType
|
||||||
|
: mimeType // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$FileImpl implements _File {
|
||||||
|
const _$FileImpl(
|
||||||
|
{required this.path,
|
||||||
|
required this.isFolder,
|
||||||
|
required this.name,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.updatedAt,
|
||||||
|
required this.size,
|
||||||
|
required this.mimeType});
|
||||||
|
|
||||||
|
factory _$FileImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$FileImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String path;
|
||||||
|
@override
|
||||||
|
final bool isFolder;
|
||||||
|
@override
|
||||||
|
final String name;
|
||||||
|
@override
|
||||||
|
final DateTime? createdAt;
|
||||||
|
@override
|
||||||
|
final DateTime? updatedAt;
|
||||||
|
@override
|
||||||
|
final int? size;
|
||||||
|
@override
|
||||||
|
final String? mimeType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'File(path: $path, isFolder: $isFolder, name: $name, createdAt: $createdAt, updatedAt: $updatedAt, size: $size, mimeType: $mimeType)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$FileImpl &&
|
||||||
|
(identical(other.path, path) || other.path == path) &&
|
||||||
|
(identical(other.isFolder, isFolder) ||
|
||||||
|
other.isFolder == isFolder) &&
|
||||||
|
(identical(other.name, name) || other.name == name) &&
|
||||||
|
(identical(other.createdAt, createdAt) ||
|
||||||
|
other.createdAt == createdAt) &&
|
||||||
|
(identical(other.updatedAt, updatedAt) ||
|
||||||
|
other.updatedAt == updatedAt) &&
|
||||||
|
(identical(other.size, size) || other.size == size) &&
|
||||||
|
(identical(other.mimeType, mimeType) ||
|
||||||
|
other.mimeType == mimeType));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType, path, isFolder, name, createdAt, updatedAt, size, mimeType);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$FileImplCopyWith<_$FileImpl> get copyWith =>
|
||||||
|
__$$FileImplCopyWithImpl<_$FileImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$FileImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _File implements File {
|
||||||
|
const factory _File(
|
||||||
|
{required final String path,
|
||||||
|
required final bool isFolder,
|
||||||
|
required final String name,
|
||||||
|
required final DateTime? createdAt,
|
||||||
|
required final DateTime? updatedAt,
|
||||||
|
required final int? size,
|
||||||
|
required final String? mimeType}) = _$FileImpl;
|
||||||
|
|
||||||
|
factory _File.fromJson(Map<String, dynamic> json) = _$FileImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get path;
|
||||||
|
@override
|
||||||
|
bool get isFolder;
|
||||||
|
@override
|
||||||
|
String get name;
|
||||||
|
@override
|
||||||
|
DateTime? get createdAt;
|
||||||
|
@override
|
||||||
|
DateTime? get updatedAt;
|
||||||
|
@override
|
||||||
|
int? get size;
|
||||||
|
@override
|
||||||
|
String? get mimeType;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$FileImplCopyWith<_$FileImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
50
lib/state/app/modules/files/bloc/files_state.g.dart
Normal file
50
lib/state/app/modules/files/bloc/files_state.g.dart
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'files_state.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
_$FilesStateImpl _$$FilesStateImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$FilesStateImpl(
|
||||||
|
currentFolder: json['currentFolder'] as String,
|
||||||
|
files: (json['files'] as Map<String, dynamic>).map(
|
||||||
|
(k, e) => MapEntry(
|
||||||
|
k,
|
||||||
|
(e as List<dynamic>)
|
||||||
|
.map((e) => File.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList()),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$FilesStateImplToJson(_$FilesStateImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'currentFolder': instance.currentFolder,
|
||||||
|
'files': instance.files,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$FileImpl _$$FileImplFromJson(Map<String, dynamic> json) => _$FileImpl(
|
||||||
|
path: json['path'] as String,
|
||||||
|
isFolder: json['isFolder'] as bool,
|
||||||
|
name: json['name'] as String,
|
||||||
|
createdAt: json['createdAt'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['createdAt'] as String),
|
||||||
|
updatedAt: json['updatedAt'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['updatedAt'] as String),
|
||||||
|
size: (json['size'] as num?)?.toInt(),
|
||||||
|
mimeType: json['mimeType'] as String?,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$FileImplToJson(_$FileImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'path': instance.path,
|
||||||
|
'isFolder': instance.isFolder,
|
||||||
|
'name': instance.name,
|
||||||
|
'createdAt': instance.createdAt?.toIso8601String(),
|
||||||
|
'updatedAt': instance.updatedAt?.toIso8601String(),
|
||||||
|
'size': instance.size,
|
||||||
|
'mimeType': instance.mimeType,
|
||||||
|
};
|
31
lib/state/app/modules/files/repository/files_repository.dart
Normal file
31
lib/state/app/modules/files/repository/files_repository.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
import 'package:nextcloud/nextcloud.dart';
|
||||||
|
|
||||||
|
import '../../../../../api/marianumcloud/webdav/webdavApi.dart';
|
||||||
|
import '../../../infrastructure/repository/repository.dart';
|
||||||
|
import '../bloc/files_state.dart';
|
||||||
|
|
||||||
|
class FilesRepository extends Repository<FilesState> {
|
||||||
|
Future<List<File>> getFileList(String path) async {
|
||||||
|
var webdav = await WebdavApi.webdav;
|
||||||
|
var response = await webdav.propfind(PathUri.parse(path)); // TODO move to custom data loader
|
||||||
|
var davFiles = response.toWebDavFiles();
|
||||||
|
|
||||||
|
davFiles.removeWhere((file) {
|
||||||
|
var filePath = file.path.path;
|
||||||
|
return filePath.isEmpty || filePath == path;
|
||||||
|
});
|
||||||
|
|
||||||
|
var files = davFiles.map((davFile) => File(
|
||||||
|
path: davFile.path.path,
|
||||||
|
isFolder: davFile.isDirectory,
|
||||||
|
name: davFile.name,
|
||||||
|
createdAt: davFile.createdDate,
|
||||||
|
updatedAt: davFile.lastModified,
|
||||||
|
size: davFile.size,
|
||||||
|
mimeType: davFile.mimeType
|
||||||
|
));
|
||||||
|
|
||||||
|
return files.toList();
|
||||||
|
}
|
||||||
|
}
|
17
lib/state/app/modules/files/view/files_view.dart
Normal file
17
lib/state/app/modules/files/view/files_view.dart
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../../infrastructure/loadableState/loadable_state.dart';
|
||||||
|
import '../../../infrastructure/utilityWidgets/bloc_module.dart';
|
||||||
|
import '../bloc/files_bloc.dart';
|
||||||
|
import '../bloc/files_state.dart';
|
||||||
|
import 'folder_view.dart';
|
||||||
|
|
||||||
|
class FilesView extends StatelessWidget {
|
||||||
|
const FilesView({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => BlocModule<FilesBloc, LoadableState<FilesState>>(
|
||||||
|
create: (context) => FilesBloc(),
|
||||||
|
autoRebuild: true,
|
||||||
|
child: (context, bloc, state) => FolderView(bloc),
|
||||||
|
);
|
||||||
|
}
|
57
lib/state/app/modules/files/view/folder_view.dart
Normal file
57
lib/state/app/modules/files/view/folder_view.dart
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:filesize/filesize.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jiffy/jiffy.dart';
|
||||||
|
|
||||||
|
import '../../../../../widget/centeredLeading.dart';
|
||||||
|
import '../../../../../widget/list_view_util.dart';
|
||||||
|
import '../../../infrastructure/loadableState/view/loadable_state_consumer.dart';
|
||||||
|
import '../bloc/files_bloc.dart';
|
||||||
|
import '../bloc/files_event.dart';
|
||||||
|
import '../bloc/files_state.dart';
|
||||||
|
|
||||||
|
class FolderView extends StatelessWidget {
|
||||||
|
final FilesBloc bloc;
|
||||||
|
const FolderView(this.bloc, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: !bloc.canGoBack() ? null : IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
onPressed: () {
|
||||||
|
bloc.add(EnterFolder(bloc.goBackLocation()));
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
title: Text(bloc.getCurrentFolderName()),
|
||||||
|
|
||||||
|
actions: [
|
||||||
|
IconButton(onPressed: () {
|
||||||
|
log(bloc.innerState?.toJson().toString() ?? 'leer');
|
||||||
|
}, icon: const Icon(Icons.bug_report)),
|
||||||
|
IconButton(onPressed: () {
|
||||||
|
bloc.add(EnterFolder('/'));
|
||||||
|
}, icon: const Icon(Icons.home)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: LoadableStateConsumer<FilesBloc, FilesState>(
|
||||||
|
controllerByValue: bloc,
|
||||||
|
child: (state, loading) => ListViewUtil.fromList<File>(bloc.getVisibleFiles(), (file) => ListTile(
|
||||||
|
leading: CenteredLeading(Icon(file.isFolder ? Icons.folder : Icons.description_outlined)),
|
||||||
|
title: Text(file.name),
|
||||||
|
subtitle: file.isFolder
|
||||||
|
? Text('geändert ${Jiffy.parseFromDateTime(file.updatedAt ?? DateTime.now()).fromNow()}')
|
||||||
|
: Text('${filesize(file.size)}, ${Jiffy.parseFromDateTime(file.updatedAt ?? DateTime.now()).fromNow()}'),
|
||||||
|
trailing: Icon(file.isFolder ? Icons.arrow_right : null),
|
||||||
|
onTap: () {
|
||||||
|
log(file.path);
|
||||||
|
if(!file.isFolder) return;
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(builder: (context) => FolderView(bloc)));
|
||||||
|
bloc.add(EnterFolder(file.path));
|
||||||
|
},
|
||||||
|
))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
@@ -11,7 +11,9 @@ _$GradeAveragesStateImpl _$$GradeAveragesStateImplFromJson(
|
|||||||
_$GradeAveragesStateImpl(
|
_$GradeAveragesStateImpl(
|
||||||
gradingSystem: $enumDecode(
|
gradingSystem: $enumDecode(
|
||||||
_$GradeAveragesGradingSystemEnumMap, json['gradingSystem']),
|
_$GradeAveragesGradingSystemEnumMap, json['gradingSystem']),
|
||||||
grades: (json['grades'] as List<dynamic>).map((e) => e as int).toList(),
|
grades: (json['grades'] as List<dynamic>)
|
||||||
|
.map((e) => (e as num).toInt())
|
||||||
|
.toList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$GradeAveragesStateImplToJson(
|
Map<String, dynamic> _$$GradeAveragesStateImplToJson(
|
||||||
|
37
lib/state/app/modules/holidays/bloc/holidays_bloc.dart
Normal file
37
lib/state/app/modules/holidays/bloc/holidays_bloc.dart
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc.dart';
|
||||||
|
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc_event.dart';
|
||||||
|
import '../repository/holidays_repository.dart';
|
||||||
|
import 'holidays_event.dart';
|
||||||
|
import 'holidays_state.dart';
|
||||||
|
|
||||||
|
class HolidaysBloc extends LoadableHydratedBloc<HolidaysEvent, HolidaysState, HolidaysRepository> {
|
||||||
|
HolidaysBloc() {
|
||||||
|
on<SetPastHolidaysVisible>((event, emit) {
|
||||||
|
add(Emit((state) => state.copyWith(showPastHolidays: event.shouldBeVisible)));
|
||||||
|
});
|
||||||
|
|
||||||
|
on<DisclaimerDismissed>((event, emit) => add(
|
||||||
|
Emit((state) => state.copyWith(showDisclaimer: false))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool showPastHolidays() => innerState?.showPastHolidays ?? false;
|
||||||
|
bool showDisclaimerOnEntry() => innerState?.showDisclaimer ?? false;
|
||||||
|
List<Holiday>? getHolidays() => innerState?.holidays
|
||||||
|
.where((element) => showPastHolidays() || DateTime.parse(element.end).isAfter(DateTime.now()))
|
||||||
|
.toList() ?? [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
fromNothing() => const HolidaysState(showPastHolidays: false, holidays: [], showDisclaimer: true);
|
||||||
|
@override
|
||||||
|
fromStorage(Map<String, dynamic> json) => HolidaysState.fromJson(json);
|
||||||
|
@override
|
||||||
|
Future<void> gatherData() async {
|
||||||
|
var holidays = await repo.getHolidays();
|
||||||
|
add(DataGathered((state) => state.copyWith(holidays: holidays)));
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
repository() => HolidaysRepository();
|
||||||
|
@override
|
||||||
|
Map<String, dynamic>? toStorage(state) => state.toJson();
|
||||||
|
}
|
9
lib/state/app/modules/holidays/bloc/holidays_event.dart
Normal file
9
lib/state/app/modules/holidays/bloc/holidays_event.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import '../../../infrastructure/utilityWidgets/loadableHydratedBloc/loadable_hydrated_bloc_event.dart';
|
||||||
|
import 'holidays_state.dart';
|
||||||
|
|
||||||
|
sealed class HolidaysEvent extends LoadableHydratedBlocEvent<HolidaysState> {}
|
||||||
|
class SetPastHolidaysVisible extends HolidaysEvent {
|
||||||
|
final bool shouldBeVisible;
|
||||||
|
SetPastHolidaysVisible(this.shouldBeVisible);
|
||||||
|
}
|
||||||
|
class DisclaimerDismissed extends HolidaysEvent {}
|
30
lib/state/app/modules/holidays/bloc/holidays_state.dart
Normal file
30
lib/state/app/modules/holidays/bloc/holidays_state.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
part 'holidays_state.freezed.dart';
|
||||||
|
part 'holidays_state.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class HolidaysState with _$HolidaysState {
|
||||||
|
const factory HolidaysState({
|
||||||
|
required bool showPastHolidays,
|
||||||
|
required bool showDisclaimer,
|
||||||
|
required List<Holiday> holidays,
|
||||||
|
}) = _HolidaysState;
|
||||||
|
|
||||||
|
factory HolidaysState.fromJson(Map<String, Object?> json) => _$HolidaysStateFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class Holiday with _$Holiday {
|
||||||
|
const factory Holiday({
|
||||||
|
required String start,
|
||||||
|
required String end,
|
||||||
|
required int year,
|
||||||
|
required String stateCode,
|
||||||
|
required String name,
|
||||||
|
required String slug,
|
||||||
|
}) = _Holiday;
|
||||||
|
|
||||||
|
factory Holiday.fromJson(Map<String, Object?> json) => _$HolidayFromJson(json);
|
||||||
|
}
|
463
lib/state/app/modules/holidays/bloc/holidays_state.freezed.dart
Normal file
463
lib/state/app/modules/holidays/bloc/holidays_state.freezed.dart
Normal file
@@ -0,0 +1,463 @@
|
|||||||
|
// coverage:ignore-file
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
|
part of 'holidays_state.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||||
|
|
||||||
|
HolidaysState _$HolidaysStateFromJson(Map<String, dynamic> json) {
|
||||||
|
return _HolidaysState.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$HolidaysState {
|
||||||
|
bool get showPastHolidays => throw _privateConstructorUsedError;
|
||||||
|
bool get showDisclaimer => throw _privateConstructorUsedError;
|
||||||
|
List<Holiday> get holidays => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$HolidaysStateCopyWith<HolidaysState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $HolidaysStateCopyWith<$Res> {
|
||||||
|
factory $HolidaysStateCopyWith(
|
||||||
|
HolidaysState value, $Res Function(HolidaysState) then) =
|
||||||
|
_$HolidaysStateCopyWithImpl<$Res, HolidaysState>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{bool showPastHolidays, bool showDisclaimer, List<Holiday> holidays});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$HolidaysStateCopyWithImpl<$Res, $Val extends HolidaysState>
|
||||||
|
implements $HolidaysStateCopyWith<$Res> {
|
||||||
|
_$HolidaysStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? showPastHolidays = null,
|
||||||
|
Object? showDisclaimer = null,
|
||||||
|
Object? holidays = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
showPastHolidays: null == showPastHolidays
|
||||||
|
? _value.showPastHolidays
|
||||||
|
: showPastHolidays // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
showDisclaimer: null == showDisclaimer
|
||||||
|
? _value.showDisclaimer
|
||||||
|
: showDisclaimer // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
holidays: null == holidays
|
||||||
|
? _value.holidays
|
||||||
|
: holidays // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<Holiday>,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$HolidaysStateImplCopyWith<$Res>
|
||||||
|
implements $HolidaysStateCopyWith<$Res> {
|
||||||
|
factory _$$HolidaysStateImplCopyWith(
|
||||||
|
_$HolidaysStateImpl value, $Res Function(_$HolidaysStateImpl) then) =
|
||||||
|
__$$HolidaysStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{bool showPastHolidays, bool showDisclaimer, List<Holiday> holidays});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$HolidaysStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$HolidaysStateCopyWithImpl<$Res, _$HolidaysStateImpl>
|
||||||
|
implements _$$HolidaysStateImplCopyWith<$Res> {
|
||||||
|
__$$HolidaysStateImplCopyWithImpl(
|
||||||
|
_$HolidaysStateImpl _value, $Res Function(_$HolidaysStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? showPastHolidays = null,
|
||||||
|
Object? showDisclaimer = null,
|
||||||
|
Object? holidays = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$HolidaysStateImpl(
|
||||||
|
showPastHolidays: null == showPastHolidays
|
||||||
|
? _value.showPastHolidays
|
||||||
|
: showPastHolidays // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
showDisclaimer: null == showDisclaimer
|
||||||
|
? _value.showDisclaimer
|
||||||
|
: showDisclaimer // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
holidays: null == holidays
|
||||||
|
? _value._holidays
|
||||||
|
: holidays // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<Holiday>,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$HolidaysStateImpl
|
||||||
|
with DiagnosticableTreeMixin
|
||||||
|
implements _HolidaysState {
|
||||||
|
const _$HolidaysStateImpl(
|
||||||
|
{required this.showPastHolidays,
|
||||||
|
required this.showDisclaimer,
|
||||||
|
required final List<Holiday> holidays})
|
||||||
|
: _holidays = holidays;
|
||||||
|
|
||||||
|
factory _$HolidaysStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$HolidaysStateImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final bool showPastHolidays;
|
||||||
|
@override
|
||||||
|
final bool showDisclaimer;
|
||||||
|
final List<Holiday> _holidays;
|
||||||
|
@override
|
||||||
|
List<Holiday> get holidays {
|
||||||
|
if (_holidays is EqualUnmodifiableListView) return _holidays;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_holidays);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||||
|
return 'HolidaysState(showPastHolidays: $showPastHolidays, showDisclaimer: $showDisclaimer, holidays: $holidays)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
super.debugFillProperties(properties);
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('type', 'HolidaysState'))
|
||||||
|
..add(DiagnosticsProperty('showPastHolidays', showPastHolidays))
|
||||||
|
..add(DiagnosticsProperty('showDisclaimer', showDisclaimer))
|
||||||
|
..add(DiagnosticsProperty('holidays', holidays));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$HolidaysStateImpl &&
|
||||||
|
(identical(other.showPastHolidays, showPastHolidays) ||
|
||||||
|
other.showPastHolidays == showPastHolidays) &&
|
||||||
|
(identical(other.showDisclaimer, showDisclaimer) ||
|
||||||
|
other.showDisclaimer == showDisclaimer) &&
|
||||||
|
const DeepCollectionEquality().equals(other._holidays, _holidays));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, showPastHolidays, showDisclaimer,
|
||||||
|
const DeepCollectionEquality().hash(_holidays));
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$HolidaysStateImplCopyWith<_$HolidaysStateImpl> get copyWith =>
|
||||||
|
__$$HolidaysStateImplCopyWithImpl<_$HolidaysStateImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$HolidaysStateImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _HolidaysState implements HolidaysState {
|
||||||
|
const factory _HolidaysState(
|
||||||
|
{required final bool showPastHolidays,
|
||||||
|
required final bool showDisclaimer,
|
||||||
|
required final List<Holiday> holidays}) = _$HolidaysStateImpl;
|
||||||
|
|
||||||
|
factory _HolidaysState.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$HolidaysStateImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get showPastHolidays;
|
||||||
|
@override
|
||||||
|
bool get showDisclaimer;
|
||||||
|
@override
|
||||||
|
List<Holiday> get holidays;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$HolidaysStateImplCopyWith<_$HolidaysStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
Holiday _$HolidayFromJson(Map<String, dynamic> json) {
|
||||||
|
return _Holiday.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$Holiday {
|
||||||
|
String get start => throw _privateConstructorUsedError;
|
||||||
|
String get end => throw _privateConstructorUsedError;
|
||||||
|
int get year => throw _privateConstructorUsedError;
|
||||||
|
String get stateCode => throw _privateConstructorUsedError;
|
||||||
|
String get name => throw _privateConstructorUsedError;
|
||||||
|
String get slug => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$HolidayCopyWith<Holiday> get copyWith => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $HolidayCopyWith<$Res> {
|
||||||
|
factory $HolidayCopyWith(Holiday value, $Res Function(Holiday) then) =
|
||||||
|
_$HolidayCopyWithImpl<$Res, Holiday>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{String start,
|
||||||
|
String end,
|
||||||
|
int year,
|
||||||
|
String stateCode,
|
||||||
|
String name,
|
||||||
|
String slug});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$HolidayCopyWithImpl<$Res, $Val extends Holiday>
|
||||||
|
implements $HolidayCopyWith<$Res> {
|
||||||
|
_$HolidayCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? start = null,
|
||||||
|
Object? end = null,
|
||||||
|
Object? year = null,
|
||||||
|
Object? stateCode = null,
|
||||||
|
Object? name = null,
|
||||||
|
Object? slug = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
start: null == start
|
||||||
|
? _value.start
|
||||||
|
: start // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
end: null == end
|
||||||
|
? _value.end
|
||||||
|
: end // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
year: null == year
|
||||||
|
? _value.year
|
||||||
|
: year // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
stateCode: null == stateCode
|
||||||
|
? _value.stateCode
|
||||||
|
: stateCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
name: null == name
|
||||||
|
? _value.name
|
||||||
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
slug: null == slug
|
||||||
|
? _value.slug
|
||||||
|
: slug // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$HolidayImplCopyWith<$Res> implements $HolidayCopyWith<$Res> {
|
||||||
|
factory _$$HolidayImplCopyWith(
|
||||||
|
_$HolidayImpl value, $Res Function(_$HolidayImpl) then) =
|
||||||
|
__$$HolidayImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{String start,
|
||||||
|
String end,
|
||||||
|
int year,
|
||||||
|
String stateCode,
|
||||||
|
String name,
|
||||||
|
String slug});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$HolidayImplCopyWithImpl<$Res>
|
||||||
|
extends _$HolidayCopyWithImpl<$Res, _$HolidayImpl>
|
||||||
|
implements _$$HolidayImplCopyWith<$Res> {
|
||||||
|
__$$HolidayImplCopyWithImpl(
|
||||||
|
_$HolidayImpl _value, $Res Function(_$HolidayImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? start = null,
|
||||||
|
Object? end = null,
|
||||||
|
Object? year = null,
|
||||||
|
Object? stateCode = null,
|
||||||
|
Object? name = null,
|
||||||
|
Object? slug = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$HolidayImpl(
|
||||||
|
start: null == start
|
||||||
|
? _value.start
|
||||||
|
: start // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
end: null == end
|
||||||
|
? _value.end
|
||||||
|
: end // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
year: null == year
|
||||||
|
? _value.year
|
||||||
|
: year // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
stateCode: null == stateCode
|
||||||
|
? _value.stateCode
|
||||||
|
: stateCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
name: null == name
|
||||||
|
? _value.name
|
||||||
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
slug: null == slug
|
||||||
|
? _value.slug
|
||||||
|
: slug // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$HolidayImpl with DiagnosticableTreeMixin implements _Holiday {
|
||||||
|
const _$HolidayImpl(
|
||||||
|
{required this.start,
|
||||||
|
required this.end,
|
||||||
|
required this.year,
|
||||||
|
required this.stateCode,
|
||||||
|
required this.name,
|
||||||
|
required this.slug});
|
||||||
|
|
||||||
|
factory _$HolidayImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$HolidayImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String start;
|
||||||
|
@override
|
||||||
|
final String end;
|
||||||
|
@override
|
||||||
|
final int year;
|
||||||
|
@override
|
||||||
|
final String stateCode;
|
||||||
|
@override
|
||||||
|
final String name;
|
||||||
|
@override
|
||||||
|
final String slug;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||||
|
return 'Holiday(start: $start, end: $end, year: $year, stateCode: $stateCode, name: $name, slug: $slug)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
super.debugFillProperties(properties);
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('type', 'Holiday'))
|
||||||
|
..add(DiagnosticsProperty('start', start))
|
||||||
|
..add(DiagnosticsProperty('end', end))
|
||||||
|
..add(DiagnosticsProperty('year', year))
|
||||||
|
..add(DiagnosticsProperty('stateCode', stateCode))
|
||||||
|
..add(DiagnosticsProperty('name', name))
|
||||||
|
..add(DiagnosticsProperty('slug', slug));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$HolidayImpl &&
|
||||||
|
(identical(other.start, start) || other.start == start) &&
|
||||||
|
(identical(other.end, end) || other.end == end) &&
|
||||||
|
(identical(other.year, year) || other.year == year) &&
|
||||||
|
(identical(other.stateCode, stateCode) ||
|
||||||
|
other.stateCode == stateCode) &&
|
||||||
|
(identical(other.name, name) || other.name == name) &&
|
||||||
|
(identical(other.slug, slug) || other.slug == slug));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, start, end, year, stateCode, name, slug);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$HolidayImplCopyWith<_$HolidayImpl> get copyWith =>
|
||||||
|
__$$HolidayImplCopyWithImpl<_$HolidayImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$HolidayImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Holiday implements Holiday {
|
||||||
|
const factory _Holiday(
|
||||||
|
{required final String start,
|
||||||
|
required final String end,
|
||||||
|
required final int year,
|
||||||
|
required final String stateCode,
|
||||||
|
required final String name,
|
||||||
|
required final String slug}) = _$HolidayImpl;
|
||||||
|
|
||||||
|
factory _Holiday.fromJson(Map<String, dynamic> json) = _$HolidayImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get start;
|
||||||
|
@override
|
||||||
|
String get end;
|
||||||
|
@override
|
||||||
|
int get year;
|
||||||
|
@override
|
||||||
|
String get stateCode;
|
||||||
|
@override
|
||||||
|
String get name;
|
||||||
|
@override
|
||||||
|
String get slug;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$HolidayImplCopyWith<_$HolidayImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
43
lib/state/app/modules/holidays/bloc/holidays_state.g.dart
Normal file
43
lib/state/app/modules/holidays/bloc/holidays_state.g.dart
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'holidays_state.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
_$HolidaysStateImpl _$$HolidaysStateImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$HolidaysStateImpl(
|
||||||
|
showPastHolidays: json['showPastHolidays'] as bool,
|
||||||
|
showDisclaimer: json['showDisclaimer'] as bool,
|
||||||
|
holidays: (json['holidays'] as List<dynamic>)
|
||||||
|
.map((e) => Holiday.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$HolidaysStateImplToJson(_$HolidaysStateImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'showPastHolidays': instance.showPastHolidays,
|
||||||
|
'showDisclaimer': instance.showDisclaimer,
|
||||||
|
'holidays': instance.holidays,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$HolidayImpl _$$HolidayImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$HolidayImpl(
|
||||||
|
start: json['start'] as String,
|
||||||
|
end: json['end'] as String,
|
||||||
|
year: (json['year'] as num).toInt(),
|
||||||
|
stateCode: json['stateCode'] as String,
|
||||||
|
name: json['name'] as String,
|
||||||
|
slug: json['slug'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$HolidayImplToJson(_$HolidayImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'start': instance.start,
|
||||||
|
'end': instance.end,
|
||||||
|
'year': instance.year,
|
||||||
|
'stateCode': instance.stateCode,
|
||||||
|
'name': instance.name,
|
||||||
|
'slug': instance.slug,
|
||||||
|
};
|
@@ -0,0 +1,13 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
import '../../../basis/dataloader/holiday_data_loader.dart';
|
||||||
|
import '../../../infrastructure/dataLoader/http_data_loader.dart';
|
||||||
|
import '../bloc/holidays_state.dart';
|
||||||
|
|
||||||
|
class HolidaysGetHolidays extends HolidayDataLoader<List<Holiday>> {
|
||||||
|
@override
|
||||||
|
List<Holiday> assemble(DataLoaderResult data) => data.asListOfMaps().map(Holiday.fromJson).toList();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Response<String>> fetch() => dio.get('/holidays/HE');
|
||||||
|
}
|
@@ -0,0 +1,7 @@
|
|||||||
|
import '../../../infrastructure/repository/repository.dart';
|
||||||
|
import '../bloc/holidays_state.dart';
|
||||||
|
import '../dataProvider/holidays_get_holidays.dart';
|
||||||
|
|
||||||
|
class HolidaysRepository extends Repository<HolidaysState> {
|
||||||
|
Future<List<Holiday>> getHolidays() => HolidaysGetHolidays().run();
|
||||||
|
}
|
119
lib/state/app/modules/holidays/view/holidays_view.dart
Normal file
119
lib/state/app/modules/holidays/view/holidays_view.dart
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jiffy/jiffy.dart';
|
||||||
|
|
||||||
|
import '../../../../../widget/animatedTime.dart';
|
||||||
|
import '../../../../../widget/list_view_util.dart';
|
||||||
|
import '../../../../../widget/centeredLeading.dart';
|
||||||
|
import '../../../../../widget/debug/debugTile.dart';
|
||||||
|
import '../../../../../widget/string_extensions.dart';
|
||||||
|
import '../../../infrastructure/loadableState/loadable_state.dart';
|
||||||
|
import '../../../infrastructure/loadableState/view/loadable_state_consumer.dart';
|
||||||
|
import '../../../infrastructure/utilityWidgets/bloc_module.dart';
|
||||||
|
import '../bloc/holidays_bloc.dart';
|
||||||
|
import '../bloc/holidays_event.dart';
|
||||||
|
import '../bloc/holidays_state.dart';
|
||||||
|
|
||||||
|
class HolidaysView extends StatelessWidget {
|
||||||
|
const HolidaysView({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => BlocModule<HolidaysBloc, LoadableState<HolidaysState>>(
|
||||||
|
create: (context) => HolidaysBloc(),
|
||||||
|
autoRebuild: true,
|
||||||
|
child: (context, bloc, state) {
|
||||||
|
void showDisclaimer() {
|
||||||
|
showDialog(context: context, builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Richtigkeit und Bereitstellung der Daten'),
|
||||||
|
content: const Text(''
|
||||||
|
'Sämtliche Datumsangaben sind ohne Gewähr.\n'
|
||||||
|
'Ich übernehme weder Verantwortung für die Richtigkeit der Daten noch hafte ich für wirtschaftliche Schäden die aus der Verwendung dieser Daten entstehen können.\n\n'
|
||||||
|
'Die Daten stammen von https://ferien-api.de/'),
|
||||||
|
actions: [
|
||||||
|
TextButton(child: const Text('Okay'), onPressed: () => Navigator.of(context).pop()),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Schulferien in Hessen'),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.info_outline),
|
||||||
|
onPressed: showDisclaimer,
|
||||||
|
),
|
||||||
|
PopupMenuButton<bool>(
|
||||||
|
initialValue: bloc.showPastHolidays(),
|
||||||
|
icon: const Icon(Icons.history),
|
||||||
|
itemBuilder: (context) => [true, false].map((e) => PopupMenuItem<bool>(
|
||||||
|
value: e,
|
||||||
|
enabled: e != bloc.showPastHolidays(),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(e ? Icons.history_outlined : Icons.history_toggle_off_outlined, color: Theme.of(context).colorScheme.onSurface),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
Text(e ? 'Alle anzeigen' : 'Nur zukünftige anzeigen')
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)).toList(),
|
||||||
|
onSelected: (e) => bloc.add(SetPastHolidaysVisible(e)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: LoadableStateConsumer<HolidaysBloc, HolidaysState>(
|
||||||
|
onLoad: (state) {
|
||||||
|
if(state.showDisclaimer) showDisclaimer();
|
||||||
|
bloc.add(DisclaimerDismissed());
|
||||||
|
},
|
||||||
|
child: (state, loading) => ListViewUtil.fromList<Holiday>(bloc.getHolidays(), (holiday) {
|
||||||
|
var holidayType = holiday.name.split(' ').first.capitalize();
|
||||||
|
String formatDate(String date) => Jiffy.parse(date).format(pattern: 'dd.MM.yyyy');
|
||||||
|
String getYear(String date, {String format = 'yyyy'}) => Jiffy.parse(date).format(pattern: format);
|
||||||
|
|
||||||
|
String getHolidayYear(String startDate, String endDate) => getYear(startDate) == getYear(endDate)
|
||||||
|
? getYear(startDate)
|
||||||
|
: '${getYear(startDate)}/${getYear(endDate, format: 'yy')}';
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
leading: const CenteredLeading(Icon(Icons.calendar_month)),
|
||||||
|
title: Text('$holidayType ${getHolidayYear(holiday.start, holiday.end)}'),
|
||||||
|
subtitle: Text('${formatDate(holiday.start)} - ${formatDate(holiday.end)}'),
|
||||||
|
onTap: () => showDialog(context: context, builder: (context) => SimpleDialog(
|
||||||
|
title: Text('$holidayType ${holiday.year} in Hessen'),
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
leading: const CenteredLeading(Icon(Icons.signpost_outlined)),
|
||||||
|
title: Text(holiday.name.capitalize()),
|
||||||
|
subtitle: Text(holiday.slug.capitalize()),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.date_range_outlined),
|
||||||
|
title: Text('vom ${formatDate(holiday.start)}'),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.date_range_outlined),
|
||||||
|
title: Text('bis zum ${formatDate(holiday.end)}'),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: !DateTime.parse(holiday.start).difference(DateTime.now()).isNegative,
|
||||||
|
replacement: ListTile(
|
||||||
|
leading: const CenteredLeading(Icon(Icons.content_paste_search_outlined)),
|
||||||
|
title: Text(Jiffy.parse(holiday.start).fromNow()),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
leading: const CenteredLeading(Icon(Icons.timer_outlined)),
|
||||||
|
title: AnimatedTime(callback: () => DateTime.parse(holiday.start).difference(DateTime.now())),
|
||||||
|
subtitle: Text(Jiffy.parse(holiday.start).fromNow()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DebugTile(context).jsonData(holiday.toJson()),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
trailing: const Icon(Icons.arrow_right),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
@@ -8,7 +8,7 @@ class MarianumMessageBloc extends LoadableHydratedBloc<MarianumMessageEvent, Mar
|
|||||||
@override
|
@override
|
||||||
Future<void> gatherData() async {
|
Future<void> gatherData() async {
|
||||||
var messages = await repo.getMessages();
|
var messages = await repo.getMessages();
|
||||||
add(Emit((state) => state.copyWith(messageList: messages)));
|
add(DataGathered((state) => state.copyWith(messageList: messages)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
import '../../../infrastructure/dataLoader/data_loader.dart';
|
import '../../../infrastructure/dataLoader/http_data_loader.dart';
|
||||||
import '../../../infrastructure/dataLoader/mhsl_data_loader.dart';
|
import '../../../basis/dataloader/mhsl_data_loader.dart';
|
||||||
import '../bloc/marianum_message_state.dart';
|
import '../bloc/marianum_message_state.dart';
|
||||||
|
|
||||||
class MarianumMessageGetMessages extends MhslDataLoader<MarianumMessageList> {
|
class MarianumMessageGetMessages extends MhslDataLoader<MarianumMessageList> {
|
||||||
|
@@ -8,6 +8,6 @@ class LightAppTheme {
|
|||||||
colorScheme: ColorScheme.fromSeed(seedColor: marianumRed),
|
colorScheme: ColorScheme.fromSeed(seedColor: marianumRed),
|
||||||
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
||||||
foregroundColor: Colors.white
|
foregroundColor: Colors.white
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -60,12 +60,17 @@ class _FeedbackDialogState extends State<FeedbackDialog> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
onChanged: (value) {
|
||||||
|
if(value.trim().toLowerCase() == 'ranzig') {
|
||||||
|
_feedbackInput.text = 'selber';
|
||||||
|
}
|
||||||
|
},
|
||||||
controller: _feedbackInput,
|
controller: _feedbackInput,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
label: const Text('Feedback und Verbesserungen'),
|
label: const Text('Feedback und Verbesserungen'),
|
||||||
errorText: _textFieldEmpty ? 'Bitte gib eine Beschreibung an' : null,
|
errorText: _textFieldEmpty ? 'Bitte gib eine Beschreibung an???' : null,
|
||||||
),
|
),
|
||||||
minLines: 4,
|
minLines: 4,
|
||||||
maxLines: 7,
|
maxLines: 7,
|
||||||
|
@@ -1,157 +0,0 @@
|
|||||||
import 'dart:core';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:jiffy/jiffy.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import '../../../../model/holidays/holidaysProps.dart';
|
|
||||||
import '../../../../storage/base/settingsProvider.dart';
|
|
||||||
import '../../../../widget/centeredLeading.dart';
|
|
||||||
import '../../../../widget/confirmDialog.dart';
|
|
||||||
import '../../../../widget/debug/debugTile.dart';
|
|
||||||
import '../../../../widget/loadingSpinner.dart';
|
|
||||||
import '../../../../widget/placeholderView.dart';
|
|
||||||
import '../../../../widget/animatedTime.dart';
|
|
||||||
|
|
||||||
class Holidays extends StatefulWidget {
|
|
||||||
const Holidays({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<Holidays> createState() => _HolidaysState();
|
|
||||||
}
|
|
||||||
|
|
||||||
extension StringExtension on String {
|
|
||||||
String capitalize() => '${this[0].toUpperCase()}${substring(1).toLowerCase()}';
|
|
||||||
}
|
|
||||||
|
|
||||||
class _HolidaysState extends State<Holidays> {
|
|
||||||
late SettingsProvider settings = Provider.of<SettingsProvider>(context, listen: false);
|
|
||||||
late bool showPastEvents = settings.val().holidaysSettings.showPastEvents;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
||||||
Provider.of<HolidaysProps>(context, listen: false).run();
|
|
||||||
if(!settings.val().holidaysSettings.dismissedDisclaimer) showDisclaimer();
|
|
||||||
});
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
String parseString(String enDate) => Jiffy.parse(enDate).format(pattern: 'dd.MM.yyyy');
|
|
||||||
|
|
||||||
void showDisclaimer() {
|
|
||||||
showDialog(context: context, builder: (context) => AlertDialog(
|
|
||||||
title: const Text('Richtigkeit und Bereitstellung der Daten'),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const Text(''
|
|
||||||
'Sämtliche Datumsangaben sind ohne Gewähr.\n'
|
|
||||||
'Ich übernehme weder Verantwortung für die Richtigkeit der Daten noch hafte ich für wirtschaftliche Schäden die aus der Verwendung dieser Daten entstehen können.\n\n'
|
|
||||||
'Die Daten stammen von https://ferien-api.de/'),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
ListTile(
|
|
||||||
title: const Text('Diese Meldung nicht mehr anzeigen'),
|
|
||||||
trailing: Checkbox(
|
|
||||||
value: settings.val().holidaysSettings.dismissedDisclaimer,
|
|
||||||
onChanged: (value) => settings.val(write: true).holidaysSettings.dismissedDisclaimer = value!,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
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) => Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Schulferien in Hessen'),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.warning_amber_outlined),
|
|
||||||
onPressed: showDisclaimer,
|
|
||||||
),
|
|
||||||
PopupMenuButton<bool>(
|
|
||||||
initialValue: settings.val().holidaysSettings.showPastEvents,
|
|
||||||
icon: const Icon(Icons.manage_history_outlined),
|
|
||||||
itemBuilder: (context) => [true, false].map((e) => PopupMenuItem<bool>(
|
|
||||||
value: e,
|
|
||||||
enabled: e != showPastEvents,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(e ? Icons.history_outlined : Icons.history_toggle_off_outlined, color: Theme.of(context).colorScheme.onSurface),
|
|
||||||
const SizedBox(width: 15),
|
|
||||||
Text(e ? 'Alle anzeigen' : 'Nur zukünftige anzeigen')
|
|
||||||
],
|
|
||||||
)
|
|
||||||
)).toList(),
|
|
||||||
onSelected: (e) {
|
|
||||||
setState(() {
|
|
||||||
showPastEvents = e;
|
|
||||||
settings.val(write: true).holidaysSettings.showPastEvents = e;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: Consumer<HolidaysProps>(builder: (context, value, child) {
|
|
||||||
if(value.primaryLoading()) return const LoadingSpinner();
|
|
||||||
|
|
||||||
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!');
|
|
||||||
|
|
||||||
return ListView.builder(
|
|
||||||
itemCount: holidays.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
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)}'),
|
|
||||||
subtitle: Text('bis ${parseString(holiday.end)}'),
|
|
||||||
onTap: () => showDialog(context: context, builder: (context) => SimpleDialog(
|
|
||||||
title: Text('$holidayType ${holiday.year} in Hessen'),
|
|
||||||
children: [
|
|
||||||
ListTile(
|
|
||||||
leading: const CenteredLeading(Icon(Icons.signpost_outlined)),
|
|
||||||
title: Text(holiday.name),
|
|
||||||
subtitle: Text(holiday.slug),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.arrow_forward),
|
|
||||||
title: Text('vom ${parseString(holiday.start)}'),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.arrow_back),
|
|
||||||
title: Text('bis zum ${parseString(holiday.end)}'),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: !DateTime.parse(holiday.start).difference(DateTime.now()).isNegative,
|
|
||||||
replacement: ListTile(
|
|
||||||
leading: const CenteredLeading(Icon(Icons.content_paste_search_outlined)),
|
|
||||||
title: Text(Jiffy.parse(holiday.start).fromNow()),
|
|
||||||
),
|
|
||||||
child: ListTile(
|
|
||||||
leading: const CenteredLeading(Icon(Icons.timer_outlined)),
|
|
||||||
title: AnimatedTime(callback: () => DateTime.parse(holiday.start).difference(DateTime.now())),
|
|
||||||
subtitle: Text(Jiffy.parse(holiday.start).fromNow()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DebugTile(context).jsonData(holiday.toJson()),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
trailing: const Icon(Icons.arrow_right),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
@@ -2,7 +2,6 @@ import 'package:better_open_file/better_open_file.dart';
|
|||||||
import 'package:bubble/bubble.dart';
|
import 'package:bubble/bubble.dart';
|
||||||
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis;
|
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis;
|
||||||
import 'package:flowder/flowder.dart';
|
import 'package:flowder/flowder.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@@ -51,4 +51,4 @@ class ChatBubbleStyles {
|
|||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
lib/widget/list_view_util.dart
Normal file
9
lib/widget/list_view_util.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ListViewUtil {
|
||||||
|
static ListView fromList<T>(List<T>? items, Widget Function(T item) map) => ListView.builder(
|
||||||
|
itemCount: items?.length ?? 0,
|
||||||
|
itemBuilder: (context, index) => items != null ? map(items[index]) : null,
|
||||||
|
);
|
||||||
|
}
|
3
lib/widget/string_extensions.dart
Normal file
3
lib/widget/string_extensions.dart
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
extension StringExtensions on String {
|
||||||
|
String capitalize() => '${this[0].toUpperCase()}${substring(1).toLowerCase()}';
|
||||||
|
}
|
@@ -104,6 +104,7 @@ dependencies:
|
|||||||
connectivity_plus: ^6.0.3
|
connectivity_plus: ^6.0.3
|
||||||
hydrated_bloc: ^9.1.5
|
hydrated_bloc: ^9.1.5
|
||||||
dio: ^4.0.6
|
dio: ^4.0.6
|
||||||
|
sorted: ^2.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user