Browse Source

fix maxlevel

develop
sina 3 days ago
parent
commit
dd56221a87
  1. 15
      lib/features/level/data/datasource/level_datasource.dart
  2. 2
      lib/features/level/presentation/bloc/level_bloc.dart

15
lib/features/level/data/datasource/level_datasource.dart

@ -34,13 +34,14 @@ class LocalLevelDatasourceImpl implements ILevelDatasource {
response?['path'], response?['path'],
(json) => NodeModel.fromJson(json), (json) => NodeModel.fromJson(json),
); );
final maxLevel = levels.takeWhile((e) => e.nodeType != NodeType.comingSoon).length;
final playableLevels = levels
.takeWhile((e) => e.nodeType != NodeType.comingSoon)
.where((e) => e.nodeType == NodeType.level)
.toList();
LocalStorage.saveData(
key: MyConstants.maxLevelCount,
value:
'$maxLevel',
);
final maxLevel = playableLevels.length;
debugPrint("Saving maxLevel to $maxLevel");
LocalStorage.saveData(key: MyConstants.maxLevelCount, value: '$maxLevel');
final Box<TotalDataEntity> levelBox = Hive.box(MyConstants.levelBox); final Box<TotalDataEntity> levelBox = Hive.box(MyConstants.levelBox);
dynamic existingKey; dynamic existingKey;
@ -82,4 +83,4 @@ class LocalLevelDatasourceImpl implements ILevelDatasource {
throw const MyException(errorMessage: 'Operation Failed'); throw const MyException(errorMessage: 'Operation Failed');
} }
} }
}
}

2
lib/features/level/presentation/bloc/level_bloc.dart

@ -119,7 +119,7 @@ class LevelBloc extends Bloc<LevelEvent, LevelState> {
), ),
LevelLocation( LevelLocation(
bottom: setSize(context: MyContext.get, mobile: 0.75.h, tablet: 1.37.h), bottom: setSize(context: MyContext.get, mobile: 0.75.h, tablet: 1.37.h),
left: setSize(context: MyContext.get, mobile: 0.182.w, tablet: 0.635.w),
left: setSize(context: MyContext.get, mobile: 0.21.w, tablet: 0.635.w),
), ),
////// //////
LevelLocation( LevelLocation(

Loading…
Cancel
Save