TF-1098 Remove class not used
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
class DatabaseConfig {
|
|
||||||
static final String databaseName = 'TMailDatabase.db';
|
|
||||||
static final int databaseVersion = 1;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
class EmailAddressTable {
|
|
||||||
static const String TABLE_NAME = 'EmailAddress';
|
|
||||||
|
|
||||||
static const String EMAIL = 'email';
|
|
||||||
static const String NAME = 'name';
|
|
||||||
|
|
||||||
static const String CREATE = '''CREATE TABLE IF NOT EXISTS $TABLE_NAME (
|
|
||||||
$EMAIL TEXT PRIMARY KEY,
|
|
||||||
$NAME TEXT
|
|
||||||
)''';
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:core/data/local/config/database_config.dart';
|
|
||||||
import 'package:core/data/local/config/email_address_table.dart';
|
|
||||||
import 'package:path/path.dart';
|
|
||||||
import 'package:sqflite/sqflite.dart';
|
|
||||||
|
|
||||||
class DatabaseClient {
|
|
||||||
|
|
||||||
Database? _database;
|
|
||||||
Batch? _batch;
|
|
||||||
|
|
||||||
Future<Database> get database async {
|
|
||||||
return _database ?? await _initDatabase();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Batch> get batch async {
|
|
||||||
return _batch ?? (await database).batch();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Database> _initDatabase() async {
|
|
||||||
final databasePath = await getDatabasesPath();
|
|
||||||
final path = join(databasePath, DatabaseConfig.databaseName);
|
|
||||||
return await openDatabase(
|
|
||||||
path,
|
|
||||||
version: DatabaseConfig.databaseVersion,
|
|
||||||
onOpen: (db) {},
|
|
||||||
onCreate: (db, version) async {
|
|
||||||
final batch = db.batch();
|
|
||||||
batch.execute(EmailAddressTable.CREATE);
|
|
||||||
await batch.commit();
|
|
||||||
},
|
|
||||||
onUpgrade: (db, oldVersion, newVersion) async {});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future closeDatabase() async {
|
|
||||||
final db = await database;
|
|
||||||
_database = null;
|
|
||||||
await db.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<int> insertData(String tableName, Map<String, dynamic> mapObject) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.insert(tableName, mapObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<int> deleteData(String tableName, String key, String value) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.delete(
|
|
||||||
tableName,
|
|
||||||
where: '$key = ?',
|
|
||||||
whereArgs: [value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<int> updateData(String tableName, String key, String value, Map<String, dynamic> mapObject) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.update(
|
|
||||||
tableName,
|
|
||||||
mapObject,
|
|
||||||
where: '$key = ?',
|
|
||||||
whereArgs: [value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getData(String tableName, String key, String value) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.query(
|
|
||||||
tableName,
|
|
||||||
where: '$key = ?',
|
|
||||||
whereArgs: [value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getListData(String tableName, {int? limit, String? orderBy}) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.query(tableName, limit: limit, orderBy: orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future deleteLocalFile(String localPath) async {
|
|
||||||
final fileSaved = File(localPath);
|
|
||||||
final fileExist = await fileSaved.exists();
|
|
||||||
if (fileExist) {
|
|
||||||
await fileSaved.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getListDataWithCondition(String tableName, String condition, List<dynamic> values, {int? limit, String? orderBy}) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.query(
|
|
||||||
tableName,
|
|
||||||
where: condition,
|
|
||||||
whereArgs: values,
|
|
||||||
limit: limit,
|
|
||||||
orderBy: orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getDataBySql(String sql) async {
|
|
||||||
final db = await database;
|
|
||||||
return await db.rawQuery(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Object?>> insertMultipleData(String tableName, List<Map<String, dynamic>?> mapObjects) async {
|
|
||||||
final batchInsert = await batch;
|
|
||||||
mapObjects.forEach((element) {
|
|
||||||
if (element != null) {
|
|
||||||
batchInsert.insert(tableName, element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return await batchInsert.commit(noResult: false, continueOnError: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
abstract class DatabaseManager<T> {
|
|
||||||
Future<bool> insertData(T newObject);
|
|
||||||
|
|
||||||
Future<bool> insertMultipleData(List<T> listObject);
|
|
||||||
|
|
||||||
Future<bool> deleteData(String key);
|
|
||||||
|
|
||||||
Future<bool> updateData(T newObject);
|
|
||||||
|
|
||||||
Future<T?> getData(String key);
|
|
||||||
|
|
||||||
Future<List<T>> getListData({String? word, int? limit, String? orderBy});
|
|
||||||
|
|
||||||
Future<List<T>> getListDataWithCondition(String condition, {String? word, int? limit, String? orderBy});
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
import 'package:core/core.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
|
||||||
@@ -27,14 +26,9 @@ class LocalBindings extends Bindings {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dependencies() {
|
void dependencies() {
|
||||||
_bindingDatabase();
|
|
||||||
_bindingCaching();
|
_bindingCaching();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _bindingDatabase() {
|
|
||||||
Get.put(DatabaseClient());
|
|
||||||
}
|
|
||||||
|
|
||||||
void _bindingCaching() {
|
void _bindingCaching() {
|
||||||
Get.put(MailboxCacheClient());
|
Get.put(MailboxCacheClient());
|
||||||
Get.put(StateCacheClient());
|
Get.put(StateCacheClient());
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
import 'package:core/data/local/config/email_address_table.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
|
||||||
|
|
||||||
part 'email_address_cache.g.dart';
|
|
||||||
|
|
||||||
@JsonSerializable()
|
|
||||||
class EmailAddressCache with EquatableMixin {
|
|
||||||
|
|
||||||
@JsonKey(name: EmailAddressTable.NAME)
|
|
||||||
final String name;
|
|
||||||
@JsonKey(name: EmailAddressTable.EMAIL)
|
|
||||||
final String email;
|
|
||||||
|
|
||||||
EmailAddressCache(this.name, this.email);
|
|
||||||
|
|
||||||
factory EmailAddressCache.fromJson(Map<String, dynamic> json) => _$EmailAddressCacheFromJson(json);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => _$EmailAddressCacheToJson(this);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [name, email];
|
|
||||||
}
|
|
||||||
|
|
||||||
extension EmailAddressCacheExtension on EmailAddressCache {
|
|
||||||
EmailAddress toEmailAddress() => EmailAddress(name, email);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
import 'package:model/email/email_address_cache.dart';
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
@@ -32,8 +31,6 @@ extension EmailAddressExtension on EmailAddress {
|
|||||||
|
|
||||||
String get displayName => name ?? '';
|
String get displayName => name ?? '';
|
||||||
|
|
||||||
EmailAddressCache toEmailAddressCache() => EmailAddressCache(displayName, emailAddress);
|
|
||||||
|
|
||||||
List<Color> get avatarColors {
|
List<Color> get avatarColors {
|
||||||
return AppColor.mapGradientColor[_generateIndex()];
|
return AppColor.mapGradientColor[_generateIndex()];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export 'contact/device_contact.dart';
|
|||||||
export 'download/download_task_id.dart';
|
export 'download/download_task_id.dart';
|
||||||
export 'email/attachment.dart';
|
export 'email/attachment.dart';
|
||||||
export 'email/email_action_type.dart';
|
export 'email/email_action_type.dart';
|
||||||
export 'email/email_address_cache.dart';
|
|
||||||
export 'email/email_content.dart';
|
export 'email/email_content.dart';
|
||||||
export 'email/email_content_type.dart';
|
export 'email/email_content_type.dart';
|
||||||
export 'email/email_property.dart';
|
export 'email/email_property.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user