You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
5.6 KiB
159 lines
5.6 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/my_image.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/screen_size.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/domain/entity/level_entity.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/presentation/bloc/level_bloc.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/presentation/bloc/level_state.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/presentation/ui/widgets/bottom_path.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/presentation/ui/widgets/hint_level_widget.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/presentation/ui/widgets/level_widget.dart';
|
|
import 'package:hadi_hoda_flutter/features/level/presentation/ui/widgets/top_path.dart';
|
|
|
|
class LevelPage extends StatelessWidget {
|
|
const LevelPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Stack(
|
|
children: [
|
|
SingleChildScrollView(
|
|
controller: context.read<LevelBloc>().scrollController,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
_background(),
|
|
_topPath(context),
|
|
_bottomPath(context),
|
|
],
|
|
),
|
|
),
|
|
_topButtons(context),
|
|
_hintMission(context)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _hintMission(BuildContext context) {
|
|
return BlocBuilder<LevelBloc, LevelState>(
|
|
buildWhen: (previous, current) =>
|
|
previous.chooseLevel?.id != current.chooseLevel?.id,
|
|
builder: (context, state) {
|
|
if (state.chooseLevel != null) {
|
|
return Positioned(
|
|
bottom: MediaQuery
|
|
.viewPaddingOf(context)
|
|
.bottom + MySpaces.s10,
|
|
right: MySpaces.s16,
|
|
left: MySpaces.s16,
|
|
child: HintLevelWidget(
|
|
level: state.chooseLevel ?? LevelEntity(),
|
|
onTap: (level) =>
|
|
context.read<LevelBloc>().goToQuestionPage(context, level),
|
|
),
|
|
);
|
|
} else {
|
|
return SizedBox.shrink();
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
Positioned _topButtons(BuildContext context) {
|
|
return Positioned(
|
|
left: MySpaces.s16,
|
|
right: MySpaces.s16,
|
|
top: MediaQuery.viewPaddingOf(context).top,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
InkWell(
|
|
onTap: () => context.read<LevelBloc>().goToHomePage(context),
|
|
child: MyImage(
|
|
image: MyAssets.homeButton,
|
|
),
|
|
),
|
|
MyImage(
|
|
image: MyAssets.musicOn,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
MyImage _background() {
|
|
return MyImage(image: MyAssets.mapBackground, fit: BoxFit.cover);
|
|
}
|
|
|
|
Positioned _topPath(BuildContext context) {
|
|
return Positioned(
|
|
top: context.heightScreen * 0.16,
|
|
left: context.widthScreen * 0.15,
|
|
child: BlocBuilder<LevelBloc, LevelState>(
|
|
builder: (context, state) => Stack(
|
|
children: [
|
|
TopPath(
|
|
height: 950,
|
|
width: context.widthScreen * 0.6,
|
|
),
|
|
...List.generate(
|
|
context.read<LevelBloc>().top12LevelList.length,
|
|
(index) => Positioned(
|
|
top: context.read<LevelBloc>().topLocationList[index].top,
|
|
bottom: context.read<LevelBloc>().topLocationList[index].bottom,
|
|
right: context.read<LevelBloc>().topLocationList[index].right,
|
|
left: context.read<LevelBloc>().topLocationList[index].left,
|
|
child: LevelWidget(
|
|
index: context.read<LevelBloc>().topLocationList[index].index ?? 0,
|
|
level: context.read<LevelBloc>().top12LevelList[index],
|
|
onTap: (LevelEntity level) {
|
|
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Positioned _bottomPath(BuildContext context) {
|
|
return Positioned(
|
|
bottom: context.heightScreen * 0.18,
|
|
left: context.widthScreen * 0.2,
|
|
child: BlocBuilder<LevelBloc, LevelState>(
|
|
builder: (context, state) => Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
BottomPath(
|
|
width: context.widthScreen * 0.75,
|
|
height: context.heightScreen * 0.6,
|
|
),
|
|
...List.generate(
|
|
context.read<LevelBloc>().bottom8LevelList.length,
|
|
(index) => Positioned(
|
|
top: context.read<LevelBloc>().bottomLocationList[index].top,
|
|
bottom: context.read<LevelBloc>().bottomLocationList[index].bottom,
|
|
right: context.read<LevelBloc>().bottomLocationList[index].right,
|
|
left: context.read<LevelBloc>().bottomLocationList[index].left,
|
|
child: LevelWidget(
|
|
index: context.read<LevelBloc>().bottomLocationList[index].index ?? 0,
|
|
level: context.read<LevelBloc>().bottom8LevelList[index],
|
|
type: index == 0 ? LevelType.current : LevelType.unFinished,
|
|
onTap: (LevelEntity level) {
|
|
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|