27 changed files with 195 additions and 195 deletions
-
2lib/common_ui/resources/my_assets.dart
-
13lib/core/params/home_params.dart
-
13lib/core/params/level_params.dart
-
16lib/core/routers/my_routes.dart
-
28lib/features/home/data/datasource/home_datasource.dart
-
13lib/features/home/data/model/home_model.dart
-
29lib/features/home/data/repository_impl/home_repository_impl.dart
-
8lib/features/home/domain/repository/home_repository.dart
-
17lib/features/home/domain/usecases/get_home_usecase.dart
-
5lib/features/home/presentation/bloc/home_event.dart
-
15lib/features/home/presentation/bloc/home_state.dart
-
28lib/features/level/data/datasource/level_datasource.dart
-
13lib/features/level/data/model/level_model.dart
-
29lib/features/level/data/repository_impl/level_repository_impl.dart
-
4lib/features/level/domain/entity/level_entity.dart
-
0lib/features/level/domain/entity/level_location.dart
-
8lib/features/level/domain/repository/level_repository.dart
-
17lib/features/level/domain/usecases/get_level_usecase.dart
-
30lib/features/level/presentation/bloc/level_bloc.dart
-
5lib/features/level/presentation/bloc/level_event.dart
-
15lib/features/level/presentation/bloc/level_state.dart
-
44lib/features/level/presentation/ui/level_page.dart
-
0lib/features/level/presentation/ui/widgets/bottom_path.dart
-
4lib/features/level/presentation/ui/widgets/hint_level_widget.dart
-
18lib/features/level/presentation/ui/widgets/level_widget.dart
-
0lib/features/level/presentation/ui/widgets/top_path.dart
-
16lib/init_bindings.dart
@ -1,13 +0,0 @@ |
|||||
class HomeParams { |
|
||||
int? id; |
|
||||
|
|
||||
HomeParams({this.id}); |
|
||||
|
|
||||
HomeParams copyWith({ |
|
||||
int? id, |
|
||||
}) { |
|
||||
return HomeParams( |
|
||||
id: id ?? this.id, |
|
||||
); |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,13 @@ |
|||||
|
class LevelParams { |
||||
|
int? id; |
||||
|
|
||||
|
LevelParams({this.id}); |
||||
|
|
||||
|
LevelParams copyWith({ |
||||
|
int? id, |
||||
|
}) { |
||||
|
return LevelParams( |
||||
|
id: id ?? this.id, |
||||
|
); |
||||
|
} |
||||
|
} |
@ -1,28 +0,0 @@ |
|||||
import 'package:hadi_hoda_flutter/core/constants/my_api.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/network/http_request.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/params/home_params.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/response/base_response.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/data/model/home_model.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/domain/entity/home_entity.dart'; |
|
||||
|
|
||||
abstract class IHomeDatasource { |
|
||||
Future<HomeEntity> getData({required HomeParams params}); |
|
||||
} |
|
||||
|
|
||||
class HomeDatasourceImpl implements IHomeDatasource { |
|
||||
final IHttpRequest httpRequest; |
|
||||
|
|
||||
const HomeDatasourceImpl(this.httpRequest); |
|
||||
|
|
||||
@override |
|
||||
Future<HomeEntity> getData({required HomeParams params}) async { |
|
||||
final response = await httpRequest.get( |
|
||||
path: MyApi.baseUrl, |
|
||||
); |
|
||||
|
|
||||
return BaseResponse.getData<HomeEntity>( |
|
||||
response?['data'], |
|
||||
(json) => HomeModel.fromJson(json), |
|
||||
); |
|
||||
} |
|
||||
} |
|
@ -1,13 +0,0 @@ |
|||||
import 'package:hadi_hoda_flutter/features/home/domain/entity/home_entity.dart'; |
|
||||
|
|
||||
class HomeModel extends HomeEntity { |
|
||||
const HomeModel({ |
|
||||
super.id, |
|
||||
}); |
|
||||
|
|
||||
factory HomeModel.fromJson(Map<String, dynamic> json) { |
|
||||
return HomeModel( |
|
||||
id: json['id'], |
|
||||
); |
|
||||
} |
|
||||
} |
|
@ -1,29 +0,0 @@ |
|||||
import 'package:hadi_hoda_flutter/core/params/home_params.dart'; |
|
||||
import 'package:flutter/foundation.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/error_handler/my_exception.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/utils/data_state.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/data/datasource/home_datasource.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/domain/entity/home_entity.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/domain/repository/home_repository.dart'; |
|
||||
|
|
||||
class HomeRepositoryImpl implements IHomeRepository { |
|
||||
final IHomeDatasource datasource; |
|
||||
|
|
||||
const HomeRepositoryImpl(this.datasource); |
|
||||
|
|
||||
@override |
|
||||
Future<DataState<HomeEntity, MyException>> getData({required HomeParams params}) async { |
|
||||
try { |
|
||||
final HomeEntity response = await datasource.getData(params: params); |
|
||||
return DataState.success(response); |
|
||||
} on MyException catch (e) { |
|
||||
return DataState.error(e); |
|
||||
} catch (e) { |
|
||||
if (kDebugMode) { |
|
||||
rethrow; |
|
||||
} else { |
|
||||
return DataState.error(MyException(errorMessage: '$e')); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,8 +0,0 @@ |
|||||
import 'package:hadi_hoda_flutter/core/error_handler/my_exception.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/params/home_params.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/utils/data_state.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/domain/entity/home_entity.dart'; |
|
||||
|
|
||||
abstract class IHomeRepository { |
|
||||
Future<DataState<HomeEntity, MyException>> getData({required HomeParams params}); |
|
||||
} |
|
@ -1,17 +0,0 @@ |
|||||
import 'package:hadi_hoda_flutter/core/error_handler/my_exception.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/params/home_params.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/usecase/usecase.dart'; |
|
||||
import 'package:hadi_hoda_flutter/core/utils/data_state.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/domain/entity/home_entity.dart'; |
|
||||
import 'package:hadi_hoda_flutter/features/home/domain/repository/home_repository.dart'; |
|
||||
|
|
||||
class GetHomeUseCase implements UseCase<HomeEntity, HomeParams> { |
|
||||
final IHomeRepository repository; |
|
||||
|
|
||||
const GetHomeUseCase(this.repository); |
|
||||
|
|
||||
@override |
|
||||
Future<DataState<HomeEntity, MyException>> call(HomeParams params) { |
|
||||
return repository.getData(params: params); |
|
||||
} |
|
||||
} |
|
@ -1,5 +0,0 @@ |
|||||
sealed class HomeEvent { |
|
||||
const HomeEvent(); |
|
||||
} |
|
||||
|
|
||||
class GetHomeEvent extends HomeEvent {} |
|
@ -1,15 +0,0 @@ |
|||||
import 'package:hadi_hoda_flutter/core/status/base_status.dart'; |
|
||||
|
|
||||
class HomeState { |
|
||||
final BaseStatus getHomeStatus; |
|
||||
|
|
||||
const HomeState({this.getHomeStatus = const BaseInit()}); |
|
||||
|
|
||||
HomeState copyWith({ |
|
||||
BaseStatus? getHomeStatus, |
|
||||
}) { |
|
||||
return HomeState( |
|
||||
getHomeStatus: getHomeStatus ?? this.getHomeStatus, |
|
||||
); |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,28 @@ |
|||||
|
import 'package:hadi_hoda_flutter/core/constants/my_api.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/network/http_request.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/params/level_params.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/response/base_response.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/data/model/level_model.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart'; |
||||
|
|
||||
|
abstract class ILevelDatasource { |
||||
|
Future<LevelEntity> getData({required LevelParams params}); |
||||
|
} |
||||
|
|
||||
|
class LevelDatasourceImpl implements ILevelDatasource { |
||||
|
final IHttpRequest httpRequest; |
||||
|
|
||||
|
const LevelDatasourceImpl(this.httpRequest); |
||||
|
|
||||
|
@override |
||||
|
Future<LevelEntity> getData({required LevelParams params}) async { |
||||
|
final response = await httpRequest.get( |
||||
|
path: MyApi.baseUrl, |
||||
|
); |
||||
|
|
||||
|
return BaseResponse.getData<LevelEntity>( |
||||
|
response?['data'], |
||||
|
(json) => LevelModel.fromJson(json), |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart'; |
||||
|
|
||||
|
class LevelModel extends LevelEntity { |
||||
|
const LevelModel({ |
||||
|
super.id, |
||||
|
}); |
||||
|
|
||||
|
factory LevelModel.fromJson(Map<String, dynamic> json) { |
||||
|
return LevelModel( |
||||
|
id: json['id'], |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
import 'package:hadi_hoda_flutter/core/params/level_params.dart'; |
||||
|
import 'package:flutter/foundation.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/error_handler/my_exception.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/utils/data_state.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/data/datasource/level_datasource.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/domain/repository/level_repository.dart'; |
||||
|
|
||||
|
class LevelRepositoryImpl implements ILevelRepository { |
||||
|
final ILevelDatasource datasource; |
||||
|
|
||||
|
const LevelRepositoryImpl(this.datasource); |
||||
|
|
||||
|
@override |
||||
|
Future<DataState<LevelEntity, MyException>> getData({required LevelParams params}) async { |
||||
|
try { |
||||
|
final LevelEntity response = await datasource.getData(params: params); |
||||
|
return DataState.success(response); |
||||
|
} on MyException catch (e) { |
||||
|
return DataState.error(e); |
||||
|
} catch (e) { |
||||
|
if (kDebugMode) { |
||||
|
rethrow; |
||||
|
} else { |
||||
|
return DataState.error(MyException(errorMessage: '$e')); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,9 +1,9 @@ |
|||||
import 'package:equatable/equatable.dart'; |
import 'package:equatable/equatable.dart'; |
||||
|
|
||||
class HomeEntity extends Equatable { |
|
||||
|
class LevelEntity extends Equatable { |
||||
final int? id; |
final int? id; |
||||
|
|
||||
const HomeEntity({ |
|
||||
|
const LevelEntity({ |
||||
this.id, |
this.id, |
||||
}); |
}); |
||||
|
|
@ -0,0 +1,8 @@ |
|||||
|
import 'package:hadi_hoda_flutter/core/error_handler/my_exception.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/params/level_params.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/utils/data_state.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart'; |
||||
|
|
||||
|
abstract class ILevelRepository { |
||||
|
Future<DataState<LevelEntity, MyException>> getData({required LevelParams params}); |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
import 'package:hadi_hoda_flutter/core/error_handler/my_exception.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/params/level_params.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/usecase/usecase.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/utils/data_state.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/level/domain/repository/level_repository.dart'; |
||||
|
|
||||
|
class GetLevelUseCase implements UseCase<LevelEntity, LevelParams> { |
||||
|
final ILevelRepository repository; |
||||
|
|
||||
|
const GetLevelUseCase(this.repository); |
||||
|
|
||||
|
@override |
||||
|
Future<DataState<LevelEntity, MyException>> call(LevelParams params) { |
||||
|
return repository.getData(params: params); |
||||
|
} |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
sealed class LevelEvent { |
||||
|
const LevelEvent(); |
||||
|
} |
||||
|
|
||||
|
class GetLevelEvent extends LevelEvent {} |
@ -0,0 +1,15 @@ |
|||||
|
import 'package:hadi_hoda_flutter/core/status/base_status.dart'; |
||||
|
|
||||
|
class LevelState { |
||||
|
final BaseStatus getLevelStatus; |
||||
|
|
||||
|
const LevelState({this.getLevelStatus = const BaseInit()}); |
||||
|
|
||||
|
LevelState copyWith({ |
||||
|
BaseStatus? getLevelStatus, |
||||
|
}) { |
||||
|
return LevelState( |
||||
|
getLevelStatus: getLevelStatus ?? this.getLevelStatus, |
||||
|
); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue