elCaribe app - customization and branding
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class DeleteCommRemoteDataSource {
|
||||
Future deleteComm({required String commId}) async {
|
||||
try {
|
||||
final body = {COMMENT_ID: commId};
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.setCommentDeleteApi);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:news/data/repositories/NewsComment/DeleteComment/deleteCommDataSource.dart';
|
||||
|
||||
class DeleteCommRepository {
|
||||
static final DeleteCommRepository _deleteCommRepository = DeleteCommRepository._internal();
|
||||
late DeleteCommRemoteDataSource _deleteCommRemoteDataSource;
|
||||
|
||||
factory DeleteCommRepository() {
|
||||
_deleteCommRepository._deleteCommRemoteDataSource = DeleteCommRemoteDataSource();
|
||||
return _deleteCommRepository;
|
||||
}
|
||||
|
||||
DeleteCommRepository._internal();
|
||||
|
||||
Future setDeleteComm({required String commId}) async {
|
||||
final result = await _deleteCommRemoteDataSource.deleteComm(commId: commId);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class SetFlagRemoteDataSource {
|
||||
Future<dynamic> setFlag({required String commId, required String newsId, required String message}) async {
|
||||
try {
|
||||
final body = {COMMENT_ID: commId, NEWS_ID: newsId, MESSAGE: message};
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.setFlagApi);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:news/data/repositories/NewsComment/FlagComment/flagCommRemoteDataSource.dart';
|
||||
|
||||
class SetFlagRepository {
|
||||
static final SetFlagRepository _setFlagRepository = SetFlagRepository._internal();
|
||||
|
||||
late SetFlagRemoteDataSource _setFlagRemoteDataSource;
|
||||
|
||||
factory SetFlagRepository() {
|
||||
_setFlagRepository._setFlagRemoteDataSource = SetFlagRemoteDataSource();
|
||||
return _setFlagRepository;
|
||||
}
|
||||
|
||||
SetFlagRepository._internal();
|
||||
|
||||
Future<Map<String, dynamic>> setFlag({required String commId, required String newsId, required String message}) async {
|
||||
final result = await _setFlagRemoteDataSource.setFlag(commId: commId, newsId: newsId, message: message);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class LikeAndDislikeCommRemoteDataSource {
|
||||
Future likeAndDislikeComm({required String langId, required String commId, required String status}) async {
|
||||
try {
|
||||
final body = {LANGUAGE_ID: langId, COMMENT_ID: commId, STATUS: status};
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.setLikeDislikeComApi);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:news/data/models/CommentModel.dart';
|
||||
import 'package:news/data/repositories/NewsComment/LikeAndDislikeComment/likeAndDislikeCommDataSource.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class LikeAndDislikeCommRepository {
|
||||
static final LikeAndDislikeCommRepository _likeAndDislikeCommRepository = LikeAndDislikeCommRepository._internal();
|
||||
late LikeAndDislikeCommRemoteDataSource _likeAndDislikeCommRemoteDataSource;
|
||||
|
||||
factory LikeAndDislikeCommRepository() {
|
||||
_likeAndDislikeCommRepository._likeAndDislikeCommRemoteDataSource = LikeAndDislikeCommRemoteDataSource();
|
||||
return _likeAndDislikeCommRepository;
|
||||
}
|
||||
|
||||
LikeAndDislikeCommRepository._internal();
|
||||
|
||||
Future<Map<String, dynamic>> setLikeAndDislikeComm({required String langId, required String commId, required String status}) async {
|
||||
final result = await _likeAndDislikeCommRemoteDataSource.likeAndDislikeComm(langId: langId, commId: commId, status: status);
|
||||
|
||||
if (result[ERROR]) {
|
||||
return {ERROR: result[ERROR], MESSAGE: result[MESSAGE]};
|
||||
} else {
|
||||
final List<CommentModel> commentsList = (result[DATA] as List).map((e) => CommentModel.fromJson(e)).toList();
|
||||
CommentModel? updatedComment;
|
||||
|
||||
commentsList.forEach((element) {
|
||||
if (element.id! == commId) {
|
||||
updatedComment = element;
|
||||
} else if (element.replyComList!.any((sublist) => sublist.id == commId) == true) {
|
||||
updatedComment = element;
|
||||
}
|
||||
});
|
||||
return {ERROR: result[ERROR], "total": result[TOTAL], "updatedComment": updatedComment ?? CommentModel.fromJson({})};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class SetCommentRemoteDataSource {
|
||||
Future<dynamic> setComment({required String parentId, required String newsId, required String message}) async {
|
||||
try {
|
||||
final body = {PARENT_ID: parentId, NEWS_ID: newsId, MESSAGE: message};
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.setCommentApi);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:news/data/repositories/NewsComment/SetComment/setComRemoteDataSource.dart';
|
||||
import 'package:news/data/models/CommentModel.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class SetCommentRepository {
|
||||
static final SetCommentRepository _setCommentRepository = SetCommentRepository._internal();
|
||||
|
||||
late SetCommentRemoteDataSource _setCommentRemoteDataSource;
|
||||
|
||||
factory SetCommentRepository() {
|
||||
_setCommentRepository._setCommentRemoteDataSource = SetCommentRemoteDataSource();
|
||||
return _setCommentRepository;
|
||||
}
|
||||
SetCommentRepository._internal();
|
||||
Future<Map<String, dynamic>> setComment({required String parentId, required String newsId, required String message}) async {
|
||||
final result = await _setCommentRemoteDataSource.setComment(parentId: parentId, newsId: newsId, message: message);
|
||||
return {"SetComment": (result[DATA] as List).map((e) => CommentModel.fromJson(e)).toList(), "total": result[TOTAL]};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user