Skip to content

Commit f9d2ecd

Browse files
Added : Local Storage
1 parent 9969374 commit f9d2ecd

File tree

14 files changed

+669
-35
lines changed

14 files changed

+669
-35
lines changed

assets/env/develop.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"backend_url": "",
88
"api_url": "",
99
"firebase_id": null,
10-
"timeout_limit": 20000,
10+
"timeout_limit": 20,
1111
"enable_local_logs": false,
1212
"enable_cloud_logs": false,
1313
"enable_api_log_interceptor": false,
@@ -17,5 +17,6 @@
1717
"one_signal_config": null,
1818
"pusher_config": null,
1919
"show_debug_panel": true,
20+
"local_storage_type": "none",
2021
"debug_panel_color": 3422552064
21-
}
22+
}

assets/env/production.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"backend_url": "",
88
"api_url": "",
99
"firebase_id": null,
10-
"timeout_limit": 20000,
10+
"timeout_limit": 20,
1111
"enable_local_logs": false,
1212
"enable_cloud_logs": false,
1313
"enable_api_log_interceptor": false,
@@ -17,5 +17,6 @@
1717
"one_signal_config": null,
1818
"pusher_config": null,
1919
"show_debug_panel": false,
20+
"local_storage_type": "none",
2021
"debug_panel_color": 3422552064
21-
}
22+
}

assets/env/staging.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"backend_url": "",
88
"api_url": "",
99
"firebase_id": null,
10-
"timeout_limit": 20000,
10+
"timeout_limit": 20,
1111
"enable_local_logs": false,
1212
"enable_cloud_logs": false,
1313
"enable_api_log_interceptor": false,
@@ -17,5 +17,6 @@
1717
"one_signal_config": null,
1818
"pusher_config": null,
1919
"show_debug_panel": true,
20+
"local_storage_type": "none",
2021
"debug_panel_color": 3422552064
21-
}
22+
}

lib/vaahextendflutter/base/base_controller.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../env/env.dart';
1111
import '../services/api.dart';
1212
import '../services/notification/internal/notification.dart';
1313
import '../services/notification/push/notification.dart';
14+
import '../services/storage/local/storage.dart';
1415
import 'root_assets_controller.dart';
1516

1617
class BaseController extends GetxController {
@@ -47,6 +48,8 @@ class BaseController extends GetxController {
4748
await InternalNotifications.init();
4849
PushNotifications.askPermission();
4950

51+
await LocalDatabaseStorage.init();
52+
5053
// Sentry Initialization (And/ Or) Running main app
5154
if (null != config.sentryConfig && config.sentryConfig!.dsn.isNotEmpty) {
5255
await SentryFlutter.init(

lib/vaahextendflutter/env/env.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:json_annotation/json_annotation.dart';
99
import '../services/logging_library/logging_library.dart';
1010
import 'logging.dart';
1111
import 'notification.dart';
12+
import 'storage.dart';
1213

1314
part 'env.g.dart';
1415

@@ -58,6 +59,7 @@ class EnvironmentConfig {
5859
this.oneSignalConfig,
5960
this.pusherConfig,
6061
required this.showDebugPanel,
62+
required this.localDatabaseStorageType,
6163
required this.debugPanelColor,
6264
});
6365

@@ -78,6 +80,7 @@ class EnvironmentConfig {
7880
final OneSignalConfig? oneSignalConfig;
7981
final PusherConfig? pusherConfig;
8082
final bool showDebugPanel;
83+
final LocalDatabaseStorageType localDatabaseStorageType;
8184
@JsonKey(fromJson: _colorFromJson, toJson: _colorToJson)
8285
final Color debugPanelColor;
8386

@@ -119,6 +122,7 @@ class EnvironmentConfig {
119122
pushNotificationsServiceType: PushNotificationsServiceType.none,
120123
internalNotificationsServiceType: InternalNotificationsServiceType.none,
121124
showDebugPanel: true,
125+
localDatabaseStorageType: LocalDatabaseStorageType.none,
122126
debugPanelColor: Colors.black.withOpacity(0.8),
123127
);
124128
}

lib/vaahextendflutter/env/env.g.dart

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum LocalDatabaseStorageType { hive, none }
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
abstract class LocalStorageService {
2+
static Future<LocalStorageService> init() async {
3+
throw UnimplementedError();
4+
}
5+
6+
Future<void> addCollection({
7+
required String collectionName,
8+
});
9+
10+
Future<void> create({
11+
required String collectionName,
12+
required String key,
13+
required String value,
14+
});
15+
16+
Future<void> createMany({
17+
required String collectionName,
18+
required Map<String, String> values,
19+
});
20+
21+
Future<String?> read({
22+
required String collectionName,
23+
required String key,
24+
});
25+
26+
Future<Map<String, String>> readMany({
27+
required String collectionName,
28+
required List<String> keys,
29+
});
30+
31+
Future<Map<String, String>> readAll({
32+
required String collectionName,
33+
});
34+
35+
Future<void> update({
36+
required String collectionName,
37+
required String key,
38+
required String value,
39+
});
40+
41+
Future<void> updateMany({
42+
required String collectionName,
43+
required Map<String, String> values,
44+
});
45+
46+
Future<void> createOrUpdate({
47+
required String collectionName,
48+
required String key,
49+
required String value,
50+
});
51+
52+
Future<void> createOrUpdateMany({
53+
required String collectionName,
54+
required Map<String, String> values,
55+
});
56+
57+
Future<void> delete({required String collectionName, required String key});
58+
59+
Future<void> deleteMany({
60+
required String collectionName,
61+
List<String> keys = const [],
62+
});
63+
64+
Future<void> deleteAll({required String collectionName});
65+
}

0 commit comments

Comments
 (0)