elCaribe app - customization and branding
This commit is contained in:
43
news-app/lib/cubits/Author/authorCubit.dart
Normal file
43
news-app/lib/cubits/Author/authorCubit.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
abstract class AuthorState {}
|
||||
|
||||
class AuthorInitial extends AuthorState {}
|
||||
|
||||
class AuthorInProgress extends AuthorState {}
|
||||
|
||||
class AuthorApproved extends AuthorState {
|
||||
AuthorApproved();
|
||||
}
|
||||
|
||||
class AuthorRequestSent extends AuthorState {
|
||||
final String responseMessage;
|
||||
AuthorRequestSent(this.responseMessage);
|
||||
}
|
||||
|
||||
class AuthorPending extends AuthorState {
|
||||
final String errorMessage;
|
||||
|
||||
AuthorPending(this.errorMessage);
|
||||
}
|
||||
|
||||
class AuthorRejected extends AuthorState {
|
||||
final String errorMessage;
|
||||
|
||||
AuthorRejected(this.errorMessage);
|
||||
}
|
||||
|
||||
class AuthorCubit extends Cubit<AuthorState> {
|
||||
AuthorCubit() : super(AuthorInitial());
|
||||
|
||||
void requestToBecomeAuthor() async {
|
||||
try {
|
||||
final result = await Api.sendApiRequest(body: {}, url: Api.becomeAnAuthorApi);
|
||||
(!result[ERROR]) ? emit(AuthorRequestSent(result[MESSAGE])) : emit(AuthorPending(result[MESSAGE]));
|
||||
} catch (e) {
|
||||
emit(AuthorPending(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user