24 changed files with 243 additions and 103 deletions
-
15lib/core/constants/my_api.dart
-
19lib/core/error_handler/error_handler.dart
-
1lib/core/network/http_request_impl.dart
-
4lib/core/network/interceptors/logging_interceptor.dart
-
5lib/core/params/battle_league_params.dart
-
5lib/core/params/topic_params.dart
-
3lib/core/status/base_status.dart
-
4lib/core/widgets/loading/my_loading.dart
-
23lib/features/battle_league/first_part/data/datasource/battle_league_datasource.dart
-
41lib/features/battle_league/first_part/data/model/topics_model.dart
-
13lib/features/battle_league/first_part/data/repository_impl/battle_league_repository_impl.dart
-
50lib/features/battle_league/first_part/domain/entity/topics_entity.dart
-
9lib/features/battle_league/first_part/domain/repository/battle_league_repository.dart
-
14lib/features/battle_league/first_part/domain/usecases/get_topics_usecase.dart
-
39lib/features/battle_league/first_part/presentation/controller/battle_league_controller.dart
-
63lib/features/battle_league/first_part/presentation/ui/battle_league_topic_page.dart
-
11lib/features/battle_league/first_part/presentation/ui/widgets/topic_page/topic_widget.dart
-
3lib/features/home/presentation/controller/home_controller.dart
-
4lib/init_bindings.dart
-
1lib/l10n/app_en.arb
-
6lib/l10n/app_localizations.dart
-
4lib/l10n/app_localizations_en.dart
-
8pubspec.lock
-
1pubspec.yaml
@ -0,0 +1,5 @@ |
|||
class BattleLeagueParams { |
|||
int? id; |
|||
|
|||
BattleLeagueParams({this.id}); |
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
class TopicParams { |
|||
int? id; |
|||
|
|||
TopicParams({this.id}); |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
import 'package:shia_game_flutter/features/battle_league/first_part/domain/entity/topics_entity.dart'; |
|||
|
|||
class TopicsModel extends TopicsEntity { |
|||
const TopicsModel({ |
|||
super.id, |
|||
super.slug, |
|||
super.title, |
|||
super.description, |
|||
super.icon, |
|||
super.iconUrl, |
|||
super.order, |
|||
super.isActive, |
|||
super.difficultyLevel, |
|||
super.difficultyDisplay, |
|||
super.questionsCount, |
|||
super.createdAt, |
|||
super.updatedAt, |
|||
}); |
|||
|
|||
factory TopicsModel.fromJson(Map<String, dynamic> json) { |
|||
return TopicsModel( |
|||
id: json['id'], |
|||
slug: json['slug'], |
|||
title: json['title'], |
|||
description: json['description'], |
|||
icon: json['icon'], |
|||
iconUrl: json['icon_url'], |
|||
order: json['order'], |
|||
isActive: json['is_active'], |
|||
difficultyLevel: json['difficulty_level'], |
|||
difficultyDisplay: json['difficulty_display'], |
|||
questionsCount: json['questions_count'], |
|||
createdAt: json['created_at'] == null |
|||
? null |
|||
: DateTime.parse(json['created_at']), |
|||
updatedAt: json['updated_at'] == null |
|||
? null |
|||
: DateTime.parse(json['updated_at']), |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
import 'package:equatable/equatable.dart'; |
|||
|
|||
class TopicsEntity extends Equatable { |
|||
final int? id; |
|||
final String? slug; |
|||
final String? title; |
|||
final String? description; |
|||
final String? icon; |
|||
final String? iconUrl; |
|||
final int? order; |
|||
final bool? isActive; |
|||
final String? difficultyLevel; |
|||
final String? difficultyDisplay; |
|||
final int? questionsCount; |
|||
final DateTime? createdAt; |
|||
final DateTime? updatedAt; |
|||
|
|||
const TopicsEntity({ |
|||
this.id, |
|||
this.slug, |
|||
this.title, |
|||
this.description, |
|||
this.icon, |
|||
this.iconUrl, |
|||
this.order, |
|||
this.isActive, |
|||
this.difficultyLevel, |
|||
this.difficultyDisplay, |
|||
this.questionsCount, |
|||
this.createdAt, |
|||
this.updatedAt, |
|||
}); |
|||
|
|||
@override |
|||
List<Object?> get props => [ |
|||
id, |
|||
slug, |
|||
title, |
|||
description, |
|||
icon, |
|||
iconUrl, |
|||
order, |
|||
isActive, |
|||
difficultyLevel, |
|||
difficultyDisplay, |
|||
questionsCount, |
|||
createdAt, |
|||
updatedAt, |
|||
]; |
|||
} |
|||
@ -1,9 +1,10 @@ |
|||
import 'package:shia_game_flutter/core/error_handler/my_exception.dart'; |
|||
import 'package:shia_game_flutter/core/params/sample_params.dart'; |
|||
import 'package:shia_game_flutter/core/params/battle_league_params.dart'; |
|||
import 'package:shia_game_flutter/core/utils/data_state.dart'; |
|||
import 'package:shia_game_flutter/features/battle_league/first_part/domain/entity/battle_league_entity.dart'; |
|||
import 'package:shia_game_flutter/features/battle_league/first_part/domain/entity/topics_entity.dart'; |
|||
|
|||
abstract class IBattleLeagueRepository { |
|||
Future<DataState<BattleLeagueEntity, MyException>> getData({required SampleParams params}); |
|||
Future<DataState<List<TopicsEntity>, MyException>> getTopics({ |
|||
required BattleLeagueParams params, |
|||
}); |
|||
} |
|||
|
|||
@ -1,18 +1,18 @@ |
|||
import 'package:shia_game_flutter/core/error_handler/my_exception.dart'; |
|||
import 'package:shia_game_flutter/core/params/sample_params.dart'; |
|||
import 'package:shia_game_flutter/core/params/battle_league_params.dart'; |
|||
import 'package:shia_game_flutter/core/usecase/usecase.dart'; |
|||
import 'package:shia_game_flutter/core/utils/data_state.dart'; |
|||
import 'package:shia_game_flutter/features/battle_league/first_part/domain/entity/battle_league_entity.dart'; |
|||
import 'package:shia_game_flutter/features/battle_league/first_part/domain/entity/topics_entity.dart'; |
|||
import 'package:shia_game_flutter/features/battle_league/first_part/domain/repository/battle_league_repository.dart'; |
|||
|
|||
class GetBattleLeagueUseCase implements UseCase<BattleLeagueEntity, SampleParams> { |
|||
class GetTopicsUseCase |
|||
implements UseCase<List<TopicsEntity>, BattleLeagueParams> { |
|||
final IBattleLeagueRepository repository; |
|||
|
|||
const GetBattleLeagueUseCase(this.repository); |
|||
const GetTopicsUseCase(this.repository); |
|||
|
|||
@override |
|||
Future<DataState<BattleLeagueEntity, MyException>> call(SampleParams params) { |
|||
return repository.getData(params: params); |
|||
Future<DataState<List<TopicsEntity>, MyException>> call(BattleLeagueParams params,) { |
|||
return repository.getTopics(params: params); |
|||
} |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue