-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from CollActionteam/fix/1.2.0-fixes
Fix/1.2.0 fixes
- Loading branch information
Showing
46 changed files
with
1,274 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
lib/application/crowdaction/crowdaction_participants/crowdaction_participants_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
lib/application/participation/top_participants/top_participants_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:collaction_app/domain/participation/i_participation_repository.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
import '../../../domain/participation/participation.dart'; | ||
|
||
part 'top_participants_event.dart'; | ||
part 'top_participants_state.dart'; | ||
part 'top_participants_bloc.freezed.dart'; | ||
|
||
@injectable | ||
class TopParticipantsBloc | ||
extends Bloc<TopParticipantsEvent, TopParticipantsState> { | ||
final IParticipationRepository _participationRepository; | ||
|
||
TopParticipantsBloc(this._participationRepository) : super(const _Initial()) { | ||
on<TopParticipantsEvent>((event, emit) async { | ||
await event.map( | ||
fetchParticipants: (event) async { | ||
emit(const TopParticipantsState.fetching()); | ||
|
||
final participantsOrFailure = await _participationRepository | ||
.getTopParticipants(crowdActionId: event.crowdActionId); | ||
|
||
participantsOrFailure.fold( | ||
(failure) => emit(const TopParticipantsState.failure()), | ||
(participants) => emit(TopParticipantsState.fetched(participants)), | ||
); | ||
}, | ||
); | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
lib/application/participation/top_participants/top_participants_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
part of 'top_participants_bloc.dart'; | ||
|
||
@freezed | ||
class TopParticipantsEvent with _$TopParticipantsEvent { | ||
const factory TopParticipantsEvent.fetchParticipants({ | ||
required String crowdActionId, | ||
}) = _FetchParticipants; | ||
} |
11 changes: 11 additions & 0 deletions
11
lib/application/participation/top_participants/top_participants_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
part of 'top_participants_bloc.dart'; | ||
|
||
@freezed | ||
class TopParticipantsState with _$TopParticipantsState { | ||
const factory TopParticipantsState.initial() = _Initial; | ||
const factory TopParticipantsState.fetching() = _Fetching; | ||
const factory TopParticipantsState.fetched( | ||
List<Participation> topParticipants, | ||
) = _Fetched; | ||
const factory TopParticipantsState.failure() = _Failure; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'page_info.freezed.dart'; | ||
|
||
@freezed | ||
class PageInfo with _$PageInfo { | ||
const PageInfo._(); | ||
|
||
const factory PageInfo({ | ||
required int page, | ||
required int pageSize, | ||
required int totalPages, | ||
required int totalItems, | ||
}) = _PageInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
import '../core/page_info.dart'; | ||
import 'crowdaction.dart'; | ||
|
||
part 'paginated_crowdactions.freezed.dart'; | ||
|
||
@freezed | ||
class PaginatedCrowdActions with _$PaginatedCrowdActions { | ||
const PaginatedCrowdActions._(); | ||
|
||
const factory PaginatedCrowdActions({ | ||
required List<CrowdAction> crowdActions, | ||
required PageInfo pageInfo, | ||
}) = _PaginatedCrowdActions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
import '../../domain/core/page_info.dart'; | ||
|
||
part 'page_info_dto.g.dart'; | ||
part 'page_info_dto.freezed.dart'; | ||
|
||
@freezed | ||
class PageInfoDto with _$PageInfoDto { | ||
const PageInfoDto._(); | ||
|
||
const factory PageInfoDto({ | ||
required int page, | ||
required int pageSize, | ||
required int totalPages, | ||
required int totalItems, | ||
}) = _PageInfoDto; | ||
|
||
factory PageInfoDto.fromJson(Map<String, dynamic> json) => | ||
_$PageInfoDtoFromJson(json); | ||
|
||
PageInfo toDomain() => PageInfo( | ||
page: page, | ||
pageSize: pageSize, | ||
totalPages: totalPages, | ||
totalItems: totalItems, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.