Skip to content

Commit

Permalink
feat: floor database for storing draft data
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 16, 2024
1 parent b8912e1 commit d398452
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 4 deletions.
4 changes: 3 additions & 1 deletion evently/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@
"update_failed": "Upload Fehlgeschlagen",
"uploading": "Hochladen ...",
"something_wrong_while_uploading": "Beim Hochladen ist etwas schief gelaufen. Bitte versuche es erneut.",
"cookbook_not_found": "Cookbook nicht gefunden"
"cookbook_not_found": "Cookbook nicht gefunden",
"loading": "Wird geladen ...",
"something_wrong": "Etwas ist schief gelaufen. Bitte versuchen Sie, die Anwendung neu zu starten."
}
4 changes: 3 additions & 1 deletion evently/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@
"update_failed": "Upload Failed",
"uploading": "Uploading ...",
"something_wrong_while_uploading": "Something went wrong while uploading. Please try again.",
"cookbook_not_found": "Cookbook not found"
"cookbook_not_found": "Cookbook not found",
"loading": "loading ...",
"something_wrong": "Something went wrong. Please try restarting the application."
}
4 changes: 3 additions & 1 deletion evently/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@
"update_failed": "Subida ha fallado",
"uploading": "Subiendo...",
"something_wrong_while_uploading": "Algo salió mal durante la carga. Inténtalo de nuevo.",
"cookbook_not_found": "Cookbook extraviado"
"cookbook_not_found": "Cookbook extraviado",
"loading": "cargando ...",
"something_wrong": "Algo salió mal. Intenta reiniciar la aplicación."
}
4 changes: 3 additions & 1 deletion evently/i18n/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@
"update_failed": "Загрузка не удалась",
"uploading": "Загрузка...",
"something_wrong_while_uploading": "Что-то пошло не так во время загрузки. Пожалуйста, попробуйте еще раз.",
"cookbook_not_found": "Cookbook не найден"
"cookbook_not_found": "Cookbook не найден",
"loading": "cargando ...",
"something_wrong": "Что-то пошло не так. Попробуйте перезапустить приложение."
}
2 changes: 2 additions & 0 deletions evently/lib/generated/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ abstract class LocaleKeys {
static const uploading = 'uploading';
static const something_wrong_while_uploading = 'something_wrong_while_uploading';
static const cookbook_not_found = 'cookbook_not_found';
static const loading = 'loading';
static const something_wrong = 'something_wrong';

}
17 changes: 17 additions & 0 deletions evently/lib/repository/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:developer';
import 'package:dartz/dartz.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:evently/generated/locale_keys.g.dart';
import 'package:evently/models/events.dart';
import 'package:evently/models/picked_file_model.dart';
import 'package:evently/models/storage_response_model.dart';
import 'package:evently/services/datasources/local_datasource.dart';
Expand Down Expand Up @@ -53,6 +54,10 @@ abstract class Repository {
/// Output: if successful the output will be the list of [pylons.Recipe]
/// will return error in the form of failure
Future<Either<Failure, List<Recipe>>> getRecipesBasedOnCookBookId({required String cookBookId});

/// This method will get the drafts List from the local database
/// Output: [List] returns that contains a number of [NFT]
Future<Either<Failure, List<Events>>> getEvents();
}

@LazySingleton(as: Repository)
Expand Down Expand Up @@ -129,4 +134,16 @@ class RepositoryImp implements Repository {
return Left(CookBookNotFoundFailure(LocaleKeys.cookbook_not_found.tr()));
}
}

@override
Future<Either<Failure, List<Events>>> getEvents() async {
try {
final response = await localDataSource.getEvents();

return Right(response);
} on Exception catch (exception) {
crashlyticsHelper.recordFatalError(error: exception.toString());
return Left(CacheFailure(LocaleKeys.something_wrong.tr()));
}
}
}
21 changes: 21 additions & 0 deletions evently/lib/screens/event_hub/event_hub_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:evently/generated/locale_keys.g.dart';
import 'package:evently/models/events.dart';
import 'package:evently/repository/repository.dart';
import 'package:evently/utils/extension_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:injectable/injectable.dart';
import 'package:pylons_sdk/pylons_sdk.dart';
Expand Down Expand Up @@ -89,4 +92,22 @@ class EventHubViewModel extends ChangeNotifier {
_eventPublishedList.add(nft);
}
}

Future<void> getDraftsList() async {
// final loading = Loading()..showLoading(message: LocaleKeys.loading.tr());

final getNftResponse = await repository.getEvents();

if (getNftResponse.isLeft()) {
loading.dismiss();
LocaleKeys.something_wrong.tr().show();
return;
}

nftDraftList = getNftResponse.getOrElse(() => []);

loading.dismiss();

notifyListeners();
}
}
11 changes: 11 additions & 0 deletions evently/lib/services/datasources/local_datasource.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:evently/models/events.dart';
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/date_utils.dart';
import 'package:injectable/injectable.dart';
Expand Down Expand Up @@ -33,6 +34,10 @@ abstract class LocalDataSource {
/// Input: [name] the name of the artist which the user want to save
/// Output: [bool] returns whether the operation is successful or not
Future<bool> saveHostName(String name);

/// This method will get the drafts List from the local database
/// Output: [List][NFT] returns the List of drafts
Future<List<Events>> getEvents();
}

@LazySingleton(as: LocalDataSource)
Expand Down Expand Up @@ -86,4 +91,10 @@ class LocalDataSourceImpl extends LocalDataSource {
await sharedPreferences.setString(kHostName, name);
return true;
}

@override
Future<List<Events>> getEvents() {
// TODO: implement getEvents
throw UnimplementedError();
}
}
1 change: 1 addition & 0 deletions evently/lib/utils/extension_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ extension ScaffoldStateHelper on ScaffoldMessengerState {
));
}
}

80 changes: 80 additions & 0 deletions evently/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
charcode:
dependency: transitive
description:
name: charcode
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
url: "https://pub.dev"
source: hosted
version: "1.3.1"
checked_yaml:
dependency: transitive
description:
Expand Down Expand Up @@ -225,6 +233,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.3"
dev_build:
dependency: transitive
description:
name: dev_build
sha256: "2fa3bf81b5e92504f8d7a412df2c69b61a24ceca468466e5e777cbb59c30af96"
url: "https://pub.dev"
source: hosted
version: "0.16.5"
dio:
dependency: "direct main"
description:
Expand Down Expand Up @@ -305,6 +321,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
floor:
dependency: "direct main"
description:
name: floor
sha256: c1b06023912b5b8e49deb6a9d867863c535ae1a232d991c3582bba3ee8687867
url: "https://pub.dev"
source: hosted
version: "1.5.0"
floor_annotation:
dependency: transitive
description:
name: floor_annotation
sha256: a40949580a7ab0eee572686e2d3b1638fd6bd6a753e661d792ab4236b365b23b
url: "https://pub.dev"
source: hosted
version: "1.5.0"
floor_common:
dependency: transitive
description:
name: floor_common
sha256: "41c9914862f83a821815e1b1ffd47a1e1ae2130c35ff882ba2d000a67713ba64"
url: "https://pub.dev"
source: hosted
version: "1.5.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -733,6 +773,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.5.1"
process_run:
dependency: transitive
description:
name: process_run
sha256: "8d9c6198b98fbbfb511edd42e7364e24d85c163e47398919871b952dc86a423e"
url: "https://pub.dev"
source: hosted
version: "0.14.2"
protobuf:
dependency: transitive
description:
Expand Down Expand Up @@ -921,6 +969,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.5.4"
sqflite_common_ffi:
dependency: transitive
description:
name: sqflite_common_ffi
sha256: "4d6137c29e930d6e4a8ff373989dd9de7bac12e3bc87bce950f6e844e8ad3bb5"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
sqflite_common_ffi_web:
dependency: transitive
description:
name: sqflite_common_ffi_web
sha256: cfc9d1c61a3e06e5b2e96994a44b11125b4f451fee95b9fad8bd473b4613d592
url: "https://pub.dev"
source: hosted
version: "0.4.3+1"
sqlite3:
dependency: transitive
description:
name: sqlite3
sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295
url: "https://pub.dev"
source: hosted
version: "2.4.3"
sqlparser:
dependency: transitive
description:
name: sqlparser
sha256: "7b20045d1ccfb7bc1df7e8f9fee5ae58673fce6ff62cefbb0e0fd7214e90e5a0"
url: "https://pub.dev"
source: hosted
version: "0.34.1"
stack_trace:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions evently/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ dependencies:
cached_network_image: ^3.3.1
shimmer_animation: 2.1.0+1
network_info_plus: ^5.0.3
floor: ^1.5.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit d398452

Please sign in to comment.