diff --git a/lib/features/level/data/datasource/level_datasource.dart b/lib/features/level/data/datasource/level_datasource.dart index 1921cc1..e3c75fe 100644 --- a/lib/features/level/data/datasource/level_datasource.dart +++ b/lib/features/level/data/datasource/level_datasource.dart @@ -1,7 +1,9 @@ import 'package:hadi_hoda_flutter/core/constants/my_constants.dart'; 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/local_storage.dart'; import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart'; +import 'package:hadi_hoda_flutter/features/level/domain/entity/total_data_entity.dart'; import 'package:hive/hive.dart'; abstract class ILevelDatasource { @@ -10,14 +12,19 @@ abstract class ILevelDatasource { /// Local class LocalLevelDatasourceImpl implements ILevelDatasource { - const LocalLevelDatasourceImpl(); @override Future> getLevels({required LevelParams params}) async { try { - final Box levelBox = Hive.box(MyConstants.levelBox); - return levelBox.values.toList(); + final String selectedLanguage = LocalStorage.readData( + key: MyConstants.selectLanguage); + final Box levelBox = Hive.box(MyConstants.levelBox); + final TotalDataEntity findData = levelBox.values.singleWhere((e) => + e.code == selectedLanguage, + orElse: () => TotalDataEntity(), + ); + return findData.levels ?? []; } catch (_) { throw MyException(errorMessage: 'Operation Failed'); } diff --git a/lib/features/level/presentation/bloc/level_bloc.dart b/lib/features/level/presentation/bloc/level_bloc.dart index ed56711..93374b5 100644 --- a/lib/features/level/presentation/bloc/level_bloc.dart +++ b/lib/features/level/presentation/bloc/level_bloc.dart @@ -63,7 +63,6 @@ class LevelBloc extends Bloc { final ScrollController scrollController = ScrollController(); /// ------------Functions------------ - void goToQuestionPage(BuildContext context, LevelEntity level){ context.pushNamed( Routes.questionPage, @@ -73,6 +72,10 @@ class LevelBloc extends Bloc { ); } + void goToHomePage(BuildContext context){ + context.pop(); + } + /// ------------Api Calls------------ FutureOr _getLevelListEvent(GetLevelListEvent event, Emitter emit) async { @@ -87,12 +90,13 @@ class LevelBloc extends Bloc { getLevelStatus: const BaseComplete(''), chooseLevel: data.first, )); - await Future.delayed(Duration(milliseconds: 500)); - scrollController.animateTo( - scrollController.position.maxScrollExtent, - duration: Duration(seconds: 1), - curve: Curves.easeInOut, - ); + await Future.delayed(Duration(milliseconds: 500), () { + scrollController.animateTo( + scrollController.position.maxScrollExtent, + duration: Duration(seconds: 500), + curve: Curves.easeInOut, + ); + }); }, (error) {}, ); diff --git a/lib/features/level/presentation/ui/level_page.dart b/lib/features/level/presentation/ui/level_page.dart index 9a9673d..1c53899 100644 --- a/lib/features/level/presentation/ui/level_page.dart +++ b/lib/features/level/presentation/ui/level_page.dart @@ -26,7 +26,7 @@ class LevelPage extends StatelessWidget { alignment: Alignment.center, children: [ _background(), - // _topPath(context), + _topPath(context), _bottomPath(context), ], ), @@ -47,7 +47,7 @@ class LevelPage extends StatelessWidget { return Positioned( bottom: MediaQuery .viewPaddingOf(context) - .bottom + 10, + .bottom + MySpaces.s10, right: MySpaces.s16, left: MySpaces.s16, child: HintLevelWidget( @@ -71,8 +71,11 @@ class LevelPage extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - MyImage( - image: MyAssets.homeButton, + InkWell( + onTap: () => context.read().goToHomePage(context), + child: MyImage( + image: MyAssets.homeButton, + ), ), MyImage( image: MyAssets.musicOn,