WIP - Replaced get_it + injectable with Provider

This commit is contained in:
Anton Stubenbord
2022-12-21 01:14:06 +01:00
parent 10149fb7c1
commit 60aecb549d
59 changed files with 1099 additions and 1362 deletions

View File

@@ -1,11 +1,10 @@
import 'package:paperless_mobile/core/type/types.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:paperless_mobile/features/login/model/client_certificate.dart';
class AuthenticationInformation {
static const tokenKey = 'token';
static const serverUrlKey = 'serverUrl';
static const clientCertificateKey = 'clientCertificate';
part 'authentication_information.g.dart';
@JsonSerializable()
class AuthenticationInformation {
final String? token;
final String serverUrl;
final ClientCertificate? clientCertificate;
@@ -16,21 +15,6 @@ class AuthenticationInformation {
this.clientCertificate,
});
AuthenticationInformation.fromJson(JSON json)
: token = json[tokenKey],
serverUrl = json[serverUrlKey],
clientCertificate = json[clientCertificateKey] != null
? ClientCertificate.fromJson(json[clientCertificateKey])
: null;
JSON toJson() {
return {
tokenKey: token,
serverUrlKey: serverUrl,
clientCertificateKey: clientCertificate?.toJson(),
};
}
bool get isValid {
return serverUrl.isNotEmpty && (token?.isNotEmpty ?? false);
}
@@ -48,4 +32,9 @@ class AuthenticationInformation {
(removeClientCertificate ? null : this.clientCertificate),
);
}
factory AuthenticationInformation.fromJson(Map<String, dynamic> json) =>
_$AuthenticationInformationFromJson(json);
Map<String, dynamic> toJson() => _$AuthenticationInformationToJson(this);
}

View File

@@ -0,0 +1,26 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'authentication_information.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
AuthenticationInformation _$AuthenticationInformationFromJson(
Map<String, dynamic> json) =>
AuthenticationInformation(
token: json['token'] as String?,
serverUrl: json['serverUrl'] as String,
clientCertificate: json['clientCertificate'] == null
? null
: ClientCertificate.fromJson(
json['clientCertificate'] as Map<String, dynamic>),
);
Map<String, dynamic> _$AuthenticationInformationToJson(
AuthenticationInformation instance) =>
<String, dynamic>{
'token': instance.token,
'serverUrl': instance.serverUrl,
'clientCertificate': instance.clientCertificate,
};