double tap on messages to show options #63
@ -28,6 +28,13 @@ linter:
|
||||
prefer_relative_imports: true
|
||||
unnecessary_lambdas: true
|
||||
prefer_single_quotes: true
|
||||
prefer_if_elements_to_conditional_expressions: true
|
||||
prefer_expression_function_bodies: true
|
||||
omit_local_variable_types: true
|
||||
eol_at_end_of_file: true
|
||||
cast_nullable_to_non_nullable: true
|
||||
avoid_void_async: true
|
||||
avoid_multiple_declarations_per_line: true
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
|
@ -4,7 +4,5 @@ class ApiError {
|
||||
ApiError(this.message);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ApiError: $message';
|
||||
}
|
||||
}
|
||||
String toString() => 'ApiError: $message';
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
class ApiParams {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
class ApiRequest {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,4 @@ abstract class ApiResponse {
|
||||
|
||||
@JsonKey(includeIfNull: false)
|
||||
late Map<String, String>? headers;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import 'getHolidaysResponse.dart';
|
||||
|
||||
class GetHolidays {
|
||||
Future<GetHolidaysResponse> query() async {
|
||||
String response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
|
||||
var response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
|
||||
return GetHolidaysResponse(
|
||||
List<GetHolidaysResponseObject>.from(
|
||||
jsonDecode(response).map<GetHolidaysResponseObject>(
|
||||
@ -15,4 +15,4 @@ class GetHolidays {
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,5 @@ class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetHolidaysResponse> onLoad() {
|
||||
return GetHolidays().query();
|
||||
}
|
||||
}
|
||||
Future<GetHolidaysResponse> onLoad() => GetHolidays().query();
|
||||
}
|
||||
|
@ -35,4 +35,4 @@ class GetHolidaysResponseObject {
|
||||
|
||||
factory GetHolidaysResponseObject.fromJson(Map<String, dynamic> json) => _$GetHolidaysResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetHolidaysResponseObjectToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../model/accountData.dart';
|
||||
import '../../../model/endpointData.dart';
|
||||
@ -10,7 +9,7 @@ import 'autocompleteResponse.dart';
|
||||
|
||||
class AutocompleteApi {
|
||||
Future<AutocompleteResponse> find(String query) async {
|
||||
Map<String, dynamic> getParameters = {
|
||||
var getParameters = <String, dynamic>{
|
||||
'search': query,
|
||||
'itemType': ' ',
|
||||
'itemId': ' ',
|
||||
@ -18,16 +17,16 @@ class AutocompleteApi {
|
||||
'limit': '10',
|
||||
};
|
||||
|
||||
Map<String, String> headers = {};
|
||||
var headers = <String, String>{};
|
||||
headers.putIfAbsent('Accept', () => 'application/json');
|
||||
headers.putIfAbsent('OCS-APIRequest', () => 'true');
|
||||
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters);
|
||||
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters);
|
||||
|
||||
Response response = await http.get(endpoint, headers: headers);
|
||||
var response = await http.get(endpoint, headers: headers);
|
||||
if(response.statusCode != HttpStatus.ok) throw Exception('Api call failed with ${response.statusCode}: ${response.body}');
|
||||
String result = response.body;
|
||||
var result = response.body;
|
||||
return AutocompleteResponse.fromJson(jsonDecode(result)['ocs']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,4 @@ class AutocompleteResponseObject {
|
||||
|
||||
factory AutocompleteResponseObject.fromJson(Map<String, dynamic> json) => _$AutocompleteResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AutocompleteResponseObjectToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../model/accountData.dart';
|
||||
import '../../../model/endpointData.dart';
|
||||
@ -9,15 +8,15 @@ import 'fileSharingApiParams.dart';
|
||||
|
||||
class FileSharingApi {
|
||||
Future<void> share(FileSharingApiParams query) async {
|
||||
Map<String, String> headers = {};
|
||||
var headers = <String, String>{};
|
||||
headers.putIfAbsent('Accept', () => 'application/json');
|
||||
headers.putIfAbsent('OCS-APIRequest', () => 'true');
|
||||
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString())));
|
||||
Response response = await http.post(endpoint, headers: headers);
|
||||
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString())));
|
||||
var response = await http.post(endpoint, headers: headers);
|
||||
|
||||
if(response.statusCode != HttpStatus.ok) {
|
||||
throw Exception('Api call failed with ${response.statusCode}: ${response.body}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,4 +20,4 @@ class FileSharingApiParams {
|
||||
|
||||
factory FileSharingApiParams.fromJson(Map<String, dynamic> json) => _$FileSharingApiParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$FileSharingApiParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,9 @@ class GetChat extends TalkApi<GetChatResponse> {
|
||||
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
assemble(String raw) => GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetChatResponse> onLoad() {
|
||||
return GetChat(
|
||||
Future<GetChatResponse> onLoad() => GetChat(
|
||||
chatToken,
|
||||
GetChatParams(
|
||||
lookIntoFuture: GetChatParamsSwitch.off,
|
||||
@ -22,11 +21,8 @@ class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
limit: 200,
|
||||
)
|
||||
).run();
|
||||
}
|
||||
|
||||
@override
|
||||
GetChatResponse onLocalData(String json) {
|
||||
return GetChatResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetChatResponse onLocalData(String json) => GetChatResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -31,4 +31,4 @@ class GetChatParams extends ApiParams {
|
||||
enum GetChatParamsSwitch {
|
||||
@JsonValue(1) on,
|
||||
@JsonValue(0) off,
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class GetChatResponse extends ApiResponse {
|
||||
Map<String, dynamic> toJson() => _$GetChatResponseToJson(this);
|
||||
|
||||
List<GetChatResponseObject> sortByTimestamp() {
|
||||
List<GetChatResponseObject> sorted = data.toList();
|
||||
var sorted = data.toList();
|
||||
sorted.sort((a, b) => a.timestamp.compareTo(b.timestamp));
|
||||
return sorted;
|
||||
}
|
||||
@ -60,12 +60,11 @@ class GetChatResponseObject {
|
||||
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
|
||||
|
||||
static GetChatResponseObject getDateDummy(int timestamp) {
|
||||
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
var elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy'));
|
||||
}
|
||||
|
||||
static GetChatResponseObject getTextDummy(String text) {
|
||||
return GetChatResponseObject(
|
||||
static GetChatResponseObject getTextDummy(String text) => GetChatResponseObject(
|
||||
0,
|
||||
'',
|
||||
GetRoomResponseObjectMessageActorType.user,
|
||||
@ -81,13 +80,12 @@ class GetChatResponseObject {
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Map<String, RichObjectString>? _fromJson(json) {
|
||||
if(json is Map<String, dynamic>) {
|
||||
Map<String, RichObjectString> data = {};
|
||||
var data = <String, RichObjectString>{};
|
||||
for (var element in json.keys) {
|
||||
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element]));
|
||||
}
|
||||
@ -119,4 +117,4 @@ enum RichObjectStringObjectType {
|
||||
@JsonValue('guest') guest,
|
||||
@JsonValue('highlight') highlight,
|
||||
@JsonValue('talk-poll') talkPoll,
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ class RichObjectStringProcessor {
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ class CreateRoom extends TalkApi {
|
||||
CreateRoom(this.params) : super('v4/room', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
@ -22,4 +20,4 @@ class CreateRoom extends TalkApi {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,4 @@ class CreateRoomParams extends ApiParams {
|
||||
|
||||
factory CreateRoomParams.fromJson(Map<String, dynamic> json) => _$CreateRoomParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CreateRoomParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,9 @@ class DeleteMessage extends TalkApi {
|
||||
DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.delete(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class DeleteReactMessage extends TalkApi {
|
||||
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
@ -23,4 +21,4 @@ class DeleteReactMessage extends TalkApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ class DeleteReactMessageParams extends ApiParams {
|
||||
|
||||
factory DeleteReactMessageParams.fromJson(Map<String, dynamic> json) => _$DeleteReactMessageParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DeleteReactMessageParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,9 @@ class GetParticipants extends TalkApi<GetParticipantsResponse> {
|
||||
GetParticipants(this.token) : super('v4/room/$token/participants', null);
|
||||
|
||||
@override
|
||||
GetParticipantsResponse assemble(String raw) {
|
||||
return GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
GetParticipantsResponse assemble(String raw) => GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,15 +12,11 @@ class GetParticipantsCache extends RequestCache<GetParticipantsResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetParticipantsResponse> onLoad() {
|
||||
return GetParticipants(
|
||||
Future<GetParticipantsResponse> onLoad() => GetParticipants(
|
||||
chatToken,
|
||||
).run();
|
||||
}
|
||||
|
||||
@override
|
||||
GetParticipantsResponse onLocalData(String json) {
|
||||
return GetParticipantsResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetParticipantsResponse onLocalData(String json) => GetParticipantsResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -69,4 +69,4 @@ enum GetParticipantsResponseObjectParticipantsInCallFlags {
|
||||
@JsonValue(2) providesAudio,
|
||||
@JsonValue(3) providesVideo,
|
||||
@JsonValue(4) usesSipDialIn
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,9 @@ class GetReactions extends TalkApi<GetReactionsResponse> {
|
||||
GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
assemble(String raw) => GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,4 +30,4 @@ class GetReactionsResponseObject {
|
||||
enum GetReactionsResponseObjectActorType {
|
||||
@JsonValue('guests') guests,
|
||||
@JsonValue('users') users,
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,8 @@ class LeaveRoom extends TalkApi {
|
||||
LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
}
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.delete(uri, headers: headers);
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class ReactMessage extends TalkApi {
|
||||
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
@ -23,4 +21,4 @@ class ReactMessage extends TalkApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ class ReactMessageParams extends ApiParams {
|
||||
|
||||
factory ReactMessageParams.fromJson(Map<String, dynamic> json) => _$ReactMessageParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ReactMessageParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,9 @@ class GetRoom extends TalkApi<GetRoomResponse> {
|
||||
|
||||
|
||||
@override
|
||||
GetRoomResponse assemble(String raw) {
|
||||
return GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
GetRoomResponse assemble(String raw) => GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,12 @@ class GetRoomCache extends RequestCache<GetRoomResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetRoomResponse onLocalData(String json) {
|
||||
return GetRoomResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetRoomResponse onLocalData(String json) => GetRoomResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetRoomResponse> onLoad() {
|
||||
return GetRoom(
|
||||
Future<GetRoomResponse> onLoad() => GetRoom(
|
||||
GetRoomParams(
|
||||
includeStatus: true,
|
||||
)
|
||||
).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ class GetRoomParams extends ApiParams {
|
||||
enum GetRoomParamsStatusUpdate {
|
||||
@JsonValue(0) defaults,
|
||||
@JsonValue(1) keepAlive,
|
||||
}
|
||||
}
|
||||
|
@ -164,4 +164,4 @@ enum GetRoomResponseObjectMessageType {
|
||||
@JsonValue('comment_deleted') deletedComment,
|
||||
@JsonValue('system') system,
|
||||
@JsonValue('command') command,
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ class SendMessage extends TalkApi {
|
||||
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
@ -22,4 +20,4 @@ class SendMessage extends TalkApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ class SendMessageParams extends ApiParams {
|
||||
|
||||
factory SendMessageParams.fromJson(Map<String, dynamic> json) => _$SendMessageParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SendMessageParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@ import '../../../apiResponse.dart';
|
||||
|
||||
class SendMessageResponse extends ApiResponse {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class SetFavorite extends TalkApi {
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
@ -24,4 +22,4 @@ class SetFavorite extends TalkApi {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,7 @@ class SetReadMarker extends TalkApi {
|
||||
}
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
@ -29,4 +27,4 @@ class SetReadMarker extends TalkApi {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ class SetReadMarkerParams extends ApiParams {
|
||||
|
||||
factory SetReadMarkerParams.fromJson(Map<String, dynamic> json) => _$SetReadMarkerParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SetReadMarkerParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
getParameters?.update(key, (value) => value.toString());
|
||||
});
|
||||
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
|
||||
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
|
||||
|
||||
headers ??= {};
|
||||
headers?.putIfAbsent('Accept', () => 'application/json');
|
||||
@ -65,4 +65,4 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
throw Exception('Error assembling Talk API response');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,5 @@ class TalkError {
|
||||
TalkError(this.status, this.code, this.message);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Talk - $status - ($code): $message';
|
||||
}
|
||||
}
|
||||
String toString() => 'Talk - $status - ($code): $message';
|
||||
}
|
||||
|
@ -19,4 +19,4 @@ class DownloadFile extends WebdavApi<DownloadFileParams> {
|
||||
// OpenFile.open(localPath);
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ class DownloadFileParams extends ApiParams {
|
||||
|
||||
factory DownloadFileParams.fromJson(Map<String, dynamic> json) => _$DownloadFileParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DownloadFileParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ class DownloadFileResponse {
|
||||
|
||||
factory DownloadFileResponse.fromJson(Map<String, dynamic> json) => _$DownloadFileResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DownloadFileResponseToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,4 @@ class CacheableFile {
|
||||
|
||||
factory CacheableFile.fromJson(Map<String, dynamic> json) => _$CacheableFileFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CacheableFileToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
|
||||
@override
|
||||
Future<ListFilesResponse> run() async {
|
||||
List<WebDavFile> davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles();
|
||||
Set<CacheableFile> files = davFiles.map(CacheableFile.fromDavFile).toSet();
|
||||
var davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles();
|
||||
var files = davFiles.map(CacheableFile.fromDavFile).toSet();
|
||||
|
||||
// webdav handles subdirectories wrong, this is a fix
|
||||
// currently this fix is not needed anymore
|
||||
@ -30,4 +30,4 @@ class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
|
||||
return ListFilesResponse(files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,19 +11,17 @@ class ListFilesCache extends RequestCache<ListFilesResponse> {
|
||||
|
||||
ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
var bytes = utf8.encode('MarianumMobile-$path');
|
||||
String cacheName = md5.convert(bytes).toString();
|
||||
var cacheName = md5.convert(bytes).toString();
|
||||
start('MarianumMobile', 'wd-folder-$cacheName');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ListFilesResponse> onLoad() async {
|
||||
ListFilesResponse data = await ListFiles(ListFilesParams(path)).run();
|
||||
var data = await ListFiles(ListFilesParams(path)).run();
|
||||
return data;
|
||||
}
|
||||
|
||||
@override
|
||||
ListFilesResponse onLocalData(String json) {
|
||||
return ListFilesResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
ListFilesResponse onLocalData(String json) => ListFilesResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ class ListFilesParams extends ApiParams {
|
||||
|
||||
factory ListFilesParams.fromJson(Map<String, dynamic> json) => _$ListFilesParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ListFilesParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -54,4 +54,4 @@ class ListFilesResponse extends ApiResponse {
|
||||
var list = files.toList()..sort((a, b) => b.sort!.compareTo(a.sort!));
|
||||
return reversed ? list.reversed.toList() : list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,7 @@ abstract class WebdavApi<T> extends ApiRequest {
|
||||
static Future<WebDavClient> webdav = establishWebdavConnection();
|
||||
static Future<String> webdavConnectString = buildWebdavConnectString();
|
||||
|
||||
static Future<WebDavClient> establishWebdavConnection() async {
|
||||
return NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav;
|
||||
}
|
||||
static Future<WebDavClient> establishWebdavConnection() async => NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav;
|
||||
|
||||
static Future<String> buildWebdavConnectString() async {
|
||||
return 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/';
|
||||
}
|
||||
}
|
||||
static Future<String> buildWebdavConnectString() async => 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/';
|
||||
}
|
||||
|
@ -9,13 +9,9 @@ class GetBreakers extends MhslApi<GetBreakersResponse> {
|
||||
GetBreakers() : super('breaker/');
|
||||
|
||||
@override
|
||||
GetBreakersResponse assemble(String raw) {
|
||||
return GetBreakersResponse.fromJson(jsonDecode(raw));
|
||||
}
|
||||
GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw));
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.get(uri);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetBreakersCache extends RequestCache<GetBreakersResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetBreakersResponse onLocalData(String json) {
|
||||
return GetBreakersResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetBreakersResponse onLocalData(String json) => GetBreakersResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetBreakersResponse> onLoad() {
|
||||
return GetBreakers().run();
|
||||
}
|
||||
}
|
||||
Future<GetBreakersResponse> onLoad() => GetBreakers().run();
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ enum BreakerArea {
|
||||
@JsonValue('TALK') talk,
|
||||
@JsonValue('FILES') files,
|
||||
@JsonValue('MORE') more,
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class AddCustomTimetableEvent extends MhslApi<void> {
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
String body = jsonEncode(params.toJson());
|
||||
var body = jsonEncode(params.toJson());
|
||||
return http.post(uri, body: body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ class AddCustomTimetableEventParams {
|
||||
|
||||
factory AddCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$AddCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AddCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ class CustomTimetableEvent {
|
||||
|
||||
factory CustomTimetableEvent.fromJson(Map<String, dynamic> json) => _$CustomTimetableEventFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CustomTimetableEventToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,8 @@ class GetCustomTimetableEvent extends MhslApi<GetCustomTimetableEventResponse> {
|
||||
GetCustomTimetableEvent(this.params) : super('server/timetable/customEvents?user=${params.user}');
|
||||
|
||||
@override
|
||||
GetCustomTimetableEventResponse assemble(String raw) {
|
||||
return GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
|
||||
}
|
||||
GetCustomTimetableEventResponse assemble(String raw) => GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.get(uri);
|
||||
}
|
||||
|
@ -13,12 +13,8 @@ class GetCustomTimetableEventCache extends RequestCache<GetCustomTimetableEventR
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetCustomTimetableEventResponse> onLoad() {
|
||||
return GetCustomTimetableEvent(params).run();
|
||||
}
|
||||
Future<GetCustomTimetableEventResponse> onLoad() => GetCustomTimetableEvent(params).run();
|
||||
|
||||
@override
|
||||
GetCustomTimetableEventResponse onLocalData(String json) {
|
||||
return GetCustomTimetableEventResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
}
|
||||
GetCustomTimetableEventResponse onLocalData(String json) => GetCustomTimetableEventResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ class GetCustomTimetableEventParams {
|
||||
|
||||
factory GetCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$GetCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ class GetCustomTimetableEventResponse extends ApiResponse {
|
||||
|
||||
factory GetCustomTimetableEventResponse.fromJson(Map<String, dynamic> json) => _$GetCustomTimetableEventResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetCustomTimetableEventResponseToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ class RemoveCustomTimetableEvent extends MhslApi<void> {
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.delete(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.delete(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ class RemoveCustomTimetableEventParams {
|
||||
|
||||
factory RemoveCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$RemoveCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$RemoveCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ class UpdateCustomTimetableEvent extends MhslApi<void> {
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.patch(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.patch(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ class UpdateCustomTimetableEventParams {
|
||||
|
||||
factory UpdateCustomTimetableEventParams.fromJson(Map<String, dynamic> json) => _$UpdateCustomTimetableEventParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UpdateCustomTimetableEventParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetMessages extends MhslApi<GetMessagesResponse> {
|
||||
|
||||
|
||||
@override
|
||||
GetMessagesResponse assemble(String raw) {
|
||||
return GetMessagesResponse.fromJson(jsonDecode(raw));
|
||||
}
|
||||
GetMessagesResponse assemble(String raw) => GetMessagesResponse.fromJson(jsonDecode(raw));
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
return http.get(uri);
|
||||
}
|
||||
}
|
||||
Future<http.Response> request(Uri uri) => http.get(uri);
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetMessagesCache extends RequestCache<GetMessagesResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetMessagesResponse onLocalData(String json) {
|
||||
return GetMessagesResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetMessagesResponse onLocalData(String json) => GetMessagesResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetMessagesResponse> onLoad() {
|
||||
return GetMessages().run();
|
||||
}
|
||||
}
|
||||
Future<GetMessagesResponse> onLoad() => GetMessages().run();
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ abstract class MhslApi<T> extends ApiRequest {
|
||||
T assemble(String raw);
|
||||
|
||||
Future<T> run() async {
|
||||
Uri endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
|
||||
var endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
|
||||
|
||||
http.Response? data = await request(endpoint);
|
||||
var data = await request(endpoint);
|
||||
if(data == null) {
|
||||
throw ApiError('Request could not be dispatched!');
|
||||
}
|
||||
@ -31,5 +31,4 @@ abstract class MhslApi<T> extends ApiRequest {
|
||||
|
||||
static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss');
|
||||
static DateTime dateTimeFromJson(String time) => DateTime.parse(time);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ class NotifyRegister extends MhslApi<void> {
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
String requestString = jsonEncode(params.toJson());
|
||||
var requestString = jsonEncode(params.toJson());
|
||||
log(requestString);
|
||||
return http.post(uri, body: requestString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ class NotifyRegisterParams {
|
||||
|
||||
factory NotifyRegisterParams.fromJson(Map<String, dynamic> json) => _$NotifyRegisterParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$NotifyRegisterParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ class AddFeedback extends MhslApi<void> {
|
||||
void assemble(String raw) {}
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri) {
|
||||
return http.post(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
}
|
||||
Future<Response>? request(Uri uri) => http.post(uri, body: jsonEncode(params.toJson()));
|
||||
}
|
||||
|
@ -19,4 +19,4 @@ class AddFeedbackParams {
|
||||
|
||||
factory AddFeedbackParams.fromJson(Map<String, dynamic> json) => _$AddFeedbackParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AddFeedbackParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -21,4 +21,4 @@ class UpdateUserIndexParams {
|
||||
|
||||
factory UpdateUserIndexParams.fromJson(Map<String, dynamic> json) => _$UpdateUserIndexParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UpdateUserIndexParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ class UpdateUserIndex extends MhslApi<void> {
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
String data = jsonEncode(params.toJson());
|
||||
var data = jsonEncode(params.toJson());
|
||||
log('Updating userindex:\n $data');
|
||||
return http.post(uri, body: data);
|
||||
}
|
||||
|
||||
static void index() async {
|
||||
static Future<void> index() async {
|
||||
UpdateUserIndex(
|
||||
UpdateUserIndexParams(
|
||||
username: AccountData().getUsername(),
|
||||
@ -35,4 +35,4 @@ class UpdateUserIndex extends MhslApi<void> {
|
||||
),
|
||||
).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ abstract class RequestCache<T extends ApiResponse?> {
|
||||
|
||||
static void ignore(Exception e) {}
|
||||
|
||||
void start(String file, String document) async {
|
||||
Map<String, dynamic>? tableData = await Localstore.instance.collection(file).doc(document).get();
|
||||
Future<void> start(String file, String document) async {
|
||||
var tableData = await Localstore.instance.collection(file).doc(document).get();
|
||||
if(tableData != null) {
|
||||
onUpdate(onLocalData(tableData['json']));
|
||||
}
|
||||
@ -31,7 +31,7 @@ abstract class RequestCache<T extends ApiResponse?> {
|
||||
}
|
||||
|
||||
try {
|
||||
T newValue = await onLoad();
|
||||
var newValue = await onLoad();
|
||||
onUpdate(newValue);
|
||||
|
||||
Localstore.instance.collection(file).doc(document).set({
|
||||
@ -46,4 +46,4 @@ abstract class RequestCache<T extends ApiResponse?> {
|
||||
T onLocalData(String json);
|
||||
Future<T> onLoad();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class Authenticate extends WebuntisApi {
|
||||
@override
|
||||
Future<AuthenticateResponse> run() async {
|
||||
awaitingResponse = true;
|
||||
String rawAnswer = await query(this);
|
||||
var rawAnswer = await query(this);
|
||||
AuthenticateResponse response = finalize(AuthenticateResponse.fromJson(jsonDecode(rawAnswer)['result']));
|
||||
_lastResponse = response;
|
||||
if(!awaitedResponse.isCompleted) awaitedResponse.complete();
|
||||
@ -46,4 +46,4 @@ class Authenticate extends WebuntisApi {
|
||||
return _lastResponse!;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ class AuthenticateParams extends ApiParams {
|
||||
factory AuthenticateParams.fromJson(Map<String, dynamic> json) => _$AuthenticateParamsFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthenticateParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ class AuthenticateResponse extends ApiResponse {
|
||||
|
||||
factory AuthenticateResponse.fromJson(Map<String, dynamic> json) => _$AuthenticateResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AuthenticateResponseToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class GetHolidays extends WebuntisApi {
|
||||
|
||||
@override
|
||||
Future<GetHolidaysResponse> run() async {
|
||||
String rawAnswer = await query(this);
|
||||
var rawAnswer = await query(this);
|
||||
return finalize(GetHolidaysResponse.fromJson(jsonDecode(rawAnswer)));
|
||||
}
|
||||
|
||||
@ -17,12 +17,12 @@ class GetHolidays extends WebuntisApi {
|
||||
time = DateTime(time.year, time.month, time.day, 0, 0, 0, 0, 0);
|
||||
|
||||
for (var element in holidaysResponse.result) {
|
||||
DateTime start = DateTime.parse(element.startDate.toString());
|
||||
DateTime end = DateTime.parse(element.endDate.toString());
|
||||
var start = DateTime.parse(element.startDate.toString());
|
||||
var end = DateTime.parse(element.endDate.toString());
|
||||
|
||||
if(!start.isAfter(time) && !end.isBefore(time)) return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,8 @@ class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetHolidaysResponse> onLoad() {
|
||||
return GetHolidays().run();
|
||||
}
|
||||
Future<GetHolidaysResponse> onLoad() => GetHolidays().run();
|
||||
|
||||
@override
|
||||
GetHolidaysResponse onLocalData(String json) {
|
||||
return GetHolidaysResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
}
|
||||
GetHolidaysResponse onLocalData(String json) => GetHolidaysResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
|
@ -26,4 +26,4 @@ class GetHolidaysResponseObject {
|
||||
|
||||
factory GetHolidaysResponseObject.fromJson(Map<String, dynamic> json) => _$GetHolidaysResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetHolidaysResponseObjectToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class GetRooms extends WebuntisApi {
|
||||
|
||||
@override
|
||||
Future<GetRoomsResponse> run() async {
|
||||
String rawAnswer = await query(this);
|
||||
var rawAnswer = await query(this);
|
||||
try {
|
||||
return finalize(GetRoomsResponse.fromJson(jsonDecode(rawAnswer)));
|
||||
} catch(e, trace) {
|
||||
@ -20,4 +20,4 @@ class GetRooms extends WebuntisApi {
|
||||
throw Exception('Failed to parse getRoom server response: $rawAnswer');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,9 @@ class GetRoomsCache extends RequestCache<GetRoomsResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetRoomsResponse> onLoad() {
|
||||
return GetRooms().run();
|
||||
}
|
||||
Future<GetRoomsResponse> onLoad() => GetRooms().run();
|
||||
|
||||
@override
|
||||
GetRoomsResponse onLocalData(String json) {
|
||||
return GetRoomsResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetRoomsResponse onLocalData(String json) => GetRoomsResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,4 @@ class GetRoomsResponseObject {
|
||||
|
||||
factory GetRoomsResponseObject.fromJson(Map<String, dynamic> json) => _$GetRoomsResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetRoomsResponseObjectToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class GetSubjects extends WebuntisApi {
|
||||
|
||||
@override
|
||||
Future<GetSubjectsResponse> run() async {
|
||||
String rawAnswer = await query(this);
|
||||
var rawAnswer = await query(this);
|
||||
return finalize(GetSubjectsResponse.fromJson(jsonDecode(rawAnswer)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,9 @@ class GetSubjectsCache extends RequestCache<GetSubjectsResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetSubjectsResponse> onLoad() {
|
||||
return GetSubjects().run();
|
||||
}
|
||||
Future<GetSubjectsResponse> onLoad() => GetSubjects().run();
|
||||
|
||||
@override
|
||||
onLocalData(String json) {
|
||||
return GetSubjectsResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
onLocalData(String json) => GetSubjectsResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,4 @@ class GetSubjectsResponseObject {
|
||||
|
||||
factory GetSubjectsResponseObject.fromJson(Map<String, dynamic> json) => _$GetSubjectsResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetSubjectsResponseObjectToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ class GetTimetable extends WebuntisApi {
|
||||
|
||||
@override
|
||||
Future<GetTimetableResponse> run() async {
|
||||
String rawAnswer = await query(this);
|
||||
var rawAnswer = await query(this);
|
||||
return finalize(GetTimetableResponse.fromJson(jsonDecode(rawAnswer)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,10 @@ class GetTimetableCache extends RequestCache<GetTimetableResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetTimetableResponse onLocalData(String json) {
|
||||
return GetTimetableResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetTimetableResponse onLocalData(String json) => GetTimetableResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetTimetableResponse> onLoad() async {
|
||||
return GetTimetable(
|
||||
Future<GetTimetableResponse> onLoad() async => GetTimetable(
|
||||
GetTimetableParams(
|
||||
options: GetTimetableParamsOptions(
|
||||
element: GetTimetableParamsOptionsElement(
|
||||
@ -38,5 +35,4 @@ class GetTimetableCache extends RequestCache<GetTimetableResponse> {
|
||||
)
|
||||
)
|
||||
).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,4 +91,4 @@ enum GetTimetableParamsOptionsElementKeyType {
|
||||
@JsonValue('id') id,
|
||||
@JsonValue('name') name,
|
||||
@JsonValue('externalkey') externalkey
|
||||
}
|
||||
}
|
||||
|
@ -136,4 +136,4 @@ class GetTimetableResponseObjectRoom {
|
||||
|
||||
factory GetTimetableResponseObjectRoom.fromJson(Map<String, dynamic> json) => _$GetTimetableResponseObjectRoomFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GetTimetableResponseObjectRoomToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
|
||||
|
||||
Future<String> query(WebuntisApi untis) async {
|
||||
String query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
|
||||
var query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
|
||||
|
||||
String sessionId = '0';
|
||||
var sessionId = '0';
|
||||
if(authenticatedResponse) {
|
||||
sessionId = (await Authenticate.getSession()).sessionId;
|
||||
}
|
||||
http.Response data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'});
|
||||
var data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'});
|
||||
response = data;
|
||||
|
||||
dynamic jsonData = jsonDecode(data.body);
|
||||
@ -48,16 +48,12 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
|
||||
Future<ApiResponse> run();
|
||||
|
||||
String _body() {
|
||||
return genericParam == null ? '{}' : jsonEncode(genericParam);
|
||||
}
|
||||
String _body() => genericParam == null ? '{}' : jsonEncode(genericParam);
|
||||
|
||||
Future<http.Response> post(String data, Map<String, String>? headers) async {
|
||||
return await http
|
||||
Future<http.Response> post(String data, Map<String, String>? headers) async => await http
|
||||
.post(endpoint, body: data, headers: headers)
|
||||
.timeout(
|
||||
const Duration(seconds: 10),
|
||||
onTimeout: () => throw WebuntisError('Timeout', 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,5 @@ class WebuntisError implements Exception {
|
||||
WebuntisError(this.message, this.code);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WebUntis ($code): $message';
|
||||
}
|
||||
}
|
||||
String toString() => 'WebUntis ($code): $message';
|
||||
}
|
||||
|
@ -94,10 +94,8 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PersistentTabView(
|
||||
Widget build(BuildContext context) => PersistentTabView(
|
||||
controller: App.bottomNavigator,
|
||||
gestureNavigationEnabled: true,
|
||||
navBarOverlap: const NavBarOverlap.none(),
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
|
||||
@ -120,7 +118,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
icon: Consumer<ChatListProps>(
|
||||
builder: (context, value, child) {
|
||||
if(value.primaryLoading()) return const Icon(Icons.chat);
|
||||
int messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b);
|
||||
var messages = value.getRoomsResponse.data.map((e) => e.unreadMessages).reduce((a, b) => a+b);
|
||||
return badges.Badge(
|
||||
showBadge: messages > 0,
|
||||
position: badges.BadgePosition.topEnd(top: -3, end: -3),
|
||||
@ -165,7 +163,6 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@ -174,4 +171,4 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension IsSameDay on DateTime {
|
||||
bool isSameDay(DateTime other) {
|
||||
return year == other.year && month == other.month && day == other.day;
|
||||
}
|
||||
bool isSameDay(DateTime other) => year == other.year && month == other.month && day == other.day;
|
||||
|
||||
DateTime nextWeekday(int day) {
|
||||
return add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
|
||||
}
|
||||
DateTime nextWeekday(int day) => add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
|
||||
|
||||
DateTime withTime(TimeOfDay time) {
|
||||
return copyWith(hour: time.hour, minute: time.minute);
|
||||
}
|
||||
DateTime withTime(TimeOfDay time) => copyWith(hour: time.hour, minute: time.minute);
|
||||
|
||||
TimeOfDay toTimeOfDay() {
|
||||
return TimeOfDay(hour: hour, minute: minute);
|
||||
}
|
||||
TimeOfDay toTimeOfDay() => TimeOfDay(hour: hour, minute: minute);
|
||||
|
||||
bool isSameDateTime(DateTime other) {
|
||||
bool isSameDay = this.isSameDay(other);
|
||||
bool isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay());
|
||||
var isSameDay = this.isSameDay(other);
|
||||
var isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay());
|
||||
|
||||
return isSameDay && isSameTimeOfDay;
|
||||
}
|
||||
|
||||
bool isSameOrAfter(DateTime other) {
|
||||
return isSameDateTime(other) || isAfter(other);
|
||||
}
|
||||
}
|
||||
bool isSameOrAfter(DateTime other) => isSameDateTime(other) || isAfter(other);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
extension RenderNotNullExt<T> on T? {
|
||||
R? wrapNullable<R>(R Function(T data) defaultValueCallback) {
|
||||
return this != null ? defaultValueCallback(this as T) : null;
|
||||
}
|
||||
}
|
||||
R? wrapNullable<R>(R Function(T data) defaultValueCallback) => this != null ? defaultValueCallback(this as T) : null;
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
|
||||
|
||||
extension TextExt on Text {
|
||||
Size get size {
|
||||
final TextPainter textPainter = TextPainter(
|
||||
final textPainter = TextPainter(
|
||||
text: TextSpan(text: data, style: style),
|
||||
maxLines: 1,
|
||||
textDirection: TextDirection.ltr
|
||||
)..layout(minWidth: 0, maxWidth: double.infinity);
|
||||
return textPainter.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension TimeOfDayExt on TimeOfDay {
|
||||
bool isBefore(TimeOfDay other) {
|
||||
return hour < other.hour && minute < other.minute;
|
||||
}
|
||||
bool isBefore(TimeOfDay other) => hour < other.hour && minute < other.minute;
|
||||
|
||||
bool isAfter(TimeOfDay other) {
|
||||
return hour > other.hour && minute > other.minute;
|
||||
}
|
||||
bool isAfter(TimeOfDay other) => hour > other.hour && minute > other.minute;
|
||||
|
||||
TimeOfDay add({int hours = 0, int minutes = 0}) {
|
||||
return replacing(hour: hour + hours, minute: minute + minutes);
|
||||
}
|
||||
}
|
||||
TimeOfDay add({int hours = 0, int minutes = 0}) => replacing(hour: hour + hours, minute: minute + minutes);
|
||||
}
|
||||
|
@ -41,16 +41,14 @@ Future<void> main() async {
|
||||
log('Error initializing Firebase app!');
|
||||
}
|
||||
|
||||
ByteData data = await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem');
|
||||
var data = await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem');
|
||||
SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List());
|
||||
|
||||
if(kReleaseMode) {
|
||||
ErrorWidget.builder = (error) {
|
||||
return PlaceholderView(
|
||||
ErrorWidget.builder = (error) => PlaceholderView(
|
||||
icon: Icons.phonelink_erase_rounded,
|
||||
text: error.toStringShort(),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
runApp(
|
||||
@ -101,8 +99,7 @@ class _MainState extends State<Main> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
Widget build(BuildContext context) => Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Consumer<SettingsProvider>(
|
||||
builder: (context, settings, child) {
|
||||
@ -146,7 +143,6 @@ class _MainState extends State<Main> {
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
@ -17,9 +17,7 @@ class AccountData {
|
||||
final Future<SharedPreferences> _storage = SharedPreferences.getInstance();
|
||||
Completer<void> _populated = Completer();
|
||||
|
||||
factory AccountData() {
|
||||
return _instance;
|
||||
}
|
||||
factory AccountData() => _instance;
|
||||
|
||||
AccountData._construct() {
|
||||
_updateFromStorage();
|
||||
@ -38,16 +36,12 @@ class AccountData {
|
||||
return _password!;
|
||||
}
|
||||
|
||||
String getUserSecret() {
|
||||
return sha512.convert(utf8.encode('${AccountData().getUsername()}:${AccountData().getPassword()}')).toString();
|
||||
}
|
||||
String getUserSecret() => sha512.convert(utf8.encode('${AccountData().getUsername()}:${AccountData().getPassword()}')).toString();
|
||||
|
||||
Future<String> getDeviceId() async {
|
||||
return sha512.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}')).toString();
|
||||
}
|
||||
Future<String> getDeviceId() async => sha512.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}')).toString();
|
||||
|
||||
Future<void> setData(String username, String password) async {
|
||||
SharedPreferences storage = await _storage;
|
||||
var storage = await _storage;
|
||||
|
||||
storage.setString(_usernameField, username);
|
||||
storage.setString(_passwordField, password);
|
||||
@ -59,13 +53,13 @@ class AccountData {
|
||||
|
||||
if(context != null) Provider.of<AccountModel>(context, listen: false).setState(AccountModelState.loggedOut);
|
||||
|
||||
SharedPreferences storage = await _storage;
|
||||
var storage = await _storage;
|
||||
await storage.remove(_usernameField);
|
||||
await storage.remove(_passwordField);
|
||||
}
|
||||
|
||||
Future<void> _updateFromStorage() async {
|
||||
SharedPreferences storage = await _storage;
|
||||
var storage = await _storage;
|
||||
//await storage.reload(); // This line was the cause of the first rejected google play upload :(
|
||||
if(storage.containsKey(_usernameField) && storage.containsKey(_passwordField)) {
|
||||
_username = storage.getString(_usernameField);
|
||||
@ -79,12 +73,10 @@ class AccountData {
|
||||
return isPopulated();
|
||||
}
|
||||
|
||||
bool isPopulated() {
|
||||
return _username != null && _password != null;
|
||||
}
|
||||
bool isPopulated() => _username != null && _password != null;
|
||||
|
||||
String buildHttpAuthString() {
|
||||
if(!isPopulated()) throw Exception('AccountData (e.g. username or password) is not initialized!');
|
||||
return '$_username:$_password';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user