TF-1018 Implement AppDashboardConfigurationParser
This commit is contained in:
committed by
Dat H. Pham
parent
a443eccd6c
commit
2b259809f7
+24
@@ -0,0 +1,24 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:core/utils/config/app_config_parser.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/app_dashboard/linagora_applications.dart';
|
||||||
|
|
||||||
|
class AppDashboardConfigurationParser extends AppConfigParser<LinagoraApplications> {
|
||||||
|
@override
|
||||||
|
Future<LinagoraApplications> parse(String value) async {
|
||||||
|
try {
|
||||||
|
final jsonObject = jsonDecode(value);
|
||||||
|
return LinagoraApplications.fromJson(jsonObject);
|
||||||
|
} catch (e) {
|
||||||
|
logError('AppDashboardConfigurationParser::parse(): $e');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<LinagoraApplications> parseData(ByteData data) {
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
|
part 'linagora_app.g.dart';
|
||||||
|
|
||||||
|
@JsonSerializable()
|
||||||
|
class LinagoraApp with EquatableMixin{
|
||||||
|
@JsonKey(name: 'appName')
|
||||||
|
final String appName;
|
||||||
|
|
||||||
|
@JsonKey(name: 'icon')
|
||||||
|
final String iconName;
|
||||||
|
|
||||||
|
@JsonKey(name: 'appLink')
|
||||||
|
final Uri appUri;
|
||||||
|
|
||||||
|
LinagoraApp(this.appName, this.iconName, this.appUri);
|
||||||
|
|
||||||
|
factory LinagoraApp.fromJson(Map<String, dynamic> json) => _$LinagoraAppFromJson(json);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => _$LinagoraAppToJson(this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [appName, iconName, appUri];
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
import 'linagora_app.dart';
|
||||||
|
|
||||||
|
part 'linagora_applications.g.dart';
|
||||||
|
|
||||||
|
@JsonSerializable()
|
||||||
|
class LinagoraApplications with EquatableMixin {
|
||||||
|
@JsonKey(name: 'apps')
|
||||||
|
final List<LinagoraApp> apps;
|
||||||
|
|
||||||
|
LinagoraApplications(this.apps);
|
||||||
|
|
||||||
|
factory LinagoraApplications.fromJson(Map<String, dynamic> json) => _$LinagoraApplicationsFromJson(json);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => _$LinagoraApplicationsToJson(this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [apps];
|
||||||
|
}
|
||||||
@@ -59,5 +59,6 @@ class CoreBindings extends Bindings {
|
|||||||
void _bindingUtils() {
|
void _bindingUtils() {
|
||||||
Get.put(const Uuid());
|
Get.put(const Uuid());
|
||||||
Get.put(CompressFileUtils());
|
Get.put(CompressFileUtils());
|
||||||
|
Get.lazyPut(() => AppConfigLoader());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user