Skip to content

Commit

Permalink
final release
Browse files Browse the repository at this point in the history
  • Loading branch information
iampato committed Feb 24, 2021
1 parent 4e4f594 commit b340d41
Show file tree
Hide file tree
Showing 28 changed files with 610 additions and 517 deletions.
Binary file added assets/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/no-conn.flr
Binary file not shown.
Binary file added assets/images/server_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions lib/cubit/cubit/questioncubit_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/widgets.dart';
import 'package:mbunge/models/add_reponse.dart';
import 'package:mbunge/models/reponses.dart';
import 'package:mbunge/repository/share_preferences.dart';
import 'package:mbunge/repository/webinar_repository.dart';

part 'questioncubit_state.dart';

class QuestioncubitCubit extends Cubit<QuestioncubitState> {
final WebinarRepository webinarRepository;
final SharePreferenceRepo sharePreferenceRepo;
QuestioncubitCubit(this.webinarRepository, this.sharePreferenceRepo)
: super(QuestioncubitInitial());

Future<void> fetchQuestions(String id) async {
try {
final responses = await webinarRepository.getResponses(
id,
);
if (responses != null) {
emit(QuestioncubitSuccess(responses: responses, message: ""));
}
} catch (e) {
emit(QuestioncubitError(message: e.toString()));
}
}

Future<void> addQuestion({@required String id, @required String body}) async {
final currentState = state;
try {
AddResponse response = AddResponse(
userId: await sharePreferenceRepo.getUserId(),
participationId: id,
body: body,
);

debugPrint("${response.toJson()}");

final result = await webinarRepository.addResponse(response);
debugPrint("##################################");
debugPrint("${result.toJson()}");
debugPrint("##################################");
if (currentState is QuestioncubitSuccess) {
final _questions = currentState.responses;
if (result != null) {
_questions.insert(0, result);
_questions.sort((a, b) => a.createdAt.compareTo(b.createdAt));
emit(
QuestioncubitSuccess(
responses: _questions,
message: "Added successfully!",
),
);
} else {
emit(
QuestioncubitSuccess(
responses: _questions,
message: "Unable to add your question!",
),
);
}
}
} catch (e) {}
}
}
29 changes: 29 additions & 0 deletions lib/cubit/cubit/questioncubit_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
part of 'questioncubit_cubit.dart';

// abstract class QuestioncubitState extends Equatable {
// const QuestioncubitState();

// @override
// List<Object> get props => [];
// }

abstract class QuestioncubitState {
const QuestioncubitState();
}

class QuestioncubitInitial extends QuestioncubitState {}

class QuestioncubitSuccess extends QuestioncubitState {
final List<Responses> responses;
final String message;

QuestioncubitSuccess({@required this.responses, @required this.message});
// @override
// List<Object> get props => [responses, message];
}

class QuestioncubitError extends QuestioncubitState {
final String message;

QuestioncubitError({@required this.message});
}
1 change: 1 addition & 0 deletions lib/cubit/event/event_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class EventCubit extends Cubit<EventState> {

Future<void> getEvents() async {
try {
print("*********************");
final List<Event> events = await eventRepository.getEvents();
events.insert(0, null);
emit(EventsLoaded(events: events));
Expand Down
15 changes: 9 additions & 6 deletions lib/cubit/event/event_state.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
part of 'event_cubit.dart';

abstract class EventState extends Equatable {
// abstract class EventState extends Equatable {
// const EventState();

// @override
// List<Object> get props => [];
// }

abstract class EventState {
const EventState();

@override
List<Object> get props => [];
}


class EventInitial extends EventState {}

class EventsLoaded extends EventState {
final List<Event> events;

const EventsLoaded({@required this.events}) : assert(events != null);

@override
List<Object> get props => [events];

@override
String toString() => 'EventsLoaded { events: $events }';
}
Expand Down
44 changes: 0 additions & 44 deletions lib/cubit/responses/addresponse_bloc.dart

This file was deleted.

24 changes: 0 additions & 24 deletions lib/cubit/responses/addresponse_event.dart

This file was deleted.

22 changes: 0 additions & 22 deletions lib/cubit/responses/addresponse_state.dart

This file was deleted.

18 changes: 0 additions & 18 deletions lib/cubit/responses/deleteresponses_bloc.dart

This file was deleted.

8 changes: 0 additions & 8 deletions lib/cubit/responses/deleteresponses_event.dart

This file was deleted.

10 changes: 0 additions & 10 deletions lib/cubit/responses/deleteresponses_state.dart

This file was deleted.

28 changes: 0 additions & 28 deletions lib/cubit/responses/getresponses_bloc.dart

This file was deleted.

17 changes: 0 additions & 17 deletions lib/cubit/responses/getresponses_event.dart

This file was deleted.

21 changes: 0 additions & 21 deletions lib/cubit/responses/getresponses_state.dart

This file was deleted.

Loading

0 comments on commit b340d41

Please sign in to comment.