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,41 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:news/data/models/adSpaceModel.dart';
import 'package:news/utils/api.dart';
import 'package:news/utils/strings.dart';
abstract class AdSpacesNewsDetailsState {}
class AdSpacesNewsDetailsInitial extends AdSpacesNewsDetailsState {}
class AdSpacesNewsDetailsFetchInProgress extends AdSpacesNewsDetailsState {}
class AdSpacesNewsDetailsFetchSuccess extends AdSpacesNewsDetailsState {
final AdSpaceModel? adSpaceTopData;
final AdSpaceModel? adSpaceBottomData;
AdSpacesNewsDetailsFetchSuccess({this.adSpaceTopData, this.adSpaceBottomData});
}
class AdSpacesNewsDetailsFetchFailure extends AdSpacesNewsDetailsState {
final String errorMessage;
AdSpacesNewsDetailsFetchFailure(this.errorMessage);
}
class AdSpacesNewsDetailsCubit extends Cubit<AdSpacesNewsDetailsState> {
AdSpacesNewsDetailsCubit() : super(AdSpacesNewsDetailsInitial());
void getAdspaceForNewsDetails({required String langId}) async {
emit(AdSpacesNewsDetailsFetchInProgress());
try {
final body = {LANGUAGE_ID: langId};
final Map<String, dynamic> result = await Api.sendApiRequest(body: body, url: Api.getAdsNewsDetailsApi);
final Map<String, dynamic> resultData = result[DATA];
emit(AdSpacesNewsDetailsFetchSuccess(
adSpaceTopData: (resultData.containsKey('ad_spaces_top')) ? (AdSpaceModel.fromJson(resultData['ad_spaces_top'])) : null,
adSpaceBottomData: (resultData.containsKey('ad_spaces_bottom')) ? AdSpaceModel.fromJson(resultData['ad_spaces_bottom']) : null));
} catch (e) {
emit(AdSpacesNewsDetailsFetchFailure(e.toString()));
}
}
}