elCaribe app - customization and branding

This commit is contained in:
2025-12-12 19:09:42 -04:00
parent 9e5d0d8ebf
commit ba7deac9f3
402 changed files with 31833 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import 'package:news/utils/api.dart';
import 'package:news/utils/strings.dart';
class SubCategoryRemoteDataSource {
Future<dynamic> getSubCategory({required String catId, required String langId}) async {
try {
final body = {CATEGORY_ID: catId, LANGUAGE_ID: langId};
final result = await Api.sendApiRequest(body: body, url: Api.getSubCategoryApi);
return result;
} catch (e) {
throw ApiMessageAndCodeException(errorMessage: e.toString());
}
}
}

View File

@@ -0,0 +1,29 @@
import 'package:flutter/cupertino.dart';
import 'package:news/data/repositories/SubCategory/subCatRemoteDataSource.dart';
import 'package:news/utils/strings.dart';
import 'package:news/utils/uiUtils.dart';
import 'package:news/data/models/CategoryModel.dart';
class SubCategoryRepository {
static final SubCategoryRepository _subCategoryRepository = SubCategoryRepository._internal();
late SubCategoryRemoteDataSource _subCategoryRemoteDataSource;
factory SubCategoryRepository() {
_subCategoryRepository._subCategoryRemoteDataSource = SubCategoryRemoteDataSource();
return _subCategoryRepository;
}
SubCategoryRepository._internal();
Future<Map<String, dynamic>> getSubCategory({required BuildContext context, required String catId, required String langId}) async {
final result = await _subCategoryRemoteDataSource.getSubCategory(langId: langId, catId: catId);
List<SubCategoryModel> subCatList = [];
subCatList.insert(0, SubCategoryModel(id: "0", subCatName: UiUtils.getTranslatedLabel(context, 'allLbl')));
subCatList.addAll((result[DATA] as List).map((e) => SubCategoryModel.fromJson(e)).toList());
return {"SubCategory": subCatList};
}
}