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,98 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:news/data/models/AuthModel.dart';
import 'package:news/data/repositories/Auth/authRepository.dart';
const String loginEmail = "email";
const String loginGmail = "gmail";
const String loginFb = "fb";
const String loginMbl = "mobile";
const String loginApple = "apple";
enum AuthProviders { gmail, fb, apple, mobile, email }
@immutable
abstract class AuthState {}
class AuthInitial extends AuthState {}
class Authenticated extends AuthState {
//to store authDetails
final AuthModel authModel;
Authenticated({required this.authModel});
}
class Unauthenticated extends AuthState {}
class AuthCubit extends Cubit<AuthState> {
final AuthRepository _authRepository;
AuthCubit(this._authRepository) : super(AuthInitial()) {
checkAuthStatus();
}
AuthRepository get authRepository => _authRepository;
void checkAuthStatus() {
//authDetails is map. keys are isLogin,userId,authProvider
final authDetails = _authRepository.getLocalAuthDetails();
(authDetails['isLogIn']) ? emit(Authenticated(authModel: AuthModel.fromJson(authDetails))) : emit(Unauthenticated());
}
String getUserId() {
return (state is Authenticated) ? (state as Authenticated).authModel.id! : "0";
}
String getProfile() {
return (state is Authenticated)
? ((state as Authenticated).authModel.profile!.trim().isNotEmpty)
? (state as Authenticated).authModel.profile!
: ""
: "";
}
String getMobile() {
return (state is Authenticated) ? (state as Authenticated).authModel.mobile! : "";
}
String getType() {
return (state is Authenticated) ? (state as Authenticated).authModel.type! : "";
}
String getAuthorBio() {
return (state is Authenticated && (state as Authenticated).authModel.authorDetails != null) ? ((state as Authenticated).authModel.authorDetails?.bio ?? "") : "";
}
String getAuthorWhatsappLink() {
return (state is Authenticated && (state as Authenticated).authModel.authorDetails != null) ? (state as Authenticated).authModel.authorDetails?.whatsappLink ?? "" : "0";
}
String getAuthorTelegramLink() {
return (state is Authenticated && (state as Authenticated).authModel.authorDetails != null) ? (state as Authenticated).authModel.authorDetails?.telegramLink ?? "" : "0";
}
String getAuthorFacebookLink() {
return (state is Authenticated && (state as Authenticated).authModel.authorDetails != null) ? (state as Authenticated).authModel.authorDetails?.facebookLink ?? "" : "0";
}
String getAuthorLinkedInLink() {
return (state is Authenticated && (state as Authenticated).authModel.authorDetails != null) ? (state as Authenticated).authModel.authorDetails?.linkedinLink ?? "" : "0";
}
void updateDetails({required AuthModel authModel}) {
emit(Authenticated(authModel: authModel));
}
Future signOut(AuthProviders authProvider) async {
if (state is Authenticated) {
_authRepository.signOut(authProvider);
emit(Unauthenticated());
}
}
bool isAuthor() {
return (state is Authenticated) ? ((state as Authenticated).authModel.isAuthor == 1) : false;
}
}