TF-571 Implement AccountRepository with HiveAccountDataSource

This commit is contained in:
Dat PHAM HOANG
2022-05-31 14:26:15 +07:00
committed by Dat H. Pham
parent f8e7429751
commit ff6e6d8878
7 changed files with 256 additions and 0 deletions
@@ -0,0 +1,20 @@
import 'package:model/account/account.dart';
import 'package:model/account/authentication_type.dart';
import 'package:tmail_ui_user/features/login/data/model/account_cache.dart';
extension AccountCacheExtension on AccountCache {
AuthenticationType fromAuthenticationTypeString() {
if (authenticationType == 'basic') {
return AuthenticationType.basic;
} else if (authenticationType == 'oidc') {
return AuthenticationType.oidc;
} else {
return AuthenticationType.none;
}
}
Account toAccount() {
final authenticationType = fromAuthenticationTypeString();
return Account(id, authenticationType, isSelected: isSelected);
}
}
@@ -0,0 +1,9 @@
import 'package:model/account/account.dart';
import 'package:model/account/authentication_type.dart';
import 'package:tmail_ui_user/features/login/data/model/account_cache.dart';
extension AccountExtensions on Account {
AccountCache toCache() {
return AccountCache(id, authenticationType.asString(), isSelected: isSelected);
}
}